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, quantity: props.brushOrderData.quantity || 1,
remark: props.brushOrderData.remark, remark: props.brushOrderData.remark,
}; };
if (props.brushOrderData.productId) {
searchProducts('');
if (props.brushOrderData.productSpecId) {
searchProductSpecs('');
}
}
} else { } else {
resetFormData(); resetFormData();
} }
@@ -163,6 +157,11 @@ watch(
modalApi.open(); modalApi.open();
await nextTick(); await nextTick();
formRef.value?.clearValidate?.(); formRef.value?.clearValidate?.();
// 远程搜索 Select 仅 @search 不会在「只点开下拉」时请求,这里打开弹窗后预加载一页
void searchProducts('');
if (formData.value.productId) {
void searchProductSpecs('');
}
}, },
{ immediate: true }, { 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) { function handleProductChange(productId: number | undefined) {
if (!productId) { if (!productId) {
@@ -354,6 +366,7 @@ onMounted(() => {
:loading="productLoading" :loading="productLoading"
allow-clear allow-clear
@search="searchProducts" @search="searchProducts"
@focus="onProductSelectFocus"
@change="handleProductChange" @change="handleProductChange"
> >
<template #notFoundContent> <template #notFoundContent>
@@ -385,6 +398,7 @@ onMounted(() => {
:disabled="!formData.productId" :disabled="!formData.productId"
allow-clear allow-clear
@search="searchProductSpecs" @search="searchProductSpecs"
@focus="onProductSpecSelectFocus"
> >
<template #notFoundContent> <template #notFoundContent>
<div v-if="productSpecLoading" class="py-4 text-center"> <div v-if="productSpecLoading" class="py-4 text-center">