Browse Source

关联元素修改

duy 1 month ago
parent
commit
ace8da835d
2 changed files with 85 additions and 28 deletions
  1. 2 2
      src/api/ruleManage/fileRule.js
  2. 83 26
      src/views/codeRule/LinkEle.vue

+ 2 - 2
src/api/ruleManage/fileRule.js

@@ -94,9 +94,9 @@ export const saveConditionSet = (data,id) => {
     });
 }
 //关联元素
-export const saveElementJoin = (data) => {
+export const saveElementJoin = (data,id) => {
     return request({
-        url: '/api/blade-business/uStandardInfo/saveElementJoin',
+        url: '/api/blade-business/uStandardInfo/saveElementJoin'+'?id='+id,
         method: 'post',
         data
     });

+ 83 - 26
src/views/codeRule/LinkEle.vue

@@ -66,7 +66,7 @@
         <div class="condition-list">
           <div class="condition-item1">
            <div 
-                 v-for="(item, index) in paramList[activeIndex].standardInfos" 
+                 v-for="(item, index) in paramList[activeIndex].group" 
                 :key="index"
               
                 >
@@ -74,13 +74,13 @@
             <span>
                 <div class="condition-header-content">
                 <div style="color: black;">
-                    {{item.name}}
+                    {{item.privateName}}
                 </div>
                 <i class="el-icon-close" @click.stop="handleDeleteItem(item,index)"></i>
                 </div>
                 <div class="code-list">
                 <div class="code-item">
-                     {{ item.standardInfoGroupNameVO.name }}
+                     {{ item.elementNames}}
                 </div>
                 </div>
             </span>
@@ -106,9 +106,9 @@
                        <i class="el-icon-connection" style="color: black; font-size: larger;"></i>
                   </div>
                   <div class="code-list">
-                    <div v-for="(codeItem, codeIndex) in item.standardInfos" :key="codeIndex" class="code-item">
-                        <div class="code-title">{{ codeItem.name }}</div>
-                        <div class="code-detail">{{ codeItem.standardInfoGroupNameVO.name }}</div>
+                    <div v-for="(codeItem, codeIndex) in item.group" :key="codeIndex" class="code-item">
+                        <div class="code-title">{{ codeItem.privateName }}</div>
+                        <div class="code-detail">{{ codeItem.elementNames }}</div>
                     </div>
 
                   </div>
@@ -216,7 +216,7 @@
 import { getDictionary } from "@/api/system/dict";
 import { findNodeTableByCondition as selectByNodeTable} from "@/api/manager/wbsprivate";
 import checkEleHtml from "./checkEleHtml.vue";
-import {getInfoPage,saveConditionSet,getConditionSet,getElementJoin } from "@/api/ruleManage/fileRule.js";
+import {saveElementJoin,deleteElementJoin,getElementJoin } from "@/api/ruleManage/fileRule.js";
 export default {
   name: 'ConditionsSet',
   components: {
@@ -229,11 +229,9 @@ export default {
       paramList: [
         {
           symbolName: '<0.75',
-          standardInfos:[
+          group:[
             {name: 'C3A', 
-            rightStandardInfos: [
-              {name:'矿渣硅酸盐水泥',id:'1'}
-            ],
+          
             standardInfoGroupNameVO:{
               name: '矿渣硅酸盐水泥'
             }
@@ -293,12 +291,12 @@ export default {
      
       if(arr.length>0){
           this.$nextTick(()=>{
-              // this.paramList[index].standardInfos = arr[0]['standardInfos']
-              this.$set(this.paramList, index, { ...this.paramList[index], standardInfos: arr[0]['standardInfos'] });
+              // this.paramList[index].group = arr[0]['group']
+              this.$set(this.paramList, index, { ...this.paramList[index], group: arr[0]['group'] });
           })
 
       }else{
-        this.paramList[index].standardInfos = []
+        this.paramList[index].group = []
       }
       
     },
@@ -345,12 +343,59 @@ export default {
     },
   
     handleConfirm() {
+      
+      saveElementJoin(this.linkListData,this.id).then((res)=>{
+        if(res.data.code === 200) {
+          this.$message({
+            type: 'success',
+            message: res.data.msg,
+          })
+        }else{
+          this.$message({
+            type: 'error',
+            message: res.data.msg,
+          })
+        }
+      })
       this.hide()
       this.$emit('confirm')
     },
+    toggleClick(item, index) {
+        this.linkListData.forEach(listItem => {
+          this.$set(listItem, 'clicked', false);
+        });
+        this.$set(item, 'clicked', !item.clicked);
+        let clickedIndex = this.paramList.findIndex(listItem => listItem.id === item.id);
+        console.log(clickedIndex, 'clickedIndex');
+        this.activeIndex = clickedIndex;
+        
+    },
+    handleDeleteLinkItem(item,index){
+        this.$confirm('删除后,数据将无法恢复,是否确认删除!', '提示', {
+            confirmButtonText: '确定',
+            cancelButtonText: '取消',
+            type: 'warning'
+          }).then(() => {
+  
+            deleteElementJoin({leftId:item.id}).then((res) => {
+              if(res.data.code==200){
+                this.$message.success(res.data.msg);
+              
+                this.linkListData.splice(index, 1);
+                this.getLinkSetData(this.id);
+              }else{
+                this.$message.error(res.data.msg);
+              }
+            });
+          }).catch(() => {
+            this.$message.info('已取消删除');
+          })
+    },
     addCondition() {
       // 添加条件逻辑
            this.addDialogVisible = true
+           this.pkeyId = ''
+
       this.getTableData();
     },
    handleSelect1(index) {
@@ -359,8 +404,8 @@ export default {
 
  
     handleDeleteItem(item, index) {
-      this.paramList[this.activeIndex].codeList.splice(index, 1)
-      this.$message.success('删除成功')
+      this.paramList[this.activeIndex].group.splice(index, 1)
+     
     },
     confirmAdd() {
       if (this.checkEleList.length === 0) {
@@ -372,18 +417,26 @@ export default {
         return;
       }
       const selectedCodes = this.checkEleList.map(ele => ({
-        name: ele.keyName,
-        value: ele.elementId
+        colName: ele.keyName,
+        colKey: ele.elementId 
       }));
       console.log(selectedCodes,'selectedCodes');
-      
-       this.paramList[this.activeIndex].codeList.push({
-        codeName: this.checkTableRow.tableName,
-
-        codeValue: selectedCodes
-       })
-
-     
+      console.log(this.paramList,'this.paramList');
+      let objArr={}
+       const elementNames = selectedCodes.map(code => code.colName).join(' ');
+        objArr={
+          
+          privateName: this.checkTableRow.tableName,
+          privateId: this.checkTableRow.id,
+          elementNames: elementNames,
+          keys: selectedCodes,
+        
+        }
+  
+        
+        this.paramList[this.activeIndex].group.push(objArr);
+    
+  
          
 
       this.addDialogVisible = false;
@@ -396,6 +449,10 @@ export default {
     },
     //保存条件
     saveEle(){
+      console.log(this.paramList,'保存条件');
+      
+        const filteredArr = this.paramList.filter(item => item.group.length !== 0);
+        this.linkListData = JSON.parse(JSON.stringify(filteredArr));
 
     },
     formatTableType(row, column, cellValue) {