Browse Source

基础规范修改

duy 2 tháng trước cách đây
mục cha
commit
614d0afddb
2 tập tin đã thay đổi với 94 bổ sung23 xóa
  1. 91 17
      src/views/codeRule/ConditionsSet.vue
  2. 3 6
      src/views/codeRule/ruleManage.vue

+ 91 - 17
src/views/codeRule/ConditionsSet.vue

@@ -172,6 +172,7 @@
 </template>
 
 <script>
+import {getInfoPage,saveConditionSet,getConditionSet } from "@/api/ruleManage/fileRule.js";
 export default {
   name: 'ConditionsSet',
   data() {
@@ -198,15 +199,10 @@ export default {
             codeNameId: ''
         },
         sampleOptions: [
-            { value: '1', label: '试验值水泥' }
-            // 添加更多选项...
-        ],
-        basicOptions: [
-            { value: '1', label: '矿渣硅酸盐水泥' },
-            { value: '2', label: '普通酸盐水泥' },
-              { value: '3', label: '普通酸盐水泥' },
+          
             // 添加更多选项...
         ],
+        basicOptions: [],
       linkListData: [
         {paramName:'<0.75',codeList:[
           {codeName: 'C3A', codeValue: [
@@ -248,27 +244,50 @@ export default {
         ]},
            
       ], // 关联关系数据
+      id:'', // 传入的ID规范文件id
 
     }
   },
   methods: {
-    show(val) {
-      console.log(val,'val');
-      
+    show(val,id) {
+      this.id = id
+      this.getSampleOptions(id)
       this.visible = true
       if(val.length > 0&&val[0].name) {
-        console.log(val,'val');
         this.paramList = val.map(item => {
           return {
-            paramName: item.select + item.name,
-            codeList: []
+            paramName: item.symbolName,
+            codeList: [],
+            id: item.id
           }
         })
        
       }else{
         this.paramList = []
       }
+      this.getConditionSetData(this.id);
     },
+    //获取样品信息列表
+     getSampleOptions(id){
+             getInfoPage({
+                current:1,
+                size:100,
+                type: 1,
+                standardId: id,
+              }).then((res) => {
+                this.ruleLoading = false;
+                if (res.data.code === 200) {
+                  this.sampleOptions= res.data.data.records.map(item => ({
+                    value: item.id,
+                    label: item.name,
+                    info:item.info
+                  }));
+                  // 
+                } else {
+                  this.sampleOptions = [];
+                }
+              });
+      },
     hide() {
       this.visible = false  
     },
@@ -283,6 +302,7 @@ export default {
     addCondition() {
       // 添加条件逻辑
            this.addDialogVisible = true
+           this.addForm = {}
     },
     addOperation() {
       // 添加操作逻辑
@@ -316,6 +336,13 @@ export default {
        
         }
       });
+       const selectedOption = this.sampleOptions.find(option => option.value === value);
+       console.log(selectedOption,'selectedOption');
+       this.basicOptions = selectedOption ? selectedOption.info.map(item => ({
+         value: item.id,
+         label: item.name
+       })) : [];
+       
     },
     handleDeleteItem(item, index) {
       this.paramList[this.activeIndex].codeList.splice(index, 1)
@@ -336,10 +363,57 @@ export default {
       }
       this.$message.success('添加成功')
     },
-    //保存条件
-    saveCondition() {
-      // 这里可以添加保存条件的逻辑
-      this.$message.success('条件已保存')
+          //保存条件
+      saveCondition() {
+      let resArr = this.paramList.map(item => {
+        // 收集所有 codeValue 的 value,不需要额外的数组包装
+        const rightIds = item.codeList.reduce((acc, codeItem) => {
+          // codeItem.codeValue[0].value 是一个数组,直接展开到 acc 中
+          return [...acc, ...codeItem.codeValue[0].value];
+        }, []);
+
+        return {
+          leftId: item.id, // leftId 保持数组形式
+          rightIds // rightIds 是展开后的一维数组
+        };
+      });
+
+        // 调用保存接口
+        if (resArr.length === 0) {
+          this.$message.warning('请先设置关联关系');
+          return;
+        }
+        console.log(resArr,'resArr');
+        
+        saveConditionSet(resArr).then((res) => {
+          if(res.data.code == 200) {
+            this.$message.success(res.data.msg);
+            this.getConditionSetData(this.id);
+          } else {
+            this.$message.error(res.data.msg);
+          }
+        }).finally(() => {
+          this.saveYpLoad = false;
+        });
+      },
+    // 获取条件设置
+    getConditionSetData(id) {
+      getConditionSet({id}).then((res) => {
+        if (res.data.code === 200) {
+          console.log(res.data.data, '获取的条件设置数据');
+          
+          // this.paramList = res.data.data.map(item => ({
+          //   paramName: item.symbolName,
+          //   codeList: item.codeList.map(codeItem => ({
+          //     codeName: codeItem.codeName,
+          //     codeValue: codeItem.codeValue.map(val => ({ name: val.name, value: val.value }))
+          //   })),
+          //   id: item.id
+          // }));
+        } else {
+          // this.$message.error(res.data.msg);
+        }
+      });
     }
   }
 }

+ 3 - 6
src/views/codeRule/ruleManage.vue

@@ -493,7 +493,7 @@ import { getStore, setStore } from "@/util/store";
         jsList:[
           {id:1,name:'技术指标名称',
           info:
-          [{name:'基本信息1'} , {name:'基本信息2'}    , {name:'基本信息3'}    , {name:'基本信息4'}]
+          []
           },  
         ],
         isShowJsList:false,
@@ -972,10 +972,7 @@ import { getStore, setStore } from "@/util/store";
          
         }).catch(() => {});
       },
-       handleEdit1(item, index) {
-        // 处理编辑逻辑
-        console.log('编辑项目:', item, index);
-      },
+  
 
       handleDelete1(item,index) {
         this.$confirm('删除后,数据无法恢复,是否确认删除?', '删除确认', {
@@ -1105,7 +1102,7 @@ import { getStore, setStore } from "@/util/store";
         this.$message.error('请先添加技术指标内容');
         return;
       }
-      this.$refs.conditionsSetRef.show(this.jsDetail.info)
+      this.$refs.conditionsSetRef.show(this.jsDetail.info,this.ruleItemDetail.id);
 
     },
     // 添加确认取消处理方法