1. 在发货单组件中增加订单号显示,替换原有电话字段 2. 实现统一的日期格式化工具函数,修复参数冲突问题 3. 发货操作后自动添加待操作记录 4. 优化钢卷操作中的日期处理逻辑
102 lines
3.3 KiB
JavaScript
102 lines
3.3 KiB
JavaScript
import { addMaterialCoil, updateMaterialCoil, updateMaterialCoilSimple } from "@/api/wms/coil"
|
||
import { addPendingAction, updatePendingAction } from '@/api/wms/pendingAction';
|
||
import { addCoilWarehouseOperationLog } from '@/api/wms/coilWarehouseOperationLog';
|
||
|
||
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
|
||
// 并行执行更新操作记录和更新钢卷状态
|
||
// 将日期格式化为yyyy-MM-dd HH:mm:ss
|
||
const completeTime = new Date()
|
||
function parseDate(date) {
|
||
return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds()
|
||
}
|
||
await Promise.all([
|
||
updatePendingAction({
|
||
...action,
|
||
actionStatus: 2,
|
||
completeTime: parseDate(completeTime),
|
||
}),
|
||
updateMaterialCoilSimple({
|
||
...coil,
|
||
dataType: 1,
|
||
}),
|
||
// addCoilWarehouseOperationLog({
|
||
// coilId: coil.coilId,
|
||
// actualWarehouseId: coil.actualWarehouseId,
|
||
// operationType: 1,
|
||
// inOutType: 1,
|
||
// })
|
||
])
|
||
// 如果填写了实际库区,还需要新增一条库区出入记录
|
||
if (coil.actualWarehouseId) {
|
||
await addCoilWarehouseOperationLog({
|
||
coilId: coil.coilId,
|
||
actualWarehouseId: coil.actualWarehouseId,
|
||
operationType: 1,
|
||
inOutType: 1,
|
||
remark: '钢卷收货入库'
|
||
})
|
||
}
|
||
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
|
||
|
||
|