1
This commit is contained in:
parent
9d434f3be3
commit
3641af8694
@ -46,6 +46,7 @@ export type ExpressInterfaceCreateParams = {
|
||||
express_code: string
|
||||
platform_code: string
|
||||
platform_shop_id?: string | null
|
||||
providerid?: string
|
||||
shop_id?: number
|
||||
sys_express_code?: string
|
||||
is_system_express_code?: number
|
||||
@ -67,8 +68,10 @@ export type ExpressInterfaceCreateParams = {
|
||||
address?: string
|
||||
town_name?: string
|
||||
site_code?: string
|
||||
template_id?: string | null
|
||||
template_url?: string
|
||||
product_type?: string
|
||||
brandno?: string
|
||||
shop_name?: string
|
||||
ext_data?: Record<string, any>
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ export const expressInterfaceListFieldOrder = [
|
||||
'name',
|
||||
'platform_code',
|
||||
'platform_shop_id',
|
||||
'providerid',
|
||||
'express_code',
|
||||
'sys_express_code',
|
||||
'is_system_express_code',
|
||||
@ -21,8 +22,10 @@ export const expressInterfaceListFieldOrder = [
|
||||
'address',
|
||||
'town_name',
|
||||
'site_code',
|
||||
'template_id',
|
||||
'template_url',
|
||||
'product_type',
|
||||
'brandno',
|
||||
'is_hide_goods',
|
||||
'weight',
|
||||
'weight_type',
|
||||
@ -44,6 +47,7 @@ export const expressInterfaceFieldLabels: Record<string, string> = {
|
||||
sys_express_code: '系统快递编码',
|
||||
platform_code: '平台编码',
|
||||
platform_shop_id: '平台店铺ID',
|
||||
providerid: '服务商ID',
|
||||
sender_name: '发件人',
|
||||
sender_tel: '发件电话',
|
||||
weight: '默认重量',
|
||||
@ -62,8 +66,10 @@ export const expressInterfaceFieldLabels: Record<string, string> = {
|
||||
address: '详细地址',
|
||||
town_name: '乡镇/街道',
|
||||
site_code: '站点编码',
|
||||
template_id: '模板ID',
|
||||
template_url: '打印模板',
|
||||
product_type: '产品编码',
|
||||
brandno: '品牌编码',
|
||||
is_hide_goods: '是否隐藏商品',
|
||||
is_system_express_code: '是否系统快递编码',
|
||||
shop_name: '店铺名称',
|
||||
@ -439,6 +445,7 @@ export const defaultExpressInterfaceForm = {
|
||||
is_system_express_code: 1,
|
||||
platform_code: '',
|
||||
platform_shop_id: null as string | null,
|
||||
providerid: '',
|
||||
express_name: '',
|
||||
sender_name: '',
|
||||
sender_tel: '',
|
||||
@ -452,9 +459,11 @@ export const defaultExpressInterfaceForm = {
|
||||
shipperno: '',
|
||||
can_use_count: undefined as number | undefined,
|
||||
site_code: '',
|
||||
template_id: null as string | null,
|
||||
template_url: '',
|
||||
shop_name: '',
|
||||
product_type: '',
|
||||
brandno: '',
|
||||
is_hide_goods: 0,
|
||||
address: '',
|
||||
town_name: '',
|
||||
@ -518,6 +527,7 @@ export function applyExpressInterfaceRowToForm(
|
||||
const v = toFormString(row.platform_shop_id ?? row.platformShopId)
|
||||
return v || null
|
||||
})(),
|
||||
providerid: toFormString(row.providerid ?? row.provider_id ?? row.providerId),
|
||||
express_name: toFormString(row.express_name || row.express?.name),
|
||||
sender_name: toFormString(row.sender_name),
|
||||
sender_tel: toFormString(row.sender_tel),
|
||||
@ -531,9 +541,14 @@ export function applyExpressInterfaceRowToForm(
|
||||
shipperno: toFormString(row.shipperno),
|
||||
can_use_count: toFormOptionalNumber(row.can_use_count),
|
||||
site_code: toFormString(row.site_code),
|
||||
template_id: (() => {
|
||||
const v = toFormString(row.template_id ?? row.templateId)
|
||||
return v || null
|
||||
})(),
|
||||
template_url: toFormString(row.template_url ?? row.templateUrl),
|
||||
shop_name: toFormString(row.shop_name),
|
||||
product_type: toFormString(row.product_type),
|
||||
brandno: toFormString(row.brandno),
|
||||
is_hide_goods: toFormOptionalNumber(row.is_hide_goods) ?? 0,
|
||||
address: toFormString(row.address),
|
||||
town_name: toFormString(row.town_name),
|
||||
@ -607,6 +622,7 @@ export function buildExpressInterfaceCreatePayload(
|
||||
'sys_express_code',
|
||||
'sender_name',
|
||||
'sender_tel',
|
||||
'providerid',
|
||||
'token',
|
||||
'viewer',
|
||||
'client_id',
|
||||
@ -617,8 +633,10 @@ export function buildExpressInterfaceCreatePayload(
|
||||
'address',
|
||||
'town_name',
|
||||
'site_code',
|
||||
'template_id',
|
||||
'template_url',
|
||||
'product_type',
|
||||
'brandno',
|
||||
'shop_name'
|
||||
] as const
|
||||
for (const key of optionalStrings) {
|
||||
|
||||
@ -420,6 +420,7 @@
|
||||
:loading="printTemplateLoading"
|
||||
:disabled="!activeTemplateExpressCode"
|
||||
placeholder="请选择打印模板"
|
||||
@change="handleTemplateChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in templateOptions"
|
||||
@ -514,13 +515,19 @@ import {
|
||||
buildExpressInterfaceUpdatePayload
|
||||
} from './express-interface-config'
|
||||
|
||||
type ExpressOption = { code: string; name: string; label?: string; sysExpressCode?: string }
|
||||
type ExpressOption = { code: string; name: string; label?: string; sysExpressCode?: string; providerid?: string }
|
||||
type PlatformOption = { code: string; name: string; label?: string }
|
||||
type ShopOption = { value: number | string; label: string }
|
||||
type ServiceOption = { code: string; name: string; raw: Record<string, any> }
|
||||
type AddressOption = { key: string; label: string; raw: Record<string, any> }
|
||||
type MonthlyAccountOption = { value: string; label: string }
|
||||
type TemplateOption = { value: string; label: string; raw: Record<string, any> }
|
||||
type TemplateOption = {
|
||||
value: string
|
||||
label: string
|
||||
templateId: string | null
|
||||
brandCode: string
|
||||
raw: Record<string, any>
|
||||
}
|
||||
type ServiceFlatField = {
|
||||
key: string
|
||||
serviceCode: string
|
||||
@ -1077,6 +1084,8 @@ async function loadPrintPlatformTemplateOptions(sourceExpressCode?: string, sour
|
||||
if (!expressCode) {
|
||||
templateOptions.value = []
|
||||
formData.template_url = ''
|
||||
formData.template_id = null
|
||||
formData.brandno = ''
|
||||
return
|
||||
}
|
||||
if (printTemplateLoading.value) return
|
||||
@ -1092,6 +1101,8 @@ async function loadPrintPlatformTemplateOptions(sourceExpressCode?: string, sour
|
||||
if (!isSuccess(res)) {
|
||||
templateOptions.value = []
|
||||
formData.template_url = ''
|
||||
formData.template_id = null
|
||||
formData.brandno = ''
|
||||
ElMessage.error(res?.message || '获取打印模板列表失败')
|
||||
return
|
||||
}
|
||||
@ -1102,26 +1113,51 @@ async function loadPrintPlatformTemplateOptions(sourceExpressCode?: string, sour
|
||||
.map((item: any) => ({
|
||||
value: String(item?.standard_template_url || '').trim(),
|
||||
label: String(item?.standard_template_name || item?.standard_template_url || '').trim(),
|
||||
templateId: String(item?.standard_template_id || '').trim() || null,
|
||||
brandCode: String(item?.brand_code || '').trim(),
|
||||
raw: item || {}
|
||||
}))
|
||||
.filter((item: TemplateOption) => !!item.value)
|
||||
templateOptions.value = nextOptions
|
||||
const fallbackBrandCode = nextOptions[0]?.brandCode || ''
|
||||
formData.brandno = fallbackBrandCode
|
||||
|
||||
const currentTemplateUrl = String(formData.template_url || '').trim()
|
||||
if (!currentTemplateUrl) return
|
||||
const exists = nextOptions.some((item: TemplateOption) => item.value === currentTemplateUrl)
|
||||
if (!exists) {
|
||||
formData.template_url = ''
|
||||
if (!currentTemplateUrl) {
|
||||
formData.template_id = null
|
||||
return
|
||||
}
|
||||
const matchedOption = nextOptions.find((item: TemplateOption) => item.value === currentTemplateUrl)
|
||||
if (!matchedOption) {
|
||||
formData.template_url = ''
|
||||
formData.template_id = null
|
||||
return
|
||||
}
|
||||
formData.template_id = matchedOption.templateId
|
||||
formData.brandno = matchedOption.brandCode || fallbackBrandCode
|
||||
} catch {
|
||||
templateOptions.value = []
|
||||
formData.template_url = ''
|
||||
formData.template_id = null
|
||||
formData.brandno = ''
|
||||
ElMessage.error('获取打印模板列表失败')
|
||||
} finally {
|
||||
printTemplateLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleTemplateChange(value: string | number | undefined) {
|
||||
const templateUrl = String(value ?? '').trim()
|
||||
if (!templateUrl) {
|
||||
formData.template_id = null
|
||||
formData.brandno = ''
|
||||
return
|
||||
}
|
||||
const matched = templateOptions.value.find((item) => item.value === templateUrl)
|
||||
formData.template_id = matched?.templateId ?? null
|
||||
formData.brandno = matched?.brandCode || ''
|
||||
}
|
||||
|
||||
async function loadCustomExpressOptions(sourceExpressCode?: string) {
|
||||
const expressCode = String(sourceExpressCode ?? formData.sys_express_code ?? '').trim().toUpperCase()
|
||||
if (!expressCode) {
|
||||
@ -1220,6 +1256,7 @@ async function loadShopExpressOptions(shopId: string | number) {
|
||||
.map((item: any) => {
|
||||
const code = item?.wp_code || item?.express_code || item?.code
|
||||
const sysExpressCode = String(item?.sys_express_code || item?.express_code || item?.code || '').trim()
|
||||
const providerid = String(item?.providerid || item?.provider_id || item?.providerId || '').trim()
|
||||
const name = item?.wp_name || item?.express_name || item?.name
|
||||
const label = item?.label || name
|
||||
if (code) {
|
||||
@ -1318,7 +1355,7 @@ async function loadShopExpressOptions(shopId: string | number) {
|
||||
siteMap[sysExpressCode] = mappedSites
|
||||
}
|
||||
}
|
||||
return { code, name, label, sysExpressCode }
|
||||
return { code, name, label, sysExpressCode, providerid }
|
||||
})
|
||||
.filter((item: ExpressOption) => !!item.code)
|
||||
|
||||
@ -1346,6 +1383,10 @@ async function loadShopExpressOptions(shopId: string | number) {
|
||||
}
|
||||
}
|
||||
}
|
||||
const selectedBySignedCode = dialogExpressOptions.value.find(
|
||||
(item) => String(item.sysExpressCode || item.code || '').trim() === String(formData.sys_express_code || '').trim()
|
||||
)
|
||||
formData.providerid = String(selectedBySignedCode?.providerid || '').trim()
|
||||
shopExpressSitesMap.value = siteMap
|
||||
} catch {
|
||||
dialogExpressOptions.value = []
|
||||
@ -1558,12 +1599,15 @@ async function handleExpressCodeChange() {
|
||||
selectedSiteKey.value = ''
|
||||
selectedAddressKey.value = ''
|
||||
formData.site_code = ''
|
||||
formData.providerid = String(selectedSignedExpress?.providerid || '').trim()
|
||||
formData.shipperno = ''
|
||||
customExpressOptions.value = []
|
||||
if (useCustomExpressCode.value) {
|
||||
formData.express_code = ''
|
||||
}
|
||||
formData.template_url = ''
|
||||
formData.template_id = null
|
||||
formData.brandno = ''
|
||||
templateOptions.value = []
|
||||
applyAddressRaw(undefined)
|
||||
serviceValueMap.value = {}
|
||||
@ -1597,10 +1641,13 @@ async function handlePlatformCodeChange(value: string | number | undefined) {
|
||||
formData.shop_id = undefined
|
||||
formData.shop_name = ''
|
||||
formData.express_code = ''
|
||||
formData.providerid = ''
|
||||
formData.site_code = ''
|
||||
formData.shipperno = ''
|
||||
formData.sys_express_code = ''
|
||||
formData.template_url = ''
|
||||
formData.template_id = null
|
||||
formData.brandno = ''
|
||||
customExpressOptions.value = []
|
||||
templateOptions.value = []
|
||||
selectedSiteKey.value = ''
|
||||
@ -1620,11 +1667,14 @@ async function handleShopChange(value: string | number | undefined) {
|
||||
const current = shopOptions.value.find((item) => item.value === target)
|
||||
formData.shop_name = current?.label || ''
|
||||
formData.express_code = ''
|
||||
formData.providerid = ''
|
||||
serviceValueMap.value = {}
|
||||
formData.ext_data = undefined
|
||||
formData.shipperno = ''
|
||||
formData.sys_express_code = ''
|
||||
formData.template_url = ''
|
||||
formData.template_id = null
|
||||
formData.brandno = ''
|
||||
customExpressOptions.value = []
|
||||
templateOptions.value = []
|
||||
dialogExpressOptions.value = []
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user