fix(ecom-dmb): 修复刷单管理模态框表单问题

This commit is contained in:
小蟑螂
2026-04-18 14:21:56 +08:00
parent 26e0c85aa4
commit 5e8864b355
@@ -150,12 +150,6 @@ watch(
quantity: props.brushOrderData.quantity || 1,
remark: props.brushOrderData.remark,
};
if (props.brushOrderData.productId) {
searchProducts('');
if (props.brushOrderData.productSpecId) {
searchProductSpecs('');
}
}
} else {
resetFormData();
}
@@ -163,6 +157,11 @@ watch(
modalApi.open();
await nextTick();
formRef.value?.clearValidate?.();
// 远程搜索 Select 仅 @search 不会在「只点开下拉」时请求,这里打开弹窗后预加载一页
void searchProducts('');
if (formData.value.productId) {
void searchProductSpecs('');
}
},
{ immediate: true },
);
@@ -241,6 +240,19 @@ async function searchProductSpecs(keyword: string) {
}
}
/** 点开/聚焦商品下拉时再拉一次(不输入关键词也能看到列表) */
function onProductSelectFocus() {
if (!productLoading.value) {
void searchProducts(productSearchKeyword.value || '');
}
}
/** 点开规格下拉时拉规格列表 */
function onProductSpecSelectFocus() {
if (!formData.value.productId || productSpecLoading.value) return;
void searchProductSpecs(productSpecSearchKeyword.value || '');
}
// 处理商品选择
function handleProductChange(productId: number | undefined) {
if (!productId) {
@@ -354,6 +366,7 @@ onMounted(() => {
:loading="productLoading"
allow-clear
@search="searchProducts"
@focus="onProductSelectFocus"
@change="handleProductChange"
>
<template #notFoundContent>
@@ -385,6 +398,7 @@ onMounted(() => {
:disabled="!formData.productId"
allow-clear
@search="searchProductSpecs"
@focus="onProductSpecSelectFocus"
>
<template #notFoundContent>
<div v-if="productSpecLoading" class="py-4 text-center">