fire select popup for focused input

This commit is contained in:
Timi
2026-10-13 21:09:11 +08:00
parent 5f0c5bb1c9
commit d8ac19baa7
+5 -36
View File
@@ -3,10 +3,11 @@
<div class="filters glass">
<t-input
class="customer"
v-model.trim="customerSearchKeyword"
:value="customerDisplayText"
readonly
borderless
placeholder="输入客户编码或姓名"
@enter="applyCustomerSearch"
placeholder="选择客户"
@click="customerSelectorVisible = true"
>
<template #suffix-icon>
<div class="actions">
@@ -219,7 +220,6 @@ const salesOrder = ref<SalesOrder>();
const skuFilterOptionList = ref<SkuFilterOption[]>([]);
const skuFilterVisible = ref(false);
const customerSelectorVisible = ref(false);
const customerSearchKeyword = ref("");
const dateFilterType = ref<DateFilterType>(parseDateFilterType(getQueryText(route.query.dateType), dateOptions, "all"));
const dateRange = ref<[string, string]>(parseDateRange(dateFilterType.value));
const startDraft = ref("");
@@ -244,6 +244,7 @@ const statusOptions = [
{ label: "已冲正", value: "REVOKED" }
];
const dateFilterLabel = computed(() => dateOptions.find(item => item.value === dateFilterType.value)?.label || "时间范围");
const customerDisplayText = computed(() => selectedCustomer.value?.name || selectedCustomer.value?.code || "");
const selectedSkuOptionList = computed(() => {
const optionMap = new Map(skuFilterOptionList.value.map(option => [option.skuId, option]));
return selectedSkuIdList.value
@@ -373,46 +374,15 @@ async function handleCustomerChange(value: string | string[]): Promise<void> {
customerId.value = Array.isArray(value) ? String(value[0] || "") : value;
try {
selectedCustomer.value = customerId.value ? await CustomerAPI.detail(customerId.value) : undefined;
customerSearchKeyword.value = getCustomerSearchKeyword(selectedCustomer.value);
await fetchList(true);
} catch (error) {
Message.error(getErrorMessage(error, "客户履约单加载失败"));
}
}
async function applyCustomerSearch(): Promise<void> {
const keyword = customerSearchKeyword.value.trim();
if (!keyword) {
await clearCustomer();
return;
}
if (keyword === getCustomerSearchKeyword(selectedCustomer.value)) {
return;
}
try {
const customer = await CustomerAPI.findByCode(keyword) || await CustomerAPI.findByName(keyword);
if (!customer?.id) {
Message.warning("未找到客户");
return;
}
customerId.value = customer.id;
selectedCustomer.value = customer;
customerSearchKeyword.value = getCustomerSearchKeyword(customer);
await fetchList(true);
} catch (error) {
Message.error(getErrorMessage(error, "客户信息加载失败"));
}
}
function getCustomerSearchKeyword(customer?: Customer): string {
return customer?.name?.trim() || customer?.code?.trim() || "";
}
async function clearCustomer(): Promise<void> {
customerId.value = "";
selectedCustomer.value = undefined;
customerSearchKeyword.value = "";
await reloadList();
}
@@ -567,7 +537,6 @@ onMounted(async () => {
await loadSalesOrder();
if (customerId.value) {
selectedCustomer.value = await CustomerAPI.detail(customerId.value);
customerSearchKeyword.value = getCustomerSearchKeyword(selectedCustomer.value);
}
await fetchList(true);
} catch (error) {