فهرست منبع

独立填写单占位符只能输入一个

zhouna 6 سال پیش
والد
کامیت
2c8111e49c
1فایلهای تغییر یافته به همراه16 افزوده شده و 11 حذف شده
  1. 16 11
      src/components/preTreat/PubSelect.vue

+ 16 - 11
src/components/preTreat/PubSelect.vue

@@ -3,10 +3,10 @@
         <el-form>
             <div class="operation-row">
                 <el-checkbox-group size="small">
-                    <el-checkbox-button :label="0" @change="handlePlaceholder(0)">文字输入框占位符</el-checkbox-button>
+                    <el-checkbox-button :label="0" :disabled="disableBtn" @change="handlePlaceholder(0)">文字输入框占位符</el-checkbox-button>
                 </el-checkbox-group>
                 <el-checkbox-group size="small">
-                    <el-checkbox-button :label="0" @change="handlePlaceholder(1)">数字输入框占位符</el-checkbox-button>
+                    <el-checkbox-button :label="0" :disabled="disableBtn" @change="handlePlaceholder(1)">数字输入框占位符</el-checkbox-button>
                 </el-checkbox-group>
                 <el-checkbox-group size="small" v-if="type==2">
                     <el-checkbox-button :label="0" @change="handleExclu">互斥项</el-checkbox-button>
@@ -148,6 +148,7 @@
         rows:[...initRows],
         focusOn:-1,         //聚焦的行index
         focusName:'name',        //是否聚焦医生界面输入框
+        disableBtn:false,       //占位符是否禁用
       }
     },
     mounted(){
@@ -194,6 +195,12 @@
       selectRow(index,name){
         this.focusOn = index;
         this.focusName = name;
+        const placeReg = /(\$\{number_\S*?\})|(\$\{input_\S*?\})/g;
+        if(placeReg.test(this.rows[index][name])){
+          this.disableBtn = true;
+          return;
+        }
+        this.disableBtn = false;
       },
       handlePlaceholder(type){          //占位符类型,type=0文本输入框,type=1数字输入框
         const i = this.focusOn;
@@ -208,6 +215,7 @@
         const maps = {0:'${input_输入}',1:'${number_输入}'};
         const key = this.focusName;
         this.rows[i][key] = this.rows[i][key]+maps[type];
+        this.disableBtn = true;
         //this.rows[i].description = this.rows[i].description+maps[type];
       },
       handleExclu(){
@@ -242,16 +250,13 @@
       },
       HandleInputName(i, name, isName) {
         const pureName=name.replace(/(\$\{number_\S*?\})|(\$\{input_\S*?\})/g,'');
-        //console.log(pureName);
+        const hasPlace = /(\$\{number_\S*?\})|(\$\{input_\S*?\})/g.test(name);
+        if(hasPlace&&this.disableBtn==false){
+          this.disableBtn = true;
+        }else if(!hasPlace&&this.disableBtn==true){
+          this.disableBtn = false;
+        }
         if(pureName.length > 30) {
-          /*if(isName){
-            Vue.set(this.rows[i], 'name', this.rows[i].name.slice(0, 30));
-            this.$refs.inputName[i].currentValue = this.rows[i].name;
-          }else{
-            Vue.set(this.rows[i], 'description', this.rows[i].description.slice(0, 30));
-            this.$refs.inputDesc[i].currentValue = this.rows[i].description;
-          }*/
-
           this.$message({
             message: '最多输入30个字',
             type: 'warning',