From 15aa2ad0d6c3665491d209c58cbe604876283430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E6=98=AF=E7=AD=96=E8=AF=97=E6=BA=90?= Date: Thu, 5 Aug 2021 04:30:18 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=85=B6=E4=BB=96=E9=80=89?= =?UTF-8?q?=E9=A1=B9=E8=BE=93=E5=85=A5=E6=A1=86=E9=80=BB=E8=BE=91=201?= =?UTF-8?q?=E3=80=81=E5=B0=86=E5=85=B6=E4=BB=96=E9=80=89=E9=A1=B9=E7=9A=84?= =?UTF-8?q?label=E5=92=8Cinput=E5=86=85=E5=AE=B9=E5=88=86=E5=88=AB?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E5=92=8Cfield=E5=92=8Cfieldother=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=EF=BC=8C=E8=BF=99=E6=A0=B7=E7=BB=9F=E8=AE=A1=E5=9B=BE?= =?UTF-8?q?=E9=87=8C=E6=89=8D=E8=83=BD=E7=9C=8B=E5=88=B0=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E9=80=89=E9=A1=B9=E7=9A=84=E6=95=B0=E9=87=8F?= =?UTF-8?q?=202=E3=80=81=E5=A6=82=E6=9E=9C=E6=B2=A1=E6=9C=89=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=85=B6=E4=BB=96=E9=80=89=E9=A1=B9=EF=BC=8C=E6=8A=8A?= =?UTF-8?q?fieldother=E5=92=8C=E8=BE=93=E5=85=A5=E6=A1=86=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E9=83=BD=E6=B8=85=E7=A9=BA=EF=BC=8C=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=A1=86=E6=95=B0=E6=8D=AE=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/parser/Parser.vue | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/components/parser/Parser.vue b/src/components/parser/Parser.vue index 5792294..baf2d2c 100644 --- a/src/components/parser/Parser.vue +++ b/src/components/parser/Parser.vue @@ -258,25 +258,35 @@ function setValueLabel(event, config, scheme) { let tagOptionKey = processType[config.tag] if (tagOptionKey) { if (event instanceof Array) { + // 多选 其他自定义输入 let labelArr = new Array() + if(!event.includes(0)){ + // 如果多选里没有选择其他,就清掉other + this.$set(this[this.formConf.labelFormModel], `${scheme.__vModel__}other`, '') + // 同时把输入框清空 + document.querySelector('.'+config.tag).querySelector(".item-other-input").value = "" + } event.forEach(item => { // 拼到头部 其他选项 - if (item === 0) { - labelArr.push(this[this.formConf.labelFormModel][`${scheme.__vModel__}other`]) - } else if (item) { - let {label} = getObject(_.get(scheme, tagOptionKey), 'value', item) - labelArr.push(label) - } + let {label} = getObject(_.get(scheme, tagOptionKey), 'value', item) + labelArr.push(label) }) this.$set(this[this.formConf.labelFormModel], scheme.__vModel__, labelArr.join(',')) } else { - // 多选 单选 其他自定义输入 + // 单选 其他自定义输入 if (event == 0) { console.log(this[this.formConf.labelFormModel][`${scheme.__vModel__}other`]) - this.$set(this[this.formConf.labelFormModel], `${scheme.__vModel__}`, this[this.formConf.labelFormModel][`${scheme.__vModel__}other`]) + // 如果选择了其他,把label存在field字段,把输入框内容存在fieldother字段 + let item = _.find(_.get(scheme, tagOptionKey), {'value': event}) + this.$set(this[this.formConf.labelFormModel], scheme.__vModel__, item.label) + this.$set(this[this.formConf.labelFormModel], `${scheme.__vModel__}other`,this[this.formConf.labelFormModel][`${scheme.__vModel__}other`]) } else { let item = _.find(_.get(scheme, tagOptionKey), {'value': event}) this.$set(this[this.formConf.labelFormModel], scheme.__vModel__, item.label) + // 如果没有选择其他,就清掉other + this.$set(this[this.formConf.labelFormModel], `${scheme.__vModel__}other`,'') + // 同时把输入框清空 + document.querySelector('.'+config.tag).querySelector(".item-other-input").value = "" } } } else if (config.tag === 'el-upload') {