refactor(wms): 优化报表查询逻辑和界面显示
- 将查询参数中的 updateBy 改为 createBy 以匹配实际业务需求 - 移除不再使用的 selectType 参数 - 优化员工信息页面显示,调整离职时间展示 - 提取公共的 fetch 逻辑到单独文件 - 重构报表查询逻辑,使用 Promise.all 并行请求 - 调整钢卷文档页面,增加创建人选择功能
This commit is contained in:
77
klp-ui/src/views/wms/report/js/fetch.js
Normal file
77
klp-ui/src/views/wms/report/js/fetch.js
Normal file
@@ -0,0 +1,77 @@
|
||||
import { listCoilWithIds } from "@/api/wms/coil";
|
||||
import {
|
||||
listPendingAction,
|
||||
} from '@/api/wms/pendingAction';
|
||||
|
||||
export async function fetchOutputList(queryParams) {
|
||||
const resList = await Promise.all([
|
||||
listCoilWithIds({
|
||||
...queryParams,
|
||||
selectType: 'raw_material',
|
||||
itemType: 'raw_material',
|
||||
pageSize: 99999,
|
||||
pageNum: 1,
|
||||
}),
|
||||
listCoilWithIds({
|
||||
...queryParams,
|
||||
selectType: 'product',
|
||||
itemType: 'product',
|
||||
pageSize: 99999,
|
||||
pageNum: 1,
|
||||
}),
|
||||
])
|
||||
const list = resList.flatMap(res => res.rows)
|
||||
// 按照createTime 降序排序
|
||||
const sortedList = list.sort(
|
||||
(a, b) => new Date(b.createTime) - new Date(a.createTime)
|
||||
).map(item => {
|
||||
// 计算宽度和厚度,将规格按照*分割,*前的是厚度,*后的是宽度
|
||||
const [thickness, width] = item.specification.split('*')
|
||||
return {
|
||||
...item,
|
||||
computedThickness: parseFloat(thickness),
|
||||
computedWidth: parseFloat(width),
|
||||
}
|
||||
})
|
||||
return sortedList
|
||||
}
|
||||
|
||||
export async function fetchLossList(queryParams) {
|
||||
const resultList = await Promise.all(this.actionTypes.map(actionType => {
|
||||
return listPendingAction({
|
||||
...queryParams,
|
||||
actionStatus: 2,
|
||||
actionType,
|
||||
pageSize: 99999,
|
||||
pageNum: 1,
|
||||
})
|
||||
}))
|
||||
const actions = resultList.flatMap(item => item.rows)
|
||||
const actionIds = actions.map(item => item.actionId).join(',')
|
||||
console.log(actionIds)
|
||||
if (!actionIds) {
|
||||
this.$message({
|
||||
message: '暂无数据',
|
||||
type: 'warning',
|
||||
})
|
||||
throw new Error('暂无数据')
|
||||
}
|
||||
const res = await listCoilWithIds({
|
||||
...queryParams,
|
||||
byCreateTimeStart: undefined,
|
||||
byCreateTimeEnd: undefined,
|
||||
actionIds: actionIds,
|
||||
pageSize: 99999,
|
||||
pageNum: 1,
|
||||
})
|
||||
const lossList = res.rows.map(item => {
|
||||
// 计算宽度和厚度,将规格按照*分割,*前的是厚度,*后的是宽度
|
||||
const [thickness, width] = item.specification?.split('*') || [0, 0]
|
||||
return {
|
||||
...item,
|
||||
computedThickness: parseFloat(thickness),
|
||||
computedWidth: parseFloat(width),
|
||||
}
|
||||
})
|
||||
return lossList
|
||||
}
|
||||
Reference in New Issue
Block a user