Kaynağa Gözat

字段表模板字段编辑部分

zishan-an 1 yıl önce
ebeveyn
işleme
f8736d349c
2 değiştirilmiş dosya ile 161 ekleme ve 18 silme
  1. 14 3
      src/api/index.js
  2. 147 15
      src/views/system/fieldTemplateEdit.vue

+ 14 - 3
src/api/index.js

@@ -82,13 +82,21 @@ export function findCooperatorProductByNum(cooperatorNum,pageNum,pageSize){
         pageSize:pageSize,
     })  ;
 }
-export function findTemplateFieldByNum(templateNo,pageNum,pageSize){
-    return request.post('/fieldtemplate/findTemplateFieldByNum/',{
+export function findBaseFieldByNo(templateNo,pageNum,pageSize){
+    return request.post('/fieldtemplate/findBaseFieldByNo/',{
         templateNo:templateNo,
         pageNum:pageNum,
         pageSize:pageSize,
     })  ;
 }
+export function findDeriveFieldByNo(templateNo,pageNum,pageSize){
+    return request.post('/fieldtemplate/findDeriveFieldByNo/',{
+        templateNo:templateNo,
+        pageNum:pageNum,
+        pageSize:pageSize,
+    })  ;
+}
+
 export function fieldTemplateList(pageNum,pageSize) {
     return request.post('/fieldtemplate/findAll',
     {
@@ -395,7 +403,10 @@ export function fieldTemplateEdit(templateData) {
         templateNo : templateData.templateNo,
         templateName : templateData.templateName,
         // status : templateData.status,
-        fieldSelected:templateData.fieldBaseSelected,
+        fieldBaseSelected:templateData.fieldBaseSelected,
+        fieldBaseSelectedOld:templateData.fieldBaseSelectedOld,
+        fieldDeriveSelected:templateData.fieldDeriveSelected,
+        fieldDeriveSelectedOld:templateData.fieldDeriveSelectedOld,
 
 
     });

+ 147 - 15
src/views/system/fieldTemplateEdit.vue

@@ -200,7 +200,7 @@
 
 import {
   getList,
-  userInfo, partnerList, fieldDel, cooperatorEdit, findTemplateFieldByNum, fieldListBase
+  userInfo, partnerList, fieldDel, cooperatorEdit, findBaseFieldByNo, fieldListBase, fieldListDerive,findDeriveFieldByNo
 } from '@/api/index.js'
 import store from "@/store";
 import request from '@/utils/request.js'
@@ -228,7 +228,12 @@ export default {
       fieldBaseShow:[],
       fieldDerive:[],
       fieldBaseSelected:[],
+      fieldBaseSelectedOld:[],
+
       fieldDeriveSelected:[],
+      fieldDeriveSelectedOld:[],
+      fieldTemplateDerive:[],
+      fieldTemplateBase:[],
       baseTotal:'',
       deriveTotal:'',
       allField: [],
@@ -255,7 +260,11 @@ export default {
             templateNo:this.$route.query.templateNo,
             templateName:this.$route.query.templateName,
             fieldBaseSelected:[],
+            fieldBaseSelectedOld:[],
+
             fieldDeriveSelected:[],
+            fieldDeriveSelectedOld:[],
+
             // status:this.$route.query.status,
             // createBy:'',
             // createTime:'',
@@ -270,16 +279,77 @@ export default {
 
   mounted()
   {
-    findTemplateFieldByNum(this.templateNo,this.currentPage1,this.pagesize1).then(
-      res=>
-      {
-        this.fieldBase=res.data.base_field.list;
-        this.fieldBaseShow = this.fieldBase
-
-        var j = parseInt(res.data.base_field.total)
-        this.baseTotal = j
-      }
-  );
+    fieldListBase(this.currentPage1,this.pagesize1).then(
+        res=>
+        {
+          this.fieldBase=res.data.fieldListBase.list;
+          this.fieldBaseShow = this.fieldBase
+          var j = parseInt(res.data.fieldListBase.total)
+          this.baseTotal = j
+          findBaseFieldByNo(this.templateNo,this.currentPage1,this.pagesize1).then(
+              res=>
+              {
+                this.fieldTemplateBase=res.data.base_field.list;
+                for (let i = 0; i < this.fieldTemplateBase.length; i++) {
+                  if (!this.fieldBaseSelected.includes(this.fieldTemplateBase[i].fieldDefineId)) {
+                    // 回显数据里没有本条,把这条加进来(选中)
+                    this.fieldBaseSelected.push(this.fieldTemplateBase[i].fieldDefineId);
+                    this.fieldBaseSelectedOld.push(this.fieldTemplateBase[i].id);
+
+                  }
+                }
+                this.fieldBase.forEach(item => {
+                  // 重点: 在当前分页列表中查询与回显数据是否有一致的id,一致则勾选数据回显
+                  // toggleRowSelection(item, true):设置当前行数据为选中状态
+                  if (this.fieldBaseSelected.includes(item.id)) {
+                    this.$refs.baseTable.toggleRowSelection(item, true);
+                  }
+                });
+                console.log("adshkjagsdhiuka")
+                console.log(this.fieldTemplateBase)
+
+                console.log(this.fieldBaseSelectedOld)
+
+              }
+          );
+          // console.log(this.fieldBase)
+        }
+    )
+    fieldListDerive(this.currentPage2,this.pagesize2).then(
+        res=>
+        {
+          this.fieldDerive=res.data.fieldListDerive.list;
+
+          this.fieldDeriveShow = this.fieldDerive
+          var k = parseInt(res.data.fieldListDerive.total)
+          this.deriveTotal = k
+          findDeriveFieldByNo(this.templateNo,this.currentPage2,this.pagesize2).then(
+              res=>
+              {
+                this.fieldTemplateDerive=res.data.derive_field.list;
+                for (let i = 0; i < this.fieldTemplateDerive.length; i++) {
+                  if (!this.fieldDeriveSelected.includes(this.fieldTemplateDerive[i].fieldDefineId)) {
+                    // 回显数据里没有本条,把这条加进来(选中)
+                    this.fieldDeriveSelected.push(this.fieldTemplateDerive[i].fieldDefineId);
+                    this.fieldDeriveSelectedOld.push(this.fieldTemplateDerive[i].id);
+
+                  }
+                }
+                this.fieldDerive.forEach(item => {
+                  // 重点: 在当前分页列表中查询与回显数据是否有一致的id,一致则勾选数据回显
+                  // toggleRowSelection(item, true):设置当前行数据为选中状态
+                  if (this.fieldDeriveSelected.includes(item.id)) {
+                    this.$refs.deriveTable.toggleRowSelection(item, true);
+                  }
+                });
+                console.log(this.fieldDeriveSelectedOld)
+
+              }
+          );
+          // console.log(this.fieldDerive)
+        }
+    )
+
   },
   beforeUpdate() {},
   updated() {},
@@ -301,12 +371,13 @@ export default {
         });
       }
     },
+
     handleCurrentChange1:function(currentPage){
       this.currentPage1=currentPage;
-      findTemplateFieldByNum(this.templateNo,this.currentPage1,this.pagesize1).then(
+      fieldListBase(this.currentPage1,this.pagesize1).then(
           res=>
           {
-            this.fieldBase=res.data.base_field.list;
+            this.fieldBase=res.data.fieldListBase.list;
             this.fieldBaseShow = this.fieldBase
             this.$nextTick(() => {
               this.fieldBase.forEach(item => {
@@ -322,10 +393,10 @@ export default {
     },
     handleSizeChange1:function(size){
       this.pagesize1=size;
-      findTemplateFieldByNum(this.templateNo,this.currentPage1,this.pagesize1).then(
+      fieldListBase(this.currentPage1,this.pagesize1).then(
           res=>
           {
-            this.fieldBase=res.data.base_field.list;
+            this.fieldBase=res.data.fieldListBase.list;
             this.fieldBaseShow = this.fieldBase
             this.$nextTick(() => {
               this.fieldBase.forEach(item => {
@@ -339,6 +410,63 @@ export default {
           }
       )
     },
+
+    handleSelectionChange2(selecteds, row) {
+      if (!this.fieldDeriveSelected.includes(row.id)) {
+        // 回显数据里没有本条,把这条加进来(选中)
+        this.fieldDeriveSelected.push(row.id);
+        console.log(this.fieldDeriveSelected)
+
+      } else {
+        // 回显数据里有本条,把这条删除(取消选中)
+        this.fieldDeriveSelected.forEach((id, index) => {
+          if (id === row.id) {
+            this.fieldDeriveSelected.splice(index, 1);
+          }
+        });
+      }
+    },
+    handleCurrentChange2:function(currentPage){
+      this.currentPage2=currentPage;
+      fieldListDerive(this.currentPage2,this.pagesize2).then(
+          res=>
+          {
+            this.fieldDerive=res.data.fieldListDerive.list;
+
+            this.fieldDeriveShow = this.fieldDerive
+            this.$nextTick(() => {
+              this.fieldDerive.forEach(item => {
+                // 重点: 在当前分页列表中查询与回显数据是否有一致的id,一致则勾选数据回显
+                // toggleRowSelection(item, true):设置当前行数据为选中状态
+                if (this.fieldDeriveSelected.includes(item.id)) {
+                  this.$refs.deriveTable.toggleRowSelection(item, true);
+                }
+              });
+            });
+          }
+      )
+    },
+    handleSizeChange2:function(size){
+      this.pagesize2=size;
+      fieldListDerive(this.currentPage2,this.pagesize2).then(
+          res=>
+          {
+            this.fieldDerive=res.data.fieldListDerive.list;
+
+            this.fieldDeriveShow = this.fieldDerive
+            this.$nextTick(() => {
+              this.fieldDerive.forEach(item => {
+                // 重点: 在当前分页列表中查询与回显数据是否有一致的id,一致则勾选数据回显
+                // toggleRowSelection(item, true):设置当前行数据为选中状态
+                if (this.fieldDeriveSelected.includes(item.id)) {
+                  this.$refs.deriveTable.toggleRowSelection(item, true);
+                }
+              });
+            });
+          }
+      )
+
+    },
     handleClick(tab, event) {
       if(tab.name=='second'){
         this.gotolinkbusiness();
@@ -379,6 +507,10 @@ export default {
       this.templateData.templateNo = this.templateNo;
       this.templateData.templateName = this.templateName;
       this.templateData.fieldBaseSelected = this.fieldBaseSelected;
+      this.templateData.fieldBaseSelectedOld = this.fieldBaseSelectedOld;
+
+      this.templateData.fieldDeriveSelected = this.fieldDeriveSelected;
+      this.templateData.fieldDeriveSelectedOld = this.fieldDeriveSelectedOld;
 
       // this.templateData.status = this.status;