user-taskinstance.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <!-- 用户编辑弹窗 -->
  2. <template>
  3. <ele-modal
  4. width="1060px"
  5. :visible="visible"
  6. :append-to-body="true"
  7. :close-on-click-modal="true"
  8. custom-class="ele-dialog-form"
  9. :title="`给工序【${this.data?.code}${this.data?.name}】配置工序`"
  10. @update:visible="updateVisible"
  11. >
  12. <div class="ele-body">
  13. <ele-pro-table
  14. ref="table"
  15. :needPage="false"
  16. :columns="columns"
  17. :datasource="datasource"
  18. row-key="code"
  19. >
  20. <!-- 表头工具栏 -->
  21. <template v-slot:toolbar>
  22. <el-button
  23. size="small"
  24. type="primary"
  25. icon="el-icon-plus"
  26. class="ele-btn-icon"
  27. @click="showAddLog"
  28. >
  29. 添加参数
  30. </el-button>
  31. </template>
  32. <!-- 状态列 -->
  33. <!-- 操作列 -->
  34. <template v-slot:action="{ row }">
  35. <el-link
  36. type="primary"
  37. :underline="false"
  38. icon="el-icon-edit"
  39. @click="openEdit(row)"
  40. >
  41. 修改
  42. </el-link>
  43. <el-link
  44. :type="row.id ? 'primary' : 'info'"
  45. :underline="false"
  46. icon="el-icon-setting"
  47. @click="openSetting(row)"
  48. >
  49. 配置工艺参数
  50. </el-link>
  51. <el-popconfirm
  52. class="ele-action"
  53. title="删除数据操作立即生效!!!确定要删除当前工序吗?"
  54. @confirm="remove(row)"
  55. >
  56. <template v-slot:reference>
  57. <el-link type="danger" :underline="false" icon="el-icon-delete">
  58. 删除
  59. </el-link>
  60. </template>
  61. </el-popconfirm>
  62. </template>
  63. </ele-pro-table>
  64. </div>
  65. <template v-slot:footer>
  66. <el-button @click="updateVisible(false)">取消</el-button>
  67. <el-button type="primary" :loading="loading" @click="save(false)">
  68. 保存
  69. </el-button>
  70. <el-button type="primary" :loading="loading" @click="save(true)">
  71. 保存并关闭
  72. </el-button>
  73. </template>
  74. <ele-modal
  75. width="1720px"
  76. :visible="addDialog"
  77. :append-to-body="true"
  78. :close-on-click-modal="true"
  79. @update:visible="closeAdd"
  80. >
  81. <Production :data="tableData" ref="ProductionCom" />
  82. <template v-slot:footer>
  83. <el-button @click="closeAdd">取消</el-button>
  84. <el-button type="primary" :loading="loading" @click="addParamrter">
  85. 添加
  86. </el-button>
  87. </template>
  88. </ele-modal>
  89. <!-- 编辑弹窗 -->
  90. <user-edit
  91. :visible.sync="showEdit"
  92. :controlList="controlList"
  93. :data="current"
  94. @done="reload"
  95. ref="userEdit"
  96. />
  97. <!-- 配置工艺参数 -->
  98. <user-setting
  99. :visible.sync="showSetting"
  100. :data="current"
  101. ref="userSetting"
  102. />
  103. </ele-modal>
  104. </template>
  105. <script>
  106. import route from '@/api/technology/route';
  107. import Production from './production';
  108. import UserEdit from './production/components/user-edit.vue';
  109. import UserSetting from './production/components/user-setting.vue';
  110. import control from '@/api/technology/control';
  111. export default {
  112. components: { Production, UserEdit, UserSetting },
  113. props: {
  114. // 弹窗是否打开
  115. visible: Boolean,
  116. // 修改回显的数据
  117. data: Object
  118. },
  119. data() {
  120. return {
  121. timeType: [
  122. { value: 1, label: '是' },
  123. { value: 0, label: '否' }
  124. ],
  125. // 表格列配置
  126. columns: [
  127. {
  128. prop: 'code',
  129. label: '工序编码',
  130. // sortable: 'custom',
  131. showOverflowTooltip: true,
  132. align: 'center',
  133. minWidth: 110
  134. },
  135. {
  136. prop: 'name',
  137. label: '工序名称',
  138. showOverflowTooltip: true,
  139. align: 'center',
  140. minWidth: 110
  141. },
  142. {
  143. align: 'center',
  144. prop: 'controlName',
  145. label: '工序控制码',
  146. showOverflowTooltip: true,
  147. minWidth: 110
  148. },
  149. {
  150. prop: 'workCenterName',
  151. label: '所属工作中心',
  152. align: 'center',
  153. showOverflowTooltip: true,
  154. minWidth: 110
  155. },
  156. {
  157. columnKey: 'action',
  158. label: '操作',
  159. width: 260,
  160. align: 'center',
  161. resizable: false,
  162. slot: 'action',
  163. showOverflowTooltip: true
  164. }
  165. ],
  166. loading: false,
  167. addDialog: false,
  168. showSetting: false,
  169. showEdit: false,
  170. current: {},
  171. removeList: [],
  172. tableData: [],
  173. controlList:[]
  174. };
  175. },
  176. methods: {
  177. addParamrter() {
  178. // console.log(this.$refs.ProductionCom?.selection);
  179. let arr = this.$refs.ProductionCom.selection;
  180. let arrM = arr.map((item, index) => {
  181. return { ...item.detail };
  182. });
  183. arrM.forEach((element) => {
  184. if (element.id) {
  185. this.$set(element, 'sourceTaskId', element.id);
  186. delete element.id;
  187. }
  188. });
  189. this.$refs.table.setData([...arrM, ...this.$refs.table.getData()]);
  190. this.closeAdd();
  191. },
  192. showAddLog() {
  193. this.tableData = this.$refs.table.getData();
  194. this.addDialog = true;
  195. // this.$nextTick(() => {
  196. // this.$refs.ProductionCom.reload();
  197. // });
  198. },
  199. /* 打开编辑弹窗 */
  200. openEdit(row) {
  201. this.getControlList()
  202. this.current = row;
  203. this.showEdit = true;
  204. this.$refs.userEdit.$refs.form &&
  205. this.$refs.userEdit.$refs.form.clearValidate();
  206. },
  207. getControlList(){
  208. const params = {
  209. pageNum: 1, size: -1
  210. }
  211. control.list().then(res=>{
  212. this.controlList = res.list
  213. })
  214. },
  215. /*配置工艺参数 */
  216. openSetting(row) {
  217. if (!row.id) {
  218. this.$message.warning('新增的数据需要保存之后才能配置工艺参数');
  219. return;
  220. }
  221. this.current = row;
  222. this.showSetting = true;
  223. },
  224. /*关闭选择参数*/
  225. closeAdd() {
  226. this.$refs.ProductionCom.$refs.table.setSelectedRows([]);
  227. this.addDialog = false;
  228. },
  229. /* 刷新表格 */
  230. reload() {
  231. this.$refs.table.reload();
  232. },
  233. remove(row) {
  234. if (row.id) {
  235. route.taskinstanceDelete([row.id]).then(() => {
  236. this.$message.success('删除成功');
  237. this.reload();
  238. });
  239. } else {
  240. const data = this.$refs.table.getData() ?? [];
  241. console.log(data);
  242. this.$refs.table.setData(data.filter((d) => d.code !== row.code));
  243. }
  244. },
  245. /* 表格数据源 */
  246. async datasource({ page, limit, where }) {
  247. if (this.data?.id) {
  248. console.log(22222);
  249. const res = await route.taskinstanceList({
  250. routingId: this.data.id,
  251. isDetail: true,
  252. pageNum: 1,
  253. size: -1
  254. });
  255. let arr = res.list.map((it) => it.detail);
  256. return {
  257. list: arr,
  258. count: res.count
  259. };
  260. }
  261. },
  262. /* 保存编辑 */
  263. save(isClose) {
  264. let arr = this.$refs.table.getData();
  265. if (arr.length == 0) {
  266. this.$message.warning('至少配置一条工序才能保存');
  267. return;
  268. }
  269. let arr1 = arr.map((it, i) => {
  270. if (it.orderNum) {
  271. delete it.orderNum;
  272. }
  273. return {
  274. ...it,
  275. orderNum: i + 1
  276. };
  277. });
  278. route
  279. .taskinstanceSave({
  280. routingId: this.data.id,
  281. taskInstanceList: arr1
  282. })
  283. .then((res) => {
  284. if (res) {
  285. this.$message.success('保存成功!');
  286. if (isClose) {
  287. this.updateVisible(false);
  288. } else {
  289. this.reload();
  290. }
  291. }
  292. });
  293. // arr.forEach((it) => {
  294. // if (!it.taskId) {
  295. // this.$set(it, 'taskId', this.data.id);
  296. // }
  297. // });
  298. // producetask
  299. // .paramSave({
  300. // removeList: this.removeList,
  301. // saveList: arr
  302. // })
  303. // .then(() => {
  304. // this.$message.success('保存成功!');
  305. // this.updateVisible(false);
  306. // });
  307. // this.$refs.form.validate((valid) => {
  308. // if (!valid) {
  309. // return false;
  310. // }
  311. // if (!this.isUpdate) {
  312. // delete this.form.id;
  313. // }
  314. // this.form.workBeat.beatTimes = this.totalTime;
  315. // this.loading = true;
  316. // producetask
  317. // .save(this.form)
  318. // .then((msg) => {
  319. // this.form = {};
  320. // this.loading = false;
  321. // this.$message.success(msg);
  322. // this.updateVisible(false);
  323. // this.$emit('done');
  324. // })
  325. // .catch((e) => {
  326. // this.loading = false;
  327. // // this.$message.error(e.message);
  328. // });
  329. // });
  330. },
  331. /* 更新visible */
  332. updateVisible(value) {
  333. this.removeList = [];
  334. this.$refs.table.setData([]);
  335. this.$emit('update:visible', value);
  336. }
  337. },
  338. watch: {
  339. visible(visible) {
  340. if (visible) {
  341. this.$nextTick(() => {
  342. this.reload();
  343. });
  344. }
  345. }
  346. }
  347. };
  348. </script>