feat(钢卷管理): 添加长度字段支持及相关功能

refactor(订单管理): 重构订单状态显示及操作记录功能

fix(权限控制): 移除导出订单明细的权限校验

perf(钢卷操作): 使用策略模式重构钢卷操作逻辑
This commit is contained in:
砂糖
2025-12-29 16:22:18 +08:00
parent 9b8c5ab80b
commit 825a967f7b
13 changed files with 344 additions and 170 deletions

View File

@@ -0,0 +1,79 @@
import { addMaterialCoil, updateMaterialCoil, updateMaterialCoilSimple } from "@/api/wms/coil"
import { addPendingAction, updatePendingAction } from '@/api/wms/pendingAction';
export const COIL_ACTIONS = {
RECEIVE: 'RECEIVE', // 收货与入库的区别在于,收货相当于计划入库,不管是否已到货都执行这个操作,计划收货也是收获
STORE: 'STORE', // 入库相当于实际收货与入库
CORRECTION: 'CORRECTION',
PROCESSING: 'PROCESSING',
MERGE: 'MERGE',
SPLIT: 'SPLIT',
PACK: 'PACK',
DELIVER: 'DELIVER',
MOVE: 'MOVE',
EDIT: 'EDIT', // 对应“根据库位码编辑钢卷信息”
ALLOCATE: 'ALLOCATE'
}
export const actions = Object.values(COIL_ACTIONS)
export const actionStrategies = {
RECEIVE: {
type: COIL_ACTIONS.RECEIVE,
name: '计划钢卷收货',
description: '计划钢卷收货,不管是否已到货都执行这个操作,计划收货也是收货',
handler: async (coil, planId) => {
// 收货逻辑创建一个dataType为10的钢卷和一个待操作记录
const response = await addMaterialCoil({
...coil,
dataType: 10,
})
await addPendingAction({
// 计划ID 对应 warehouseId warehouseId字段并不是仓库ID而是一个根据操作类型自适应的查询字段
warehouseId: planId,
actionType: 401,
currentCoilNo: coil.currentCoilNo,
sourceType: 'manual',
coilId: response.data.coilId,
priority: 0,
remark: coil.remark,
actionStatus: 0,
})
return response.data.coilId
}
},
STORE: {
type: COIL_ACTIONS.STORE,
name: '实际钢卷入库',
description: '实际钢卷入库,只有在已到货的情况下才执行这个操作',
handler: async (coil, action) => {
// 更新操作记录状态 actionStatus: 2
// 并行执行更新操作记录和更新钢卷状态
await Promise.all([
updatePendingAction({
...action,
actionStatus: 2,
}),
updateMaterialCoilSimple({
...coil,
dataType: 1,
})
])
return true
}
},
}
const handleCoil = (action, ...args) => {
const strategy = actionStrategies[action]
if (strategy && strategy.handler) {
return strategy.handler(...args)
} else {
console.error(`No strategy found for action: ${action}`)
}
}
export default handleCoil