fire select popup for focused input
This commit is contained in:
@@ -3,10 +3,11 @@
|
|||||||
<div class="filters glass">
|
<div class="filters glass">
|
||||||
<t-input
|
<t-input
|
||||||
class="customer"
|
class="customer"
|
||||||
v-model.trim="customerSearchKeyword"
|
:value="customerDisplayText"
|
||||||
|
readonly
|
||||||
borderless
|
borderless
|
||||||
placeholder="输入客户编码或姓名"
|
placeholder="选择客户"
|
||||||
@enter="applyCustomerSearch"
|
@click="customerSelectorVisible = true"
|
||||||
>
|
>
|
||||||
<template #suffix-icon>
|
<template #suffix-icon>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
@@ -219,7 +220,6 @@ const salesOrder = ref<SalesOrder>();
|
|||||||
const skuFilterOptionList = ref<SkuFilterOption[]>([]);
|
const skuFilterOptionList = ref<SkuFilterOption[]>([]);
|
||||||
const skuFilterVisible = ref(false);
|
const skuFilterVisible = ref(false);
|
||||||
const customerSelectorVisible = ref(false);
|
const customerSelectorVisible = ref(false);
|
||||||
const customerSearchKeyword = ref("");
|
|
||||||
const dateFilterType = ref<DateFilterType>(parseDateFilterType(getQueryText(route.query.dateType), dateOptions, "all"));
|
const dateFilterType = ref<DateFilterType>(parseDateFilterType(getQueryText(route.query.dateType), dateOptions, "all"));
|
||||||
const dateRange = ref<[string, string]>(parseDateRange(dateFilterType.value));
|
const dateRange = ref<[string, string]>(parseDateRange(dateFilterType.value));
|
||||||
const startDraft = ref("");
|
const startDraft = ref("");
|
||||||
@@ -244,6 +244,7 @@ const statusOptions = [
|
|||||||
{ label: "已冲正", value: "REVOKED" }
|
{ label: "已冲正", value: "REVOKED" }
|
||||||
];
|
];
|
||||||
const dateFilterLabel = computed(() => dateOptions.find(item => item.value === dateFilterType.value)?.label || "时间范围");
|
const dateFilterLabel = computed(() => dateOptions.find(item => item.value === dateFilterType.value)?.label || "时间范围");
|
||||||
|
const customerDisplayText = computed(() => selectedCustomer.value?.name || selectedCustomer.value?.code || "");
|
||||||
const selectedSkuOptionList = computed(() => {
|
const selectedSkuOptionList = computed(() => {
|
||||||
const optionMap = new Map(skuFilterOptionList.value.map(option => [option.skuId, option]));
|
const optionMap = new Map(skuFilterOptionList.value.map(option => [option.skuId, option]));
|
||||||
return selectedSkuIdList.value
|
return selectedSkuIdList.value
|
||||||
@@ -373,46 +374,15 @@ async function handleCustomerChange(value: string | string[]): Promise<void> {
|
|||||||
customerId.value = Array.isArray(value) ? String(value[0] || "") : value;
|
customerId.value = Array.isArray(value) ? String(value[0] || "") : value;
|
||||||
try {
|
try {
|
||||||
selectedCustomer.value = customerId.value ? await CustomerAPI.detail(customerId.value) : undefined;
|
selectedCustomer.value = customerId.value ? await CustomerAPI.detail(customerId.value) : undefined;
|
||||||
customerSearchKeyword.value = getCustomerSearchKeyword(selectedCustomer.value);
|
|
||||||
await fetchList(true);
|
await fetchList(true);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Message.error(getErrorMessage(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> {
|
async function clearCustomer(): Promise<void> {
|
||||||
customerId.value = "";
|
customerId.value = "";
|
||||||
selectedCustomer.value = undefined;
|
selectedCustomer.value = undefined;
|
||||||
customerSearchKeyword.value = "";
|
|
||||||
await reloadList();
|
await reloadList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -567,7 +537,6 @@ onMounted(async () => {
|
|||||||
await loadSalesOrder();
|
await loadSalesOrder();
|
||||||
if (customerId.value) {
|
if (customerId.value) {
|
||||||
selectedCustomer.value = await CustomerAPI.detail(customerId.value);
|
selectedCustomer.value = await CustomerAPI.detail(customerId.value);
|
||||||
customerSearchKeyword.value = getCustomerSearchKeyword(selectedCustomer.value);
|
|
||||||
}
|
}
|
||||||
await fetchList(true);
|
await fetchList(true);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user