Selaa lähdekoodia

多选下拉框回显修改

duy 1 vuosi sitten
vanhempi
commit
f9ba4fdb1c

+ 28 - 1
src/views/manager/projectinfo/treeTemplate/dynamicExcel.vue

@@ -233,7 +233,6 @@ export default {
       }
       //console.log(target.getAttribute('trindex'))
       let tdEle = this.getParentTD(target);
-      console.log(tdEle,'tdEle');
       console.log(tdEle.getAttribute('dqid'),'dianqianid');
       this.htmlData.dqid=tdEle.getAttribute('dqid')
       // const {data: res} = await getSignDetail({id: this.htmlData.dqid})
@@ -303,6 +302,30 @@ export default {
 
     //获取控件信息
     getWidget(tdEle){
+      let selectElement = tdEle.querySelectorAll('.el-select');
+      let isMultiple =false
+      if(selectElement.length){
+  
+     // 遍历每个元素,检查是否包含 is-multiple 类名
+     selectElement.forEach(element => {
+          if (element.classList.contains('is-multiple')) {
+            isMultiple = true;
+          }
+      });
+        if(isMultiple){
+          let options = selectElement[0].__vue__.options;
+          let selectDatas = [];
+          for (let i = 0; i < options.length; i++) {
+            selectDatas.push({
+              dictValue:options[i].label
+            });
+          }
+          return {
+            type:'selectBox',
+            selectDatas
+          }
+        }
+      }
       let checkLabels = tdEle.querySelectorAll('.el-checkbox-group span.el-checkbox__label');
       //console.log(checkLabels)
       if(checkLabels.length > 0){
@@ -347,8 +370,12 @@ export default {
           type:'select',
           selectDatas
         }
+        
       }
 
+  
+    
+
       return {};
     },
 

+ 6 - 2
src/views/manager/projectinfo/treeTemplate/template/setInputTPT.vue

@@ -184,7 +184,7 @@ export default {
   },
   watch: {
     myHtmlData: function (newV) {
-      //console.log(newV)
+      console.log(newV,'1111111111')
       if (newV.type) {
         if (newV.type == 'checkbox') {
           this.from.type = 'checkbox';
@@ -196,6 +196,10 @@ export default {
           this.from.type = 'select';
           this.setInputTable = newV.selectDatas;
         }
+        else if (newV.type == 'selectBox') {
+          this.from.type = 'selectBox';
+          this.setInputTable = newV.selectDatas;
+        }
       } else {
        
         // this.from.type = '';
@@ -267,7 +271,7 @@ export default {
       this.disabled = true
       if (this.from.type) {
         let ks = false
-        if (this.from.type == 'select' | this.from.type == 'radio' | this.from.type == 'checkbox') {
+        if (this.from.type == 'select' | this.from.type == 'radio' | this.from.type == 'checkbox' | this.from.type == 'selectBox') {
           if (this.setInputTable) {
             this.setInputTable.forEach(val => {
               if (!val.dictValue) {