From 7dde297f528c05e035b01d755957c54a49c0c5aa Mon Sep 17 00:00:00 2001 From: liufumingren Date: Tue, 2 Jun 2026 09:16:01 +0800 Subject: [PATCH] 1 --- .../system/setting/expressinterface/index.vue | 53 +++++++++++++++---- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/src/views/system/setting/expressinterface/index.vue b/src/views/system/setting/expressinterface/index.vue index 316702bc..f5a421dd 100644 --- a/src/views/system/setting/expressinterface/index.vue +++ b/src/views/system/setting/expressinterface/index.vue @@ -414,7 +414,7 @@ @@ -524,6 +524,7 @@ type MonthlyAccountOption = { value: string; label: string } type TemplateOption = { value: string label: string + templateUrl: string templateId: string | null brandCode: string raw: Record @@ -608,6 +609,7 @@ const shopOptions = ref([]) const dialogExpressOptions = ref([]) const customExpressOptions = ref([]) const templateOptions = ref([]) +const templateSelectValue = ref('') const selectedShopId = ref(undefined) const useCustomExpressCode = ref(false) const printTemplateLoading = ref(false) @@ -1083,6 +1085,7 @@ async function loadPrintPlatformTemplateOptions(sourceExpressCode?: string, sour const expressCode = String(sourceExpressCode ?? formData.sys_express_code ?? '').trim().toUpperCase() if (!expressCode) { templateOptions.value = [] + templateSelectValue.value = '' formData.template_url = '' formData.template_id = null formData.brandno = '' @@ -1100,6 +1103,7 @@ async function loadPrintPlatformTemplateOptions(sourceExpressCode?: string, sour }) if (!isSuccess(res)) { templateOptions.value = [] + templateSelectValue.value = '' formData.template_url = '' formData.template_id = null formData.brandno = '' @@ -1111,8 +1115,20 @@ async function loadPrintPlatformTemplateOptions(sourceExpressCode?: string, sour : [] const nextOptions = templateList .map((item: any) => ({ - value: String(item?.standard_template_url || '').trim(), - label: String(item?.standard_template_name || item?.standard_template_url || '').trim(), + value: (() => { + const templateUrl = String(item?.standard_template_url || '').trim() + const templateId = String(item?.standard_template_id || '').trim() + return templateUrl || (templateId ? `ID:${templateId}` : '') + })(), + label: (() => { + const templateName = String(item?.standard_template_name || '').trim() + const templateUrl = String(item?.standard_template_url || '').trim() + const templateId = String(item?.standard_template_id || '').trim() + const identity = templateUrl || templateId + if (!templateName) return identity || '--' + return identity ? `${templateName}(${identity})` : templateName + })(), + templateUrl: String(item?.standard_template_url || '').trim(), templateId: String(item?.standard_template_id || '').trim() || null, brandCode: String(item?.brand_code || '').trim(), raw: item || {} @@ -1123,20 +1139,30 @@ async function loadPrintPlatformTemplateOptions(sourceExpressCode?: string, sour formData.brandno = fallbackBrandCode const currentTemplateUrl = String(formData.template_url || '').trim() - if (!currentTemplateUrl) { + const currentTemplateId = String(formData.template_id || '').trim() + if (!currentTemplateUrl && !currentTemplateId) { + templateSelectValue.value = '' formData.template_id = null return } - const matchedOption = nextOptions.find((item: TemplateOption) => item.value === currentTemplateUrl) + const matchedOption = nextOptions.find( + (item: TemplateOption) => + item.templateUrl === currentTemplateUrl || + (!!currentTemplateId && item.templateId === currentTemplateId) + ) if (!matchedOption) { + templateSelectValue.value = '' formData.template_url = '' formData.template_id = null return } + templateSelectValue.value = matchedOption.value + formData.template_url = matchedOption.templateUrl formData.template_id = matchedOption.templateId formData.brandno = matchedOption.brandCode || fallbackBrandCode } catch { templateOptions.value = [] + templateSelectValue.value = '' formData.template_url = '' formData.template_id = null formData.brandno = '' @@ -1147,13 +1173,16 @@ async function loadPrintPlatformTemplateOptions(sourceExpressCode?: string, sour } function handleTemplateChange(value: string | number | undefined) { - const templateUrl = String(value ?? '').trim() - if (!templateUrl) { + const templateValue = String(value ?? '').trim() + if (!templateValue) { + templateSelectValue.value = '' + formData.template_url = '' formData.template_id = null formData.brandno = '' return } - const matched = templateOptions.value.find((item) => item.value === templateUrl) + const matched = templateOptions.value.find((item) => item.value === templateValue) + formData.template_url = matched?.templateUrl || '' formData.template_id = matched?.templateId ?? null formData.brandno = matched?.brandCode || '' } @@ -1607,6 +1636,7 @@ async function handleExpressCodeChange() { } formData.template_url = '' formData.template_id = null + templateSelectValue.value = '' formData.brandno = '' templateOptions.value = [] applyAddressRaw(undefined) @@ -1647,6 +1677,7 @@ async function handlePlatformCodeChange(value: string | number | undefined) { formData.sys_express_code = '' formData.template_url = '' formData.template_id = null + templateSelectValue.value = '' formData.brandno = '' customExpressOptions.value = [] templateOptions.value = [] @@ -1674,6 +1705,7 @@ async function handleShopChange(value: string | number | undefined) { formData.sys_express_code = '' formData.template_url = '' formData.template_id = null + templateSelectValue.value = '' formData.brandno = '' customExpressOptions.value = [] templateOptions.value = [] @@ -1716,6 +1748,7 @@ function resetForm() { useCustomExpressCode.value = false serviceValueMap.value = {} templateOptions.value = [] + templateSelectValue.value = '' formRef.value?.clearValidate() } @@ -1731,6 +1764,7 @@ async function openCreate() { selectedAddressKey.value = '' shopOptions.value = [] templateOptions.value = [] + templateSelectValue.value = '' } async function openEdit(row: ExpressInterfaceRecord) { @@ -1748,6 +1782,7 @@ async function openEdit(row: ExpressInterfaceRecord) { selectedSiteKey.value = '' selectedAddressKey.value = '' templateOptions.value = [] + templateSelectValue.value = '' applyExpressInterfaceRowToForm(formData, row) if (formData.is_system_express_code === 0 || String(formData.is_system_express_code) === '0') { useCustomExpressCode.value = true