From baff37ad4516faa9f707ac341a7501ccbff881c6 Mon Sep 17 00:00:00 2001 From: yin <3313488199@qq.com> Date: Sat, 16 May 2026 18:13:28 +0800 Subject: [PATCH] =?UTF-8?q?5=E6=9C=8816?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../expressInterface.ts | 23 +- src/api/setting.permission/permission.ts | 3 + src/views/storage/report/report-config.ts | 12 +- .../express-interface-config.ts | 517 ++++++++ .../system/setting/expressinterface/index.vue | 1098 ++++++++++------- src/views/system/setting/permission/index.vue | 6 + .../setting/permission/permission-config.ts | 10 +- .../system/setting/printStation/index.vue | 4 +- workflows/api-doc-agent/config/响应.md | 607 ++++++--- workflows/api-doc-system/apidata/config.json | 26 +- workflows/api-doc-system/apidata/data.json | 692 ++++++++--- .../interface-details/interface-details.json | 350 ++++-- .../data/module-list/module-list.json | 70 +- .../data/module/config/_module.lifecycle.json | 2 +- .../data/module/config/module.json | 4 +- .../module/dashboard/_module.lifecycle.json | 2 +- .../data/module/dashboard/module.json | 4 +- .../data/module/index/_module.lifecycle.json | 2 +- .../data/module/index/module.json | 4 +- .../order.archiveorder/_module.lifecycle.json | 2 +- .../module/order.archiveorder/module.json | 4 +- .../_module.lifecycle.json | 2 +- .../order.deliveryexpectionorder/module.json | 4 +- .../_module.lifecycle.json | 2 +- .../module/order.deliveryorder/module.json | 4 +- .../order.entrustorder/_module.lifecycle.json | 2 +- .../module/order.entrustorder/module.json | 4 +- .../_module.lifecycle.json | 2 +- .../module/order.expectionorder/module.json | 4 +- .../module/order.index/_module.lifecycle.json | 2 +- .../data/module/order.index/module.json | 4 +- .../_module.lifecycle.json | 2 +- .../module/order.outboundorder/module.json | 4 +- .../order.pendingorder/_module.lifecycle.json | 2 +- .../module/order.pendingorder/module.json | 4 +- .../module/order.print/_module.lifecycle.json | 2 +- .../data/module/order.print/module.json | 4 +- .../order.revieworder/_module.lifecycle.json | 2 +- .../data/module/order.revieworder/module.json | 4 +- .../module/order.wave/_module.lifecycle.json | 2 +- .../data/module/order.wave/module.json | 4 +- .../data/module/order/_module.lifecycle.json | 2 +- .../data/module/order/module.json | 4 +- .../data/module/pick/_module.lifecycle.json | 2 +- .../data/module/pick/module.json | 4 +- .../data/module/print/_module.lifecycle.json | 2 +- .../data/module/print/module.json | 4 +- .../printer.station/_module.lifecycle.json | 2 +- .../data/module/printer.station/module.json | 4 +- .../setting.account/_module.lifecycle.json | 2 +- .../data/module/setting.account/module.json | 4 +- .../setting.express/_module.lifecycle.json | 2 +- .../data/module/setting.express/module.json | 4 +- .../_module.lifecycle.json | 2 +- .../setting.expressinterface/module.json | 44 +- .../setting.permission/_module.lifecycle.json | 2 +- .../module/setting.permission/module.json | 4 +- .../setting.platform/_module.lifecycle.json | 2 +- .../data/module/setting.platform/module.json | 4 +- .../_module.lifecycle.json | 2 +- .../module/setting.printtemplate/module.json | 4 +- .../setting.role/_module.lifecycle.json | 2 +- .../data/module/setting.role/module.json | 4 +- .../setting.warehouse/_module.lifecycle.json | 2 +- .../data/module/setting.warehouse/module.json | 4 +- .../data/module/stock/_module.lifecycle.json | 2 +- .../data/module/stock/module.json | 4 +- .../storage.entry/_module.lifecycle.json | 2 +- .../data/module/storage.entry/module.json | 4 +- .../storage.inventory/_module.lifecycle.json | 2 +- .../data/module/storage.inventory/module.json | 8 +- .../storage.report/_module.lifecycle.json | 2 +- .../data/module/storage.report/module.json | 254 +++- .../storage.stockout/_module.lifecycle.json | 2 +- .../data/module/storage.stockout/module.json | 4 +- .../storage_receiving/_module.lifecycle.json | 2 +- .../data/module/storage_receiving/module.json | 4 +- .../data/module/store/_module.lifecycle.json | 2 +- .../data/module/store/module.json | 4 +- .../_module.lifecycle.json | 2 +- .../module/storewarehouse.store/module.json | 4 +- .../data/module/user/_module.lifecycle.json | 2 +- .../data/module/user/module.json | 4 +- .../module/warehouse/_module.lifecycle.json | 2 +- .../data/module/warehouse/module.json | 4 +- 85 files changed, 2877 insertions(+), 1051 deletions(-) create mode 100644 src/views/system/setting/expressinterface/express-interface-config.ts diff --git a/src/api/setting.expressInterface/expressInterface.ts b/src/api/setting.expressInterface/expressInterface.ts index 2d68d854..e767a61a 100644 --- a/src/api/setting.expressInterface/expressInterface.ts +++ b/src/api/setting.expressInterface/expressInterface.ts @@ -41,7 +41,28 @@ export function expressInterfaceListByWarehousePlatformCode(data: Record) { +export type ExpressInterfaceCreateParams = { + name: string + express_code: string + platform_code: string + sender_name?: string + sender_tel?: string + weight?: number + token?: string + viewer?: string + client_id?: string + is_share?: number + share_id?: number + can_use_count?: number + province_name?: string + city_name?: string + district_name?: string + site_code?: string + product_type?: string + shop_name?: string +} + +export function expressInterfaceCreate(data: ExpressInterfaceCreateParams) { return request({ url: '/system', method: 'post', diff --git a/src/api/setting.permission/permission.ts b/src/api/setting.permission/permission.ts index 5ba77e3c..b09262f3 100644 --- a/src/api/setting.permission/permission.ts +++ b/src/api/setting.permission/permission.ts @@ -71,7 +71,10 @@ export function permissionUpdate(data: { path?: string type?: string name?: string + component?: string parent_id?: number + meta_title?: string + meta_icon?: string sort?: number status?: number }) { diff --git a/src/views/storage/report/report-config.ts b/src/views/storage/report/report-config.ts index df80dc00..4a82f5f4 100644 --- a/src/views/storage/report/report-config.ts +++ b/src/views/storage/report/report-config.ts @@ -194,12 +194,12 @@ export function buildDefaultReportWhere() { /** ScanBox 侧栏可用字段(与 storage.report.search 的 where 对应) */ export const reportScanBoxAvailableFields = [ - { - value: 'report_period', - label: '统计时间', - type: 'daterange', - defaultValue: getDefaultReportPeriodRange() - }, + // { + // value: 'report_period', + // label: '统计时间', + // type: 'daterange', + // defaultValue: getDefaultReportPeriodRange() + // }, { value: 'store_id', label: '货主', diff --git a/src/views/system/setting/expressinterface/express-interface-config.ts b/src/views/system/setting/expressinterface/express-interface-config.ts new file mode 100644 index 00000000..660dea3d --- /dev/null +++ b/src/views/system/setting/expressinterface/express-interface-config.ts @@ -0,0 +1,517 @@ +import pcasCodeData from 'china-division/dist/pcas-code.json' + +export const expressInterfaceFieldLabels: Record = { + id: 'ID', + name: '配置名称', + express_code: '快递编码', + platform_code: '平台编码', + express_platform_id: '平台接口ID', + sender_name: '发件人', + sender_tel: '发件电话', + weight: '预设重量', + token: 'Token', + viewer: '查看者', + client_id: '客户端ID', + is_share: '是否共享', + share_id: '共享记录ID', + can_use_count: '可用单量', + province_name: '省', + city_name: '市', + district_name: '区/县', + site_code: '站点编码', + product_type: '快递产品类型', + shop_name: '店铺名称', + warehouse_id: '仓库ID', + express: '关联快递', + express_name: '关联快递', + express_platform_label: '快递平台' +} + +const DETAIL_KEY_ORDER = [ + 'id', + 'name', + 'express_code', + 'platform_code', + 'express_platform_id', + 'weight', + 'sender_name', + 'sender_tel', + 'site_code', + 'shop_name', + 'product_type', + 'can_use_count', + 'province_name', + 'city_name', + 'district_name', + 'viewer', + 'client_id', + 'is_share', + 'share_id', + 'token', + 'warehouse_id' +] + +export function sortExpressInterfaceDetailKeys(keys: string[]) { + const head = DETAIL_KEY_ORDER.filter((k) => keys.includes(k)) + const tail = keys.filter((k) => !DETAIL_KEY_ORDER.includes(k)).sort() + return [...head, ...tail] +} + +export function formatExpressInterfaceCell(val: unknown): string { + if (val === null || val === undefined || val === '') return '--' + if (typeof val === 'object') return JSON.stringify(val) + return String(val) +} + +export function formatExpressInterfaceNumber(val: unknown): string { + if (val === null || val === undefined || val === '') return '--' + const n = Number(val) + if (Number.isNaN(n)) return '--' + return String(n) +} + +export type ExpressInterfaceColumn = { + prop: string + label: string + width?: string | number + minWidth?: string | number + align?: 'left' | 'center' | 'right' + fixed?: 'left' | 'right' | boolean + formatter?: (row: Record) => string +} + +/** 分页列表列(setting.expressInterface.list) */ +export const expressInterfaceColumns: ExpressInterfaceColumn[] = [ + { prop: 'id', label: 'ID', width: 80, align: 'center', formatter: (row) => formatExpressInterfaceCell(row.id) }, + { prop: 'name', label: '配置名称', minWidth: 150, formatter: (row) => row.name || '--' }, + { prop: 'express_code', label: '快递编码', minWidth: 110, formatter: (row) => row.express_code || '--' }, + { prop: 'platform_code', label: '平台编码', minWidth: 110, formatter: (row) => row.platform_code || '--' }, + { + prop: 'express_platform_id', + label: '平台接口ID', + width: 110, + align: 'right', + formatter: (row) => formatExpressInterfaceNumber(row.express_platform_id) + }, + { prop: 'sender_name', label: '发件人', minWidth: 100, formatter: (row) => row.sender_name || '--' }, + { prop: 'sender_tel', label: '发件电话', minWidth: 120, formatter: (row) => row.sender_tel || '--' }, + { prop: 'shop_name', label: '店铺', minWidth: 140, formatter: (row) => row.shop_name || '--' }, + { prop: 'site_code', label: '站点编码', minWidth: 100, formatter: (row) => row.site_code || '--' }, + { + prop: 'can_use_count', + label: '可用单量', + width: 96, + align: 'right', + formatter: (row) => formatExpressInterfaceNumber(row.can_use_count) + }, + { + prop: 'weight', + label: '预设重量', + width: 96, + align: 'right', + formatter: (row) => formatExpressInterfaceNumber(row.weight) + }, + { prop: 'actions', label: '操作', width: 140, align: 'center', fixed: 'right' } +] + +/** 按仓库+平台全量列表列(setting.expressInterface.listByWarehousePlatformCode) */ +export const expressInterfaceWarehouseColumns: ExpressInterfaceColumn[] = [ + { prop: 'id', label: 'ID', width: 80, align: 'center', formatter: (row) => formatExpressInterfaceCell(row.id) }, + { + prop: 'weight', + label: '权重', + width: 80, + align: 'right', + formatter: (row) => formatExpressInterfaceNumber(row.weight) + }, + + { prop: 'name', label: '配置名称', minWidth: 140, formatter: (row) => row.name || '--' }, + { prop: 'express_code', label: '快递编码', minWidth: 100, formatter: (row) => row.express_code || '--' }, + { + prop: 'express_name', + label: '关联快递', + minWidth: 160, + formatter: (row) => { + if (row.express?.name) { + const code = row.express?.code || row.express_code || '' + return code ? `${row.express.name}(${code})` : row.express.name + } + return row.express_name || '--' + } + }, + { + prop: 'express_platform_label', + label: '快递平台', + minWidth: 100, + formatter: (row) => row.express?.platform ?? row.express_platform_label ?? '--' + }, + { prop: 'platform_code', label: '平台编码', minWidth: 100, formatter: (row) => row.platform_code || '--' }, + { prop: 'sender_name', label: '发件人', minWidth: 100, formatter: (row) => row.sender_name || '--' }, + { prop: 'sender_tel', label: '发件电话', minWidth: 110, formatter: (row) => row.sender_tel || '--' }, + { prop: 'shop_name', label: '店铺', minWidth: 140, formatter: (row) => row.shop_name || '--' }, + { + prop: 'can_use_count', + label: '可用单量', + width: 90, + align: 'right', + formatter: (row) => formatExpressInterfaceNumber(row.can_use_count) + }, + { prop: 'actions', label: '操作', width: 140, align: 'center', fixed: 'right' } +] + +/** ScanBox 可用字段(与 list 接口 where 一致) */ +export const expressInterfaceScanFields = [ + { + value: 'quickWhere', + label: '关键词', + type: 'text', + placeholder: '配置名称/编码/店铺等快速搜索', + operators: ['contains'], + defaultOperator: 'contains' + }, + { + value: 'platform_code', + label: '平台编码', + type: 'select', + filterable: true, + clearable: true, + options: [] as { label: string; value: string }[] + }, + { + value: 'warehouse_id', + label: '仓库ID', + type: 'number', + placeholder: '按仓库+平台查询时可选', + operators: ['eq'], + defaultOperator: 'eq' + }, + { + value: 'id', + label: 'ID', + type: 'number', + placeholder: '请输入ID', + operators: ['eq', 'ne'], + defaultOperator: 'eq' + }, + { + value: 'name', + label: '配置名称', + type: 'text', + placeholder: '请输入配置名称', + operators: ['eq', 'contains', 'like'], + defaultOperator: 'contains' + }, + { + value: 'express_code', + label: '快递编码', + type: 'select', + filterable: true, + clearable: true, + options: [] as { label: string; value: string }[] + }, + + { + value: 'express_platform_id', + label: '平台接口ID', + type: 'number', + placeholder: '请输入平台接口ID', + operators: ['eq'], + defaultOperator: 'eq' + }, + { + value: 'sender_name', + label: '发件人', + type: 'text', + placeholder: '请输入发件人', + operators: ['eq', 'contains', 'like'], + defaultOperator: 'contains' + }, + { + value: 'sender_tel', + label: '发件电话', + type: 'text', + placeholder: '请输入发件电话', + operators: ['eq', 'contains', 'like'], + defaultOperator: 'contains' + }, + { + value: 'shop_name', + label: '店铺名称', + type: 'text', + placeholder: '请输入店铺名称', + operators: ['eq', 'contains', 'like'], + defaultOperator: 'contains' + }, + { + value: 'site_code', + label: '站点编码', + type: 'text', + placeholder: '请输入站点编码', + operators: ['eq', 'contains', 'like'], + defaultOperator: 'contains' + }, + { + value: 'product_type', + label: '快递产品类型', + type: 'text', + placeholder: '请输入产品类型', + operators: ['eq', 'contains', 'like'], + defaultOperator: 'contains' + }, + { + value: 'viewer', + label: '查看者', + type: 'text', + placeholder: '请输入查看者', + operators: ['eq', 'contains', 'like'], + defaultOperator: 'contains' + }, + { + value: 'client_id', + label: '客户端ID', + type: 'text', + placeholder: '请输入客户端ID', + operators: ['eq', 'contains', 'like'], + defaultOperator: 'contains' + }, + +] + +function getFieldConfig(key: string, fields: typeof expressInterfaceScanFields) { + 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 expressInterfaceScanFields) { + 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;quickWhere 为顶层字符串字段 */ +export function normalizeScanConditionToWhere( + condition: any, + fields: typeof expressInterfaceScanFields = expressInterfaceScanFields +): 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 extractPlainWhereValue(where: Record, key: string): string | number | undefined { + const raw = where[key] + if (raw == null || raw === '') return undefined + if (typeof raw === 'object' && raw !== null && 'value' in (raw as object)) { + return (raw as { value?: string | number }).value as string | number | undefined + } + return raw as string | number +} + +export function formatExpressInterfaceData(list: Record[] = []) { + return (list || []).map((item) => ({ + ...item, + express_name: item.express?.name || '', + express_platform_label: item.express?.platform ?? '' + })) +} + +/** 中国省市区(与 ManualCreatePendingOrderDialog 一致,数据来自 china-division) */ +export type RegionNode = { code: string; name: string; children?: RegionNode[] } + +export const chinaRegionTree = (Array.isArray(pcasCodeData) ? pcasCodeData : []) as RegionNode[] + +export type RegionSelectOption = { label: string; value: string } + +export function buildProvinceOptions(): RegionSelectOption[] { + return chinaRegionTree.map((item) => ({ label: item.name, value: item.code })) +} + +export function buildCityOptions(provinceCode: string): RegionSelectOption[] { + const province = chinaRegionTree.find((item) => item.code === provinceCode) + return (province?.children || []).map((item) => ({ label: item.name, value: item.code })) +} + +export function buildDistrictOptions(provinceCode: string, cityCode: string): RegionSelectOption[] { + const province = chinaRegionTree.find((item) => item.code === provinceCode) + const city = (province?.children || []).find((item) => item.code === cityCode) + return (city?.children || []).map((item) => ({ label: item.name, value: item.code })) +} + +function findRegionCodeByName(nodes: RegionNode[], name: string): string { + const trimmed = String(name || '').trim() + if (!trimmed) return '' + return nodes.find((item) => item.name === trimmed)?.code || '' +} + +export function findRegionNameByCode(nodes: RegionNode[], code: string): string { + if (!code) return '' + return nodes.find((item) => item.code === code)?.name || '' +} + +/** 根据已保存的省/市/区名称反查行政区划 code,用于编辑回填 */ +export function resolveRegionCodesFromNames(names: { + province_name?: string + city_name?: string + district_name?: string +}) { + const provinceCode = findRegionCodeByName(chinaRegionTree, names.province_name || '') + const provinceNode = chinaRegionTree.find((item) => item.code === provinceCode) + const cityCode = provinceNode + ? findRegionCodeByName(provinceNode.children || [], names.city_name || '') + : '' + const cityNode = (provinceNode?.children || []).find((item) => item.code === cityCode) + const districtCode = cityNode + ? findRegionCodeByName(cityNode.children || [], names.district_name || '') + : '' + return { provinceCode, cityCode, districtCode } +} + +export function getCityNodes(provinceCode: string): RegionNode[] { + const province = chinaRegionTree.find((item) => item.code === provinceCode) + return province?.children || [] +} + +export function getDistrictNodes(provinceCode: string, cityCode: string): RegionNode[] { + const city = getCityNodes(provinceCode).find((item) => item.code === cityCode) + return city?.children || [] +} + +export const defaultExpressInterfaceForm = { + id: undefined as number | undefined, + name: '', + express_code: '', + platform_code: '', + express_platform_id: 1, + sender_name: '', + sender_tel: '', + weight: 1, + token: '', + viewer: '', + client_id: '', + is_share: 0, + share_id: undefined as number | undefined, + can_use_count: undefined as number | undefined, + site_code: '', + shop_name: '', + province_name: '', + city_name: '', + district_name: '', + product_type: '' +} + +function omitEmptyString(val: unknown): string | undefined { + const s = String(val ?? '').trim() + return s || undefined +} + +function omitOptionalNumber(val: unknown): number | undefined { + if (val === null || val === undefined || val === '') return undefined + const n = Number(val) + return Number.isFinite(n) ? n : undefined +} + +/** setting.expressInterface.create 请求体(禁止 warehouse_id / express_platform_id) */ +export function buildExpressInterfaceCreatePayload(form: Record) { + const payload: Record = { + name: String(form.name || '').trim(), + express_code: String(form.express_code || '').trim(), + platform_code: String(form.platform_code || '').trim() + } + + const optionalStrings = [ + 'sender_name', + 'sender_tel', + 'token', + 'viewer', + 'client_id', + 'province_name', + 'city_name', + 'district_name', + 'site_code', + 'product_type', + 'shop_name' + ] as const + for (const key of optionalStrings) { + const v = omitEmptyString(form[key]) + if (v !== undefined) payload[key] = v + } + + const weight = omitOptionalNumber(form.weight) + if (weight !== undefined) payload.weight = Math.round(weight) + + const isShare = omitOptionalNumber(form.is_share) + if (isShare !== undefined) payload.is_share = isShare + + const shareId = omitOptionalNumber(form.share_id) + if (shareId !== undefined) payload.share_id = shareId + + const canUseCount = omitOptionalNumber(form.can_use_count) + if (canUseCount !== undefined) payload.can_use_count = canUseCount + + return payload +} + +/** setting.expressInterface.update 请求体 */ +export function buildExpressInterfaceUpdatePayload(form: Record) { + const payload = buildExpressInterfaceCreatePayload(form) + payload.id = form.id + const expressPlatformId = omitOptionalNumber(form.express_platform_id) + if (expressPlatformId !== undefined) payload.express_platform_id = expressPlatformId + return payload +} diff --git a/src/views/system/setting/expressinterface/index.vue b/src/views/system/setting/expressinterface/index.vue index 681ea8e4..85b74c71 100644 --- a/src/views/system/setting/expressinterface/index.vue +++ b/src/views/system/setting/expressinterface/index.vue @@ -1,20 +1,20 @@