1
This commit is contained in:
parent
79a872dea7
commit
7dde297f52
@ -414,7 +414,7 @@
|
|||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="打印模板">
|
<el-form-item label="打印模板">
|
||||||
<el-select
|
<el-select
|
||||||
v-model="formData.template_url"
|
v-model="templateSelectValue"
|
||||||
filterable
|
filterable
|
||||||
clearable
|
clearable
|
||||||
:loading="printTemplateLoading"
|
:loading="printTemplateLoading"
|
||||||
@ -425,7 +425,7 @@
|
|||||||
<el-option
|
<el-option
|
||||||
v-for="item in templateOptions"
|
v-for="item in templateOptions"
|
||||||
:key="item.value"
|
:key="item.value"
|
||||||
:label="item.label || item.value"
|
:label="item.label"
|
||||||
:value="item.value"
|
:value="item.value"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
@ -524,6 +524,7 @@ type MonthlyAccountOption = { value: string; label: string }
|
|||||||
type TemplateOption = {
|
type TemplateOption = {
|
||||||
value: string
|
value: string
|
||||||
label: string
|
label: string
|
||||||
|
templateUrl: string
|
||||||
templateId: string | null
|
templateId: string | null
|
||||||
brandCode: string
|
brandCode: string
|
||||||
raw: Record<string, any>
|
raw: Record<string, any>
|
||||||
@ -608,6 +609,7 @@ const shopOptions = ref<ShopOption[]>([])
|
|||||||
const dialogExpressOptions = ref<ExpressOption[]>([])
|
const dialogExpressOptions = ref<ExpressOption[]>([])
|
||||||
const customExpressOptions = ref<ExpressOption[]>([])
|
const customExpressOptions = ref<ExpressOption[]>([])
|
||||||
const templateOptions = ref<TemplateOption[]>([])
|
const templateOptions = ref<TemplateOption[]>([])
|
||||||
|
const templateSelectValue = ref('')
|
||||||
const selectedShopId = ref<number | string | undefined>(undefined)
|
const selectedShopId = ref<number | string | undefined>(undefined)
|
||||||
const useCustomExpressCode = ref(false)
|
const useCustomExpressCode = ref(false)
|
||||||
const printTemplateLoading = 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()
|
const expressCode = String(sourceExpressCode ?? formData.sys_express_code ?? '').trim().toUpperCase()
|
||||||
if (!expressCode) {
|
if (!expressCode) {
|
||||||
templateOptions.value = []
|
templateOptions.value = []
|
||||||
|
templateSelectValue.value = ''
|
||||||
formData.template_url = ''
|
formData.template_url = ''
|
||||||
formData.template_id = null
|
formData.template_id = null
|
||||||
formData.brandno = ''
|
formData.brandno = ''
|
||||||
@ -1100,6 +1103,7 @@ async function loadPrintPlatformTemplateOptions(sourceExpressCode?: string, sour
|
|||||||
})
|
})
|
||||||
if (!isSuccess(res)) {
|
if (!isSuccess(res)) {
|
||||||
templateOptions.value = []
|
templateOptions.value = []
|
||||||
|
templateSelectValue.value = ''
|
||||||
formData.template_url = ''
|
formData.template_url = ''
|
||||||
formData.template_id = null
|
formData.template_id = null
|
||||||
formData.brandno = ''
|
formData.brandno = ''
|
||||||
@ -1111,8 +1115,20 @@ async function loadPrintPlatformTemplateOptions(sourceExpressCode?: string, sour
|
|||||||
: []
|
: []
|
||||||
const nextOptions = templateList
|
const nextOptions = templateList
|
||||||
.map((item: any) => ({
|
.map((item: any) => ({
|
||||||
value: String(item?.standard_template_url || '').trim(),
|
value: (() => {
|
||||||
label: String(item?.standard_template_name || item?.standard_template_url || '').trim(),
|
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,
|
templateId: String(item?.standard_template_id || '').trim() || null,
|
||||||
brandCode: String(item?.brand_code || '').trim(),
|
brandCode: String(item?.brand_code || '').trim(),
|
||||||
raw: item || {}
|
raw: item || {}
|
||||||
@ -1123,20 +1139,30 @@ async function loadPrintPlatformTemplateOptions(sourceExpressCode?: string, sour
|
|||||||
formData.brandno = fallbackBrandCode
|
formData.brandno = fallbackBrandCode
|
||||||
|
|
||||||
const currentTemplateUrl = String(formData.template_url || '').trim()
|
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
|
formData.template_id = null
|
||||||
return
|
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) {
|
if (!matchedOption) {
|
||||||
|
templateSelectValue.value = ''
|
||||||
formData.template_url = ''
|
formData.template_url = ''
|
||||||
formData.template_id = null
|
formData.template_id = null
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
templateSelectValue.value = matchedOption.value
|
||||||
|
formData.template_url = matchedOption.templateUrl
|
||||||
formData.template_id = matchedOption.templateId
|
formData.template_id = matchedOption.templateId
|
||||||
formData.brandno = matchedOption.brandCode || fallbackBrandCode
|
formData.brandno = matchedOption.brandCode || fallbackBrandCode
|
||||||
} catch {
|
} catch {
|
||||||
templateOptions.value = []
|
templateOptions.value = []
|
||||||
|
templateSelectValue.value = ''
|
||||||
formData.template_url = ''
|
formData.template_url = ''
|
||||||
formData.template_id = null
|
formData.template_id = null
|
||||||
formData.brandno = ''
|
formData.brandno = ''
|
||||||
@ -1147,13 +1173,16 @@ async function loadPrintPlatformTemplateOptions(sourceExpressCode?: string, sour
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleTemplateChange(value: string | number | undefined) {
|
function handleTemplateChange(value: string | number | undefined) {
|
||||||
const templateUrl = String(value ?? '').trim()
|
const templateValue = String(value ?? '').trim()
|
||||||
if (!templateUrl) {
|
if (!templateValue) {
|
||||||
|
templateSelectValue.value = ''
|
||||||
|
formData.template_url = ''
|
||||||
formData.template_id = null
|
formData.template_id = null
|
||||||
formData.brandno = ''
|
formData.brandno = ''
|
||||||
return
|
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.template_id = matched?.templateId ?? null
|
||||||
formData.brandno = matched?.brandCode || ''
|
formData.brandno = matched?.brandCode || ''
|
||||||
}
|
}
|
||||||
@ -1607,6 +1636,7 @@ async function handleExpressCodeChange() {
|
|||||||
}
|
}
|
||||||
formData.template_url = ''
|
formData.template_url = ''
|
||||||
formData.template_id = null
|
formData.template_id = null
|
||||||
|
templateSelectValue.value = ''
|
||||||
formData.brandno = ''
|
formData.brandno = ''
|
||||||
templateOptions.value = []
|
templateOptions.value = []
|
||||||
applyAddressRaw(undefined)
|
applyAddressRaw(undefined)
|
||||||
@ -1647,6 +1677,7 @@ async function handlePlatformCodeChange(value: string | number | undefined) {
|
|||||||
formData.sys_express_code = ''
|
formData.sys_express_code = ''
|
||||||
formData.template_url = ''
|
formData.template_url = ''
|
||||||
formData.template_id = null
|
formData.template_id = null
|
||||||
|
templateSelectValue.value = ''
|
||||||
formData.brandno = ''
|
formData.brandno = ''
|
||||||
customExpressOptions.value = []
|
customExpressOptions.value = []
|
||||||
templateOptions.value = []
|
templateOptions.value = []
|
||||||
@ -1674,6 +1705,7 @@ async function handleShopChange(value: string | number | undefined) {
|
|||||||
formData.sys_express_code = ''
|
formData.sys_express_code = ''
|
||||||
formData.template_url = ''
|
formData.template_url = ''
|
||||||
formData.template_id = null
|
formData.template_id = null
|
||||||
|
templateSelectValue.value = ''
|
||||||
formData.brandno = ''
|
formData.brandno = ''
|
||||||
customExpressOptions.value = []
|
customExpressOptions.value = []
|
||||||
templateOptions.value = []
|
templateOptions.value = []
|
||||||
@ -1716,6 +1748,7 @@ function resetForm() {
|
|||||||
useCustomExpressCode.value = false
|
useCustomExpressCode.value = false
|
||||||
serviceValueMap.value = {}
|
serviceValueMap.value = {}
|
||||||
templateOptions.value = []
|
templateOptions.value = []
|
||||||
|
templateSelectValue.value = ''
|
||||||
formRef.value?.clearValidate()
|
formRef.value?.clearValidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1731,6 +1764,7 @@ async function openCreate() {
|
|||||||
selectedAddressKey.value = ''
|
selectedAddressKey.value = ''
|
||||||
shopOptions.value = []
|
shopOptions.value = []
|
||||||
templateOptions.value = []
|
templateOptions.value = []
|
||||||
|
templateSelectValue.value = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
async function openEdit(row: ExpressInterfaceRecord) {
|
async function openEdit(row: ExpressInterfaceRecord) {
|
||||||
@ -1748,6 +1782,7 @@ async function openEdit(row: ExpressInterfaceRecord) {
|
|||||||
selectedSiteKey.value = ''
|
selectedSiteKey.value = ''
|
||||||
selectedAddressKey.value = ''
|
selectedAddressKey.value = ''
|
||||||
templateOptions.value = []
|
templateOptions.value = []
|
||||||
|
templateSelectValue.value = ''
|
||||||
applyExpressInterfaceRowToForm(formData, row)
|
applyExpressInterfaceRowToForm(formData, row)
|
||||||
if (formData.is_system_express_code === 0 || String(formData.is_system_express_code) === '0') {
|
if (formData.is_system_express_code === 0 || String(formData.is_system_express_code) === '0') {
|
||||||
useCustomExpressCode.value = true
|
useCustomExpressCode.value = true
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user