Browse Source

数据映射修改

duy 1 month ago
parent
commit
10eb2045a1
2 changed files with 92 additions and 74 deletions
  1. 8 0
      src/api/tentative/testcollect.js
  2. 84 74
      src/views/tentative/components/dataMap.vue

+ 8 - 0
src/api/tentative/testcollect.js

@@ -189,4 +189,12 @@ export const getLinkData = (params) => {
     method: 'get',
     params
   })
+}
+
+export const removeLinkData = (params) => {
+  return request({
+    url: '/api/blade-manager/trial/summary/reflection/remove',
+    method: 'post',
+    params
+  })
 }

+ 84 - 74
src/views/tentative/components/dataMap.vue

@@ -20,7 +20,7 @@
              <div>
                 <span>选择表单</span>
                 <el-select
-                  v-model="eleItem.formVal"
+                  v-model="eleItem.initTabId"
                   placeholder="请选择"
                   style="width: 65%; margin-left: 10px"
                   @change="changeform($event,index)"
@@ -37,7 +37,7 @@
               <div>
                 <span>选择元素</span>
                 <el-select
-                  v-model="eleItem.eleVal"
+                  v-model="eleItem.elementId"
                   placeholder="请选择"
                   style="width: 65%; margin-left: 10px; margin-top: 15px"
                   @change="changeEle($event,index)"
@@ -45,9 +45,9 @@
                 >
                   <el-option
                     v-for="item in eleOptions"
-                    :key="item.ekey"
+                    :key="item.id"
                     :label="item.eName"
-                    :value="item.ekey"
+                    :value="item.id"
                   >
                   </el-option>
                 </el-select>
@@ -63,7 +63,7 @@
                   </el-row>
                   <div class="martop20">
                     <el-button type="primary" size="small" @click="addList(index)">新增元素</el-button>
-                    <el-button type="danger"  size="small" v-if="index>0" @click="delList(index,item)">删除元素</el-button>
+                    <el-button type="danger"  size="small" v-if="index>0" @click="delList(index,eleItem)">删除元素</el-button>
                   </div>
                 
                 </div>
@@ -79,8 +79,9 @@ import {
   getLinkTablist,
   getLinkElelist,
   getLinkDetail,
-  saveLinkDetail,
+  removeLinkData,
   getLinkData,
+  saveLinkDetail 
 } from "@/api/tentative/testcollect";
 import Vue from "vue";
 import Split from "split.js";
@@ -90,11 +91,11 @@ export default {
       formoptions: [],
       eleOptions: [],
       heights: "",
-      formVal: "",
+      initTabId: "",
       formpid: "",
       formname: "",
       classId: "",
-      eleVal: "",
+      elementId: "",
       eleId: "",
       clickKeyname: "",
       infoDetail: {
@@ -188,12 +189,7 @@ export default {
           },
           template: res.data,
           methods: {
-            //改变表单数据
-            //  setFormData(obj) {
-            //         this.formData = obj
-            //         _that.setFormData2(obj)
-            //         console.log(this.formData,'this.formData1111111');
-            //  },
+     
             contextmenuClick() {},
             getInformation() {},
             formUploadSuccess() {},
@@ -343,11 +339,9 @@ export default {
     },
     changeEle(val,index) {
       this.eleOptions.forEach((ele) => {
-        if (ele.ekey === val) {
-          this.eleId = ele.id;
-          this.infoDetail.elementName = ele.eName;
-          // this.$set(this.curItem, "elementKey", val);
-          // this.$set(this.curItem, "elementId", ele.id);
+        if (ele.id === val) {
+       
+       
           this.listArr[index].elementName= ele.eName
           this.listArr[index].elementId= ele.id
         }
@@ -358,7 +352,7 @@ export default {
       const { data: res } = await getLinkElelist({
         id: val,
       });
-      console.log(res);
+
       if (res.code === 200) {
         this.eleOptions = res.data;
       } else {
@@ -372,67 +366,56 @@ export default {
         keyName: this.clickKeyname,
       });
       if (res.code === 200) {
-        this.infoDetail = res.data;
+        this.listArr = res.data||[]
+        this.formoptions.forEach((ele)=>{
+         this.listArr.forEach(async(eleItem,eleIndex)=>{
+          if(ele.pkeyId===eleItem.trialTabId){
+            eleItem.initTabId=ele.initTabId
+            await this.getEleList(ele.initTabId)
+           this.changeEle(eleItem.elementId,eleIndex)
 
-        if (this.infoDetail && this.infoDetail.id) {
-          this.formoptions.forEach((ele) => {
-            if (ele.tabName === this.infoDetail.tabName) {
-              this.formVal = ele.initTabId;
-              // this.$set(this.curItem, "trialTabName", ele.initTableName);
-              // this.$set(this.curItem, "trialTabId", ele.pkeyId);
             
-            }
-          });
-          await this.getEleList(this.formVal);
-          this.eleOptions.forEach((ele) => {
-            if (ele.eName === this.infoDetail.elementName) {
-              this.eleVal = ele.ekey;
-              // this.curItem.elementId=ele.id
-              // this.curItem.elementKey=ele.ekey
-              this.$set(this.curItem, "elementId", ele.id);
-              this.$set(this.curItem, "elementKey", ele.ekey);
-            }
-          });
-        } else {
-          this.infoDetail = {};
-          this.formVal = "";
-          this.eleVal = "";
-          this.curItem = {};
-          // this.curItem.htmlKeyName=this.clickKeyname
-          this.$set(this.curItem, "htmlKeyName", this.clickKeyname);
-        }
+          }
+
+         })
+        })
+      
+       
+        
+
+    
       } else {
-        this.infoDetail = {};
-      }
+          this.listArr = []
+
+        }
     },
 
     //映射数据保存
     async saveInfo() {
-      console.log(this.clickArr, "this.clickArr");
-      console.log(this.listArr,'listArr')
+  
       
-      // if (this.clickArr.length === 0) {
-      //   this.$message.warning("请进行数据映射配置");
-      //   return;
-      // }
+      if (this.listArr.length === 0) {
+        this.$message.warning("请进行数据映射配置");
+        return;
+      }
 
-      // this.saveLoaing = true;
-      // const { data: res } = await saveLinkDetail({
-      //   classId: this.classId,
-      //   reflectionBeanList: this.clickArr,
-      // });
-      // console.log(res);
-      // this.saveLoaing = false;
-      // if (res.code === 200) {
-      //   this.$message({
-      //     type: "success",
-      //     message: res.msg,
-      //   });
-      //   await this.getLinkedData();
-      //   await this.getExcelHtmlCol(this.classId, this.linkedData); //获取excel模板
-      //   this.clickArr = [];
-      //   this.curItem={}
-      // }
+      this.saveLoaing = true;
+      const { data: res } = await saveLinkDetail({
+        classId: this.classId,
+        reflectionBeanList: this.listArr,
+      });
+
+      this.saveLoaing = false;
+      if (res.code === 200) {
+        this.$message({
+          type: "success",
+          message: res.msg,
+        });
+        await this.getLinkedData();
+        await this.getExcelHtmlCol(this.classId, this.linkedData); //获取excel模板
+        this.clickArr = [];
+        this.curItem={}
+      }
     },
     addList(index){
        this.listArr.splice(index + 1, 0, { 
@@ -442,8 +425,35 @@ export default {
           elementName: ''
         });
     },
-    delList(index){
-      this.listArr.splice(index,1)
+    delList(index,item){
+   
+      if(!item.id){
+        this.listArr.splice(index,1)
+        return
+      }else{
+         this.$confirm('删除后,数据将无法恢复,是否确认删除!', '提示', {
+            confirmButtonText: '确定',
+            cancelButtonText: '取消',
+            type: 'warning'
+          }).then(() => {
+  
+            removeLinkData({id:item.id}).then((res) => {
+              if(res.data.code==200){
+                this.$message.success(res.data.msg);
+              
+                this.listArr.splice(index, 1);
+              this.getLinkedData();
+              this.getExcelHtmlCol(this.classId, this.linkedData); //获取excel模板
+              }else{
+                this.$message.error(res.data.msg);
+              }
+            });
+          }).catch(() => {
+            this.$message.info('已取消删除');
+          })
+      }
+
+      
     }
   },
   async created() {