Просмотр исходного кода

查看详情不能编辑bug修复

lucw 7 месяцев назад
Родитель
Сommit
75037f2e66

+ 72 - 27
src/views/rulesManagement/components/MaterialAdd.vue

@@ -14,7 +14,7 @@
         width="244px"
         allow-collapse
         :right-style="{ overflow: 'hidden' }"
-      >   
+      >
         <div class="ele-border-lighter split-layout-right-content">
           <el-tree
             :data="treeList"
@@ -39,7 +39,18 @@
             :selection.sync="selection"
             row-key="id"
             :initLoad="false"
+            cache-key="main-material-add-2511121044"
           >
+            <template v-slot:radio="{ row }">
+              <el-radio
+                v-model="currentId"
+                :label="row.id"
+                @change="currentInfo = row"
+              >
+                <i></i>
+              </el-radio>
+            </template>
+
             <template v-slot:modelType="{ row }">
               <span>{{ row.category.modelType }}</span>
             </template>
@@ -68,6 +79,16 @@
   import { getAssetList } from '@/api/ruleManagement/plan';
   import { getTreeByPid, getTreeByGroup } from '@/api/classifyManage';
   export default {
+    components: {
+      ProductSearch
+    },
+    props: {
+      // 是否支持多选
+      multiple: {
+        type: Boolean,
+        default: true
+      }
+    },
     data() {
       return {
         ruleIdListIndex: 0,
@@ -82,19 +103,18 @@
           label: 'name'
         },
         type: null,
-        // 表格列配置
-        columns: [
-          {
-            columnKey: 'selection',
-            type: 'selection',
-            width: 45,
-            align: 'center',
-            selectable: (row, index) => {
-              return !this.processData.some((id) => id == row.id);
-            },
-            reserveSelection: true,
-            fixed: 'left'
-          },
+        // 表格选中数据
+        selection: [],
+        processData: [],
+        checkedKeys: [],
+        currentId: null,
+        currentInfo: null
+      };
+    },
+    computed: {
+      // 表格列配置
+      columns() {
+        let list = [
           {
             label: '设备名称',
             prop: 'name'
@@ -142,16 +162,31 @@
             prop: 'pathName',
             slot: 'pathName'
           }
-        ],
+        ];
 
-        // 表格选中数据
-        selection: [],
-        processData: [],
-        checkedKeys: []
-      };
-    },
-    components: {
-      ProductSearch
+        if (this.multiple) {
+          list.unshift({
+            columnKey: 'selection',
+            type: 'selection',
+            width: 45,
+            align: 'center',
+            selectable: (row, index) => {
+              return !this.processData.some((id) => id == row.id);
+            },
+            reserveSelection: true,
+            fixed: 'left'
+          });
+        } else {
+          list.unshift({
+            slot: 'radio',
+            width: 50,
+            align: 'center',
+            fixed: 'left'
+          });
+        }
+
+        return list;
+      }
     },
     methods: {
       /* 表格数据源 */
@@ -224,18 +259,28 @@
       handleClose() {
         this.visible = false;
         this.$refs.table.setSelectedRows([]);
+        this.currentInfo = null;
+        this.currentId = null;
         this.selection = [];
       },
       selected() {
-        if (!this.selection.length) {
-          this.$message.error('请至少选择一条数据');
-          return;
+        if (this.multiple) {
+          if (!this.selection.length) {
+            this.$message.error('请选择设备');
+            return;
+          }
+        } else {
+          if (!this.currentInfo) {
+            this.$message.error('请选择设备');
+            return;
+          }
         }
+
         const selectList = this.$refs.treeRef.getCheckedNodes();
         console.log('selectList-----------', selectList);
         this.$emit(
           'chooseEquipment',
-          this.selection,
+          this.multiple ? this.selection : this.currentInfo,
           this.ruleIdListIndex,
           this.categoryId
         );

+ 3 - 2
src/views/rulesManagement/releaseRules/components/permitAdd.vue

@@ -529,6 +529,7 @@
       ref="deviceSelectDialog"
       selectType="single"
       @chooseEquipment="chooseEquipment"
+      :multiple="false"
     />
 
     <ProductModal
@@ -1328,8 +1329,8 @@
       // 选择设备回调
       chooseEquipment(data, index, categoryId) {
         console.log('data', data, index, categoryId);
-        this.formData.deviceId = data[0]?.id || null;
-        this.formData.deviceName = data[0]?.name || '';
+        this.formData.deviceId = data?.id || null;
+        this.formData.deviceName = data?.name || '';
       },
       // 添加
       addRow() {

+ 15 - 10
src/views/technology/production/components/user-setting-matter-add.vue

@@ -16,6 +16,7 @@
       ref="formRef"
       label-width="120px"
       :rules="rules"
+      :disabled="type == 'details'"
     >
       <el-form-item label="类型" required prop="itemType">
         <DictSelection
@@ -136,6 +137,7 @@
       ref="deviceSelectDialog"
       selectType="single"
       @chooseEquipment="chooseEquipment"
+      :multiple="false"
     ></material-add>
 
     <selectMatterRules
@@ -205,7 +207,7 @@
 
       return {
         visible: false,
-        type: 'add', // add新增 edit编辑
+        type: 'add', // add新增 edit编辑 details 详情
         formBaseData,
         formData: JSON.parse(JSON.stringify(formBaseData)),
         // 表单验证规则
@@ -283,10 +285,11 @@
           this.formData.executeMethod = '2';
         }
       },
-      openEdit(row) {
-        this.title = '编辑事项';
+      openEdit(row, type = 'edit') {
+        console.log('type', type);
+        this.title = type == 'edit' ? '编辑事项' : '事项详情';
         console.log('row', row);
-        this.type = 'edit';
+        this.type = type;
         this.visible = true;
         this.$util.assignObject(this.formData, row);
         this.formData.executeMethod = row.executeMethod + '';
@@ -300,15 +303,14 @@
       },
       chooseEquipment(data, index, categoryId) {
         console.log('data', data, index, categoryId);
-        this.formData.deviceId = data[0]?.id || null;
-        this.formData.deviceName = data[0]?.name || '';
-        if (this.rules && this.rules.length > 1) {
-          // 提示用户选择的规则有多个事项规则
-          this.$message.warning('所选设备包含多个设备,请注意选择');
-        }
+        this.formData.deviceId = data?.id || null;
+        this.formData.deviceName = data?.name || '';
       },
       // 去选择事项规则
       selectRulesId() {
+        if (this.type == 'details') {
+          return;
+        }
         this.$refs.selectMatterRulesRef.open();
       },
       confirm() {
@@ -347,6 +349,9 @@
       },
       // 去选择记录规则
       selectReleaseId() {
+        if (this.type == 'details') {
+          return;
+        }
         this.$refs.selectReleaseRulesRef.open(
           this.formData.reportWorkType,
           this.formData.produceTaskId

+ 1 - 1
src/views/technology/production/components/user-setting-matter-process.vue

@@ -266,7 +266,7 @@
       },
       openEditMatter(row) {
         this.currentEditRow = row;
-        this.$refs.userSettingMatterAddRef.openEdit(row);
+        this.$refs.userSettingMatterAddRef.openEdit(row, 'details');
       },
       addMatter(matter, rules) {
         const id = 'tem' + new Date().getTime();

+ 4 - 2
src/views/technology/production/components/user-setting-matter.vue

@@ -168,7 +168,9 @@
       tabPaneList() {
         const list = this.dict['record_rules_report_work_type'] || [];
         // 排除过程监测
-        return list.filter((item) => item.dictCode != '2' && item.dictCode != '4');
+        return list.filter(
+          (item) => item.dictCode != '2' && item.dictCode != '4'
+        );
         // return list;
       }
     },
@@ -234,7 +236,7 @@
         this.$refs.userSettingMatterAddRef.openAdd(this.reportWorkType);
       },
       openEditMatter(row) {
-        this.$refs.userSettingMatterAddRef.openEdit(row);
+        this.$refs.userSettingMatterAddRef.openEdit(row, 'details');
       },
       addMatter(matter) {
         console.log('matter', matter);