user-taskinstance.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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. </template>
  24. <template v-slot:orderNum="{ row }">
  25. <el-input v-model="row.orderNum" placeholder="请输入排序"></el-input>
  26. </template>
  27. <!-- 操作列 -->
  28. <template v-slot:action="{ row }">
  29. <el-link
  30. type="primary"
  31. :underline="false"
  32. icon="el-icon-edit"
  33. @click="openEdit(row)"
  34. >
  35. 修改
  36. </el-link>
  37. <!-- <el-link :type="row.id ? 'primary' : 'info'" :underline="false" icon="el-icon-setting"
  38. @click="openSetting(row)">
  39. 配置工艺参数
  40. </el-link> -->
  41. <el-popconfirm
  42. class="ele-action"
  43. title="删除数据操作立即生效!!!确定要删除当前工序吗?"
  44. @confirm="remove(row)"
  45. >
  46. <template v-slot:reference>
  47. <el-link type="danger" :underline="false" icon="el-icon-delete">
  48. 删除
  49. </el-link>
  50. </template>
  51. </el-popconfirm>
  52. </template>
  53. </ele-pro-table>
  54. </div>
  55. <ele-modal
  56. width="1720px"
  57. :visible="addDialog"
  58. :append-to-body="true"
  59. :close-on-click-modal="false"
  60. @update:visible="closeAdd"
  61. :maxable="true"
  62. >
  63. <Production :tableData="tableData" ref="ProductionCom" />
  64. <template v-slot:footer>
  65. <el-button @click="closeAdd">取消</el-button>
  66. <el-button type="primary" :loading="loading" @click="addParamrter">
  67. 添加
  68. </el-button>
  69. </template>
  70. </ele-modal>
  71. <!-- 编辑弹窗 -->
  72. <user-edit
  73. :visible.sync="showEdit"
  74. :controlList="controlList"
  75. :data="current"
  76. @done="reload"
  77. ref="userEdit"
  78. />
  79. <!-- 配置工艺参数 -->
  80. <user-setting
  81. :visible.sync="showSetting"
  82. :data="current"
  83. ref="userSetting"
  84. />
  85. </div>
  86. </template>
  87. <script>
  88. import route from '@/api/technology/route';
  89. import Production from './production';
  90. import UserEdit from './production/components/user-edit.vue';
  91. import UserSetting from './production/components/user-setting.vue';
  92. import control from '@/api/technology/control';
  93. export default {
  94. components: { Production, UserEdit, UserSetting },
  95. props: {
  96. // 修改回显的数据
  97. taskInfo: Object,
  98. isEdit: Boolean
  99. },
  100. data() {
  101. return {
  102. // 表格列配置
  103. columns: [
  104. {
  105. prop: 'orderNum',
  106. label: '排序',
  107. align: 'center',
  108. slot: 'orderNum',
  109. minWidth: 120
  110. },
  111. {
  112. prop: 'code',
  113. label: '工序编码',
  114. // sortable: 'custom',
  115. showOverflowTooltip: true,
  116. align: 'center',
  117. minWidth: 110
  118. },
  119. {
  120. prop: 'name',
  121. label: '工序名称',
  122. showOverflowTooltip: true,
  123. align: 'center',
  124. minWidth: 110
  125. },
  126. {
  127. align: 'center',
  128. prop: 'controlName',
  129. label: '工序控制码',
  130. showOverflowTooltip: true,
  131. minWidth: 110
  132. },
  133. {
  134. prop: 'workCenterName',
  135. label: '所属工作中心',
  136. align: 'center',
  137. showOverflowTooltip: true,
  138. minWidth: 110
  139. },
  140. {
  141. columnKey: 'action',
  142. label: '操作',
  143. width: 260,
  144. align: 'center',
  145. resizable: false,
  146. slot: 'action',
  147. showOverflowTooltip: true
  148. }
  149. ],
  150. tableList: [],
  151. loading: false,
  152. addDialog: false,
  153. showSetting: false,
  154. showEdit: false,
  155. current: {},
  156. removeList: [],
  157. tableData: [],
  158. controlList: [],
  159. visible: true
  160. };
  161. },
  162. methods: {
  163. addParamrter() {
  164. // console.log(this.$refs.ProductionCom?.selection);
  165. let arr = this.$refs.ProductionCom.selection;
  166. let len = this.$refs.table.getData().length + 1;
  167. let arrM = arr.map((item, index) => {
  168. return { ...item.detail, orderNum: len + index };
  169. });
  170. arrM.forEach((element) => {
  171. if (element.id) {
  172. this.$set(element, 'sourceTaskId', element.id);
  173. delete element.id;
  174. }
  175. });
  176. this.$refs.table.setData([...this.$refs.table.getData(), ...arrM]);
  177. this.$emit('taskList', this.$refs.table.getData());
  178. this.closeAdd();
  179. },
  180. showAddLog() {
  181. this.tableData = this.$refs.table.getData();
  182. this.addDialog = true;
  183. },
  184. /* 打开编辑弹窗 */
  185. openEdit(row) {
  186. this.getControlList();
  187. this.current = row;
  188. this.showEdit = true;
  189. this.$refs.userEdit.$refs.form &&
  190. this.$refs.userEdit.$refs.form.clearValidate();
  191. },
  192. getControlList() {
  193. control.list().then((res) => {
  194. this.controlList = res.list;
  195. });
  196. },
  197. /*配置工艺参数 */
  198. openSetting(row) {
  199. if (!row.id) {
  200. this.$message.warning('新增的数据需要保存之后才能配置工艺参数');
  201. return;
  202. }
  203. this.current = row;
  204. this.showSetting = true;
  205. },
  206. /*关闭选择参数*/
  207. closeAdd() {
  208. this.$refs.ProductionCom.$refs.table.setSelectedRows([]);
  209. this.addDialog = false;
  210. },
  211. /* 刷新表格 */
  212. reload() {
  213. this.$refs.table.reload();
  214. },
  215. remove(row) {
  216. const data = this.$refs.table.getData();
  217. if (row.id) {
  218. this.removeList.push(row.id);
  219. }
  220. this.$refs.table.setData(
  221. data.filter((d) =>
  222. this.isEdit ? d.id !== row.id : d.sourceTaskId !== row.sourceTaskId
  223. )
  224. );
  225. this.$emit('taskList', this.$refs.table.getData());
  226. this.$emit('remove', this.removeList);
  227. },
  228. /* 表格数据源 */
  229. datasource({ page, limit, where, order }) {
  230. return [];
  231. },
  232. async getList() {
  233. this.removeList = [];
  234. if (this.isEdit) {
  235. const res = await route.taskinstanceList({
  236. routingId: this.taskInfo.id,
  237. isDetail: true,
  238. pageNum: 1,
  239. size: -1
  240. });
  241. let arr = res.list.map((it) => {
  242. it.detail.orderNum = it.orderNum;
  243. return it.detail;
  244. });
  245. this.$refs.table.setData([...arr]);
  246. }
  247. },
  248. getTaskList() {
  249. this.$emit('taskList', this.$refs.table.getData());
  250. }
  251. }
  252. };
  253. </script>
  254. <style lang="scss" scoped>
  255. .btn_box {
  256. width: 100%;
  257. margin-top: 10px;
  258. }
  259. </style>