From 17b28025d8aa4aecde84c72a9e344eeaa8c2aed5 Mon Sep 17 00:00:00 2001 From: aixianling Date: Wed, 15 Jan 2025 15:59:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(AiEartagPicker):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E9=80=89=E6=8B=A9=E5=90=8E=E5=8E=9F=E5=A7=8B?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=B8=A2=E5=A4=B1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 origin 数组以保存初始获取的数据 - 修改 handleConfirm 方法,确保选中的数据来自原始数据 --- project/xumu/components/AiEartagPicker.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/project/xumu/components/AiEartagPicker.vue b/project/xumu/components/AiEartagPicker.vue index db3701d9..f1705d22 100644 --- a/project/xumu/components/AiEartagPicker.vue +++ b/project/xumu/components/AiEartagPicker.vue @@ -16,7 +16,8 @@ export default { return { list: [], dialog: false, - selected: [] + selected: [], + origin: [] } }, computed: { @@ -41,6 +42,7 @@ export default { !/undefined/.test(this.api) && this.instance.post(this.api).then(res => { if (res?.data) { const key = this.valueKey + this.origin = res.data ?? [] this.list = res.data?.map(v => { if (typeof v == 'string') { return {key: v, label: v} @@ -54,7 +56,7 @@ export default { handleConfirm() { this.dialog = false this.$emit("input", this.selected) - this.$emit("select", this.list.filter(v => this.selected.includes(v.id))) + this.$emit("select", this.origin.filter(v => this.selected.includes(v?.[this.valueKey] ?? v))) } } }