123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- <template>
- <portal to="notification-outlet">
- <div class="select" @touchmove.prevent>
- <ul class="clearfix">
- <li
- v-for="(item,idx) in result"
- :class="[{'liSelect':item.select,'noBorder':((item.description||item.name).indexOf('${'))!=-1}]"
- :key="item.id"
- >
- <span v-if="((item.description||item.name).indexOf('${'))==-1">{{item.description||item.name}}</span>
- <OptionInp v-else :item="item" @handleInp="inpVal" :inx="idx"/>
- </li>
- </ul>
- <div :class="sure?'realSure sure':'sure'" @click="makeSuer">
- 确定 <span v-if="numPlus">({{numPlus}})</span>
- </div>
- </div>
- </portal>
- </template>
- <script>
- import OptionInp from '../common/OptionInp.vue';
- import {concatVal,getExpStr} from '../utils/tools.js';
- export default {
- props: ["symptomResult","num"],
- data() {
- return {
- result: [], //答案结果
- connectResult: [], //id
- contentResult: "", //name
- rules: [], //规则所需数据value
- numPlus:0, //已选答案个数
- sure:false
- };
- },
- mounted() {
- //this.numPlus = this.num
- // console.log(this.symptomResult.questionDetailList)
- this.result = this.symptomResult.questionDetailList;
- },
- watch:{
- result: {
- handler(newArr) {
- let num = 0,sldNum=0;
- for(let i = 0;i < newArr.length;i++){
- if(!newArr[i].select){
- ++num;
- }else{
- sldNum++;
- }
- }
- this.numPlus =sldNum;
- },
- immediate: true,
- deep:true
- }
- },
- methods: {
- inpVal(val,index){//输入框失焦处理
- // 输入框回读
- let detailList = this.result;
- let currItem = detailList[index];
- currItem.value = val;
- const notNull=val.match(/\S/g);
- if(notNull){
- this.sure=true;
- }else{
- if(detailList.findIndex((it)=>(it.value||'').match(/\S/g))!==-1){
- this.sure=true;
- }else{
- this.sure=false;
- }
- }
- },
- handleClick(it,index,flg,ipt){
- if(flg){
- document.activeElement.blur();
- document.activeElement.scrollIntoViewIfNeeded(true);
- setTimeout(()=>{
- document.activeElement.scrollIntoViewIfNeeded(true);
- },300)
- }
- /*let data = it.questionDetailList&&it.questionDetailList.slice(0); //数组深拷贝
- if(ipt){//输入框单选,输入了内容才算选中,删除内容算取消
- for(let i=0;i<data.length; i++){
- if(i==index){
- data[i].select=data[i].value?1:0;
- }else{
- data[i].select = 0
- }
- }
- }else{
- for(let i=0;i<data.length; i++){
- if(i==index){
- data[i].select = data[i].select==1?0:1;
- }else{
- data[i].select = 0
- }
- }*/
- /*}
- let temp = concatVal(data);
- const newData = Object.assign({},this.datas,{questionDetailList:data,value:temp.value,valueP:temp.valueP});
- this.$emit("updata",newData);*/
- },
- makeSuer() {
- if(!this.sure)return;
- let result = this.result;
- // if(this.numPlus == 1){
- let tmpResult=[],tmpResultp=[];
- for (let i = 0; i < result.length; i++) {
- const text=result[i].name;
- const textp=result[i].description||result[i].name;
- const msg = getExpStr(text);
- const msgp = getExpStr(textp);
- if(result[i].name.indexOf("${")!==-1){
- if((result[i].value||'').match(/\S/g)){
- tmpResult.push(msg.prefix+(result[i].value||"")+msg.suffix);
- tmpResultp.push(msgp.prefix+(result[i].value||"")+msgp.suffix);
- }
- }else {
- //tmpIds=tmpIds.concat(result[i].connectId)
- tmpResult.push(text);
- tmpResultp.push(textp);
- }
- }
- // }else{
- // }
- let number = this.num;
- this.$emit("updataResult", this.symptomResult, {val:tmpResult.join('、'),valp:tmpResultp.join('、')},++number);
- },
- /*selectResult(item,idx) {
- const { exclusion, select } = item;
- let result = JSON.parse(JSON.stringify(this.result));
- if (select) {//判断是否选中,选中的取消,关联id删除,未选中判断是否互斥
- for (let i = 0; i < result.length; i++) {
- if(i == idx){
- result[i].select = false
- }
- }
- }else{
- if(+exclusion === 1){
- for (let i = 0; i < result.length; i++) {
- if(i == idx){
- result[i].select = true
- }else{
- result[i].select = false
- }
- }
- }else{
- for (let i = 0; i < result.length; i++) {
- if(result[i].select&&+result[i].exclusion === 1){
- result[i].select=false
- }else{
- if(i == idx){
- result[i].select = true
- }
- }
- }
- }
- }
- this.result = result
- }*/
- },
- components:{
- OptionInp
- }
- };
- </script>
- <style lang="less" scoped>
- @import "../less/base.less";
- .select {
- background-color: #fff;
- padding: 0.12rem 0 0 0;
- position: fixed;
- width: 100%;
- bottom: 0;
- box-sizing: border-box;
- box-shadow: 0 0 30px -10px rgba(104, 124, 189, 0.25);
- li {
- padding: 0.14rem 0.2rem;
- border:1px #DFE0E4 solid;
- border-radius: 0.36rem;
- font-size: #font[select];
- margin: 0.15rem 0.15rem 0;
- float: left;
- color: #666;
- }
- .liSelect {
- color: #fff;
- background-color: #colors[btn];
- border-color: #colors[btn];
- }
- .noBorder{
- border: none;
- width: 100%;
- &.liSelect{
- background: none;
- }
- }
- }
- </style>
|