|
@@ -8,7 +8,7 @@
|
|
|
<el-checkbox-group size="small" v-if="type==2">
|
|
|
<el-checkbox-button :label="0">数字输入框占位符</el-checkbox-button>
|
|
|
</el-checkbox-group>
|
|
|
- <el-checkbox-group size="small">
|
|
|
+ <el-checkbox-group size="small" v-if="type==1&&ascription!=1">
|
|
|
<el-checkbox-button :label="0">互斥项</el-checkbox-button>
|
|
|
</el-checkbox-group>
|
|
|
<span v-if="type == 11" class="tip">可输入中文全角括号"()", 当作可输入内容的占位符</span>
|
|
@@ -26,16 +26,16 @@
|
|
|
v-bind:class="{select:focusOn==i}"
|
|
|
@focus="selectRow(i)"
|
|
|
ref = "inputName"
|
|
|
- @input="HandleInputName(i, rows[i].name)"
|
|
|
+ @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)"
|
|
|
- ref = "inputName"
|
|
|
- @input="HandleInputName(i, rows[i].name)"
|
|
|
+ ref = "inputDesc"
|
|
|
+ @input="HandleInputName(i, rows[i].description)"
|
|
|
@blur="emitValues"></el-input>
|
|
|
</div>
|
|
|
- <el-tag v-if="it.isExclu" type="info" size="mini">互斥项</el-tag>
|
|
|
+ <el-tag v-if="it.isExclu" type="info" size="mini" @click="">互斥项</el-tag>
|
|
|
</el-col>
|
|
|
<el-button @click="addRow">+</el-button>
|
|
|
</div>
|
|
@@ -68,6 +68,7 @@
|
|
|
}
|
|
|
.operation-row{
|
|
|
margin-left:150px;
|
|
|
+ text-align: right;
|
|
|
.del{
|
|
|
margin-left: 150px;
|
|
|
}
|
|
@@ -119,25 +120,29 @@
|
|
|
<script>
|
|
|
import utils from '@api/utils.js';
|
|
|
import Vue from 'vue';
|
|
|
+
|
|
|
+ //单行数据
|
|
|
+ const initRow = {orderNo:0,name:'',description:'',exclusion:0};
|
|
|
+ const initRows = utils.getInitRow(initRow,4);
|
|
|
export default {
|
|
|
props:['type','options','ascription','sexType'],
|
|
|
data(){
|
|
|
return {
|
|
|
//maps:{isBan:'同“伴”',isNone:'同“无”',defaultSelect:'默认选中',isError:'异常选项'},
|
|
|
- rows:new Array(4).fill({name:'',description:'',isExclu:false}),
|
|
|
- focusOn:-1
|
|
|
+ rows:[...initRows],
|
|
|
+ focusOn:-1, //聚焦的行index
|
|
|
}
|
|
|
},
|
|
|
mounted(){
|
|
|
const {options} = this.$props;
|
|
|
if(options){
|
|
|
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:''};
|
|
|
+ return {name:it.name,description:'',isExclu:false};
|
|
|
});
|
|
|
const arrLen = arr.length;
|
|
|
if(arrLen < 4) {
|
|
|
for (let i = 0; i < 4 - arrLen; i++) {
|
|
|
- arr.push({name:'',defaultSelect:'',isBan:'',isNone:'',isError:''})
|
|
|
+ arr.push(utils.getInitRow(initRow,1))
|
|
|
}
|
|
|
}
|
|
|
this.rows = arr;
|
|
@@ -154,57 +159,33 @@
|
|
|
return this.maps[name];
|
|
|
}
|
|
|
},
|
|
|
- hasDefault:function(){ //是否有选项默认选中
|
|
|
- let index =this.rows.findIndex((it)=>{
|
|
|
- return it.defaultSelect;
|
|
|
- });
|
|
|
- return index;
|
|
|
- },
|
|
|
- hasNone:function(){ //是否有选项同无
|
|
|
- let index =this.rows.findIndex((it)=>{
|
|
|
- return it.isNone;
|
|
|
- });
|
|
|
- return index;
|
|
|
- },
|
|
|
- hasBan:function(){ //是否有选项同伴
|
|
|
- let index =this.rows.findIndex((it)=>{
|
|
|
- return it.isBan;
|
|
|
- });
|
|
|
- return index;
|
|
|
- },
|
|
|
- hasError:function(){ //是否为正确选项
|
|
|
- let index =this.rows.findIndex((it)=>{
|
|
|
- return it.isError;
|
|
|
- });
|
|
|
- return index;
|
|
|
- }
|
|
|
},
|
|
|
watch: {
|
|
|
ascription(newVal, preVal) {
|
|
|
if (newVal != preVal) {
|
|
|
if (JSON.stringify(newVal) != JSON.stringify(preVal)) {
|
|
|
- this.rows = [{name:'',defaultSelect:'',isBan:'',isNone:'',isError:''},{name:'',defaultSelect:'',isBan:'',isNone:'',isError:''},{name:'',defaultSelect:'',isBan:'',isNone:'',isError:''},{name:'',defaultSelect:'',isBan:'',isNone:'',isError:''}];
|
|
|
+ this.rows = [...initRows];
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
type(newVal, preVal) {
|
|
|
if (newVal != preVal) {
|
|
|
if (JSON.stringify(newVal) != JSON.stringify(preVal)) {
|
|
|
- this.rows = [{name:'',defaultSelect:'',isBan:'',isNone:'',isError:''},{name:'',defaultSelect:'',isBan:'',isNone:'',isError:''},{name:'',defaultSelect:'',isBan:'',isNone:'',isError:''},{name:'',defaultSelect:'',isBan:'',isNone:'',isError:''}];
|
|
|
+ this.rows = [...initRows];
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
sexType(newVal, preVal) {
|
|
|
if (newVal != preVal) {
|
|
|
if (JSON.stringify(newVal) != JSON.stringify(preVal)) {
|
|
|
- this.rows = [{name:'',defaultSelect:'',isBan:'',isNone:'',isError:''},{name:'',defaultSelect:'',isBan:'',isNone:'',isError:''},{name:'',defaultSelect:'',isBan:'',isNone:'',isError:''},{name:'',defaultSelect:'',isBan:'',isNone:'',isError:''}];
|
|
|
+ this.rows = [...initRows];
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
},
|
|
|
methods:{
|
|
|
addRow(){
|
|
|
- this.rows.push({name:'',defaultSelect:'',isBan:'',isNone:'',isError:''});
|
|
|
+ this.rows.push(utils.getInitRow(initRow,1));
|
|
|
},
|
|
|
selectRow(index){
|
|
|
this.focusOn = index;
|
|
@@ -219,19 +200,25 @@
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
- const items = utils.simpleOptionData(this.rows);
|
|
|
+ const items = this.rows;
|
|
|
this.$emit('pushValues',items);
|
|
|
},
|
|
|
- HandleInputName(i, name) {
|
|
|
+ HandleInputName(i, name, isName) {
|
|
|
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].name
|
|
|
+ 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',
|
|
|
showClose: true,
|
|
|
});
|
|
|
- return
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
},
|