|
@@ -4,13 +4,11 @@
|
|
|
<p v-for="(it,index) in datas.questionDetailList" :key="it.id" class="list" @click="handleClick(it,index)">
|
|
|
<img :src="it.select==1?check:defaultPic">
|
|
|
<!-- <span :class="{'check':it.select==1}">{{it.name}}</span> -->
|
|
|
- <span v-if="(it.name.indexOf('${'))==-1" :class="{'check':it.select==1}">{{it.name}}</span>
|
|
|
+ <span v-if="(it.name.indexOf('${'))==-1" :class="[{'check':it.select==1},{'exclu':exclusion !==999 && it.exclusion !== exclusion}]">{{it.name}}</span>
|
|
|
<MultiLineInput v-else
|
|
|
- @changeMultipVal="changeMultipVal($event,index)"
|
|
|
@handleInp="inpVal($event,index)"
|
|
|
:msg="it.name"
|
|
|
:part="it"
|
|
|
- :value="it.value"
|
|
|
:border="false"
|
|
|
:inline="true"
|
|
|
:select="it.select==1"
|
|
@@ -31,28 +29,53 @@ import MultiLineInput from '../common/MultiLineInput.vue';
|
|
|
defaultPic:icon,
|
|
|
check:checkIcon,
|
|
|
datas:{},
|
|
|
- checkTxt:[]
|
|
|
+ exclusion:999 //互斥
|
|
|
}
|
|
|
},
|
|
|
props:['item'],
|
|
|
created(){
|
|
|
// this.datas = JSON.parse(JSON.stringify(this.item));
|
|
|
this.datas = this.item;
|
|
|
+ this.resetExc();
|
|
|
},
|
|
|
methods:{
|
|
|
handleClick(it,index){
|
|
|
const list = this.datas;
|
|
|
let data = list.questionDetailList&&list.questionDetailList.slice(0);
|
|
|
- let value = "";
|
|
|
+ // 处理互斥
|
|
|
+ const excluArr = data.filter(it=>it.exclusion==1);
|
|
|
+ const filArr = data.filter(it=>it.select==1);
|
|
|
+ if(excluArr.length>0){//有互斥
|
|
|
+ if(filArr.length>0){//有选中
|
|
|
+ if(it.exclusion !== filArr[0].exclusion){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.exclusion = it.exclusion;
|
|
|
+ }
|
|
|
+ // 处理选中状态
|
|
|
if(data[index].select){
|
|
|
data[index].select = 0;
|
|
|
- this.checkTxt.splice(index,1);
|
|
|
}else{
|
|
|
data[index].select = 1;
|
|
|
- this.checkTxt[index] = data[index].name;
|
|
|
+ this.exclusion = it.exclusion;
|
|
|
+ }
|
|
|
+ // 处理取消-互斥
|
|
|
+ const filArr1 = data.filter(it=>it.select==1);
|
|
|
+ if(excluArr.length>0){//有互斥
|
|
|
+ if(filArr1.length==0){//无选中
|
|
|
+ this.exclusion = 999;
|
|
|
+ }else{
|
|
|
+ this.exclusion = filArr1[0].exclusion;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let value = "";
|
|
|
+ for(let k in data){
|
|
|
+ if(data[k].select==1){
|
|
|
+ value += data[k].name + ','
|
|
|
+ }
|
|
|
}
|
|
|
- value = this.checkTxt.filter(item=>item).join(',');
|
|
|
- const newData = Object.assign({},this.datas,{questionDetailList:data},{value:value})
|
|
|
+ const newData = Object.assign({},this.datas,{questionDetailList:data},{value:value?value.substring(0,value.length-1):''})
|
|
|
this.$emit("updata",newData);
|
|
|
},
|
|
|
inpVal(val,index){//输入框失焦处理
|
|
@@ -67,14 +90,22 @@ import MultiLineInput from '../common/MultiLineInput.vue';
|
|
|
currItem.value = val;
|
|
|
this.$emit("updata",this.datas);
|
|
|
},
|
|
|
- changeMultipVal(val){
|
|
|
-
|
|
|
- },
|
|
|
+ resetExc(){
|
|
|
+ // 回读互斥项标识
|
|
|
+ const arr = this.datas.questionDetailList;
|
|
|
+ const filArr = arr.filter(it=>it.select==1);
|
|
|
+ if(filArr.length > 0){
|
|
|
+ this.exclusion = filArr[0].exclusion;
|
|
|
+ }else{
|
|
|
+ this.exclusion = 999;
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
watch:{
|
|
|
item:{
|
|
|
handler(newVal,oldVal){
|
|
|
this.datas = JSON.parse(JSON.stringify(newVal));
|
|
|
+ this.resetExc();
|
|
|
},
|
|
|
deep:true
|
|
|
}
|
|
@@ -103,5 +134,8 @@ import MultiLineInput from '../common/MultiLineInput.vue';
|
|
|
.check{
|
|
|
color: #4F50FF;
|
|
|
}
|
|
|
+ .exclu{
|
|
|
+ color:#e6e7e9;
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|