ソースを参照

添加独立标签标签明细限制30个字

zhangxc 6 年 前
コミット
22bf16a5ab

+ 0 - 1
src/components/icss/AddIndeptLabel.vue

@@ -91,7 +91,6 @@
       },
       validatePass() {      //验证成功回调,调取接口
         //仍需验证标签明细是否选择
-        console.log('this.options',this.options)
         let isNull = true
         let options2 = []
         for (let i = 0; i < this.options.length; i++) {

+ 21 - 0
src/components/icss/SingleSelect.vue

@@ -21,6 +21,8 @@
                     <el-input v-model="rows[i].name"
                               v-bind:class="{select:focusOn==i}"
                               @focus="selectRow(i)"
+                              ref = "inputName"
+                              @input="HandleInputName(i, rows[i].name)"
                               @blur="emitValues"></el-input>
                     <el-tag type="info" size="mini" v-if="showTag(it)">{{showTag(it)}}</el-tag>
                 </el-col>
@@ -81,6 +83,7 @@
 </style>
 <script>
   import utils from '@api/utils.js';
+  import Vue from 'vue';
     export default {
       props:['type','options','ascription','sexType'],
       data(){
@@ -96,6 +99,12 @@
           const arr = options.map((it)=>{
             return {name:it.name,defaultSelect:it.defaultSelect=='1'?true:false,isBan:it.code==1?true:'',isNone:it.code==2?true:'',isError:it.abnormal==1?true:''};
           });
+          const arrLen = arr.length;
+          if(arrLen < 4) {
+            for (let i = 0; i < 4 - arrLen; i++) {
+              arr.push({name:'',defaultSelect:'',isBan:'',isNone:'',isError:''})
+            }
+          }
           this.rows = arr;
           const items = utils.simpleOptionData(this.rows);
           this.$emit('pushValues',items);
@@ -177,6 +186,18 @@
           const items = utils.simpleOptionData(this.rows);
           this.$emit('pushValues',items);
         },
+        HandleInputName(i, name) {
+          if(name.length > 30) {
+            Vue.set(this.rows[i], 'name', this.rows[i].name.slice(0, 30))
+            this.$refs.inputName[i].currentValue = this.rows[i].namebvcx
+            this.$message({
+              message: '最多输入30个字',
+              type: 'warning'
+            });
+            return
+          }
+          
+        },
         delRow(){
           if(this.focusOn==-1){
             this.$message({