redeployOther.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. <template>
  2. <ele-modal
  3. :visible.sync="visible"
  4. title="转派工单"
  5. width="60%"
  6. :modal="false"
  7. :maxable="true"
  8. class="fullscreen"
  9. >
  10. <div class="sparepart-apply">
  11. <el-tabs
  12. v-model="tabValue"
  13. class="demo-monitor-tabs"
  14. @tab-click="handleClickTab"
  15. >
  16. <el-tab-pane label="执行人" name="0" />
  17. <el-tab-pane label="班组" name="1" />
  18. </el-tabs>
  19. <div class="select-box">
  20. <el-form label-width="80px">
  21. <el-row :gutter="24">
  22. <el-col :span="12">
  23. <el-form-item label="工单单号">
  24. <el-input v-model="row.code" disabled></el-input>
  25. </el-form-item>
  26. </el-col>
  27. <el-col :span="12" v-if="tabValue == '1'">
  28. <el-form-item label="班组">
  29. <el-select
  30. v-model="teamId"
  31. size="small"
  32. @change="teamChange"
  33. style="width: 100%"
  34. >
  35. <el-option
  36. :value="i.id"
  37. :label="i.name"
  38. v-for="i in teamAllList"
  39. :key="i.id"
  40. ></el-option>
  41. </el-select>
  42. </el-form-item>
  43. </el-col>
  44. <template v-if="tabValue == '0'">
  45. <el-col :span="12">
  46. <el-form-item label="部门">
  47. <deptSelect v-model="groupId" @changeGroup="deptClick" />
  48. </el-form-item>
  49. </el-col>
  50. <el-col :span="12">
  51. <el-form-item label="" label-width="10px">
  52. <el-input v-model="name" placeholder="搜索姓名"></el-input>
  53. </el-form-item>
  54. </el-col>
  55. <el-col :span="12" style="text-align: right">
  56. <el-form-item label="" label-width="10px">
  57. <el-button
  58. @click="search"
  59. type="primary"
  60. icon="el-icon-search"
  61. >搜索</el-button
  62. >
  63. <el-button @click="reset" icon="el-icon-refresh-left"
  64. >重置</el-button
  65. >
  66. </el-form-item>
  67. </el-col>
  68. </template>
  69. </el-row>
  70. </el-form>
  71. </div>
  72. <div v-if="tabValue == '0'" class="data-tab">
  73. <ele-pro-table
  74. ref="tableRef2"
  75. row-key="id"
  76. :columns="columns"
  77. :datasource="datasource"
  78. cache-key="redeployOther"
  79. :header-cell-class-name="headerCellClassName"
  80. :selection.sync="selection"
  81. :page-size="defPageSize"
  82. >
  83. </ele-pro-table>
  84. </div>
  85. </div>
  86. <div slot="footer" class="footer">
  87. <el-button @click="cancel">返回</el-button>
  88. <el-button
  89. v-if="entranceValue == 'transfer'"
  90. :loading="btnLoading"
  91. type="primary"
  92. @click="submit"
  93. >提交</el-button
  94. >
  95. <el-button
  96. v-if="entranceValue == 'noFinishSubmit'"
  97. :loading="btnLoading"
  98. type="primary"
  99. @click="confirm"
  100. >确认</el-button
  101. >
  102. </div>
  103. </ele-modal>
  104. </template>
  105. <script>
  106. import deptSelect from '@/components/CommomSelect/dept-select.vue';
  107. import { getUserPage } from '@/api/system/organization';
  108. import { recordrulesplanReManualDispatchOrder } from '@/api/recordRules/index';
  109. import { getteampage } from '@/api/main/index.js';
  110. export default {
  111. components: { deptSelect },
  112. props: {},
  113. data() {
  114. return {
  115. fullscreen: false,
  116. btnLoading: false,
  117. visible: false,
  118. treeList: [],
  119. pages: {
  120. pageNum: 1,
  121. size: 15
  122. },
  123. total: 0,
  124. selectedRow: {},
  125. selectedRowData: [],
  126. groupId: '',
  127. executorDeptName: '',
  128. name: '',
  129. row: {},
  130. columns: [
  131. {
  132. width: 45,
  133. type: 'selection',
  134. columnKey: 'selection',
  135. align: 'center'
  136. // selectable: (row, index) => {
  137. // return row.id !== this.row.executeUserId;
  138. // }
  139. },
  140. {
  141. columnKey: 'index',
  142. label: '序号',
  143. type: 'index',
  144. width: 55,
  145. align: 'center',
  146. showOverflowTooltip: true,
  147. fixed: 'left'
  148. },
  149. {
  150. prop: 'jobNumber',
  151. label: '工号',
  152. align: 'center',
  153. showOverflowTooltip: true
  154. },
  155. {
  156. prop: 'name',
  157. label: '姓名',
  158. align: 'center',
  159. showOverflowTooltip: true
  160. },
  161. {
  162. prop: 'phone',
  163. label: '电话',
  164. align: 'center',
  165. showOverflowTooltip: true
  166. },
  167. {
  168. prop: 'groupName',
  169. label: '部门',
  170. align: 'center',
  171. showOverflowTooltip: true
  172. }
  173. ],
  174. tabValue: '',
  175. selectedRowDataId: '',
  176. tableData: [],
  177. // arry: [],
  178. entranceValue: '',
  179. selection: [],
  180. teamAllList: [],
  181. teamId: '',
  182. executeUsers: [],
  183. teamName: ''
  184. };
  185. },
  186. created() {
  187. this.getList();
  188. this.getAllTeamList();
  189. },
  190. methods: {
  191. async getList() {
  192. const data = await getUserPage({
  193. pageNum: 1,
  194. size: -1,
  195. groupId: '',
  196. name: '',
  197. groupId: this.groupId
  198. });
  199. this.tableData = data.list;
  200. },
  201. handleClickTab(tab, event) {
  202. this.selectedRow = {};
  203. this.selectedRowData = [];
  204. this.tabValue = tab.name;
  205. this.$refs.tableRef2?.clearSelection();
  206. },
  207. open(row, val = 'transfer') {
  208. this.entranceValue = val;
  209. // 转派
  210. if (val == 'transfer') {
  211. if (row.type == '1') {
  212. // 班组
  213. this.tabValue = '1';
  214. } else {
  215. this.tabValue = '0';
  216. }
  217. }
  218. this.row = row;
  219. this.name = '';
  220. this.groupId = '';
  221. this.executorDeptName = '';
  222. this.visible = true;
  223. this.$nextTick(() => {
  224. this.$refs.tableRef2?.clearSelection();
  225. });
  226. },
  227. //重置
  228. reset() {
  229. this.name = '';
  230. this.search();
  231. },
  232. // 搜索
  233. search() {
  234. this.$refs.tableRef2.reload();
  235. },
  236. deptClick(data) {
  237. if (data) {
  238. this.$refs.tableRef2.reload();
  239. }
  240. },
  241. // 获取审核人列表、巡点检人员
  242. async datasource({ page, limit, where, order }) {
  243. this.selectedRow = {};
  244. // 如果传了参数就是获取巡点检人员数据
  245. return getUserPage({
  246. pageNum: page,
  247. size: limit,
  248. ...where,
  249. groupId: this.groupId,
  250. name: this.name
  251. });
  252. },
  253. handleSelectAll(selection) {
  254. this.$refs.tableRef2.clearSelection();
  255. },
  256. headerCellClassName({ columnIndex }) {
  257. // 如果是第一列(通常是全选框),则返回自定义的class名
  258. if (columnIndex === 0) {
  259. return 'hide-selection-checkbox';
  260. }
  261. return '';
  262. },
  263. async submit() {
  264. if (this.tabValue == '0' && this.selection.length == 0) {
  265. return this.$message.warning('请选择转派人员');
  266. }
  267. if (this.tabValue == '1' && !this.teamId) {
  268. return this.$message.warning('请选择班组');
  269. }
  270. let executeUsers = null;
  271. if (this.tabValue == '0') {
  272. executeUsers = this.selection.map((i) => {
  273. return {
  274. groupId: i.groupId,
  275. groupName: i.groupName,
  276. userId: i.id,
  277. userName: i.name
  278. };
  279. });
  280. } else {
  281. executeUsers = this.executeUsers;
  282. }
  283. this.btnLoading = true;
  284. let params = {
  285. executeUsers,
  286. teamName: this.teamName,
  287. teamId: this.teamId,
  288. id: this.row.id,
  289. type: this.tabValue
  290. };
  291. // 0个人 1班组
  292. if (this.tabValue == 1) {
  293. params = {
  294. executeUsers: [],
  295. teamName: this.teamName,
  296. teamId: this.teamId,
  297. id: this.row.id,
  298. type: this.tabValue
  299. };
  300. } else {
  301. params = {
  302. executeUsers,
  303. teamName: '',
  304. teamId: '',
  305. id: this.row.id,
  306. type: this.tabValue
  307. };
  308. }
  309. recordrulesplanReManualDispatchOrder(params)
  310. .then(() => {
  311. this.$message.success(`该工单成功转派`);
  312. this.visible = false;
  313. this.$emit('refresh');
  314. this.btnLoading = false;
  315. })
  316. .catch(() => {
  317. this.btnLoading = false;
  318. });
  319. },
  320. confirm() {
  321. this.visible = false;
  322. this.$emit('confirm', this.selectedRow);
  323. },
  324. cancel() {
  325. this.tabValue = '0';
  326. this.selectedRow = {};
  327. this.selectedRowData = [];
  328. this.selection = [];
  329. this.executeUsers = [];
  330. this.visible = false;
  331. },
  332. async getAllTeamList() {
  333. const { list } = await getteampage({
  334. pageNum: 1,
  335. size: -1
  336. });
  337. console.log('teamAllList 班组', list);
  338. this.teamAllList = list;
  339. },
  340. teamChange() {
  341. console.log('this.teamId', this.teamId);
  342. // 当前班组
  343. const currentTeam = this.teamAllList.find(
  344. (item) => item.id === this.teamId
  345. );
  346. this.teamName = currentTeam.name;
  347. if (currentTeam) {
  348. // 同步执行人
  349. this.executeUsers = [
  350. {
  351. teamId: currentTeam.id,
  352. teamName: currentTeam.name
  353. }
  354. ];
  355. }
  356. }
  357. }
  358. };
  359. </script>
  360. <style lang="scss" scoped>
  361. .sparepart-apply {
  362. .select-box {
  363. padding: 10px 0;
  364. }
  365. .material-item + .material-item {
  366. margin-top: 10px;
  367. }
  368. }
  369. .flex-between {
  370. display: flex;
  371. justify-content: space-between;
  372. padding-right: 20%;
  373. }
  374. .list-box {
  375. max-height: 60vh;
  376. overflow-y: auto;
  377. overflow-x: hidden;
  378. }
  379. .footer {
  380. padding: 10px;
  381. text-align: right;
  382. background: #fff;
  383. display: flex;
  384. align-items: center;
  385. justify-content: center;
  386. }
  387. ::v-deep .hide-selection-checkbox .cell .el-checkbox {
  388. // visibility: hidden !important;
  389. }
  390. </style>