Ver código fonte

fix: 修复设备信息和工具/设备列展示逻辑

yusheng 1 mês atrás
pai
commit
fb3485e19b

+ 6 - 6
src/views/rulesManagement/recordPlan/components/programRulesDialog.vue

@@ -1240,14 +1240,14 @@
 
         console.log('规则明细数据', rules);
         let deviceInfo = [];
-        if (rules.deviceId) {
+        if (data.deviceId) {
           deviceInfo = [
             {
-              code: rules.deviceCode,
-              codeNumber: rules.codeNumber,
-              fixCode: rules.fixCode,
-              id: rules.deviceId,
-              name: rules.deviceName
+              code: data.deviceCode,
+              codeNumber: data.codeNumber,
+              fixCode: data.fixCode,
+              id: data.deviceId,
+              name: data.deviceName
             }
           ];
         }

+ 51 - 29
src/views/rulesManagement/releaseRules/components/permitAdd.vue

@@ -336,6 +336,7 @@
               icon="el-icon-plus"
               class="ele-btn-icon"
               @click="bindSubstanceListOpen"
+              v-if="this.formData.reportWorkType==5"
             >
               添加物联参数
             </el-button>
@@ -564,13 +565,9 @@
           }}</span>
         </template>
         <template v-slot:toolName="{ row, $index }">
-          <el-link
-            :underline="false"
-            style="cursor: pointer"
-            v-if="formData.reportWorkType != 5"
-          >
+          <el-link :underline="false" style="cursor: pointer">
             <div class="ele-cell">
-              <div @click="handleAdd(row)">
+              <div @click="handleAdd(row, '', 'toolName')">
                 {{
                   row.tools && row.tools.length > 0
                     ? row.tools.map((i) => i.toolName).join(',')
@@ -580,32 +577,37 @@
               <i
                 v-if="row.tools.length == 0"
                 class="el-icon-arrow-down"
-                @click="handleAdd(row)"
+                @click="handleAdd(row, '', 'toolName')"
+              ></i>
+              <i
+                v-else
+                class="el-icon-close"
+                @click="clearTool(row, '', 'toolName')"
               ></i>
-              <i v-else class="el-icon-close" @click="clearTool(row)"></i>
             </div>
           </el-link>
-          <el-link :underline="false" style="cursor: pointer" v-else>
+        </template>
+        <template v-slot:substanceName="{ row, $index }">
+          <el-link :underline="false" style="cursor: pointer">
             <div class="ele-cell">
-              <div @click="handleAdd(row, $index)">
+              <div @click="handleAdd(row, $index, 'substanceName')">
                 {{ row.substanceName || '请选择' }}
               </div>
               <i
                 v-if="!row.substanceName"
                 class="el-icon-arrow-down"
-                @click="handleAdd(row, $index)"
+                @click="handleAdd(row, $index, 'substanceName')"
               ></i>
               <i
                 v-else
                 class="el-icon-close"
-                @click="clearTool(row, $index)"
+                @click="clearTool(row, $index, 'substanceName')"
               ></i>
             </div>
           </el-link>
         </template>
         <template v-slot:toolCodes="{ row }">
           <el-input
-            v-if="formData.reportWorkType != 5"
             :value="
               row.tools && row.tools.length > 0
                 ? row.tools.map((i) => i.toolCode).join(',')
@@ -615,8 +617,9 @@
             disabled
             size="mini"
           ></el-input>
+        </template>
+        <template v-slot:substanceCode="{ row }">
           <el-input
-            v-else
             :value="row.substanceCode"
             placeholder="自动带出"
             disabled
@@ -690,12 +693,7 @@
       <el-button :loading="btnLoading" @click="handleClose">取消</el-button>
     </template>
 
-    <toolModal
-      ref="toolModalRef"
-      @chooseModal="chooseModal"
-      :isMain="formData.reportWorkType != 5"
-      :multiple="formData.reportWorkType != 5"
-    />
+    <toolModal ref="toolModalRef" @chooseModal="chooseModal" />
 
     <toolModal
       ref="toolModalTowRef"
@@ -789,7 +787,7 @@
     },
     computed: {
       bankColumns() {
-        const list = [
+        let list = [
           {
             width: 110,
             type: 'index',
@@ -853,20 +851,35 @@
             slot: 'unitName',
             minWidth: 110
           },
+          {
+            prop: 'substanceName',
+            label: '设备名称',
+            align: 'center',
+            slot: 'substanceName',
+            minWidth: 110
+          },
+          {
+            prop: 'substanceCode',
+            label: '设备编码',
+            align: 'center',
+            slot: 'substanceCode',
+            minWidth: 110
+          },
           {
             prop: 'toolName',
-            label: this.formData.reportWorkType == 5 ? '设备名称' : '工具名称',
+            label: '工具名称',
             align: 'center',
             slot: 'toolName',
             minWidth: 110
           },
           {
             prop: 'toolCodes',
-            label: this.formData.reportWorkType == 5 ? '设备编码' : '工具编码',
+            label: '工具编码',
             align: 'center',
             slot: 'toolCodes',
             minWidth: 110
           },
+
           {
             prop: 'remark',
             label: '备注',
@@ -886,7 +899,13 @@
         ];
         if (this.formData.recordTemplateStyle != '4') {
           // 过滤掉 计算公式 列
-          return list.filter((i) => i.prop != 'formula');
+          list = list.filter((i) => i.prop != 'formula');
+        }
+
+        if (this.formData.reportWorkType != 5) {
+          list = list.filter(
+            (i) => !['substanceName', 'substanceCode'].includes(i.prop)
+          );
         }
         return list;
       },
@@ -1770,6 +1789,9 @@
         console.log('data', data, index, categoryId);
         this.formData.deviceId = data?.id || null;
         this.formData.deviceName = data?.name || '';
+        if (this.formData.reportWorkType == 5) {
+          this.formData.details = [];
+        }
       },
       // 添加
       addRow() {
@@ -1821,14 +1843,14 @@
           this.formData.details.splice(index, 1);
         }
       },
-      handleAdd(row, index) {
+      handleAdd(row, index, type) {
         this.currentRow = row;
         this.currentIndex = index;
-        if (this.formData.reportWorkType == 5) {
+        if (type == 'substanceName') {
           this.$refs.bindSubstanceRef.open(
             this.formData.deviceId,
             this.formData.deviceName,
-            this.formData.deviceCode,
+            this.formData.deviceCode
           );
         } else {
           this.$refs.toolModalRef.open(row.toolCodes);
@@ -1839,7 +1861,7 @@
         this.$refs.bindSubstanceRef.open(
           this.formData.deviceId,
           this.formData.deviceName,
-          this.formData.deviceCode,
+          this.formData.deviceCode
         );
       },
       bindSubstanceSuccess(list) {
@@ -1911,7 +1933,7 @@
       },
       // 清空工具
       clearTool(row, index) {
-        if (this.formData.reportWorkType == 5) {
+        if (type == 'substanceName') {
           substanceKey.forEach((key) => {
             this.$set(this.formData.details[index], key, '');
           });