Files
klp-oa/klp-ui/src/views/wms/coil/js/coilActions.js
砂糖 3c96211cc5 feat(wms): 添加订单号显示并改进日期格式化功能
1. 在发货单组件中增加订单号显示,替换原有电话字段
2. 实现统一的日期格式化工具函数,修复参数冲突问题
3. 发货操作后自动添加待操作记录
4. 优化钢卷操作中的日期处理逻辑
2026-03-12 09:20:23 +08:00

102 lines
3.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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