This commit is contained in:
liufumingren 2026-06-01 03:01:02 +08:00
parent 9d434f3be3
commit 3641af8694
3 changed files with 78 additions and 7 deletions

View File

@ -46,6 +46,7 @@ export type ExpressInterfaceCreateParams = {
express_code: string express_code: string
platform_code: string platform_code: string
platform_shop_id?: string | null platform_shop_id?: string | null
providerid?: string
shop_id?: number shop_id?: number
sys_express_code?: string sys_express_code?: string
is_system_express_code?: number is_system_express_code?: number
@ -67,8 +68,10 @@ export type ExpressInterfaceCreateParams = {
address?: string address?: string
town_name?: string town_name?: string
site_code?: string site_code?: string
template_id?: string | null
template_url?: string template_url?: string
product_type?: string product_type?: string
brandno?: string
shop_name?: string shop_name?: string
ext_data?: Record<string, any> ext_data?: Record<string, any>
} }

View File

@ -8,6 +8,7 @@ export const expressInterfaceListFieldOrder = [
'name', 'name',
'platform_code', 'platform_code',
'platform_shop_id', 'platform_shop_id',
'providerid',
'express_code', 'express_code',
'sys_express_code', 'sys_express_code',
'is_system_express_code', 'is_system_express_code',
@ -21,8 +22,10 @@ export const expressInterfaceListFieldOrder = [
'address', 'address',
'town_name', 'town_name',
'site_code', 'site_code',
'template_id',
'template_url', 'template_url',
'product_type', 'product_type',
'brandno',
'is_hide_goods', 'is_hide_goods',
'weight', 'weight',
'weight_type', 'weight_type',
@ -44,6 +47,7 @@ export const expressInterfaceFieldLabels: Record<string, string> = {
sys_express_code: '系统快递编码', sys_express_code: '系统快递编码',
platform_code: '平台编码', platform_code: '平台编码',
platform_shop_id: '平台店铺ID', platform_shop_id: '平台店铺ID',
providerid: '服务商ID',
sender_name: '发件人', sender_name: '发件人',
sender_tel: '发件电话', sender_tel: '发件电话',
weight: '默认重量', weight: '默认重量',
@ -62,8 +66,10 @@ export const expressInterfaceFieldLabels: Record<string, string> = {
address: '详细地址', address: '详细地址',
town_name: '乡镇/街道', town_name: '乡镇/街道',
site_code: '站点编码', site_code: '站点编码',
template_id: '模板ID',
template_url: '打印模板', template_url: '打印模板',
product_type: '产品编码', product_type: '产品编码',
brandno: '品牌编码',
is_hide_goods: '是否隐藏商品', is_hide_goods: '是否隐藏商品',
is_system_express_code: '是否系统快递编码', is_system_express_code: '是否系统快递编码',
shop_name: '店铺名称', shop_name: '店铺名称',
@ -439,6 +445,7 @@ export const defaultExpressInterfaceForm = {
is_system_express_code: 1, is_system_express_code: 1,
platform_code: '', platform_code: '',
platform_shop_id: null as string | null, platform_shop_id: null as string | null,
providerid: '',
express_name: '', express_name: '',
sender_name: '', sender_name: '',
sender_tel: '', sender_tel: '',
@ -452,9 +459,11 @@ export const defaultExpressInterfaceForm = {
shipperno: '', shipperno: '',
can_use_count: undefined as number | undefined, can_use_count: undefined as number | undefined,
site_code: '', site_code: '',
template_id: null as string | null,
template_url: '', template_url: '',
shop_name: '', shop_name: '',
product_type: '', product_type: '',
brandno: '',
is_hide_goods: 0, is_hide_goods: 0,
address: '', address: '',
town_name: '', town_name: '',
@ -518,6 +527,7 @@ export function applyExpressInterfaceRowToForm(
const v = toFormString(row.platform_shop_id ?? row.platformShopId) const v = toFormString(row.platform_shop_id ?? row.platformShopId)
return v || null return v || null
})(), })(),
providerid: toFormString(row.providerid ?? row.provider_id ?? row.providerId),
express_name: toFormString(row.express_name || row.express?.name), express_name: toFormString(row.express_name || row.express?.name),
sender_name: toFormString(row.sender_name), sender_name: toFormString(row.sender_name),
sender_tel: toFormString(row.sender_tel), sender_tel: toFormString(row.sender_tel),
@ -531,9 +541,14 @@ export function applyExpressInterfaceRowToForm(
shipperno: toFormString(row.shipperno), shipperno: toFormString(row.shipperno),
can_use_count: toFormOptionalNumber(row.can_use_count), can_use_count: toFormOptionalNumber(row.can_use_count),
site_code: toFormString(row.site_code), 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), template_url: toFormString(row.template_url ?? row.templateUrl),
shop_name: toFormString(row.shop_name), shop_name: toFormString(row.shop_name),
product_type: toFormString(row.product_type), product_type: toFormString(row.product_type),
brandno: toFormString(row.brandno),
is_hide_goods: toFormOptionalNumber(row.is_hide_goods) ?? 0, is_hide_goods: toFormOptionalNumber(row.is_hide_goods) ?? 0,
address: toFormString(row.address), address: toFormString(row.address),
town_name: toFormString(row.town_name), town_name: toFormString(row.town_name),
@ -607,6 +622,7 @@ export function buildExpressInterfaceCreatePayload(
'sys_express_code', 'sys_express_code',
'sender_name', 'sender_name',
'sender_tel', 'sender_tel',
'providerid',
'token', 'token',
'viewer', 'viewer',
'client_id', 'client_id',
@ -617,8 +633,10 @@ export function buildExpressInterfaceCreatePayload(
'address', 'address',
'town_name', 'town_name',
'site_code', 'site_code',
'template_id',
'template_url', 'template_url',
'product_type', 'product_type',
'brandno',
'shop_name' 'shop_name'
] as const ] as const
for (const key of optionalStrings) { for (const key of optionalStrings) {

View File

@ -420,6 +420,7 @@
:loading="printTemplateLoading" :loading="printTemplateLoading"
:disabled="!activeTemplateExpressCode" :disabled="!activeTemplateExpressCode"
placeholder="请选择打印模板" placeholder="请选择打印模板"
@change="handleTemplateChange"
> >
<el-option <el-option
v-for="item in templateOptions" v-for="item in templateOptions"
@ -514,13 +515,19 @@ import {
buildExpressInterfaceUpdatePayload buildExpressInterfaceUpdatePayload
} from './express-interface-config' } 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 PlatformOption = { code: string; name: string; label?: string }
type ShopOption = { value: number | string; label: string } type ShopOption = { value: number | string; label: string }
type ServiceOption = { code: string; name: string; raw: Record<string, any> } type ServiceOption = { code: string; name: string; raw: Record<string, any> }
type AddressOption = { key: string; label: string; raw: Record<string, any> } type AddressOption = { key: string; label: string; raw: Record<string, any> }
type MonthlyAccountOption = { value: string; label: string } 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 = { type ServiceFlatField = {
key: string key: string
serviceCode: string serviceCode: string
@ -1077,6 +1084,8 @@ async function loadPrintPlatformTemplateOptions(sourceExpressCode?: string, sour
if (!expressCode) { if (!expressCode) {
templateOptions.value = [] templateOptions.value = []
formData.template_url = '' formData.template_url = ''
formData.template_id = null
formData.brandno = ''
return return
} }
if (printTemplateLoading.value) return if (printTemplateLoading.value) return
@ -1092,6 +1101,8 @@ async function loadPrintPlatformTemplateOptions(sourceExpressCode?: string, sour
if (!isSuccess(res)) { if (!isSuccess(res)) {
templateOptions.value = [] templateOptions.value = []
formData.template_url = '' formData.template_url = ''
formData.template_id = null
formData.brandno = ''
ElMessage.error(res?.message || '获取打印模板列表失败') ElMessage.error(res?.message || '获取打印模板列表失败')
return return
} }
@ -1102,26 +1113,51 @@ async function loadPrintPlatformTemplateOptions(sourceExpressCode?: string, sour
.map((item: any) => ({ .map((item: any) => ({
value: String(item?.standard_template_url || '').trim(), value: String(item?.standard_template_url || '').trim(),
label: String(item?.standard_template_name || 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 || {} raw: item || {}
})) }))
.filter((item: TemplateOption) => !!item.value) .filter((item: TemplateOption) => !!item.value)
templateOptions.value = nextOptions templateOptions.value = nextOptions
const fallbackBrandCode = nextOptions[0]?.brandCode || ''
formData.brandno = fallbackBrandCode
const currentTemplateUrl = String(formData.template_url || '').trim() const currentTemplateUrl = String(formData.template_url || '').trim()
if (!currentTemplateUrl) return if (!currentTemplateUrl) {
const exists = nextOptions.some((item: TemplateOption) => item.value === currentTemplateUrl) formData.template_id = null
if (!exists) { return
formData.template_url = ''
} }
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 { } catch {
templateOptions.value = [] templateOptions.value = []
formData.template_url = '' formData.template_url = ''
formData.template_id = null
formData.brandno = ''
ElMessage.error('获取打印模板列表失败') ElMessage.error('获取打印模板列表失败')
} finally { } finally {
printTemplateLoading.value = false 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) { async function loadCustomExpressOptions(sourceExpressCode?: string) {
const expressCode = String(sourceExpressCode ?? formData.sys_express_code ?? '').trim().toUpperCase() const expressCode = String(sourceExpressCode ?? formData.sys_express_code ?? '').trim().toUpperCase()
if (!expressCode) { if (!expressCode) {
@ -1220,6 +1256,7 @@ async function loadShopExpressOptions(shopId: string | number) {
.map((item: any) => { .map((item: any) => {
const code = item?.wp_code || item?.express_code || item?.code const code = item?.wp_code || item?.express_code || item?.code
const sysExpressCode = String(item?.sys_express_code || item?.express_code || item?.code || '').trim() 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 name = item?.wp_name || item?.express_name || item?.name
const label = item?.label || name const label = item?.label || name
if (code) { if (code) {
@ -1318,7 +1355,7 @@ async function loadShopExpressOptions(shopId: string | number) {
siteMap[sysExpressCode] = mappedSites siteMap[sysExpressCode] = mappedSites
} }
} }
return { code, name, label, sysExpressCode } return { code, name, label, sysExpressCode, providerid }
}) })
.filter((item: ExpressOption) => !!item.code) .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 shopExpressSitesMap.value = siteMap
} catch { } catch {
dialogExpressOptions.value = [] dialogExpressOptions.value = []
@ -1558,12 +1599,15 @@ async function handleExpressCodeChange() {
selectedSiteKey.value = '' selectedSiteKey.value = ''
selectedAddressKey.value = '' selectedAddressKey.value = ''
formData.site_code = '' formData.site_code = ''
formData.providerid = String(selectedSignedExpress?.providerid || '').trim()
formData.shipperno = '' formData.shipperno = ''
customExpressOptions.value = [] customExpressOptions.value = []
if (useCustomExpressCode.value) { if (useCustomExpressCode.value) {
formData.express_code = '' formData.express_code = ''
} }
formData.template_url = '' formData.template_url = ''
formData.template_id = null
formData.brandno = ''
templateOptions.value = [] templateOptions.value = []
applyAddressRaw(undefined) applyAddressRaw(undefined)
serviceValueMap.value = {} serviceValueMap.value = {}
@ -1597,10 +1641,13 @@ async function handlePlatformCodeChange(value: string | number | undefined) {
formData.shop_id = undefined formData.shop_id = undefined
formData.shop_name = '' formData.shop_name = ''
formData.express_code = '' formData.express_code = ''
formData.providerid = ''
formData.site_code = '' formData.site_code = ''
formData.shipperno = '' formData.shipperno = ''
formData.sys_express_code = '' formData.sys_express_code = ''
formData.template_url = '' formData.template_url = ''
formData.template_id = null
formData.brandno = ''
customExpressOptions.value = [] customExpressOptions.value = []
templateOptions.value = [] templateOptions.value = []
selectedSiteKey.value = '' selectedSiteKey.value = ''
@ -1620,11 +1667,14 @@ async function handleShopChange(value: string | number | undefined) {
const current = shopOptions.value.find((item) => item.value === target) const current = shopOptions.value.find((item) => item.value === target)
formData.shop_name = current?.label || '' formData.shop_name = current?.label || ''
formData.express_code = '' formData.express_code = ''
formData.providerid = ''
serviceValueMap.value = {} serviceValueMap.value = {}
formData.ext_data = undefined formData.ext_data = undefined
formData.shipperno = '' formData.shipperno = ''
formData.sys_express_code = '' formData.sys_express_code = ''
formData.template_url = '' formData.template_url = ''
formData.template_id = null
formData.brandno = ''
customExpressOptions.value = [] customExpressOptions.value = []
templateOptions.value = [] templateOptions.value = []
dialogExpressOptions.value = [] dialogExpressOptions.value = []