Browse Source

编辑元素批量替换

duy 1 năm trước cách đây
mục cha
commit
6b0b00bbde

+ 8 - 0
src/api/exctab/editelement.js

@@ -17,6 +17,14 @@ export const submit = (data) => {
         data
     })
 }
+//新增修改批量
+export const submit2 = (data) => {
+  return request({
+      url: '/api/blade-manager/linkdatainfo/saveTabColInfo2',
+      method: 'post',
+      data
+  })
+}
 
 //删除元素
 export const remove = (data) => {

+ 116 - 14
src/views/manager/projectinfo/editElement/editElement.vue

@@ -262,9 +262,11 @@ import FormulaEdit from '@/views/formula/edit.vue'
 import FormulaEditone from '@/views/formula/edit1.vue'
 
 import { getExcelHtml } from '@/api/exctab/excelmodel'
-import { getElementInfoByTabId, submit, dictionarydataType, submitBatch,getUnMatchField } from '@/api/exctab/editelement'
+import { getElementInfoByTabId, submit,submit2, dictionarydataType, submitBatch,getUnMatchField } from '@/api/exctab/editelement'
 import Vue from 'vue'
 
+
+
 export default {
   components:{
     FormulaEdit,
@@ -366,6 +368,7 @@ export default {
       unMatchItems:[
 
       ],
+      checkList:[]//需要替换的数组
      
     }
   },
@@ -503,6 +506,9 @@ export default {
       })
 
     },
+    LeftClick(tr, td, x1, x2, y1, y2){
+      console.log('点击左');
+    },
 
     getTd(ele){
 
@@ -584,10 +590,23 @@ export default {
           checkboxGroupChange(){},
           keyupShiftUp() {},
           keyupShiftDown() {},
-          keyupShiftLeft() {},
-          keyupShiftRight() {},
-          inputLeftClick() {},
-        }
+          keyupShiftLeft() {
+        
+          },
+          keyupShiftRight() {
+          },
+          inputLeftClick() {
+         
+          },
+          KeyDown(e) {
+            if (e.ctrlKey|| e.metaKey) {
+              console.log("检测到按下了control键");
+            }
+          },
+        },
+        mounted() {
+          window.addEventListener("keydown", this.KeyDown, true);
+        },
       })
       var component = new MyComponent().$mount()
 
@@ -629,10 +648,16 @@ export default {
           checkboxGroupChange(){},
           keyupShiftUp() {},
           keyupShiftDown() {},
-          keyupShiftLeft() {},
+          keyupShiftLeft() {
+           
+          },
           keyupShiftRight() {},
-          inputLeftClick() {},
-        }
+          inputLeftClick() {
+           
+          },
+        },
+     
+
       })
       var component = new MyComponent().$mount()
       let na = document.getElementById('parent')
@@ -664,16 +689,41 @@ export default {
        this.$refs.cascader.clearCheckedNodes()//调用方法无效
     },
     saveReplace () {//保存按钮
-      if (this.value&& this.table) {
+      console.log(this.checkList,'checkList');
+
+      // if (this.value&& this.table) {
+      //   this.tag = true
+      //   this.submit({
+      //     tabId: this.pkeyId,
+      //     tdIndex: this.table.td,
+      //     trIndex: this.table.tr,
+      //     colName: "",
+      //     htmlType: this.value
+      //   })
+      // } 
+      if (this.value&&this.table&&this.checkList.length===0) {
         this.tag = true
-        this.submit({
+        this.submit2([{
           tabId: this.pkeyId,
           tdIndex: this.table.td,
           trIndex: this.table.tr,
           colName: "",
           htmlType: this.value
-        })
-      } else {
+        }])
+      } else if(this.value&&this.checkList.length>0){
+       let arr=[]
+       this.checkList.forEach((ele)=>{
+          arr.push({
+            tabId: this.pkeyId,
+            tdIndex: ele.td,
+            trIndex: ele.tr,
+            colName: "",
+            htmlType: this.value
+          })
+       })
+       this.submit2(arr)
+      }
+      else {
         this.$message({
           type: "error",
           message: "请右键选择要替换的元素"
@@ -704,6 +754,23 @@ export default {
         }
       }
     },
+    async submit2 (da) {//批量保存替换元素
+      const { data: res } = await submit2(da)
+      console.log(res);
+      if (res.code == 200) {
+        const { data: res } = await getExcelHtml({ pkeyId: this.pkeyId })
+        console.log(res);
+        if (res.code === 200) {
+          this.tag = false
+          // this.value = ''
+          this.options = []
+          localStorage.setItem('editElement', res.data)
+          this.getElementInfoByTabId()
+          this.copss()
+          this.getUnMatchFieldData()
+        }
+      }
+    },
     //#endregion
 
     //#region 弹框事件
@@ -831,8 +898,23 @@ export default {
       }
     },
 
+
+
+  noRepeat(tempArr) {
+      for (let i = 0; i < tempArr.length; i++) {
+          for (let j = i + 1; j < tempArr.length; j++) {
+              if (tempArr[i].tr == tempArr[j].tr&&tempArr[i].td == tempArr[j].td) {
+                  tempArr.splice(j, 1);
+                  j--;
+              }
+          }
+      }
+      return tempArr;
+  },
+
     //excel父节点点击检测
     parentClick(e){
+    const{metaKey,ctrlKey}=e
       let target = e.target;
       console.log(target,'target');
       let bgs = document.querySelectorAll("#parent .oldlace-bg")
@@ -845,8 +927,26 @@ export default {
         let tdEle = this.getParentTD(target);
         if(tdEle){
           target.classList.add("oldlace-bg");
+          if(metaKey||ctrlKey){
+            target.classList.add("select-td");
+            this.checkList.push({
+              tr:target.getAttribute('trindex'),
+              td:target.getAttribute('tdindex'),
+            })
+          }else{
+            target.classList.remove("select-td");
+            this.checkList.forEach((ele,index)=>{
+              if(ele.tr===target.getAttribute('trindex')){
+                this.checkList.splice(index,1)
+              }
+            })
+          }
+          
+         
 
         }
+      
+        this.noRepeat(this.checkList)
       }
     },
 
@@ -860,6 +960,7 @@ export default {
       }
       return targetParent;
     },
+
  
 
   },
@@ -956,8 +1057,9 @@ export default {
 /deep/ .warnstyle .el-textarea__inner{
   background-image: url('/img/login/warn.png') !important;       
   background-repeat: no-repeat;        
-  background-size:cover;        
-  background-position: center
+  // background-size:cover;        
+  background-position-x: 45%;
+  background-position-y: 46%;
 }
 
 .full-dialog{