diff --git a/dist.tar.gz b/dist.tar.gz index 59192ca6..95b1fcbf 100644 Binary files a/dist.tar.gz and b/dist.tar.gz differ diff --git a/package.json b/package.json index 3737055a..cd51865f 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "apiconfig:api-interface-update": "node ./workflows/api-doc-system/api-interface-update.mjs", "apiconfig:api-interface-clean": "node ./workflows/api-doc-system/api-interface-clean.mjs", "apiconfig:apidata": "node ./workflows/api-doc-system/scripts/apidata.mjs", + "apiconfig:apidata:quick": "node ./workflows/api-doc-system/scripts/apidata.mjs -- --quick", "apiconfig:apidata:clear": "node ./workflows/api-doc-system/scripts/apidata.mjs -- --clear", "apiconfig:apidata:help": "node ./workflows/api-doc-system/scripts/apidata.mjs -- --help", "apiagent": "node ./workflows/api-doc-system/scripts/agent/run.mjs", diff --git a/src/api/index/index.ts b/src/api/index/index.ts index 28111ef3..56f9971d 100644 --- a/src/api/index/index.ts +++ b/src/api/index/index.ts @@ -137,6 +137,20 @@ export function getExpressList(data?: Record) { } as any) } +export function tryAutoTranslateNewKeys(data?: Record) { + return request({ + url: '/system', + method: 'post', + params: { + method: 'index.tryAutoTranslateNewKeys', + v: '1.0', + timestamp: new Date().getTime() + }, + data: data ?? {}, + isSystemApi: true + } as any) +} + export function getPlatformList(data?: Record) { return request({ url: '/system', diff --git a/src/api/order.pendingOrder/orderpendingOrder.ts b/src/api/order.pendingOrder/orderpendingOrder.ts index 0143fe72..cecad707 100644 --- a/src/api/order.pendingOrder/orderpendingOrder.ts +++ b/src/api/order.pendingOrder/orderpendingOrder.ts @@ -34,6 +34,20 @@ export type PendingOrderAllocateExpressCodeParams = { orders: Array> } +/** 与文档 Params 别名对齐;不再传 warehouse_id(由登录上下文决定仓库) */ +export type PendingOrderAllocateStorageParams = { + allow_storage_location?: boolean + allowStorageLocation?: boolean + is_allow_storage?: boolean + isAllowStorage?: boolean + order_ids?: Array | string | number + orderIds?: Array | string | number + ids?: Array | string | number + order_id?: number | string + orderId?: number | string + id?: number | string +} + export function orderPendingOrderList(data: PendingOrderListParams = {}): Promise { return request({ url: '/system', @@ -106,10 +120,27 @@ export function orderPendingOrderAllocateExpressCode( } as any) } +export function orderPendingOrderAllocateStorage( + data: PendingOrderAllocateStorageParams +): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'order.pendingOrder.allocateStorage', + v, + timestamp: Date.now() + }, + data, + isSystemApi: true + } as any) +} + export const orderPendingOrder = { list: orderPendingOrderList, reverseReviewOrder: orderPendingOrderReverseReviewOrder, markPendingOutboundOrder: orderPendingOrderMarkPendingOutboundOrder, cancelOrder: orderPendingOrderCancelOrder, - allocateExpressCode: orderPendingOrderAllocateExpressCode + allocateExpressCode: orderPendingOrderAllocateExpressCode, + allocateStorage: orderPendingOrderAllocateStorage } diff --git a/src/api/order.storageallocation/orderstorageallocation.ts b/src/api/order.storageallocation/orderstorageallocation.ts deleted file mode 100644 index d7dcb759..00000000 --- a/src/api/order.storageallocation/orderstorageallocation.ts +++ /dev/null @@ -1,39 +0,0 @@ -import request from '@/utils/request' - -const v = '1.0' - -/** 与文档 Params 别名对齐;至少提供一种订单 ID 列表形式 */ -export type OrderStorageAllocationAllocateStorageParams = { - allow_storage_location?: boolean - allowStorageLocation?: boolean - is_allow_storage?: boolean - isAllowStorage?: boolean - order_ids?: Array | string | number - orderIds?: Array | string | number - ids?: Array | string | number - order_id?: number | string - orderId?: number | string - id?: number | string - warehouse_id?: number - warehouseId?: number -} - -export function orderStorageAllocationAllocateStorage( - data: OrderStorageAllocationAllocateStorageParams -): Promise { - return request({ - url: '/system', - method: 'post', - params: { - method: 'order.storageAllocation.allocateStorage', - v, - timestamp: Date.now() - }, - data, - isSystemApi: true - } as any) -} - -export const orderStorageAllocation = { - allocateStorage: orderStorageAllocationAllocateStorage -} diff --git a/src/api/print/print.ts b/src/api/print/print.ts index f3845aa7..beed5406 100644 --- a/src/api/print/print.ts +++ b/src/api/print/print.ts @@ -1,16 +1,28 @@ import request from '@/utils/request' -const v = "1.0"; -export function getList(data:any){ +const v = '1.0' + +function stamp() { + return Date.now() +} + +/** print.getList:page、pageSize、where(支持 id / name / computer_id / custom_barcode 等,见 print 模块) */ +export type PrintListParams = { + page?: number + pageSize?: number + where?: Record +} + +export function getList(data?: PrintListParams) { return request({ url: '/system', method: 'post', params: { method: 'print.getList', v, - timestamp: new Date().getTime() + timestamp: stamp() }, - data: data + data: data ?? {} }) } @@ -22,7 +34,7 @@ export function getItem(id: string | number) { params: { method: 'print.getItem', v, - timestamp: new Date().getTime() + timestamp: stamp() }, data: Number.isFinite(numId) ? { id: numId } : { id } }) @@ -40,7 +52,7 @@ export function add(data: Record) { params: { method: 'print.add', v, - timestamp: new Date().getTime() + timestamp: stamp() }, data: body }) @@ -58,15 +70,12 @@ export function hasName(data: { name: string; id?: string | number | null }) { params: { method: 'print.hasName', v, - timestamp: new Date().getTime() + timestamp: stamp() }, data: body }) } - - - export function updateItem(data: Record) { const body = { ...data } if (body.id !== undefined && body.id !== null && body.id !== '') { @@ -83,53 +92,26 @@ export function updateItem(data: Record) { params: { method: 'print.updateItem', v, - timestamp: new Date().getTime() + timestamp: stamp() }, data: body }) } function normalizeDelIds(ids: unknown[]): number[] { - return ids - .map((i) => Number(i)) - .filter((n) => Number.isFinite(n)) + return ids.map((i) => Number(i)).filter((n) => Number.isFinite(n)) } -// 删除单个打印台(兼容传入 id 或 { ids: [...] }) -export function delItem(idOrPayload: any) { - let payload: any = idOrPayload - if (typeof idOrPayload === 'string' || typeof idOrPayload === 'number') { - payload = { ids: normalizeDelIds([idOrPayload]) } - } else if (Array.isArray(idOrPayload)) { - payload = { ids: normalizeDelIds(idOrPayload) } - } else if (idOrPayload && Array.isArray(idOrPayload.ids)) { - payload = { ids: normalizeDelIds(idOrPayload.ids) } - } - - return request({ - url: '/system', - method: 'post', - params: { - method: 'print.del', - v, - timestamp: new Date().getTime() - }, - data: payload - }) -} - -// 批量删除打印台,接受 id 数组(与后端约定为数字 id) export function delItems(ids: Array) { - const payload = { ids: normalizeDelIds(ids) } return request({ url: '/system', method: 'post', params: { method: 'print.del', v, - timestamp: new Date().getTime() + timestamp: stamp() }, - data: payload + data: { ids: normalizeDelIds(ids) } }) } @@ -140,28 +122,12 @@ export function getComputer() { params: { method: 'print.getComputer', v, - timestamp: new Date().getTime() + timestamp: stamp() }, data: {} }) } -export function getExpressList(data?: Record) { - return request({ - url: '/system', - method: 'post', - params: { - method: 'index.getExpressList', - v, - timestamp: new Date().getTime() - }, - data: { - systemOnly: true, - ...(data || {}) - }, - }) -} - export function getComputerPrinter(id: string | number) { const numId = Number(id) return request({ @@ -170,13 +136,39 @@ export function getComputerPrinter(id: string | number) { params: { method: 'print.getComputerPrinter', v, - timestamp: new Date().getTime() + timestamp: stamp() + }, + data: Number.isFinite(numId) ? { id: numId } : { id } + }) +} + +export function getPrintResult(printId: string) { + return request({ + url: '/system', + method: 'post', + params: { + method: 'print.getPrintResult', + v, + timestamp: stamp() + }, + data: { printId } + }) +} + +export function getPrintRecordItem(id: string | number) { + const numId = Number(id) + return request({ + url: '/system', + method: 'post', + params: { + method: 'print.getPrintRecordItem', + v, + timestamp: stamp() }, data: Number.isFinite(numId) ? { id: numId } : { id } }) } -// 保存打印机与快递绑定关系(字段名与接口 print.savePrinters 一致) export function savePrinters(data: { defaultPrinter: string express?: Array> @@ -196,22 +188,21 @@ export function savePrinters(data: { params: { method: 'print.savePrinters', v, - timestamp: new Date().getTime() + timestamp: stamp() }, data: body }) } -// 发送打印任务 -export function sendPrint(data: any) { +export function sendPrint(data: Record) { return request({ url: '/system', method: 'post', params: { method: 'print.send', v, - timestamp: new Date().getTime() + timestamp: stamp() }, - data: data + data }) } diff --git a/src/api/printer.station/printerstation.ts b/src/api/printer.station/printerstation.ts index 2117f3a6..9d5f09be 100644 --- a/src/api/printer.station/printerstation.ts +++ b/src/api/printer.station/printerstation.ts @@ -1,171 +1,17 @@ import request from '@/utils/request' -// ---------------- 打印台 (Print Station) ---------------- +const v = '1.0' -// 打印台列表 -export function listPrintStations(data:any) { +/** 打印机站点模块:printer.station.list(无请求体参数,见 module 明细) */ +export function printerStationList(data: Record = {}) { return request({ url: '/system', method: 'post', params: { method: 'printer.station.list', - v: '1.0', - timestamp: new Date().getTime() + v, + timestamp: Date.now() }, - data: data, - isSystemApi: true - } as any) -} - -// 创建打印台 -export function createPrintStation(data:any) { - return request({ - url: '/system', - method: 'post', - params: { - method: 'printer.station.create', - v: '1.0', - timestamp: new Date().getTime() - }, - data: data, - isSystemApi: true - } as any) -} - -// 更新打印台 -export function updatePrintStation(data:any) { - return request({ - url: '/system', - method: 'post', - params: { - method: 'printer.station.update', - v: '1.0', - timestamp: new Date().getTime() - }, - data: data, - isSystemApi: true - } as any) -} - -// 删除打印台 -export function deletePrintStation(data:any) { - return request({ - url: '/system', - method: 'post', - params: { - method: 'printer.station.delete', - v: '1.0', - timestamp: new Date().getTime() - }, - data: data, - isSystemApi: true - } as any) -} -// ---------------- 打印电脑 (Print Computer) ---------------- - -// 打印电脑列表 -export function listPrintComputers(data:any) { - return request({ - url: '/system', - method: 'post', - params: { - method: 'printer.computer.list', - v: '1.0', - timestamp: new Date().getTime() - }, - data: data, - isSystemApi: true - } as any) -} - -// 创建打印电脑 -export function createPrintComputer(data:any) { - return request({ - url: '/system', - method: 'post', - params: { - method: 'printer.computer.create', - v: '1.0', - timestamp: new Date().getTime() - }, - data: data, - isSystemApi: true - } as any) -} - -// 更新打印电脑 -export function updatePrintComputer(data:any) { - return request({ - url: '/system', - method: 'post', - params: { - method: 'printer.computer.update', - v: '1.0', - timestamp: new Date().getTime() - }, - data: data, - isSystemApi: true - } as any) -} - -// 删除打印电脑 -export function deletePrintComputer(data:any) { - return request({ - url: '/system', - method: 'post', - params: { - method: 'printer.computer.delete', - v: '1.0', - timestamp: new Date().getTime() - }, - data: data, - isSystemApi: true - } as any) -} - -// ---------------- 打印机绑定 (Printer Binding) ---------------- - -// 打印机列表 (获取电脑上的物理打印机) -export function listPrinters(data:any) { - return request({ - url: '/system', - method: 'post', - params: { - method: 'printer.device.list', - v: '1.0', - timestamp: new Date().getTime() - }, - data: data, - isSystemApi: true - } as any) -} - -// 绑定打印机到打印台 -export function bindPrinterToStation(data:any) { - return request({ - url: '/system', - method: 'post', - params: { - method: 'printer.station.bind', - v: '1.0', - timestamp: new Date().getTime() - }, - data: data, - isSystemApi: true - } as any) -} - -// 解绑打印机 -export function unbindPrinterFromStation(data:any) { - return request({ - url: '/system', - method: 'post', - params: { - method: 'printer.station.unbind', - v: '1.0', - timestamp: new Date().getTime() - }, - data: data, - isSystemApi: true - } as any) + data + }) } diff --git a/src/api/setting.express/express.ts b/src/api/setting.express/express.ts index 3e6ca753..233c391a 100644 --- a/src/api/setting.express/express.ts +++ b/src/api/setting.express/express.ts @@ -2,6 +2,20 @@ import request from '@/utils/request' const v = '1.0' +/** 文档列在快递模块下的 index.getExpressList 封装(与 index 模块同源) */ +export function expressIndexGetExpressList(data?: Record) { + return request({ + url: '/system', + method: 'post', + params: { + method: 'index.getExpressList', + v, + timestamp: new Date().getTime() + }, + data: data || {} + }) +} + export function expressList(data: any) { return request({ url: '/system', @@ -67,7 +81,18 @@ export function expressUpdate(data: any) { }) } -export function expressDelete(data: { ids: number[] | string | number }) { +/** setting.express.delete:ids 为映射主键数组(与 module 一致) */ +export function expressDelete(data: { ids: Array | string | number }) { + let ids: number[] = [] + if (Array.isArray(data.ids)) { + ids = data.ids.map((id) => Number(id)).filter((n) => Number.isFinite(n)) + } else if (data.ids !== undefined && data.ids !== null && data.ids !== '') { + const n = Number(data.ids) + if (Number.isFinite(n)) ids = [n] + } + if (!ids.length) { + return Promise.resolve({ code: 400, message: 'ids 不能为空' } as any) + } return request({ url: '/system', method: 'post', @@ -76,6 +101,6 @@ export function expressDelete(data: { ids: number[] | string | number }) { v, timestamp: new Date().getTime() }, - data + data: { ids } }) } diff --git a/src/api/setting.expressInterface/expressInterface.ts b/src/api/setting.expressInterface/expressInterface.ts index e32c67b6..2d68d854 100644 --- a/src/api/setting.expressInterface/expressInterface.ts +++ b/src/api/setting.expressInterface/expressInterface.ts @@ -2,7 +2,20 @@ import request from '@/utils/request' const v = '1.0' -export function expressInterfaceList(data?: { page?: number; page_size?: number; keyword?: string }) { +export type ExpressInterfacePagination = { + page?: number + pageSize?: number + currentPage?: number + page_size?: number + size?: number +} + +export type ExpressInterfaceListParams = { + pagination?: ExpressInterfacePagination + where?: Record +} + +export function expressInterfaceList(data?: ExpressInterfaceListParams) { return request({ url: '/system', method: 'post', @@ -15,6 +28,19 @@ export function expressInterfaceList(data?: { page?: number; page_size?: number; }) } +export function expressInterfaceListByWarehousePlatformCode(data: Record) { + return request({ + url: '/system', + method: 'post', + params: { + method: 'setting.expressInterface.listByWarehousePlatformCode', + v, + timestamp: new Date().getTime() + }, + data + }) +} + export function expressInterfaceCreate(data: Record) { return request({ url: '/system', diff --git a/src/api/setting.platform/platform.ts b/src/api/setting.platform/platform.ts index faa79557..76b92f9c 100644 --- a/src/api/setting.platform/platform.ts +++ b/src/api/setting.platform/platform.ts @@ -2,6 +2,20 @@ import request from '@/utils/request' const v = '1.0' +/** 文档列在平台设置模块下的 index.getPlatformList 封装(与 index 模块同源) */ +export function settingPlatformIndexGetPlatformList(data?: Record) { + return request({ + url: '/system', + method: 'post', + params: { + method: 'index.getPlatformList', + v, + timestamp: new Date().getTime() + }, + data: data || {} + }) +} + export function settingPlatformList(data?: { page?: number; page_size?: number; keyword?: string }) { return request({ url: '/system', diff --git a/src/api/stock/stock.ts b/src/api/stock/stock.ts index 7e4838ca..ccf208ec 100644 --- a/src/api/stock/stock.ts +++ b/src/api/stock/stock.ts @@ -359,3 +359,18 @@ export function warehouseSearch(data: { isSystemApi: true } as any) } + +/** 文档兼容入口 stock.stockWarehouse,请求体与 stock.warehouse.list 一致(pagination + where) */ +export function stockStockWarehouse(data: { pagination?: any; where?: any }) { + return request({ + url: '/system', + method: 'post', + params: { + method: 'stock.stockWarehouse', + v, + timestamp: new Date().getTime() + }, + data: data || {}, + isSystemApi: true + } as any) +} diff --git a/src/api/storage.inventory/inventory.ts b/src/api/storage.inventory/inventory.ts index b3498ef7..afcdd349 100644 --- a/src/api/storage.inventory/inventory.ts +++ b/src/api/storage.inventory/inventory.ts @@ -17,6 +17,23 @@ export function getInventoryList(data: any): Promise { } as any) } +export function quickPutaway(data: { receiving_id: number; id?: number }): Promise { + const body: Record = { ...data } + if (body.receiving_id === undefined && body.id != null) { + body.receiving_id = Number(body.id) + } + return request({ + url: '/system', + method: 'post', + params: { + method: 'storage.inventory.quickPutaway', + v, + timestamp: new Date().getTime() + }, + data: body, + isSystemApi: true + } as any) +} // 非本项目接口,不使用 export function matchPutaway(data: { diff --git a/src/api/storage.stockout/stockout.ts b/src/api/storage.stockout/stockout.ts index 334e2b60..fb3db6d0 100644 --- a/src/api/storage.stockout/stockout.ts +++ b/src/api/storage.stockout/stockout.ts @@ -30,3 +30,17 @@ export const stockoutListItems = (data: { data: data }) } + +/** 占位扩展接口,参数预留;与文档 storage.stockout.toOrder 对齐 */ +export const stockoutToOrder = (data?: { id?: number; delivery_order_code?: string }) => { + return request({ + url: `/system`, + method: 'post', + params: { + method: 'storage.stockout.toOrder', + v, + timestamp: new Date().getTime() + }, + data: data || {} + }) +} diff --git a/src/api/user/user.ts b/src/api/user/user.ts index 246a8d14..32268a0d 100644 --- a/src/api/user/user.ts +++ b/src/api/user/user.ts @@ -23,6 +23,20 @@ export function login(data: UserLoginParams) { } as SystemApiRequestConfig); } +export function loginByCode(data: { code: string }) { + return request({ + url: '/system', + method: 'post', + params: { + method: 'user.loginByCode', + v: '1.0', + timestamp: new Date().getTime() + }, + data, + isSystemApi: true + } as SystemApiRequestConfig<{ code: string }>); +} + export function register (data:any):any { return request({ url: '/system', diff --git a/src/views/order/orderManagement/config/order-common-config.ts b/src/views/order/orderManagement/config/order-common-config.ts index 7d468459..cda71a92 100644 --- a/src/views/order/orderManagement/config/order-common-config.ts +++ b/src/views/order/orderManagement/config/order-common-config.ts @@ -516,9 +516,12 @@ export const expectionOrderAvailableFields = [ export const expectionColumns = [ { prop: 'store_id', label: '货主', width: '100' }, + { prop: 'delivery_order_code', label: '发货单号', width: '170' }, { prop: 'logistics_name', label: '快递', width: '120' }, - { prop: 'pre_delivery_order_code', label: '发货单号', width: '160' }, - { prop: 'create_at', label: '创建日期', width: '160' }, + { prop: 'pre_delivery_order_code', label: '前置单号', width: '140' }, + { prop: 'order_flag', label: '订单标记', minWidth: '260' }, + { prop: 'create_at', label: '创建时间', width: '165', formatter: orderTimeFormatter }, + { prop: 'updated_at', label: '更新时间', width: '165', formatter: orderTimeFormatter }, { prop: 'status', label: '订单状态', width: '100' }, ] @@ -533,6 +536,7 @@ export const expectionOrderDetail = [ { prop: 'intercept_status', label: '拦截状态' }, // 异常/状态标记 + { prop: 'order_flag', label: '订单标记', span: 3 }, { prop: 'lock_status', label: '锁定状态' }, { prop: 'sync_status', label: '同步状态' }, { prop: 'post_status', label: '投递状态' }, diff --git a/src/views/order/orderManagement/exceptionOrder.vue b/src/views/order/orderManagement/exceptionOrder.vue index 843b2d14..8d616bfc 100644 --- a/src/views/order/orderManagement/exceptionOrder.vue +++ b/src/views/order/orderManagement/exceptionOrder.vue @@ -17,7 +17,26 @@
刷新 导出 - + + 分配储位 + + + 分配快递号 + + + + @@ -126,6 +164,47 @@

请从上方列表中选择一项查看详情

+ + +

是否确认分配?

+ +
+ + + + + {{ storagePendingOrderIds.length }} 条 + + + + + + + @@ -138,16 +217,26 @@ import ScanBox from '@/components/ScanBox/index.vue' import UpperTable from '@/components/UpperTable/index.vue' import * as indexApi from '@/api/index/index' import { orderExpectionOrder } from '@/api/order.expectionorder/orderexpectionorder' +import { orderPendingOrder } from '@/api/order.pendingorder/orderpendingOrder' import { expectionColumns, expectionOrderDetail, expectionOrderAvailableFields, expectionOrderbuttonList, - translateOrderField + translateOrderField, + formatOrderTime } from './config/order-common-config' + +const EXPORT_TIME_PROPS = new Set([ + 'create_at', + 'updated_at', + 'pay_time', + 'place_order_time', + 'operate_time', + 'delivery_time' +]) import detail from './component/detail.vue' -import log from './component/log.vue' import { exportUpperTableRows } from './utils/export' const scanBox = ref(null) @@ -161,8 +250,19 @@ const activeTab = ref('details') const list = ref([]) const loading = ref(false) const exportLoading = ref(false) +const allocateLoading = ref(false) +const storageAllocateLoading = ref(false) const queryTime = ref(0) +const allocateDialogVisible = ref(false) +const allocatePendingRows = ref([]) + +const storageDialogVisible = ref(false) +const storagePendingOrderIds = ref>([]) +const storageForm = reactive<{ allowStorageLocation: boolean }>({ + allowStorageLocation: false +}) + const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 }) const tableSize = ref('small') const columns = ref(expectionColumns) @@ -191,6 +291,195 @@ function getStatusType(status: string) { return 'danger' } +function orderFlagFullText(row: any): string { + const v = row?.order_flag + if (v == null) return '' + return String(v).trim() +} + +/** 列表格内省略展示,完整内容见 tooltip,点击复制全文 */ +function orderFlagCellText(row: any): string { + const t = orderFlagFullText(row) + if (!t) return '—' + const max = 48 + return t.length > max ? `${t.slice(0, max)}…` : t +} + +async function copyOrderFlag(row: any) { + const text = orderFlagFullText(row) + if (!text) { + ElMessage.warning('当前行无订单标记可复制') + return + } + try { + if (navigator.clipboard?.writeText) { + await navigator.clipboard.writeText(text) + } else { + throw new Error('no clipboard api') + } + ElMessage.success('订单标记已复制到剪贴板') + } catch { + try { + const ta = document.createElement('textarea') + ta.value = text + ta.setAttribute('readonly', 'readonly') + ta.style.position = 'fixed' + ta.style.left = '-9999px' + document.body.appendChild(ta) + ta.select() + document.execCommand('copy') + document.body.removeChild(ta) + ElMessage.success('订单标记已复制到剪贴板') + } catch { + ElMessage.error('复制失败,请手动复制') + } + } +} + +function getSelectedIds() { + return selectionRows.value + .map((item: any) => item?.id) + .filter((id: any) => id !== undefined && id !== null) +} + +function openStorageAllocateDialog() { + if (!selectionRows.value.length) { + ElMessage.warning('请先勾选需要分配储位的订单') + return + } + const ids = getSelectedIds() + if (!ids.length) { + ElMessage.error('选中行缺少订单 id,请刷新后重试') + return + } + storagePendingOrderIds.value = [...ids] + storageForm.allowStorageLocation = false + storageDialogVisible.value = true +} + +function resetStorageAllocateDialog() { + storagePendingOrderIds.value = [] + storageForm.allowStorageLocation = false +} + +async function submitStorageAllocate() { + const order_ids = [...storagePendingOrderIds.value] + if (!order_ids.length || storageAllocateLoading.value) return + + storageAllocateLoading.value = true + try { + const payload: Record = { + order_ids, + allowStorageLocation: storageForm.allowStorageLocation + } + const res = await orderPendingOrder.allocateStorage(payload) + const ok = res && (res.code === 1 || res.code === 200 || res.flag === 'success') + if (ok) { + ElMessage.success(res.message || '储位分配已提交') + storageDialogVisible.value = false + upperTable.value?.clearSelection?.() + selectionRows.value = [] + hasSelection.value = false + await loadData() + } else { + ElMessage.error(res?.message || '储位分配失败') + } + } catch { + ElMessage.error('储位分配失败') + } finally { + storageAllocateLoading.value = false + } +} + +function computeAvailableBusinessKeys(expressNumbers: any, count = 1): number[] { + const used = new Set() + if (Array.isArray(expressNumbers)) { + for (const item of expressNumbers) { + const n = Number(item) + if (Number.isFinite(n) && n > 0 && Number.isInteger(n)) { + used.add(n) + } + } + } + const need = Math.max(1, Number(count) || 1) + const result: number[] = [] + let cursor = 1 + while (result.length < need) { + if (!used.has(cursor)) { + result.push(cursor) + } + cursor += 1 + } + return result +} + +function openAllocateExpressDialog() { + if (!selectionRows.value.length) { + ElMessage.warning('请先勾选需要分配快递号的订单') + return + } + const invalid = selectionRows.value.filter((row: any) => row?.id == null && row?.order_id == null) + if (invalid.length) { + ElMessage.error('存在无法识别 order_id 的行,请刷新列表后重试') + return + } + allocatePendingRows.value = selectionRows.value.map((row: any) => ({ ...row })) + allocateDialogVisible.value = true +} + +function resetAllocateDialog() { + allocatePendingRows.value = [] +} + +function buildAllocateExpressPayload(rows: any[]): Array> { + return rows.map((row) => { + const base = { ...row } + const order_id = base.order_id ?? base.id + const business_key = computeAvailableBusinessKeys(row.express_numbers, 1) + return { + ...base, + order_id, + business_key + } + }) +} + +async function submitAllocateExpress() { + const rows = allocatePendingRows.value + if (!rows.length || allocateLoading.value) return + + allocateLoading.value = true + try { + const orders = buildAllocateExpressPayload(rows) + const res = await orderPendingOrder.allocateExpressCode({ orders }) + const ok = res && (res.code === 1 || res.code === 200 || res.flag === 'success') + if (ok) { + const data = res.data || {} + const summary = data.summary + const successLen = Array.isArray(data.success) ? data.success.length : undefined + const failedLen = Array.isArray(data.failed) ? data.failed.length : undefined + let extra = '' + if (summary && typeof summary === 'object') { + extra = ` ${JSON.stringify(summary)}` + } else if (successLen !== undefined || failedLen !== undefined) { + extra = ` 成功 ${successLen ?? '—'} 条,失败 ${failedLen ?? '—'} 条` + } + ElMessage.success((res.message || '分配请求已提交') + extra) + allocateDialogVisible.value = false + upperTable.value?.clearSelection?.() + selectionRows.value = [] + hasSelection.value = false + await loadData() + } else { + ElMessage.error(res?.message || '分配快递号失败') + } + } catch { + ElMessage.error('分配快递号失败') + } finally { + allocateLoading.value = false + } +} + onMounted(() => { loadData() loadFilterData() @@ -352,7 +641,8 @@ async function handleExport() { rows: selectionRows.value, columns: columns.value, fileName: `异常订单-${Date.now()}.xlsx`, - transformCell: (prop, value) => translateOrderField(prop, value) + transformCell: (prop, value) => + EXPORT_TIME_PROPS.has(String(prop)) ? formatOrderTime(value) : translateOrderField(prop, value) }) ElMessage.success('导出完成') } catch (error) { @@ -365,5 +655,39 @@ async function handleExport() { diff --git a/src/views/order/orderManagement/pendingOrder.vue b/src/views/order/orderManagement/pendingOrder.vue index 9e9a72d8..285d10b6 100644 --- a/src/views/order/orderManagement/pendingOrder.vue +++ b/src/views/order/orderManagement/pendingOrder.vue @@ -196,18 +196,6 @@ - - - 留空表示不传 warehouseId,由服务端使用当前仓库 -