Explorar o código

禅道bug 修复:工单表格列配置动态化改造,新增设备相关列及数据绑定

yusheng hai 9 meses
pai
achega
608322cbcb

+ 118 - 84
src/views/workOrder/components/releaseDialog.vue

@@ -192,7 +192,7 @@
             <ele-pro-table
               class="table"
               :ref="`tableRef${index}`"
-              :columns="columns"
+              :columns="columns(item)"
               :datasource="item.list"
               cache-key="systemRoleTable"
               :pageSize="20"
@@ -465,90 +465,124 @@
         };
       },
       columns() {
-        return [
-          {
-            columnKey: 'index',
-            label: '序号',
-            type: 'index',
-            width: 55,
-            align: 'center',
-            fixed: 'left'
-          },
-          {
-            width: 45,
-            type: 'selection',
-            columnKey: 'selection',
-            align: 'center',
-            fixed: 'left',
-            reserveSelection: true
-          },
-          {
-            prop: 'name',
-            label: this.dynamicName,
-            align: 'center',
-            width: 200
-          },
-          {
-            prop: 'code',
-            label: '编码',
-            align: 'center',
-            width: 200
-          },
-          {
-            prop: 'status',
-            label: '状态',
-            align: 'center',
-            width: 150,
-            formatter: (row) => {
-              if (!row.status) return '';
-              return row.status.desc || '';
+        return (val) => {
+          let data =
+            val.assignType == 1
+              ? [
+                  {
+                    prop: 'assetCode',
+                    label: '设备编码',
+                    align: 'center',
+                    width: 150
+                  },
+                  {
+                    prop: 'assetName',
+                    label: '设备名称',
+                    align: 'center',
+                    width: 150
+                  },
+                  {
+                    prop: 'assetModelType',
+                    label: '设备型号',
+                    align: 'center',
+                    width: 150
+                  },
+                  {
+                    prop: 'assetCategoryLevelPath',
+                    label: '设备类型',
+                    align: 'center',
+                    width: 150
+                  }
+                ]
+              : [];
+
+          return [
+            {
+              columnKey: 'index',
+              label: '序号',
+              type: 'index',
+              width: 55,
+              align: 'center',
+              fixed: 'left'
+            },
+            {
+              width: 45,
+              type: 'selection',
+              columnKey: 'selection',
+              align: 'center',
+              fixed: 'left',
+              reserveSelection: true
+            },
+            {
+              prop: 'name',
+              label: this.dynamicName,
+              align: 'center',
+              width: 200
+            },
+            {
+              prop: 'code',
+              label: '编码',
+              align: 'center',
+              width: 200
+            },
+            ...data,
+
+            {
+              prop: 'status',
+              label: '状态',
+              align: 'center',
+              width: 150,
+              formatter: (row) => {
+                if (!row.status) return '';
+                return row.status.desc || '';
+              }
+            },
+            {
+              slot: 'quantity',
+              prop: 'quantity',
+              label: '数量',
+              align: 'center',
+              width: 140
+            },
+            {
+              slot: 'weight',
+              prop: 'weight',
+              label: `重量(${this.current.newWeightUnit})`,
+              align: 'center',
+              width: 140
+            },
+            {
+              slot: 'teamTimeIds',
+              prop: 'teamTimeIds',
+              label: '班次',
+              align: 'center',
+              minWidth: 220
+            },
+            {
+              slot: 'startTime',
+              prop: 'startTime',
+              label: '计划开始时间',
+              align: 'center',
+              minWidth: 240
+            },
+            {
+              slot: 'endTime',
+              prop: 'endTime',
+              label: '计划完成时间',
+              align: 'center',
+              minWidth: 240
+            },
+            {
+              columnKey: 'action',
+              label: '操作',
+              width: 120,
+              align: 'center',
+              resizable: false,
+              fixed: 'right',
+              slot: 'action'
             }
-          },
-          {
-            slot: 'quantity',
-            prop: 'quantity',
-            label: '数量',
-            align: 'center',
-            width: 140
-          },
-          {
-            slot: 'weight',
-            prop: 'weight',
-            label: `重量(${this.current.newWeightUnit})`,
-            align: 'center',
-            width: 140
-          },
-          {
-            slot: 'teamTimeIds',
-            prop: 'teamTimeIds',
-            label: '班次',
-            align: 'center',
-            minWidth: 220
-          },
-          {
-            slot: 'startTime',
-            prop: 'startTime',
-            label: '计划开始时间',
-            align: 'center',
-            minWidth: 240
-          },
-          {
-            slot: 'endTime',
-            prop: 'endTime',
-            label: '计划完成时间',
-            align: 'center',
-            minWidth: 240
-          },
-          {
-            columnKey: 'action',
-            label: '操作',
-            width: 120,
-            align: 'center',
-            resizable: false,
-            fixed: 'right',
-            slot: 'action'
-          }
-        ];
+          ];
+        };
       }
     },
     watch: {},

+ 19 - 0
src/views/workOrder/mixins/release.js

@@ -182,6 +182,7 @@ export default {
         };
         let processMap = {};
         this.processList.map((el, index) => (processMap[el.id] = index));
+        console.log(this.processList, 'processMap');
         const res = await listAssign(params);
         let isFirstData = false; // 判断默认第一道工序是否操作过
         if (res && res.length > 0) {
@@ -278,6 +279,24 @@ export default {
       listByFirstTaskId(id)
         .then((res) => {
           this.stationList = res;
+
+          this.stationList.forEach((item, index) => {
+            let substance = item.workstationSubstanceList[0]?.substance;
+            if (substance) {
+              this.$set(this.stationList[index], 'assetName', substance.name);
+              this.$set(this.stationList[index], 'assetCode', substance.code);
+              this.$set(
+                this.stationList[index],
+                'assetModelType',
+                substance.category?.category?.modelType
+              );
+              this.$set(
+                this.stationList[index],
+                'assetCategoryLevelPath',
+                substance.category?.category?.categoryLevelPath?.split('-')[0]
+              );
+            }
+          });
           this.changeDispatch();
         })
         .catch((err) => {