123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- <template>
- <div class="label-wrap bgques" v-if="item">
- <p v-for="(it,index) in datas.questionMapping" :key="it.id" :class="['symp',{'check':it.select==1},{'exclu':exclusion !==999 && it.exclusionType !== exclusion}]" @click="handleClick(it,index,true)">
- <span>{{it.description||it.name}}</span>
- <span v-if="it.select==1" @click="deletSymp($event,it,index)"><img src="../images/del.png" alt=""></span>
- </p>
- <Toast :message="delText"
- :show="showToast"
- @comfirn="comfirnDel"
- @cancel="cancelDel"/>
- </div>
- </template>
- <script>
- import Toast from '../common/Toast.vue';
- import {moduleCP} from '@utils/tools';
- import $ from 'jquery';
- export default {
- name:'Label',
- data(){
- return{
- datas:{},
- checkTxt:[],
- showToast:false,
- delText:"是否取消当前选中内容?",
- tempItem:{},
- exclusion:999, //互斥
- delIndx:null
- }
- },
- props:['item','moduleType','ppId','order'],
- created(){
- this.datas = this.item;
- // 回读互斥项标识
- const arr = this.datas.questionMapping;console.log(this.item,this.datas.questionMapping)
- const filArr = arr.filter(it=>it.select==1);
- if(filArr.length > 0){
- this.exclusion = filArr[0].exclusionType;
- }
- },
- components:{
- Toast
- },
- methods:{
- handleClick(it,index,flg){
- if(flg){
- document.activeElement.blur();
- document.activeElement.scrollIntoViewIfNeeded(true);
- setTimeout(()=>{
- document.activeElement.scrollIntoViewIfNeeded(true);
- },300)
- }
- const arr = this.datas.questionMapping;
- const excluArr = arr.filter(it=>it.exclusionType==1);
- const filArr = arr.filter(it=>it.select==1);
- if(excluArr.length>0){//有互斥
- if(filArr.length>0){//有选中
- if(it.exclusionType !== filArr[0].exclusionType){
- return
- }
- }
- this.exclusion = it.exclusionType;
- }
- const newItem = Object.assign({},it,{select:1});
- const origMapping = this.item.questionMapping;
- let mapping = this.datas.questionMapping;
- for(let i in origMapping){
- if(origMapping[i].id==it.id){
- mapping.splice(i,1,newItem)
- }
- }
- // 存值到store arrFlag:true说明要区分pId
- this.$store.commit('setDatas',{type:this.moduleType,data:newItem,pId:this.datas.id,ppId:this.ppId});
- this.$store.commit('setText',{type:this.moduleType,text:it.name,textP:(it.description||it.name),pId:it.id,order:this.order,index:index,arrFlag:true});
- if(it.questionMapping&&it.questionMapping.length>0){//有明细
- this.$store.commit('setDetail',{detail:it,ppId:this.ppId,moduleType:this.moduleType,order:this.order,index:index})
- }
- },
- deletSymp(e,it,index){
- e.stopPropagation();
- // 删除互斥项(无)不弹窗提醒 7-18
- this.delIndx = index;
- this.tempItem = it;
- if(it.exclusionType == 1){
- this.comfirnDel();
- return
- }
- this.showToast = true;
- $(".btscroll").css({'position':'fixed'})
- $(".foot").css({'position':'fixed','bottom':'0'})
- // 底部body不可滑动
- // const prehandler = function(e){e.preventDefault();}
- // document.body.addEventListener("touchmove",prehandler,false)
- },
- comfirnDel(){
- const temp = this.tempItem;
- // 从store中取origin的值
- let origin,newItem;
- if(this.moduleType==moduleCP['diagT']){
- origin = this.$store.state.diagnose.origin
- }else if(this.moduleType == moduleCP['other']){
- origin = this.$store.state.others.origin
- }
- if(origin){
- for(let i in origin){
- if(origin[i].id==this.ppId){
- let origItem = origin[i].questionMapping;
- for(let j in origItem){
- if(origItem[j].id==temp.id){
- newItem = origItem[j];
- }
- }
- }
- }
- let mapping = this.datas.questionMapping;
- for(let n in mapping){
- if(mapping[n].id==temp.id){
- mapping.splice(n,1,newItem)
- }
- }
- }
- // 是否解除互斥
- const arr = this.datas.questionMapping;
- const filArr = arr.filter(it=>it.select==1);
- if(filArr.length==0){
- this.exclusion = 999;
- }
- //存值
- this.$store.commit('setDatas',{type:this.moduleType,data:newItem,pId:this.datas.id,ppId:this.ppId});
- this.$store.commit('delText',{type:this.moduleType,pId:temp.id,order:this.order,index:this.delIndx});
- this.cancelDel();
- },
- cancelDel(){
- this.showToast = false;
- $(".btscroll").css({'position':'absolute','top':'0'})
- $(".foot").css({'position':'absolute','bottom':'0'})
- this.tempItem = {};
- this.delIndx = null;
- }
- }
- }
- </script>
- <style lang="less" scoped>
- @import '../less/base.less';
- .label-wrap{
- font-size: .3rem;
- .symp{
- display: inline-block;
- min-width:2.05rem;
- height: .72rem;
- border-radius: .08rem;
- span{
- display: inline-block;
- vertical-align: top;
- }
- span:first-child{
- min-width:1.42rem;
- height: .72rem;
- line-height: .72rem;
- text-align: center;
- }
- img{
- width:.48rem;
- height: .70rem;
- vertical-align: top;
- z-index: 22;
- }
- }
- .symp:last-child{
- margin-right: 0;
- }
- .check{
- color: #fff;
- background: #colors[btn];
- }
- .exclu{
- // background:#E3E4E8;
- }
- }
- </style>
|