|
@@ -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>
|
|
@@ -23,13 +23,13 @@
|
|
|
<div class="inps">
|
|
|
<el-input v-model="rows[i].name"
|
|
|
v-bind:class="{select:focusOn==i}"
|
|
|
- @focus="selectRow(i)"
|
|
|
+ @focus="selectRow(i,'name')"
|
|
|
ref = "inputName"
|
|
|
@input="HandleInputName(i, rows[i].name,true)"
|
|
|
@blur="emitValues"></el-input>
|
|
|
<el-input v-model="rows[i].description"
|
|
|
v-bind:class="{select:focusOn==i}"
|
|
|
- @focus="selectRow(i)"
|
|
|
+ @focus="selectRow(i,'description')"
|
|
|
ref = "inputDesc"
|
|
|
@input="HandleInputName(i, rows[i].description)"
|
|
|
@blur="emitValues"></el-input>
|
|
@@ -43,7 +43,7 @@
|
|
|
<div class="inps">
|
|
|
<el-input v-model="rows[i].name"
|
|
|
v-bind:class="{select:focusOn==i}"
|
|
|
- @focus="selectRow(i)"
|
|
|
+ @focus="selectRow(i,'name')"
|
|
|
ref = "inputName"
|
|
|
@input="HandleInputName(i, rows[i].name,true)"
|
|
|
@blur="emitValues"></el-input>
|
|
@@ -147,6 +147,8 @@
|
|
|
return {
|
|
|
rows:[...initRows],
|
|
|
focusOn:-1, //聚焦的行index
|
|
|
+ focusName:'name', //是否聚焦医生界面输入框
|
|
|
+ disableBtn:false, //占位符是否禁用
|
|
|
}
|
|
|
},
|
|
|
mounted(){
|
|
@@ -155,15 +157,10 @@
|
|
|
const arr = options.filter((it)=>{
|
|
|
return it.name;
|
|
|
});
|
|
|
- const arrLen = arr.length;
|
|
|
- if(arrLen < 4) {
|
|
|
- for (let i = 0; i < 4 - arrLen; i++) {
|
|
|
- arr.push(...utils.getInitRow(initRow,1))
|
|
|
- }
|
|
|
- }
|
|
|
- this.rows = arr;
|
|
|
- const items = utils.simpleOptionData(this.rows);
|
|
|
- this.$emit('pushValues',items);
|
|
|
+ this.rows = arr.length==0?utils.getInitRow(initRow,4):arr;
|
|
|
+ this.$emit('pushValues',arr);
|
|
|
+ }else{
|
|
|
+ this.initData();
|
|
|
}
|
|
|
},
|
|
|
computed:{
|
|
@@ -177,29 +174,32 @@
|
|
|
},
|
|
|
},
|
|
|
watch: {
|
|
|
- ascription(newVal, preVal) {
|
|
|
- if (newVal != preVal) {
|
|
|
- this.rows = [...utils.getInitRow(initRow,4)];
|
|
|
- }
|
|
|
+ /*ascription(newVal, preVal) { //永远检测不到,因为归属修改时类型被清空,本组件被销毁
|
|
|
+ this.rows = [...utils.getInitRow(initRow,4)];
|
|
|
+ },*/
|
|
|
+ type() {
|
|
|
+ this.initData();
|
|
|
},
|
|
|
- type(newVal, preVal) {
|
|
|
- if (newVal != preVal) {
|
|
|
- this.rows = [...utils.getInitRow(initRow,4)];
|
|
|
- }
|
|
|
- },
|
|
|
- sexType(newVal, preVal) {
|
|
|
- if (newVal != preVal) {
|
|
|
- this.rows = [...utils.getInitRow(initRow,4)];
|
|
|
- }
|
|
|
+ sexType() {
|
|
|
+ this.initData();
|
|
|
},
|
|
|
},
|
|
|
methods:{
|
|
|
+ initData(){
|
|
|
+ this.rows = [...utils.getInitRow(initRow,4)];
|
|
|
+ },
|
|
|
addRow(){
|
|
|
- this.rows.push(utils.getInitRow(initRow,1));
|
|
|
+ this.rows.push(Object.assign({},initRow,{orderNo:this.rows.length}));
|
|
|
},
|
|
|
- selectRow(index){
|
|
|
+ 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;
|
|
@@ -212,8 +212,10 @@
|
|
|
return ;
|
|
|
}
|
|
|
const maps = {0:'${input_输入}',1:'${number_输入}'};
|
|
|
- this.rows[i].name = this.rows[i].name+maps[type];
|
|
|
- this.rows[i].description = this.rows[i].description+maps[type];
|
|
|
+ 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(){
|
|
|
const i = this.focusOn;
|
|
@@ -246,15 +248,14 @@
|
|
|
this.$emit('pushValues',items);
|
|
|
},
|
|
|
HandleInputName(i, name, isName) {
|
|
|
- if(name.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;
|
|
|
- }
|
|
|
-
|
|
|
+ const pureName=name.replace(/(\$\{number_\S*?\})|(\$\{input_\S*?\})/g,'');
|
|
|
+ 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) {
|
|
|
this.$message({
|
|
|
message: '最多输入30个字',
|
|
|
type: 'warning',
|