From 2c576b6c8965a311313e02ed4db1d755c586c60f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8C=BF=E5=B0=8F=E5=A4=A9?= <1638245306@qq.com> Date: Fri, 11 Aug 2023 21:48:18 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D:=20=E4=BF=AE=E5=A4=8Dtabl?= =?UTF-8?q?e-selector=E7=BB=84=E4=BB=B6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../selector-table/selector-table.vue | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/web/src/components/selector-table/selector-table.vue b/web/src/components/selector-table/selector-table.vue index dc854d5..46c687f 100644 --- a/web/src/components/selector-table/selector-table.vue +++ b/web/src/components/selector-table/selector-table.vue @@ -170,26 +170,26 @@ export default { } }, watch: { - value: { - handler (value, oldVal) { - // 父组件收到input事件后会通过v-model改变value参数的值 - // 然后此处会watch到value的改变,发出change事件 - // change事件放在此处发射的好处是,当外部修改value值时,也能够触发form-data-change事件 - this.$emit('change', value) - this.$emit('input', value) - // 如果值是被外部改变的,则修改本组件的currentValue - if (Array.isArray(value) && value.length === 0) { - this.currentValue = null - this.multipleSelection = null - } else { - if (value && this.dispatch) { - this.dispatch('ElFormItem', 'el.form.blur') - } - } - }, - deep: true, - immediate: true - }, + // value: { + // handler (value, oldVal) { + // // 父组件收到input事件后会通过v-model改变value参数的值 + // // 然后此处会watch到value的改变,发出change事件 + // // change事件放在此处发射的好处是,当外部修改value值时,也能够触发form-data-change事件 + // this.$emit('change', value) + // this.$emit('input', value) + // // 如果值是被外部改变的,则修改本组件的currentValue + // if (Array.isArray(value) && value.length === 0) { + // this.currentValue = null + // this.multipleSelection = null + // } else { + // if (value && this.dispatch) { + // this.dispatch('ElFormItem', 'el.form.blur') + // } + // } + // }, + // deep: true, + // immediate: true + // }, multipleSelection: { handler (newValue, oldVal) { const { tableConfig } = this._elProps @@ -203,25 +203,25 @@ export default { deep: true, immediate: true } - // currentValue (newValue, oldVal) { - // const { tableConfig } = this._elProps - // const { value } = this.dict - // if (newValue) { - // if (!tableConfig.multiple) { - // if (newValue[0]) { - // this.$emit('input', newValue[0][value]) - // this.$emit('change', newValue[0][value]) - // } - // } else { - // console.log(newValue) - // const result = newValue.map((item) => { - // return item[value] - // }) - // this.$emit('input', result) - // this.$emit('change', result) - // } - // } - // } + currentValue (newValue, oldVal) { + const { tableConfig } = this._elProps + const { value } = this.dict + if (newValue) { + if (!tableConfig.multiple) { + if (newValue[0]) { + this.$emit('input', newValue[0][value]) + this.$emit('change', newValue[0][value]) + } + } else { + console.log(newValue) + const result = newValue.map((item) => { + return item[value] + }) + this.$emit('input', result) + this.$emit('change', result) + } + } + } }, mounted () { // 给currentValue设置初始值