diff --git a/src/api/setting.storeExpressBindingPolicy/storeExpressBindingPolicy.ts b/src/api/setting.storeExpressBindingPolicy/storeExpressBindingPolicy.ts new file mode 100644 index 00000000..7e0932a7 --- /dev/null +++ b/src/api/setting.storeExpressBindingPolicy/storeExpressBindingPolicy.ts @@ -0,0 +1,63 @@ +import request from '@/utils/request' + +const v = '1.0' + +/** 分页查询店铺快递绑定策略 */ +export function storeExpressBindingPolicyList(data?: { + page?: number + pageSize?: number + where?: Record +}) { + return request({ + url: '/system', + method: 'post', + params: { + method: 'storeExpressBindingPolicy.list', + v, + timestamp: new Date().getTime() + }, + data: data || {} + }) +} + +/** 新增店铺快递绑定策略 */ +export function storeExpressBindingPolicyAdd(data: Record) { + return request({ + url: '/system', + method: 'post', + params: { + method: 'storeExpressBindingPolicy.add', + v, + timestamp: new Date().getTime() + }, + data + }) +} + +/** 编辑店铺快递绑定策略 */ +export function storeExpressBindingPolicyEdit(data: Record) { + return request({ + url: '/system', + method: 'post', + params: { + method: 'storeExpressBindingPolicy.edit', + v, + timestamp: new Date().getTime() + }, + data + }) +} + +/** 删除店铺快递绑定策略 */ +export function storeExpressBindingPolicyDel(data: { id: number }) { + return request({ + url: '/system', + method: 'post', + params: { + method: 'storeExpressBindingPolicy.del', + v, + timestamp: new Date().getTime() + }, + data + }) +} diff --git a/src/router/map.ts b/src/router/map.ts index c13bf94c..4078f01d 100644 --- a/src/router/map.ts +++ b/src/router/map.ts @@ -68,4 +68,5 @@ export const componentMap: Record = { 'data/packingflow': () => import('@/views/data/packingflow/index.vue'), 'system/setting/printcomputer/index':() => import('@/views/system/setting/printcomputer/index.vue'), 'express/index':() => import('@/views/express/waybill/index.vue'), + 'system/setting/storeExpressBindingPolicy/index':() => import('@/views/system/setting/storeExpressBindingPolicy/index.vue'), }; \ No newline at end of file diff --git a/src/views/order/orderManagement/exceptionOrder.vue b/src/views/order/orderManagement/exceptionOrder.vue index 03069501..6cf82243 100644 --- a/src/views/order/orderManagement/exceptionOrder.vue +++ b/src/views/order/orderManagement/exceptionOrder.vue @@ -712,7 +712,7 @@ async function loadFilterData() { async function loadOrderMetaOptions() { try { const [expressRes, platformRes] = await Promise.all([ - indexApi.getExpressList({ systemOnly: 'true' }), + indexApi.getExpressList(), indexApi.getPlatformList({ systemOnly: 'true' }) ]) const expressData: any = expressRes?.data diff --git a/src/views/order/orderManagement/pendingOrder.vue b/src/views/order/orderManagement/pendingOrder.vue index 807d5176..c7e239d9 100644 --- a/src/views/order/orderManagement/pendingOrder.vue +++ b/src/views/order/orderManagement/pendingOrder.vue @@ -957,7 +957,7 @@ function mapNameOptions(rawList: any[], nameKeys: string[]) { async function loadOrderMetaOptions() { try { const [expressRes, platformRes] = await Promise.all([ - indexApi.getExpressList({ systemOnly: 'true' }), + indexApi.getExpressList(), indexApi.getPlatformList({ systemOnly: 'true' }) ]) const expressData: any = expressRes?.data diff --git a/src/views/system/setting/storeExpressBindingPolicy/index.vue b/src/views/system/setting/storeExpressBindingPolicy/index.vue new file mode 100644 index 00000000..329cf29f --- /dev/null +++ b/src/views/system/setting/storeExpressBindingPolicy/index.vue @@ -0,0 +1,709 @@ + + + + + diff --git a/src/views/system/setting/storeExpressBindingPolicy/storeExpressBindingPolicy-config.ts b/src/views/system/setting/storeExpressBindingPolicy/storeExpressBindingPolicy-config.ts new file mode 100644 index 00000000..ce673c28 --- /dev/null +++ b/src/views/system/setting/storeExpressBindingPolicy/storeExpressBindingPolicy-config.ts @@ -0,0 +1,212 @@ +export type StoreExpressBindingPolicyRecord = { + id?: number + warehouse_id?: number + custom_name?: string + store_ids?: string | null + express_code?: string + express_name?: string + prohibited_type_id?: number[] | null + prohibited_type_names?: string[] | null + weight_type?: number + shop_name?: string[] | null + store_ids?: string[] | null + store_names?: string[] | null + regions?: string[] | null + exclude_regions?: string[] | null + min_weight_g?: number | null + max_weight_g?: number | null + priority?: number + is_enabled?: number + remark?: string | null + creator_id?: number | null + created_at?: string + updated_at?: string +} + +export const WEIGHT_TYPE_MAP: Record = { + 0: '常规', + 1: '轻货', + 2: '重货', + 3: '冷链' +} + +export const storeExpressBindingPolicyColumns = [ + { prop: 'id', label: 'ID', width: '80', sortable: true }, + { prop: 'custom_name', label: '策略名称', minWidth: '160', showOverflowTooltip: true }, + { prop: 'express_name', label: '快递名称', minWidth: '120', showOverflowTooltip: true }, + { prop: 'store_ids', label: '限定货主', minWidth: '160', showOverflowTooltip: true }, + { prop: 'shop_name', label: '包含店铺名称', minWidth: '160', showOverflowTooltip: true }, + { prop: 'prohibited_type_id', label: '违禁品类型', minWidth: '140', showOverflowTooltip: true }, + { prop: 'weight_type', label: '重量段类型', width: '110' }, + { prop: 'regions', label: '限定地区', minWidth: '140', showOverflowTooltip: true }, + { prop: 'exclude_regions', label: '排除地区', minWidth: '140', showOverflowTooltip: true }, + { prop: 'min_weight_g', label: '最小重量(g)', width: '120' }, + { prop: 'max_weight_g', label: '最大重量(g)', width: '120' }, + { prop: 'priority', label: '优先级', width: '90' }, + { prop: 'is_enabled', label: '状态', width: '100' }, + { prop: 'remark', label: '备注', minWidth: '160', showOverflowTooltip: true }, + { prop: 'created_at', label: '创建时间', minWidth: '160' }, + { prop: 'updated_at', label: '更新时间', minWidth: '160' }, + { prop: 'actions', label: '操作', width: '180', fixed: 'right' } +] + +export const storeExpressBindingPolicyScanFields = [ + { + value: 'quickWhere', + label: '关键词', + type: 'text', + placeholder: '策略名称/快递编码', + operators: ['contains', 'eq'], + defaultOperator: 'eq' + }, + { + value: 'custom_name', + label: '策略名称', + type: 'text', + placeholder: '请输入策略名称', + operators: ['eq', 'contains', 'like'], + defaultOperator: 'contains' + }, + { + value: 'express_code', + label: '快递编码', + type: 'text', + placeholder: '请输入快递编码', + operators: ['eq', 'contains', 'like'], + defaultOperator: 'eq' + }, + { + value: 'prohibited_type_id', + label: '违禁品类型', + type: 'select', + filterable: true, + clearable: true, + options: [] as { label: string; value: number }[] + }, + { + value: 'weight_type', + label: '重量段类型', + type: 'select', + clearable: true, + options: [ + { label: '常规', value: 0 }, + { label: '轻货', value: 1 }, + { label: '重货', value: 2 }, + { label: '冷链', value: 3 } + ] + }, + { + value: 'is_enabled', + label: '状态', + type: 'select', + clearable: true, + options: [ + { label: '启用', value: '1' }, + { label: '禁用', value: '0' } + ] + } +] + +function getFieldConfig(key: string, fields: typeof storeExpressBindingPolicyScanFields) { + return fields.find((f) => f.value === key) +} + +function mapFieldType(type: string, value: unknown) { + if (type === 'daterange' || Array.isArray(value)) return 'daterange' + if (type === 'number' || typeof value === 'number') return 'number' + return 'text' +} + +function processConditionValue(key: string, raw: any, fields: typeof storeExpressBindingPolicyScanFields) { + if (key === 'quickWhere') { + const val = raw?.value !== undefined ? raw.value : raw + const text = val == null ? '' : String(val).trim() + return text ? text : null + } + + const config = getFieldConfig(key, fields) + const fieldType = config?.type || 'text' + + if (raw && typeof raw === 'object' && !Array.isArray(raw)) { + const op = raw.operator || (fieldType === 'select' ? 'eq' : fieldType === 'number' ? 'eq' : 'contains') + const type = raw.type || mapFieldType(fieldType, raw.value) + + if (['isnull', 'isnotnull'].includes(op)) { + return { operator: op, value: null, type } + } + + const val = raw.value !== undefined ? raw.value : raw + if (val === null || val === undefined || val === '' || (Array.isArray(val) && val.length === 0)) { + return null + } + + if (fieldType === 'select') { + return { operator: op || 'eq', value: val, type: 'text' } + } + + return { operator: op, value: val, type } + } + + if (raw === null || raw === undefined || raw === '' || (Array.isArray(raw) && raw.length === 0)) { + return null + } + + const simpleOp = fieldType === 'select' || fieldType === 'number' ? 'eq' : 'contains' + return { operator: simpleOp, value: raw, type: mapFieldType(fieldType, raw) } +} + +/** 将 ScanBox 条件转为 list 接口 where */ +export function normalizeStoreExpressBindingPolicyScanConditionToWhere( + condition: any, + fields: typeof storeExpressBindingPolicyScanFields = storeExpressBindingPolicyScanFields +): Record { + if (!condition) return {} + + const conds = + condition?.conditions && typeof condition.conditions === 'object' + ? condition.conditions + : condition && typeof condition === 'object' + ? condition + : null + + if (!conds) return {} + + const where: Record = {} + for (const key of Object.keys(conds)) { + const result = processConditionValue(key, conds[key], fields) + if (result == null) continue + if (key === 'quickWhere' && typeof result === 'string') { + where.quickWhere = result + } else { + where[key] = result + } + } + return where +} + +export function formatPolicyStatus(isEnabled: number | string | undefined | null) { + if (isEnabled === null || isEnabled === undefined) return { text: '--', type: 'info' as const } + const val = Number(isEnabled) + if (val === 1) return { text: '启用', type: 'success' as const } + if (val === 0) return { text: '禁用', type: 'info' as const } + return { text: String(isEnabled), type: 'info' as const } +} + +export function buildPolicyListPayload(options: { + page: number + pageSize: number + where?: Record +}) { + const payload: Record = { + page: options.page, + pageSize: options.pageSize, + pagination: { + page: options.page, + pageSize: options.pageSize + } + } + if (options.where && Object.keys(options.where).length) { + payload.where = options.where + } + return payload +}