Explorar o código

关联清表接口调用

duy hai 1 ano
pai
achega
43caddeac8

+ 18 - 1
src/api/tentative/testcollect.js

@@ -121,4 +121,21 @@ export const matching = (row) => {
     method: 'post',
     data: row
   })
-}
+}
+
+//关联清表
+export const relevancy = (row) => {
+  return request({
+    url: '/api/blade-manager/trial/summary/relevancy',
+    method: 'post',
+    data: row
+  })
+}
+//关联清表-清表懒加载
+export const tablazy = (params) => {
+  return request({
+    url: '/api/blade-manager/trial/summary/lazy',
+    method: 'get',
+    params
+  })
+}

+ 11 - 0
src/views/tentative/components/configDivision.vue

@@ -50,6 +50,8 @@
             show-checkbox
             @check-change="checkchange"
             v-loading="testGLExcelLoading"
+            :default-checked-keys="defaultKeys"
+          
           >
           </el-tree>
         </el-scrollbar>
@@ -84,6 +86,10 @@ import {matching} from "@/api/tentative/testcollect";
             setId:{
               type:[String,Number],
               default:''
+            },
+            trialTreeIds:{
+              type:[String,Number],
+              default:''//已勾选的数据
             }
         
         },
@@ -116,6 +122,7 @@ import {matching} from "@/api/tentative/testcollect";
                 return tag;
                 },
             },
+            defaultKeys:[]
 
             }
         },
@@ -221,6 +228,10 @@ import {matching} from "@/api/tentative/testcollect";
             },
             setId(val){
                 this.setId=val
+            },
+            trialTreeIds(val){
+              this.trialTreeIds=val
+              this.defaultKeys=this.trialTreeIds.split(',')
             }
         }
     }

+ 63 - 41
src/views/tentative/testclassifyset.vue

@@ -45,7 +45,7 @@
           style="width: 100%"
           v-model="GLExcelFrom.name"
           placeholder="请选择"
-          @change="changetherr()"
+          @change="changetherr"
         >
           <el-option
             v-for="(item, key) in GLExcelData"
@@ -58,21 +58,26 @@
         <el-scrollbar style="margin-top: 20px; height: 50vh">
           <el-input
           style="width: 100%"
-            v-model.trim="GLExcelFrom.search"
+            v-model.trim="searchVal"
             placeholder="请输入需要选择的内容"
           ></el-input>
           <el-tree
+          v-if="checkId"
+            :key="treeKey"
+            lazy
             :filter-node-method="filterNode222"
             ref="tree"
             class="filter-tree"
             style="margin-top: 10px"
             :props="GLExcelProps"
-            :data="exceldata"
+            :load="loadNode"
             node-key="id"
             accordion
             show-checkbox
             @check="checkchange"
             v-loading="GLExcelLoading"
+            :default-checked-keys="linkexcelId"
+
           >
           </el-tree>
         </el-scrollbar>
@@ -87,13 +92,13 @@
           style="margin-left: 30px"
           type="primary"
           v-throttle="2000"
-          @click="saveLinkTab()"
+          @click="saveLink()"
           >确 定</el-button
         >
       </span>
     </el-dialog>
     <!-- 配置划分数据 -->
-    <configDivision :testGLExcel="testGLExcel" :setId="setId" @changemodal="changemodal"></configDivision>
+    <configDivision :testGLExcel="testGLExcel" :setId="setId" @changemodal="changemodal" :trialTreeIds="trialTreeIds"></configDivision>
     </basic-container>
   </template>
   
@@ -102,11 +107,12 @@
   import {mapGetters} from "vuex";
   import {
   getList as getListQing,
-  tabLazytreeAll,
-  saveLinkTab,
-  getExcelHtml,
+
+
 } from "@/api/exctab/excelmodel";
+import {relevancy,tablazy} from "@/api/tentative/testcollect";
 import configDivision from "./components/configDivision.vue";
+
   
   export default {
     components:{
@@ -160,6 +166,7 @@ import configDivision from "./components/configDivision.vue";
           initTableName: "",
           initTableId:""
         },
+        searchVal:'',
         GLExcelData:[],
         exceldata:[],
         GLExcelProps: {
@@ -178,6 +185,11 @@ import configDivision from "./components/configDivision.vue";
         },
       },
       testGLExcel:false,
+      checkId:'',
+      treeKey:Math.random,
+      setId:'',
+      trialTreeIds:'',//已关联的配置划分数据
+      linkexcelId:[]//已关联的清表数据
       };
     },
     computed: {
@@ -200,12 +212,12 @@ import configDivision from "./components/configDivision.vue";
       }
     },
     watch: {
-      "GLExcelFrom.search"(val) {
-        console.log(val);
+      searchVal(val) {
         if (this.exceldata) {
           this.$refs.tree.filter(val);
         }
       },
+     
     },
     methods: {
       rowSave(row, done, loading) {
@@ -300,9 +312,12 @@ import configDivision from "./components/configDivision.vue";
         //关联清表
     Associationlist(row) {
       //关联清表点击事件
-      console.log(row,'row');
-      this.GLExcelFrom.id = row.pkeyId;
+      this.linkexcelId=row.excelId.split(',')
+      this.GLExcelFrom.id = row.id;
+      this.GLExcelFrom=row
+      this.searchVal=''
       this.GLExcel =true ;
+      this.treeKey=Math.random()
       this.getList({
         current: 1,
         size: 100000,
@@ -316,28 +331,39 @@ import configDivision from "./components/configDivision.vue";
       this.GLExcelFrom.search = "";
       this.GLExcelFrom.id = "";
       this.exceldata = [];
-
+      this.checkId=''
       this.GLExcel = false;
     },
-    changetherr() {
+    changetherr(val) {
+      console.log(val,'val');
       //清表类型选择框change事件
       if (this.GLExcelFrom.name != "") {
         this.GLExcelFrom.search = "";
-        this.tabLazytreeAll();
+        this.checkId=val
+        this.treeKey=Math.random()
+        
+    
       }
     },
-    async tabLazytreeAll() {
-      //清表树信息
-      this.GLExcelLoading = true;
-      const { data: res } = await tabLazytreeAll({
-        modeId: this.GLExcelFrom.name,
-        name: this.GLExcelFrom.search,
-      });
-      this.GLExcelLoading = false;
-      console.log(res);
-      if (res.code === 200 && res.msg === "操作成功") {
-        this.exceldata = res.data;
+
+    loadNode(node, resolve) {
+      let pid = 0;
+      let modeId=this.checkId;
+      if (node.level != 0) {
+        pid = node.data.id;
+        modeId=node.data.parentId
       }
+      tablazy({
+        modeId: modeId,
+        parentId: pid,
+        classId:this.GLExcelFrom.id
+      }).then((res) => {
+        let arr = [];
+        if (Array.isArray(res.data.data)) {
+          arr = res.data.data;
+        }
+        return resolve(arr);
+      });
     },
     filterNode222(value,data,node) {
       if(!value){
@@ -375,21 +401,14 @@ import configDivision from "./components/configDivision.vue";
           this.$refs.tree.setCheckedKeys([data.id]);
         }
     },
-    async saveLinkTab() {
+    async saveLink() {
         //保存按钮
-        let checkNodes = this.$refs.tree.getCheckedNodes();
-        if (checkNodes.length > 0) {
-          let node = checkNodes[checkNodes.length - 1];
-          if (node.fileType != 3) {
-            this.$message({
-              type: "warning",
-              message: "请先上传Excel表",
-            });
-            return;
-          }
-          const { data: res } = await saveLinkTab({
-            exceTabId: node.id,
-            tabId: this.GLExcelFrom.id,
+        let checkIds=this.$refs.tree.getCheckedKeys();
+        if (checkIds.length > 0) {
+          
+          const { data: res } = await relevancy({
+                classId:this.GLExcelFrom.id,
+                excelId:checkIds.join(',')
           });
           console.log(res);
           if (res.code === 200) {
@@ -398,11 +417,12 @@ import configDivision from "./components/configDivision.vue";
               message: "关联清表成功",
             });
             this.GLExcel =false ;
+            this.refreshChange()
           }
         } else {
           this.$message({
             type: "warning",
-            message: "请先设置清表",
+            message: "请先选择清表",
           });
         }
     },
@@ -410,9 +430,11 @@ import configDivision from "./components/configDivision.vue";
     configurationClick(row){
       this.testGLExcel=true
       this.setId=row.id
+      this.trialTreeIds=row.trialTreeIds
     },
     changemodal(){
       this.testGLExcel=false
+      this.refreshChange()
     },
     //数据映射配置
     associatedClick() {