Browse Source

单选标签属性选项置灰

zhouna 6 years ago
parent
commit
6e9b2f3504
3 changed files with 36 additions and 46 deletions
  1. 3 2
      src/api/utils.js
  2. 3 3
      src/components/icss/AddIndeptLabel.vue
  3. 30 41
      src/components/icss/SingleSelect.vue

+ 3 - 2
src/api/utils.js

@@ -148,14 +148,15 @@ export default {
     return tmpArr;
   },
   /**
-   * @
+   * 单选数据转换提交
    * **/
   simpleOptionData(data){
     const {options,defaultCheckeds,sameToNones,sameToBans} = data;
-    let defaultSelect = '0',code='';
+    let defaultSelect = '0';
     let arr=[];
     options.forEach((it,i)=>{
       if(it){
+        let code='';
         defaultSelect = +defaultCheckeds[0]===i?'1':'0';
         if(+sameToNones[0]===i){
           code='2';

+ 3 - 3
src/components/icss/AddIndeptLabel.vue

@@ -75,7 +75,7 @@
       pushValues(its){
         this.options = its;
       },
-      submitForm() {       // 调用子组件的方法验证公用部分
+      submitForm() {      // 调用子组件的方法验证公用部分
         this.$refs.submitForm.submitForm('groups');
       },
       validatePass() {      //验证成功回调,调取接口
@@ -108,8 +108,8 @@
             "questionDetails": this.options,
             "questionMappings": []       //映射关系,
           }
-        };console.log(param)
-        //this.showSaveDialog(param);
+        };
+        this.showSaveDialog(param);
       },
       showSaveDialog(param) {
         this.showConfirmDialog('是否保存该标签?', () => {

+ 30 - 41
src/components/icss/SingleSelect.vue

@@ -3,18 +3,19 @@
         <el-form :model="form">
             <div class="operation-row">
                 <el-checkbox-group size="small" v-model="form.defaultCheckeds" @change="emitValues">
-                    <el-checkbox-button v-for="(it,i) in rows" v-if="focusOn==i||(focusOn==-1&&i==0)" :label="i">默认选中</el-checkbox-button>
+                    <el-checkbox-button v-for="(it,i) in rows" v-if="focusOn==i||(focusOn==-1&&i==0)" :key="i" :label="i" :disabled="(form.defaultCheckeds[0]!=undefined&&form.defaultCheckeds[0]!=i)||form.sameToNones[0]==i||form.sameToBans[0]==i">默认选中</el-checkbox-button>
                 </el-checkbox-group>
                 <el-checkbox-group size="small" v-model="form.sameToNones" @change="emitValues">
-                    <el-checkbox-button v-for="(it,i) in rows" v-if="focusOn==i||(focusOn==-1&&i==0)" :label="i">同“无”类型</el-checkbox-button>
+                    <el-checkbox-button v-for="(it,i) in rows" v-if="focusOn==i||(focusOn==-1&&i==0)" :key="i" :label="i" :disabled="(form.sameToNones[0]!=undefined&&form.sameToNones[0]!=i)||form.defaultCheckeds[0]==i||form.sameToBans[0]==i">同“无”类型</el-checkbox-button>
                 </el-checkbox-group>
                 <el-checkbox-group size="small" v-model="form.sameToBans" @change="emitValues">
-                    <el-checkbox-button v-for="(it,i) in rows" v-if="focusOn==i||(focusOn==-1&&i==0)" :label="i">同“伴”类型</el-checkbox-button>
+                    <el-checkbox-button v-for="(it,i) in rows" v-if="focusOn==i||(focusOn==-1&&i==0)" :key="i" :label="i" :disabled="(form.sameToBans[0]!=undefined&&form.sameToBans[0]!=i)||form.sameToNones[0]==i||form.defaultCheckeds[0]==i">同“伴”类型</el-checkbox-button>
                 </el-checkbox-group>
                 <el-button type="danger" size="small" class="del" @click="delRow">删除</el-button>
             </div>
             <div class="main-area">
                 <el-input v-for="(it,i) in rows"
+                          :key="i"
                           v-model="form.options[i]"
                           v-bind:class="{select:focusOn==i}"
                           @focus="selectRow(i)"
@@ -29,6 +30,11 @@
     .el-checkbox-button--small .el-checkbox-button__inner{
         font-size: 14px;
     }
+    .el-checkbox-button.is-disabled:first-child .el-checkbox-button__inner{
+        border-color: @disableColor;
+        border-left-color: @disableColor;
+        color: @disableColor;
+    }
     .el-checkbox-button:last-child .el-checkbox-button__inner{
         border-radius: 3px;
         border-color: @adminBase;
@@ -72,6 +78,7 @@
       props:['type'],
       data(){
         return {
+          argus:['defaultCheckeds','sameToNones','sameToBans'],
           form:{
             options:[],
             defaultCheckeds:[],
@@ -82,42 +89,25 @@
           focusOn:-1
         }
       },
-      /*watch:{
-        defaultChecked:function(next){
-          if(this.focusOn==-1){
-            this.defaultChecked = false;
-            this.$message({
-              message: '请先选择要操作的行',
-              type: 'warning'
-            });
-            return;
-          }
-          this.form.defaultChecked=next?this.focusOn:-1;console.log(this.form)
-          this.emitValues();
-        },
-        sameToNone:function(next){
-          if(this.focusOn==-1){
-            this.sameToNone = false;
-            this.$message({
-              message: '请先选择要操作的行',
-              type: 'warning'
-            });
-            return;
-          }
-          this.form.sameToNone=next?this.focusOn:-1;
-          this.emitValues();
-        },
-        sameToBan:function(next){
-          if(this.focusOn==-1){
-            this.sameToBan = false;
-            this.$message({
-              message: '请先选择要操作的行',
-              type: 'warning'
-            });
-            return;
+      /*computed:{
+        isDisable:function(){               //属性按钮是否可用
+          return function(type,i){
+            if(this.form[type][0]!=undefined&&this.form[type][0]!=i){
+              return true;
+            }
+            if(this.form[type][0] == i){
+              return false;
+            }
+            for(let x=0;x<this.argus.length;x++){
+              if([...this.form.defaultCheckeds,...this.form.sameToNones,...this.form.sameToBans].length==0||this.form[this.argus[x]][0]==i){
+                return false;
+              }else{
+                return true;
+              }
+              }
+
+            return false;
           }
-          this.form.sameToBan=next?this.focusOn:-1;
-          this.emitValues();
         }
       },*/
       methods:{
@@ -141,9 +131,8 @@
 
         },
         emitValues(){
-          //console.log(this.form)
-          const items = utils.simpleOptionData(this.form);
-          //this.$emit('pushValues',items);
+          const items = utils.simpleOptionData(this.form);console.log(111,items)
+          this.$emit('pushValues',items);
         },
         delRow(){
           if(this.focusOn==-1){