user-taskinstance.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. <!-- 用户编辑弹窗 -->
  2. <template>
  3. <div>
  4. <div class="ele-body">
  5. <ele-pro-table
  6. ref="table"
  7. :needPage="false"
  8. :columns="columns"
  9. :datasource="datasource"
  10. row-key="id"
  11. >
  12. <!-- 表头工具栏 -->
  13. <template v-slot:toolbar>
  14. <el-button
  15. size="small"
  16. type="primary"
  17. icon="el-icon-plus"
  18. class="ele-btn-icon"
  19. @click="showAddLog"
  20. >
  21. 添加工序
  22. </el-button>
  23. <el-button
  24. size="small"
  25. type="primary"
  26. icon="el-icon-plus"
  27. class="ele-btn-icon"
  28. @click="showAddProcess"
  29. >
  30. 新增工序
  31. </el-button>
  32. </template>
  33. <template v-slot:orderNum="{ row }">
  34. <el-input v-model="row.orderNum" placeholder="请输入排序"></el-input>
  35. </template>
  36. <template v-slot:processLabel="{ row }">
  37. <el-tag v-if="row.processLabel == 1">自制</el-tag>
  38. <el-tag v-if="row.processLabel == 2" type="success">委外</el-tag>
  39. <el-tag v-if="row.processLabel == 3" type="warning">请托</el-tag>
  40. </template>
  41. <template v-slot:isParallel="{ row }">
  42. <el-select v-model="row.isParallel" placeholder="请选择" size="small">
  43. <el-option :value="0" label="否"></el-option>
  44. <el-option :value="1" label="是"></el-option>
  45. </el-select>
  46. </template>
  47. <!-- 操作列 -->
  48. <template v-slot:action="{ row }">
  49. <el-link
  50. type="primary"
  51. :underline="false"
  52. icon="el-icon-edit"
  53. @click="openEdit(row)"
  54. >
  55. 修改
  56. </el-link>
  57. <!-- <el-link :type="row.id ? 'primary' : 'info'" :underline="false" icon="el-icon-setting"
  58. @click="openSetting(row)">
  59. 配置工艺参数
  60. </el-link> -->
  61. <el-popconfirm
  62. class="ele-action"
  63. title="删除数据操作立即生效!!!确定要删除当前工序吗?"
  64. @confirm="remove(row)"
  65. >
  66. <template v-slot:reference>
  67. <el-link type="danger" :underline="false" icon="el-icon-delete">
  68. 删除
  69. </el-link>
  70. </template>
  71. </el-popconfirm>
  72. </template>
  73. </ele-pro-table>
  74. </div>
  75. <ele-modal
  76. width="1200px"
  77. :visible="addDialog"
  78. v-if="addDialog"
  79. :append-to-body="true"
  80. :close-on-click-modal="false"
  81. @update:visible="closeAdd"
  82. :maxable="true"
  83. >
  84. <Production
  85. :tableData="tableData"
  86. :taskInfo="taskInfo"
  87. ref="ProductionCom"
  88. />
  89. <template v-slot:footer>
  90. <el-button @click="closeAdd">取消</el-button>
  91. <el-button type="primary" :loading="loading" @click="addParamrter">
  92. 添加
  93. </el-button>
  94. </template>
  95. </ele-modal>
  96. <!-- 编辑弹窗 -->
  97. <user-edit
  98. :visible.sync="showEdit"
  99. :controlList="controlList"
  100. :data="current"
  101. @done="reload"
  102. ref="userEdit"
  103. />
  104. <!-- 配置工艺参数 -->
  105. <user-setting
  106. :visible.sync="showSetting"
  107. :data="current"
  108. ref="userSetting"
  109. />
  110. <!-- 新增工序 -->
  111. <add-process
  112. :visible.sync="showProcessEdit"
  113. :data="currentData"
  114. :controlList="controlList"
  115. ref="addProcessRef"
  116. :typeList="typeList"
  117. @done="reloadProcess"
  118. />
  119. </div>
  120. </template>
  121. <script>
  122. import route from '@/api/technology/route';
  123. import Production from './production';
  124. import producetask from '@/api/technology/production';
  125. import UserEdit from './production/components/user-edit.vue';
  126. import UserSetting from './production/components/user-setting.vue';
  127. import control from '@/api/technology/control';
  128. import addProcess from '@/views/technology/production/components/user-edit.vue';
  129. export default {
  130. components: { Production, UserEdit, UserSetting, addProcess },
  131. props: {
  132. // 修改回显的数据
  133. taskInfo: Object,
  134. isEdit: Boolean
  135. },
  136. data() {
  137. return {
  138. // 表格列配置
  139. columns: [
  140. {
  141. prop: 'orderNum',
  142. label: '排序',
  143. align: 'center',
  144. slot: 'orderNum',
  145. minWidth: 120
  146. },
  147. {
  148. prop: 'code',
  149. label: '工序编码',
  150. // sortable: 'custom',
  151. showOverflowTooltip: true,
  152. align: 'center',
  153. minWidth: 110
  154. },
  155. {
  156. prop: 'name',
  157. label: '工序名称',
  158. showOverflowTooltip: true,
  159. align: 'center',
  160. minWidth: 110
  161. },
  162. {
  163. prop: 'isParallel',
  164. label: '并行工序',
  165. showOverflowTooltip: true,
  166. align: 'center',
  167. slot: 'isParallel',
  168. minWidth: 110
  169. },
  170. {
  171. align: 'center',
  172. prop: 'controlName',
  173. label: '工序控制码',
  174. showOverflowTooltip: true,
  175. minWidth: 110
  176. },
  177. {
  178. align: 'center',
  179. prop: 'processLabel',
  180. slot: 'processLabel',
  181. label: '工序标签',
  182. showOverflowTooltip: true,
  183. minWidth: 100
  184. },
  185. {
  186. prop: 'workCenterName',
  187. label: '所属工作中心',
  188. align: 'center',
  189. showOverflowTooltip: true,
  190. minWidth: 110
  191. },
  192. {
  193. prop: 'factoriesName',
  194. label: '所属工厂',
  195. align: 'center',
  196. showOverflowTooltip: true,
  197. minWidth: 110
  198. },
  199. {
  200. columnKey: 'action',
  201. label: '操作',
  202. width: 260,
  203. align: 'center',
  204. resizable: false,
  205. slot: 'action',
  206. showOverflowTooltip: true
  207. }
  208. ],
  209. tableList: [],
  210. loading: false,
  211. addDialog: false,
  212. showSetting: false,
  213. showEdit: false,
  214. showProcessEdit: false,
  215. current: null,
  216. removeList: [],
  217. tableData: [],
  218. controlList: [],
  219. visible: true,
  220. showEdit: false,
  221. typeList: [
  222. {
  223. value: 99,
  224. label: '关键工序'
  225. },
  226. {
  227. value: 1,
  228. label: '普通工序'
  229. },
  230. // {
  231. // value: 2,
  232. // label: '抽样质检'
  233. // },
  234. {
  235. value: 3,
  236. label: '抽样质检'
  237. },
  238. {
  239. value: 4,
  240. label: '包装工序'
  241. },
  242. {
  243. value: 6,
  244. label: '质检工序'
  245. }
  246. // {
  247. // value: 7,
  248. // label: '生产准备'
  249. // }
  250. ],
  251. currentData: null
  252. };
  253. },
  254. methods: {
  255. addParamrter() {
  256. // console.log(this.$refs.ProductionCom?.selection);
  257. let arr = this.$refs.ProductionCom.selection;
  258. let len = this.$refs.table.getData().length + 1;
  259. let arrM = arr.map((item, index) => {
  260. return {
  261. ...item.detail,
  262. orderNum: len + index,
  263. isParallel: item.isParallel || 0
  264. };
  265. });
  266. arrM.forEach((element) => {
  267. if (element.id) {
  268. this.$set(element, 'sourceTaskId', element.id);
  269. delete element.id;
  270. }
  271. });
  272. this.$refs.table.setData([...this.$refs.table.getData(), ...arrM]);
  273. this.$emit('taskList', this.$refs.table.getData());
  274. this.closeAdd();
  275. },
  276. showAddLog() {
  277. this.tableData = this.$refs.table.getData();
  278. this.addDialog = true;
  279. },
  280. /* 打开编辑弹窗 */
  281. openEdit(row) {
  282. this.getControlList();
  283. this.current = row;
  284. this.showEdit = true;
  285. this.$refs.userEdit.$refs.form &&
  286. this.$refs.userEdit.$refs.form.clearValidate();
  287. },
  288. getControlList() {
  289. control.list().then((res) => {
  290. this.controlList = res.list;
  291. });
  292. },
  293. /*配置工艺参数 */
  294. openSetting(row) {
  295. if (!row.id) {
  296. this.$message.warning('新增的数据需要保存之后才能配置工艺参数');
  297. return;
  298. }
  299. this.current = row;
  300. this.showSetting = true;
  301. },
  302. /*关闭选择参数*/
  303. closeAdd() {
  304. this.$refs.ProductionCom.$refs.table.setSelectedRows([]);
  305. this.addDialog = false;
  306. },
  307. /* 刷新表格 */
  308. reload() {
  309. this.$refs.table.reload();
  310. },
  311. remove(row) {
  312. const data = this.$refs.table.getData();
  313. if (row.id) {
  314. this.removeList.push(row.id);
  315. }
  316. this.$refs.table.setData(
  317. data.filter((d) =>
  318. this.isEdit ? d.id !== row.id : d.sourceTaskId !== row.sourceTaskId
  319. )
  320. );
  321. this.$emit('taskList', this.$refs.table.getData());
  322. this.$emit('remove', this.removeList);
  323. },
  324. /* 表格数据源 */
  325. datasource({ page, limit, where, order }) {
  326. return [];
  327. },
  328. reloadProcess(processId) {
  329. this.getProcessData(processId);
  330. },
  331. async getProcessData(processId) {
  332. const res = await producetask.list({
  333. pageNum: 1,
  334. isDetail: true,
  335. size: -1
  336. });
  337. let data = [];
  338. if (processId && res.list.length != 0) {
  339. const processData = res.list.find((it) => it.id == processId);
  340. if (processData) {
  341. data.push(processData);
  342. }
  343. }
  344. if (data.length != 0) {
  345. let len = this.$refs.table.getData().length + 1;
  346. let arrM = data.map((item, index) => {
  347. return {
  348. ...item.detail,
  349. orderNum: len + index,
  350. isParallel: item.isParallel || 0
  351. };
  352. });
  353. arrM.forEach((element) => {
  354. if (element.id) {
  355. this.$set(element, 'sourceTaskId', element.id);
  356. delete element.id;
  357. }
  358. });
  359. this.$refs.table.setData([...this.$refs.table.getData(), ...arrM]);
  360. this.$emit('taskList', this.$refs.table.getData());
  361. }
  362. },
  363. showAddProcess() {
  364. this.getControlList();
  365. this.currentData = undefined;
  366. this.showProcessEdit = true;
  367. this.$refs.addProcessRef.$refs.form &&
  368. this.$refs.addProcessRef.$refs.form.clearValidate();
  369. },
  370. async getList() {
  371. this.removeList = [];
  372. if (this.isEdit) {
  373. const res = await route.taskinstanceList({
  374. routingId: this.taskInfo.id,
  375. isDetail: true,
  376. pageNum: 1,
  377. size: -1
  378. });
  379. console.log(res, '_________res');
  380. let arr =
  381. res?.list?.map((it) => {
  382. it.detail.orderNum = it.orderNum;
  383. it.detail.isParallel = it.isParallel || 0;
  384. return it.detail;
  385. }) || [];
  386. this.$refs.table.setData([...arr]);
  387. }
  388. },
  389. getTaskList() {
  390. this.$emit('taskList', this.$refs.table.getData());
  391. }
  392. }
  393. };
  394. </script>
  395. <style lang="scss" scoped>
  396. .btn_box {
  397. width: 100%;
  398. margin-top: 10px;
  399. }
  400. </style>