user-taskinstance.vue 7.1 KB

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