From f009e33db2824deca34a163b9696fcc82df4833b Mon Sep 17 00:00:00 2001 From: zjf <1799650030@qq.com> Date: Mon, 5 Oct 2026 19:24:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A5=97=E9=A4=90=E9=80=89=E6=8B=A9=E8=8F=9C?= =?UTF-8?q?=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/canteen/canteenSpu/form.vue | 60 +++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 7 deletions(-) diff --git a/src/views/canteen/canteenSpu/form.vue b/src/views/canteen/canteenSpu/form.vue index 8e202e70..f34822c6 100644 --- a/src/views/canteen/canteenSpu/form.vue +++ b/src/views/canteen/canteenSpu/form.vue @@ -28,7 +28,7 @@ - + @@ -125,10 +125,13 @@ - + - - + + + + + @@ -243,7 +246,13 @@ const childPickerVisible = ref(false) const childList = ref([]) const childTotal = ref(0) const childSelected = ref([]) -const childQuery = reactive({ current: 1, size: 10, name: "", categoryId: "" as string | number | "" }) +const childQuery = reactive({ + current: 1, + size: 10, + name: "", + categoryId: "" as string | number | "", + merchantId: "" as string | number | "", +}) const validateCombo = (_: any, __: any, cb: any) => { if (form.spuType !== 2) return cb() @@ -276,13 +285,44 @@ const onSpuTypeChange = () => { } } +watch( + () => form.merchantId, + (mid, oldMid) => { + if (mid === oldMid) return + form.categoryId = "" + childQuery.merchantId = mid || "" + childQuery.categoryId = "" + }, +) + +watch( + () => childQuery.merchantId, + (mid, oldMid) => { + if (!childPickerVisible.value) return + if (mid === oldMid) return + childQuery.categoryId = "" + childQuery.current = 1 + searchChildren() + }, +) + const openChildPicker = () => { - childPickerVisible.value = true + if (!form.merchantId) { + useMessage().warning("请先选择商户") + return + } + childQuery.merchantId = form.merchantId + childQuery.categoryId = "" childQuery.current = 1 + childPickerVisible.value = true searchChildren() } const handleChildSearch = () => { + if (!childQuery.merchantId) { + useMessage().warning("请先选择商户") + return + } childQuery.current = 1 searchChildren() } @@ -290,18 +330,24 @@ const handleChildSearch = () => { const resetChildQuery = () => { childQuery.name = "" childQuery.categoryId = "" + childQuery.merchantId = form.merchantId || "" childQuery.current = 1 searchChildren() } const searchChildren = async () => { + if (!childQuery.merchantId) { + childList.value = [] + childTotal.value = 0 + return + } try { const res: any = await fetchSimpleList({ current: childQuery.current, size: childQuery.size, name: childQuery.name || undefined, categoryId: childQuery.categoryId || undefined, - merchantId: form.merchantId || undefined, + merchantId: childQuery.merchantId, }) childList.value = (res.data?.records || []).filter((r: any) => String(r.id) !== String(form.id)) childTotal.value = res.data?.total || 0