1
This commit is contained in:
parent
cb70b96229
commit
5547fc74b1
@ -180,6 +180,34 @@ export function getPlatformList(data?: Record<string, unknown>) {
|
|||||||
} as any)
|
} as any)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getPrintPlatformList(data?: Record<string, unknown>) {
|
||||||
|
return request({
|
||||||
|
url: '/system',
|
||||||
|
method: 'post',
|
||||||
|
params: {
|
||||||
|
method: 'index.getPrintPlatformList',
|
||||||
|
v: '1.0',
|
||||||
|
timestamp: new Date().getTime()
|
||||||
|
},
|
||||||
|
data: data ?? {},
|
||||||
|
isSystemApi: true
|
||||||
|
} as any)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getPrintPlatformTemplateList(data?: { platform_code?: string; express_code: string }) {
|
||||||
|
return request({
|
||||||
|
url: '/system',
|
||||||
|
method: 'post',
|
||||||
|
params: {
|
||||||
|
method: 'index.getPrintPlatformTemplateList',
|
||||||
|
v: '1.0',
|
||||||
|
timestamp: new Date().getTime()
|
||||||
|
},
|
||||||
|
data: data ?? ({} as any),
|
||||||
|
isSystemApi: true
|
||||||
|
} as any)
|
||||||
|
}
|
||||||
|
|
||||||
/** 获取平台授权链接(当前仅支持 PDD) */
|
/** 获取平台授权链接(当前仅支持 PDD) */
|
||||||
export function getPlatformOauthLink(data?: {
|
export function getPlatformOauthLink(data?: {
|
||||||
code?: string
|
code?: string
|
||||||
|
|||||||
@ -47,6 +47,8 @@ export type ExpressInterfaceCreateParams = {
|
|||||||
platform_code: string
|
platform_code: string
|
||||||
shop_id?: number
|
shop_id?: number
|
||||||
sys_express_code?: string
|
sys_express_code?: string
|
||||||
|
is_system_express_code?: number
|
||||||
|
is_hide_goods?: number
|
||||||
sender_name?: string
|
sender_name?: string
|
||||||
sender_tel?: string
|
sender_tel?: string
|
||||||
weight?: number
|
weight?: number
|
||||||
@ -64,6 +66,7 @@ export type ExpressInterfaceCreateParams = {
|
|||||||
address?: string
|
address?: string
|
||||||
town_name?: string
|
town_name?: string
|
||||||
site_code?: string
|
site_code?: string
|
||||||
|
template_url?: string
|
||||||
product_type?: string
|
product_type?: string
|
||||||
shop_name?: string
|
shop_name?: string
|
||||||
ext_data?: Record<string, any>
|
ext_data?: Record<string, any>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import pcasCodeData from 'china-division/dist/pcas-code.json'
|
import pcasCodeData from 'china-division/dist/pcas-code.json'
|
||||||
import type { ExpressInterfaceCreateParams } from '@/api/setting.expressinterface/expressInterface'
|
import type { ExpressInterfaceCreateParams } from '@/api/setting.expressInterface/expressInterface'
|
||||||
|
|
||||||
/** setting.expressInterface.list 单条记录字段顺序(与接口返回一致) */
|
/** setting.expressInterface.list 单条记录字段顺序(与接口返回一致) */
|
||||||
export const expressInterfaceListFieldOrder = [
|
export const expressInterfaceListFieldOrder = [
|
||||||
@ -9,6 +9,7 @@ export const expressInterfaceListFieldOrder = [
|
|||||||
'platform_code',
|
'platform_code',
|
||||||
'express_code',
|
'express_code',
|
||||||
'sys_express_code',
|
'sys_express_code',
|
||||||
|
'is_system_express_code',
|
||||||
'express_name',
|
'express_name',
|
||||||
'shop_name',
|
'shop_name',
|
||||||
'sender_name',
|
'sender_name',
|
||||||
@ -19,7 +20,9 @@ export const expressInterfaceListFieldOrder = [
|
|||||||
'address',
|
'address',
|
||||||
'town_name',
|
'town_name',
|
||||||
'site_code',
|
'site_code',
|
||||||
|
'template_url',
|
||||||
'product_type',
|
'product_type',
|
||||||
|
'is_hide_goods',
|
||||||
'weight',
|
'weight',
|
||||||
'weight_type',
|
'weight_type',
|
||||||
'viewer',
|
'viewer',
|
||||||
@ -57,7 +60,10 @@ export const expressInterfaceFieldLabels: Record<string, string> = {
|
|||||||
address: '详细地址',
|
address: '详细地址',
|
||||||
town_name: '乡镇/街道',
|
town_name: '乡镇/街道',
|
||||||
site_code: '站点编码',
|
site_code: '站点编码',
|
||||||
product_type: '快递产品类型',
|
template_url: '打印模板',
|
||||||
|
product_type: '产品编码',
|
||||||
|
is_hide_goods: '是否隐藏商品',
|
||||||
|
is_system_express_code: '是否系统快递编码',
|
||||||
shop_name: '店铺名称',
|
shop_name: '店铺名称',
|
||||||
warehouse_id: '仓库ID',
|
warehouse_id: '仓库ID',
|
||||||
ext_data: '扩展数据',
|
ext_data: '扩展数据',
|
||||||
@ -428,6 +434,7 @@ export const defaultExpressInterfaceForm = {
|
|||||||
name: '',
|
name: '',
|
||||||
express_code: '',
|
express_code: '',
|
||||||
sys_express_code: '',
|
sys_express_code: '',
|
||||||
|
is_system_express_code: 1,
|
||||||
platform_code: '',
|
platform_code: '',
|
||||||
express_name: '',
|
express_name: '',
|
||||||
sender_name: '',
|
sender_name: '',
|
||||||
@ -442,8 +449,10 @@ export const defaultExpressInterfaceForm = {
|
|||||||
shipperno: '',
|
shipperno: '',
|
||||||
can_use_count: undefined as number | undefined,
|
can_use_count: undefined as number | undefined,
|
||||||
site_code: '',
|
site_code: '',
|
||||||
|
template_url: '',
|
||||||
shop_name: '',
|
shop_name: '',
|
||||||
product_type: '',
|
product_type: '',
|
||||||
|
is_hide_goods: 0,
|
||||||
address: '',
|
address: '',
|
||||||
town_name: '',
|
town_name: '',
|
||||||
ext_data: undefined as Record<string, any> | undefined,
|
ext_data: undefined as Record<string, any> | undefined,
|
||||||
@ -487,13 +496,20 @@ export function applyExpressInterfaceRowToForm(
|
|||||||
row: Record<string, any>
|
row: Record<string, any>
|
||||||
) {
|
) {
|
||||||
const ext = parseExpressInterfaceExtData(row.ext_data)
|
const ext = parseExpressInterfaceExtData(row.ext_data)
|
||||||
|
const rawExpressCode = toFormString(row.express_code)
|
||||||
|
const rawSysExpressCode = toFormString(row.sys_express_code)
|
||||||
|
const isCustomExpressCode = (toFormOptionalNumber(row.is_system_express_code) ?? 1) === 0
|
||||||
|
const signedExpressCode = rawSysExpressCode || rawExpressCode
|
||||||
|
const customExpressCode = isCustomExpressCode ? rawExpressCode : ''
|
||||||
|
|
||||||
Object.assign(form, {
|
Object.assign(form, {
|
||||||
id: row.id,
|
id: row.id,
|
||||||
warehouse_id: toFormOptionalNumber(row.warehouse_id),
|
warehouse_id: toFormOptionalNumber(row.warehouse_id),
|
||||||
shop_id: toFormOptionalNumber(row.shop_id ?? row.shopId),
|
shop_id: toFormOptionalNumber(row.shop_id ?? row.shopId),
|
||||||
name: toFormString(row.name),
|
name: toFormString(row.name),
|
||||||
express_code: toFormString(row.express_code),
|
express_code: signedExpressCode,
|
||||||
sys_express_code: toFormString(row.sys_express_code),
|
sys_express_code: customExpressCode,
|
||||||
|
is_system_express_code: toFormOptionalNumber(row.is_system_express_code) ?? 1,
|
||||||
platform_code: toFormString(row.platform_code),
|
platform_code: toFormString(row.platform_code),
|
||||||
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),
|
||||||
@ -508,8 +524,10 @@ 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_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),
|
||||||
|
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),
|
||||||
province_name: toFormString(row.province_name),
|
province_name: toFormString(row.province_name),
|
||||||
@ -524,7 +542,7 @@ export function formatExpressInterfaceFormDisplayValue(
|
|||||||
key: string,
|
key: string,
|
||||||
val: unknown
|
val: unknown
|
||||||
): string {
|
): string {
|
||||||
if (key === 'is_share' || key === 'ispickup') {
|
if (key === 'is_share' || key === 'ispickup' || key === 'is_hide_goods') {
|
||||||
if (val === 1 || val === true) return '是'
|
if (val === 1 || val === true) return '是'
|
||||||
if (val === 0 || val === false) return '否'
|
if (val === 0 || val === false) return '否'
|
||||||
return '--'
|
return '--'
|
||||||
@ -581,6 +599,7 @@ export function buildExpressInterfaceCreatePayload(
|
|||||||
'address',
|
'address',
|
||||||
'town_name',
|
'town_name',
|
||||||
'site_code',
|
'site_code',
|
||||||
|
'template_url',
|
||||||
'product_type',
|
'product_type',
|
||||||
'shop_name'
|
'shop_name'
|
||||||
] as const
|
] as const
|
||||||
@ -589,12 +608,23 @@ export function buildExpressInterfaceCreatePayload(
|
|||||||
if (v !== undefined) payload[key] = v
|
if (v !== undefined) payload[key] = v
|
||||||
}
|
}
|
||||||
|
|
||||||
const optionalNumbers = ['shop_id', 'weight', 'weight_type', 'share_id', 'ispickup', 'can_use_count'] as const
|
const optionalNumbers = [
|
||||||
|
'shop_id',
|
||||||
|
'is_system_express_code',
|
||||||
|
'is_hide_goods',
|
||||||
|
'weight',
|
||||||
|
'weight_type',
|
||||||
|
'share_id',
|
||||||
|
'ispickup',
|
||||||
|
'can_use_count'
|
||||||
|
] as const
|
||||||
for (const key of optionalNumbers) {
|
for (const key of optionalNumbers) {
|
||||||
const n = omitOptionalNumber(form[key])
|
const n = omitOptionalNumber(form[key])
|
||||||
if (n === undefined) continue
|
if (n === undefined) continue
|
||||||
const rounded =
|
const rounded =
|
||||||
key === 'shop_id' ||
|
key === 'shop_id' ||
|
||||||
|
key === 'is_system_express_code' ||
|
||||||
|
key === 'is_hide_goods' ||
|
||||||
key === 'weight' ||
|
key === 'weight' ||
|
||||||
key === 'weight_type' ||
|
key === 'weight_type' ||
|
||||||
key === 'ispickup' ||
|
key === 'ispickup' ||
|
||||||
@ -613,8 +643,14 @@ export function buildExpressInterfaceCreatePayload(
|
|||||||
|
|
||||||
/** setting.expressInterface.update 请求体 */
|
/** setting.expressInterface.update 请求体 */
|
||||||
export function buildExpressInterfaceUpdatePayload(form: Record<string, any>): Record<string, any> {
|
export function buildExpressInterfaceUpdatePayload(form: Record<string, any>): Record<string, any> {
|
||||||
|
const sourceExpressCode = String(form.express_code || '').trim()
|
||||||
|
const customExpressCode = String(form.sys_express_code || '').trim()
|
||||||
|
const basePayload = buildExpressInterfaceCreatePayload(form)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...buildExpressInterfaceCreatePayload(form),
|
...basePayload,
|
||||||
|
express_code: customExpressCode || sourceExpressCode,
|
||||||
|
sys_express_code: sourceExpressCode || undefined,
|
||||||
id: form.id
|
id: form.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -138,13 +138,13 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item class="platform-form-item" label="平台编码" prop="platform_code">
|
<el-form-item class="platform-form-item" label="平台" prop="platform_code">
|
||||||
<div class="platform-select-row">
|
<div class="platform-select-row">
|
||||||
<el-select
|
<el-select
|
||||||
v-model="formData.platform_code"
|
v-model="formData.platform_code"
|
||||||
class="platform-select"
|
class="platform-select"
|
||||||
filterable
|
filterable
|
||||||
placeholder="请选择平台编码"
|
placeholder="请选择平台"
|
||||||
@change="handlePlatformCodeChange"
|
@change="handlePlatformCodeChange"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
@ -334,6 +334,24 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
<el-col v-if="dialogMonthlyAccountOptions.length > 0" :span="24">
|
||||||
|
<el-form-item label="月结账号">
|
||||||
|
<el-select
|
||||||
|
v-model="formData.shipperno"
|
||||||
|
filterable
|
||||||
|
clearable
|
||||||
|
placeholder="请选择月结账号"
|
||||||
|
@change="handleMonthlyAccountChange"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in dialogMonthlyAccountOptions"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
<el-col v-if="dialogMode === 'create' || showRegionField" :span="24">
|
<el-col v-if="dialogMode === 'create' || showRegionField" :span="24">
|
||||||
<el-form-item label="省市区">
|
<el-form-item label="省市区">
|
||||||
@ -376,7 +394,7 @@
|
|||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="重量类型">
|
<el-form-item label="重量类型">
|
||||||
<el-select v-model="formData.weight_type" clearable placeholder="请选择重量类型">
|
<el-select v-model="formData.weight_type" clearable placeholder="请选择重量类型">
|
||||||
<el-option :value="1" label="普通" />
|
<el-option :value="0" label="普通" />
|
||||||
<el-option :value="2" label="重货" />
|
<el-option :value="2" label="重货" />
|
||||||
<el-option :value="3" label="轻货" />
|
<el-option :value="3" label="轻货" />
|
||||||
<el-option :value="4" label="生鲜" />
|
<el-option :value="4" label="生鲜" />
|
||||||
@ -388,6 +406,46 @@
|
|||||||
<el-input v-model="formData.viewer" placeholder="可选,最长 50 字符" />
|
<el-input v-model="formData.viewer" placeholder="可选,最长 50 字符" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="产品编码">
|
||||||
|
<el-input v-model="formData.product_type" placeholder="请输入产品编码" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="打印模板">
|
||||||
|
<el-select
|
||||||
|
v-model="formData.template_url"
|
||||||
|
filterable
|
||||||
|
clearable
|
||||||
|
:loading="printTemplateLoading"
|
||||||
|
:disabled="!formData.express_code"
|
||||||
|
placeholder="请选择打印模板"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in templateOptions"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label || item.value"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="是否隐藏商品">
|
||||||
|
<div class="hide-goods-field">
|
||||||
|
<el-switch
|
||||||
|
v-model="formData.is_hide_goods"
|
||||||
|
:active-value="1"
|
||||||
|
:inactive-value="0"
|
||||||
|
active-text="是"
|
||||||
|
inactive-text="否"
|
||||||
|
/>
|
||||||
|
<div class="hide-goods-tip">
|
||||||
|
开启后,快递方接收到的商品名称将统一修改为:商品
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
@ -422,7 +480,8 @@ import ScanBox from '@/components/ScanBox/index.vue'
|
|||||||
import UpperTable from '@/components/UpperTable/index.vue'
|
import UpperTable from '@/components/UpperTable/index.vue'
|
||||||
import {
|
import {
|
||||||
getExpressList,
|
getExpressList,
|
||||||
getPlatformList,
|
getPrintPlatformList,
|
||||||
|
getPrintPlatformTemplateList,
|
||||||
getPlatformOauthLink,
|
getPlatformOauthLink,
|
||||||
getShopList,
|
getShopList,
|
||||||
getShopExpressList
|
getShopExpressList
|
||||||
@ -433,7 +492,7 @@ import {
|
|||||||
expressInterfaceList,
|
expressInterfaceList,
|
||||||
expressInterfaceListByWarehousePlatformCode,
|
expressInterfaceListByWarehousePlatformCode,
|
||||||
expressInterfaceUpdate
|
expressInterfaceUpdate
|
||||||
} from '@/api/setting.expressinterface/expressInterface'
|
} from '@/api/setting.expressInterface/expressInterface'
|
||||||
import { useUserStore } from '@/stores/modules/user'
|
import { useUserStore } from '@/stores/modules/user'
|
||||||
import { useSettingsStore } from '@/stores/modules/settings'
|
import { useSettingsStore } from '@/stores/modules/settings'
|
||||||
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
||||||
@ -460,6 +519,8 @@ 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 TemplateOption = { value: string; label: string; raw: Record<string, any> }
|
||||||
type ServiceFlatField = {
|
type ServiceFlatField = {
|
||||||
key: string
|
key: string
|
||||||
serviceCode: string
|
serviceCode: string
|
||||||
@ -539,8 +600,10 @@ const platformOptions = ref<PlatformOption[]>([])
|
|||||||
const shopOptions = ref<ShopOption[]>([])
|
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 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 serviceValueMap = ref<Record<string, any>>({})
|
const serviceValueMap = ref<Record<string, any>>({})
|
||||||
const shopExpressSitesMap = ref<Record<string, SiteOption[]>>({})
|
const shopExpressSitesMap = ref<Record<string, SiteOption[]>>({})
|
||||||
const selectedSiteKey = ref<string>('')
|
const selectedSiteKey = ref<string>('')
|
||||||
@ -666,6 +729,20 @@ const selectedAddress = computed<AddressOption | null>(() => {
|
|||||||
return dialogAddressOptions.value.find((item) => item.key === selectedAddressKey.value) || null
|
return dialogAddressOptions.value.find((item) => item.key === selectedAddressKey.value) || null
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const dialogMonthlyAccountOptions = computed<MonthlyAccountOption[]>(() => {
|
||||||
|
const site = selectedSite.value
|
||||||
|
const list = Array.isArray(site?.raw?.customer_code_list) ? site.raw.customer_code_list : []
|
||||||
|
const uniq = new Set<string>()
|
||||||
|
const options: MonthlyAccountOption[] = []
|
||||||
|
list.forEach((item: any) => {
|
||||||
|
const value = String(item ?? '').trim()
|
||||||
|
if (!value || uniq.has(value)) return
|
||||||
|
uniq.add(value)
|
||||||
|
options.push({ value, label: value })
|
||||||
|
})
|
||||||
|
return options
|
||||||
|
})
|
||||||
|
|
||||||
const warehouseContextHint = computed(() => {
|
const warehouseContextHint = computed(() => {
|
||||||
const u = userStore.user || {}
|
const u = userStore.user || {}
|
||||||
const sid = u.store_id ?? u.warehouse_id
|
const sid = u.store_id ?? u.warehouse_id
|
||||||
@ -977,7 +1054,7 @@ async function loadExpressOptions() {
|
|||||||
|
|
||||||
async function loadPlatformOptions() {
|
async function loadPlatformOptions() {
|
||||||
try {
|
try {
|
||||||
const res: any = await getPlatformList({ systemOnly: true })
|
const res: any = await getPrintPlatformList({})
|
||||||
if (!isSuccess(res)) {
|
if (!isSuccess(res)) {
|
||||||
platformOptions.value = []
|
platformOptions.value = []
|
||||||
return
|
return
|
||||||
@ -992,23 +1069,88 @@ async function loadPlatformOptions() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadCustomExpressOptions() {
|
async function loadPrintPlatformTemplateOptions(sourceExpressCode?: string, sourcePlatformCode?: string) {
|
||||||
|
const expressCode = String(sourceExpressCode ?? formData.express_code ?? '').trim().toUpperCase()
|
||||||
|
if (!expressCode) {
|
||||||
|
templateOptions.value = []
|
||||||
|
formData.template_url = ''
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (printTemplateLoading.value) return
|
||||||
|
printTemplateLoading.value = true
|
||||||
|
try {
|
||||||
|
const platformCode = String(sourcePlatformCode ?? formData.platform_code ?? '').trim().toUpperCase()
|
||||||
|
const res: any = await getPrintPlatformTemplateList({
|
||||||
|
platform_code: platformCode || undefined,
|
||||||
|
express_code: expressCode
|
||||||
|
})
|
||||||
|
if (!isSuccess(res)) {
|
||||||
|
templateOptions.value = []
|
||||||
|
formData.template_url = ''
|
||||||
|
ElMessage.error(res?.message || '获取打印模板列表失败')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const templateList = Array.isArray(res?.data?.standard_templates?.standard_template_do)
|
||||||
|
? res.data.standard_templates.standard_template_do
|
||||||
|
: []
|
||||||
|
const nextOptions = templateList
|
||||||
|
.map((item: any) => ({
|
||||||
|
value: String(item?.standard_template_url || '').trim(),
|
||||||
|
label: String(item?.standard_template_name || item?.standard_template_url || '').trim(),
|
||||||
|
raw: item || {}
|
||||||
|
}))
|
||||||
|
.filter((item: TemplateOption) => !!item.value)
|
||||||
|
templateOptions.value = nextOptions
|
||||||
|
|
||||||
|
const currentTemplateUrl = String(formData.template_url || '').trim()
|
||||||
|
if (!currentTemplateUrl) return
|
||||||
|
const exists = nextOptions.some((item: TemplateOption) => item.value === currentTemplateUrl)
|
||||||
|
if (!exists) {
|
||||||
|
formData.template_url = ''
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
templateOptions.value = []
|
||||||
|
formData.template_url = ''
|
||||||
|
ElMessage.error('获取打印模板列表失败')
|
||||||
|
} finally {
|
||||||
|
printTemplateLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadCustomExpressOptions(sourceExpressCode?: string) {
|
||||||
|
const expressCode = String(sourceExpressCode ?? formData.express_code ?? '').trim().toUpperCase()
|
||||||
|
if (!expressCode) {
|
||||||
|
customExpressOptions.value = []
|
||||||
|
formData.sys_express_code = ''
|
||||||
|
return
|
||||||
|
}
|
||||||
if (customExpressLoading.value) return
|
if (customExpressLoading.value) return
|
||||||
customExpressLoading.value = true
|
customExpressLoading.value = true
|
||||||
try {
|
try {
|
||||||
const res: any = await getExpressList({})
|
const res: any = await getExpressList({
|
||||||
|
systemOnly: false,
|
||||||
|
express_code: expressCode
|
||||||
|
})
|
||||||
if (!isSuccess(res)) {
|
if (!isSuccess(res)) {
|
||||||
customExpressOptions.value = []
|
customExpressOptions.value = []
|
||||||
ElMessage.error(res?.message || '获取自定义快递编码列表失败')
|
ElMessage.error(res?.message || '获取自定义快递编码列表失败')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
customExpressOptions.value = (res?.data || [])
|
const nextOptions = (res?.data || [])
|
||||||
.map((item: any) => ({
|
.map((item: any) => ({
|
||||||
code: String(item?.express_code || item?.code || '').trim(),
|
code: String(item?.code || item?.custom_code || item?.sys_express_code || item?.express_code || '').trim(),
|
||||||
name: String(item?.express_name || item?.name || '').trim(),
|
name: String(item?.name || item?.express_name || item?.code || '').trim(),
|
||||||
label: String(item?.label || item?.express_name || item?.name || '').trim()
|
label: String(item?.label || item?.name || item?.code || '').trim()
|
||||||
}))
|
}))
|
||||||
.filter((item: ExpressOption) => !!item.code)
|
.filter((item: ExpressOption) => !!item.code)
|
||||||
|
customExpressOptions.value = nextOptions
|
||||||
|
|
||||||
|
const currentCustomCode = String(formData.sys_express_code || '').trim()
|
||||||
|
if (!currentCustomCode) return
|
||||||
|
const exists = nextOptions.some((item: ExpressOption) => item.code === currentCustomCode)
|
||||||
|
if (!exists) {
|
||||||
|
formData.sys_express_code = ''
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
customExpressOptions.value = []
|
customExpressOptions.value = []
|
||||||
ElMessage.error('获取自定义快递编码列表失败')
|
ElMessage.error('获取自定义快递编码列表失败')
|
||||||
@ -1245,10 +1387,31 @@ function initializeAddressSelection(preferredAddress?: string) {
|
|||||||
handleAddressChange(target.key)
|
handleAddressChange(target.key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleMonthlyAccountChange(value: string | number | undefined) {
|
||||||
|
formData.shipperno = String(value ?? '').trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
function initializeMonthlyAccountSelection(preferredShipperno?: string, clearWhenEmpty = true) {
|
||||||
|
const options = dialogMonthlyAccountOptions.value
|
||||||
|
if (!options.length) {
|
||||||
|
if (clearWhenEmpty) {
|
||||||
|
formData.shipperno = ''
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const preferred = String(preferredShipperno ?? formData.shipperno ?? '').trim()
|
||||||
|
const matched = preferred ? options.find((item) => item.value === preferred) : null
|
||||||
|
const first = options[0]
|
||||||
|
if (!first) return
|
||||||
|
formData.shipperno = matched ? matched.value : first.value
|
||||||
|
}
|
||||||
|
|
||||||
function initializeSiteSelection(
|
function initializeSiteSelection(
|
||||||
preferredSiteCode?: string,
|
preferredSiteCode?: string,
|
||||||
preferredAddress?: string,
|
preferredAddress?: string,
|
||||||
preferredServiceCodes?: string[]
|
preferredServiceCodes?: string[],
|
||||||
|
preferredShipperno?: string
|
||||||
) {
|
) {
|
||||||
const sites = dialogSiteOptions.value
|
const sites = dialogSiteOptions.value
|
||||||
if (!sites.length) {
|
if (!sites.length) {
|
||||||
@ -1308,6 +1471,7 @@ function initializeSiteSelection(
|
|||||||
if (!target) return
|
if (!target) return
|
||||||
handleSiteChange(target.key)
|
handleSiteChange(target.key)
|
||||||
initializeAddressSelection(preferredAddress)
|
initializeAddressSelection(preferredAddress)
|
||||||
|
initializeMonthlyAccountSelection(preferredShipperno, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
function syncExtDataByServiceSelection() {
|
function syncExtDataByServiceSelection() {
|
||||||
@ -1342,13 +1506,22 @@ function syncExtDataByServiceSelection() {
|
|||||||
formData.ext_data = Object.keys(serviceSelection).length > 0 ? serviceSelection : undefined
|
formData.ext_data = Object.keys(serviceSelection).length > 0 ? serviceSelection : undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleExpressCodeChange() {
|
async function handleExpressCodeChange() {
|
||||||
|
const currentExpressCode = String(formData.express_code || '').trim()
|
||||||
selectedSiteKey.value = ''
|
selectedSiteKey.value = ''
|
||||||
selectedAddressKey.value = ''
|
selectedAddressKey.value = ''
|
||||||
formData.site_code = ''
|
formData.site_code = ''
|
||||||
|
formData.shipperno = ''
|
||||||
|
formData.sys_express_code = ''
|
||||||
|
customExpressOptions.value = []
|
||||||
|
formData.template_url = ''
|
||||||
|
templateOptions.value = []
|
||||||
applyAddressRaw(undefined)
|
applyAddressRaw(undefined)
|
||||||
serviceValueMap.value = {}
|
serviceValueMap.value = {}
|
||||||
syncExtDataByServiceSelection()
|
syncExtDataByServiceSelection()
|
||||||
|
await loadPrintPlatformTemplateOptions(currentExpressCode, formData.platform_code)
|
||||||
|
if (!useCustomExpressCode.value || !currentExpressCode) return
|
||||||
|
await loadCustomExpressOptions(currentExpressCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleServiceValueChange() {
|
function handleServiceValueChange() {
|
||||||
@ -1357,12 +1530,14 @@ function handleServiceValueChange() {
|
|||||||
|
|
||||||
async function handleCustomExpressSwitchChange(value: boolean) {
|
async function handleCustomExpressSwitchChange(value: boolean) {
|
||||||
useCustomExpressCode.value = value
|
useCustomExpressCode.value = value
|
||||||
|
formData.is_system_express_code = value ? 0 : 1
|
||||||
if (!value) {
|
if (!value) {
|
||||||
formData.sys_express_code = ''
|
formData.sys_express_code = ''
|
||||||
|
customExpressOptions.value = []
|
||||||
formRef.value?.clearValidate('sys_express_code')
|
formRef.value?.clearValidate('sys_express_code')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
await loadCustomExpressOptions()
|
await loadCustomExpressOptions(formData.express_code)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handlePlatformCodeChange(value: string | number | undefined) {
|
async function handlePlatformCodeChange(value: string | number | undefined) {
|
||||||
@ -1373,6 +1548,11 @@ async function handlePlatformCodeChange(value: string | number | undefined) {
|
|||||||
formData.shop_name = ''
|
formData.shop_name = ''
|
||||||
formData.express_code = ''
|
formData.express_code = ''
|
||||||
formData.site_code = ''
|
formData.site_code = ''
|
||||||
|
formData.shipperno = ''
|
||||||
|
formData.sys_express_code = ''
|
||||||
|
formData.template_url = ''
|
||||||
|
customExpressOptions.value = []
|
||||||
|
templateOptions.value = []
|
||||||
selectedSiteKey.value = ''
|
selectedSiteKey.value = ''
|
||||||
selectedAddressKey.value = ''
|
selectedAddressKey.value = ''
|
||||||
applyAddressRaw(undefined)
|
applyAddressRaw(undefined)
|
||||||
@ -1392,6 +1572,11 @@ async function handleShopChange(value: string | number | undefined) {
|
|||||||
formData.express_code = ''
|
formData.express_code = ''
|
||||||
serviceValueMap.value = {}
|
serviceValueMap.value = {}
|
||||||
formData.ext_data = undefined
|
formData.ext_data = undefined
|
||||||
|
formData.shipperno = ''
|
||||||
|
formData.sys_express_code = ''
|
||||||
|
formData.template_url = ''
|
||||||
|
customExpressOptions.value = []
|
||||||
|
templateOptions.value = []
|
||||||
dialogExpressOptions.value = []
|
dialogExpressOptions.value = []
|
||||||
shopExpressSitesMap.value = {}
|
shopExpressSitesMap.value = {}
|
||||||
selectedSiteKey.value = ''
|
selectedSiteKey.value = ''
|
||||||
@ -1430,6 +1615,7 @@ function resetForm() {
|
|||||||
editExpressRelation.value = null
|
editExpressRelation.value = null
|
||||||
useCustomExpressCode.value = false
|
useCustomExpressCode.value = false
|
||||||
serviceValueMap.value = {}
|
serviceValueMap.value = {}
|
||||||
|
templateOptions.value = []
|
||||||
formRef.value?.clearValidate()
|
formRef.value?.clearValidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1444,6 +1630,7 @@ async function openCreate() {
|
|||||||
selectedSiteKey.value = ''
|
selectedSiteKey.value = ''
|
||||||
selectedAddressKey.value = ''
|
selectedAddressKey.value = ''
|
||||||
shopOptions.value = []
|
shopOptions.value = []
|
||||||
|
templateOptions.value = []
|
||||||
}
|
}
|
||||||
|
|
||||||
async function openEdit(row: ExpressInterfaceRecord) {
|
async function openEdit(row: ExpressInterfaceRecord) {
|
||||||
@ -1460,10 +1647,17 @@ async function openEdit(row: ExpressInterfaceRecord) {
|
|||||||
shopExpressSitesMap.value = {}
|
shopExpressSitesMap.value = {}
|
||||||
selectedSiteKey.value = ''
|
selectedSiteKey.value = ''
|
||||||
selectedAddressKey.value = ''
|
selectedAddressKey.value = ''
|
||||||
|
templateOptions.value = []
|
||||||
applyExpressInterfaceRowToForm(formData, row)
|
applyExpressInterfaceRowToForm(formData, row)
|
||||||
|
if (formData.is_system_express_code === 0 || String(formData.is_system_express_code) === '0') {
|
||||||
|
useCustomExpressCode.value = true
|
||||||
|
} else if (formData.is_system_express_code === 1 || String(formData.is_system_express_code) === '1') {
|
||||||
|
useCustomExpressCode.value = false
|
||||||
|
} else {
|
||||||
useCustomExpressCode.value = !!String(formData.sys_express_code || '').trim()
|
useCustomExpressCode.value = !!String(formData.sys_express_code || '').trim()
|
||||||
|
}
|
||||||
if (useCustomExpressCode.value) {
|
if (useCustomExpressCode.value) {
|
||||||
await loadCustomExpressOptions()
|
await loadCustomExpressOptions(formData.express_code)
|
||||||
}
|
}
|
||||||
editExpressRelation.value =
|
editExpressRelation.value =
|
||||||
row.express && typeof row.express === 'object' ? (row.express as Record<string, any>) : null
|
row.express && typeof row.express === 'object' ? (row.express as Record<string, any>) : null
|
||||||
@ -1487,7 +1681,12 @@ async function openEdit(row: ExpressInterfaceRecord) {
|
|||||||
extServiceValues && typeof extServiceValues === 'object'
|
extServiceValues && typeof extServiceValues === 'object'
|
||||||
? Object.keys(extServiceValues).map((key) => String(key || '').trim()).filter((key) => !!key)
|
? Object.keys(extServiceValues).map((key) => String(key || '').trim()).filter((key) => !!key)
|
||||||
: []
|
: []
|
||||||
initializeSiteSelection(rowSiteCode, String(row.address || '').trim(), preferredServiceCodes)
|
initializeSiteSelection(
|
||||||
|
rowSiteCode,
|
||||||
|
String(row.address || '').trim(),
|
||||||
|
preferredServiceCodes,
|
||||||
|
String(row.shipperno || formData.shipperno || '').trim()
|
||||||
|
)
|
||||||
if (extServiceValues && typeof extServiceValues === 'object') {
|
if (extServiceValues && typeof extServiceValues === 'object') {
|
||||||
const patch: Record<string, any> = {}
|
const patch: Record<string, any> = {}
|
||||||
const serviceFieldCount: Record<string, number> = {}
|
const serviceFieldCount: Record<string, number> = {}
|
||||||
@ -1525,6 +1724,7 @@ async function openEdit(row: ExpressInterfaceRecord) {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
await loadPrintPlatformTemplateOptions(formData.express_code, formData.platform_code)
|
||||||
formRef.value?.clearValidate()
|
formRef.value?.clearValidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1569,6 +1769,7 @@ async function submitForm() {
|
|||||||
const valid = await formRef.value.validate().catch(() => false)
|
const valid = await formRef.value.validate().catch(() => false)
|
||||||
if (!valid) return
|
if (!valid) return
|
||||||
|
|
||||||
|
formData.is_system_express_code = useCustomExpressCode.value ? 0 : 1
|
||||||
syncExtDataByServiceSelection()
|
syncExtDataByServiceSelection()
|
||||||
|
|
||||||
saving.value = true
|
saving.value = true
|
||||||
@ -1767,15 +1968,36 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.config-dialog :deep(.el-dialog__body) {
|
:deep(.config-dialog .el-dialog__body) {
|
||||||
padding-top: 8px;
|
padding-top: 8px;
|
||||||
padding-bottom: 8px;
|
padding-bottom: 8px;
|
||||||
max-height: min(70vh, 640px);
|
max-height: min(70vh, 640px);
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.config-dialog--edit :deep(.el-dialog__body) {
|
:deep(.config-dialog--edit.el-dialog) {
|
||||||
max-height: min(82vh, 780px);
|
height: calc(100dvh - 32px);
|
||||||
|
max-height: calc(100dvh - 32px);
|
||||||
|
max-width: calc(100dvw - 32px);
|
||||||
|
margin: 16px auto !important;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.config-dialog--edit.el-dialog .el-dialog__header),
|
||||||
|
:deep(.config-dialog--edit.el-dialog .el-dialog__footer) {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.config-dialog--edit.el-dialog .el-dialog__body) {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-height: 0;
|
||||||
|
max-height: none;
|
||||||
|
box-sizing: border-box;
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ext-data-preview :deep(textarea) {
|
.ext-data-preview :deep(textarea) {
|
||||||
@ -1891,4 +2113,17 @@ onMounted(async () => {
|
|||||||
.region-display-row {
|
.region-display-row {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.hide-goods-field {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 6px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hide-goods-tip {
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.4;
|
||||||
|
color: var(--el-text-color-secondary, #909399);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user