refactor(wms/report): 重构报表模块数据获取逻辑,提取公共方法到fetch.js

feat(wms/report): 新增报表结果存储页面,支持JSON数据横向对比

style(wms/coil/do): 调整钢卷修正页面样式和代码格式

fix(wms/coil/do): 修复操作记录查询参数传递问题,优化钢卷选择逻辑
This commit is contained in:
砂糖
2026-03-27 16:37:59 +08:00
parent c294149274
commit cd00b9562d
7 changed files with 448 additions and 313 deletions

View File

@@ -38,12 +38,6 @@
<muti-select style="width: 200px;" v-model="queryParams.itemManufacturer"
:options="dict.type.coil_manufacturer" placeholder="请选择厂家" clearable @keyup.enter.native="handleQuery" />
</el-form-item>
<!-- <el-form-item label="收货计划" prop="planId">
<el-select style="width: 200px;" v-model="queryParams.planId" placeholder="请输入计划名称搜索收货计划" filterable remote
:remote-method="remoteMethod">
<el-option v-for="item in planList" :key="item.planId" :label="item.planName" :value="item.planId" />
</el-select>
</el-form-item> -->
<el-form-item prop="endTime">
<el-button type="primary" @click="getList">查询</el-button>
<el-button type="primary" @click="exportData">导出</el-button>
@@ -85,6 +79,8 @@ import WarehouseSelect from "@/components/KLPService/WarehouseSelect";
import { listDeliveryPlan } from '@/api/wms/deliveryPlan'
import ColumnsSetting from "@/views/wms/report/components/setting/columns.vue";
import CoilTable from "@/views/wms/report/components/coilTable/index.vue";
import { fetchLossList } from "@/views/wms/report/js/fetch";
export default {
name: 'LossTemplate',
@@ -186,44 +182,11 @@ export default {
},
async getList() {
this.loading = true
const resultList = await Promise.all(this.actionTypes.map(actionType => {
return listPendingAction({
actionStatus: 2,
warehouseId: this.queryParams.planId,
actionType,
pageSize: 9999,
pageNum: 1,
startTime: this.queryParams.byCreateTimeStart,
endTime: this.queryParams.byCreateTimeEnd,
...this.actionQueryParams,
})
}))
const actions = resultList.flatMap(item => item.rows)
const actionIds = actions.map(item => item.actionId).join(',')
if (!actionIds) {
this.$message({
message: '暂无数据',
type: 'warning',
})
this.list = []
this.loading = false
return
}
listCoilWithIds({
fetchLossList(this.actionTypes, {
...this.queryParams,
byCreateTimeStart: undefined,
byCreateTimeEnd: undefined,
actionIds: actionIds,
...this.actionQueryParams,
}).then(res => {
this.list = res.rows.map(item => {
// 计算宽度和厚度,将规格按照*分割,*前的是厚度,*后的是宽度
const [thickness, width] = item.specification?.split('*') || [undefined, undefined]
return {
...item,
computedThickness: parseFloat(thickness),
computedWidth: parseFloat(width),
}
})
this.list = res
this.loading = false
})
},

View File

@@ -92,7 +92,7 @@
<!-- 异常统计 -->
<el-descriptions title="异常统计" :column="4" border>
<el-descriptions-item v-for="item in abSummary" :key="item.label" :label="item.label">{{ item.value
}}</el-descriptions-item>
}}</el-descriptions-item>
</el-descriptions>
<el-descriptions title="明细信息" :column="3" border>
@@ -130,6 +130,7 @@ import WarehouseSelect from "@/components/KLPService/WarehouseSelect";
import { calcSummary, calcAbSummary, calcMSummary } from "@/views/wms/report/js/calc";
import ColumnsSetting from "@/views/wms/report/components/setting/columns.vue";
import CoilTable from "@/views/wms/report/components/coilTable/index.vue";
import { fetchLossList, fetchOutputList } from "@/views/wms/report/js/fetch";
export default {
name: 'MonthTemplate',
@@ -389,9 +390,18 @@ export default {
fetchData() {
this.loading = true
Promise.all([
this.getList(),
this.getLossList()
]).then(() => {
fetchLossList(this.actionTypes, {
...this.queryParams,
...this.actionQueryParams
}),
fetchOutputList({
...this.queryParams,
...this.baseQueryParams,
warehouseIds: this.warehouseIds.join(','),
}),
]).then(([lossList, outputList]) => {
this.lossList = lossList
this.list = outputList
this.loading = false
})
},

View File

@@ -40,7 +40,7 @@
:options="dict.type.coil_manufacturer" placeholder="请选择厂家" clearable @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item prop="endTime">
<el-button type="primary" @click="getList">查询</el-button>
<el-button type="primary" @click="handleQuery">查询</el-button>
<el-button type="primary" @click="exportData">导出</el-button>
<el-button type="primary" @click="settingVisible = true">列设置</el-button>
</el-form-item>
@@ -76,6 +76,8 @@ import MutiSelect from "@/components/MutiSelect";
import WarehouseSelect from "@/components/KLPService/WarehouseSelect";
import ColumnsSetting from "@/views/wms/report/components/setting/columns.vue";
import CoilTable from "@/views/wms/report/components/coilTable/index.vue";
import { fetchOutputList } from "@/views/wms/report/js/fetch";
export default {
name: 'OutTemplate',
@@ -160,7 +162,7 @@ export default {
handler(newVal, oldVal) {
if (newVal !== oldVal) {
this.warehouseIds = newVal.map(item => item.value)
this.getList()
this.handleQuery()
}
},
immediate: true,
@@ -186,40 +188,13 @@ export default {
},
// 统一查询入口
handleQuery() {
this.getList()
},
getList() {
this.loading = true
Promise.all([
listCoilWithIds({
selectType: 'raw_material',
itemType: 'raw_material',
warehouseIds: this.warehouseIds.join(','),
...this.queryParams,
...this.baseQueryParams,
}),
listCoilWithIds({
selectType: 'product',
itemType: 'product',
warehouseIds: this.warehouseIds.join(','),
...this.queryParams,
...this.baseQueryParams,
}),
]).then((resList) => {
console.log(resList)
const list = resList.flatMap(res => res.rows)
// 按照createTime 降序排序
this.list = 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),
}
})
fetchOutputList({
...this.queryParams,
...this.baseQueryParams,
warehouseIds: this.warehouseIds.join(','),
}).then((resList) => {
this.list = resList
this.loading = false
})
},
@@ -231,7 +206,7 @@ export default {
},
},
mounted() {
this.getList()
this.handleQuery()
this.loadColumns()
}
}

View File

@@ -135,6 +135,7 @@ import WarehouseSelect from "@/components/KLPService/WarehouseSelect";
import { calcSummary, calcAbSummary, calcTeamSummary, calcMSummary } from "@/views/wms/report/js/calc";
import ColumnsSetting from "@/views/wms/report/components/setting/columns.vue";
import CoilTable from "@/views/wms/report/components/coilTable/index.vue";
import { fetchLossList, fetchOutputList } from "@/views/wms/report/js/fetch";
export default {
name: 'TeamTemplate',
@@ -263,94 +264,24 @@ export default {
this.lossColumns = JSON.parse(localStorage.getItem('preference-tableColumns-coil-report-loss') || '[]') || []
this.outputColumns = JSON.parse(localStorage.getItem('preference-tableColumns-coil-report-output') || '[]') || []
},
// 统一查询入口(兼容回车和按钮点击)
handleQuery() {
this.getList();
// this.getLossList();
},
getList() {
this.loading = true;
this.loading = true
Promise.all([
listCoilWithIds({
selectType: 'raw_material',
itemType: 'raw_material',
warehouseIds: this.warehouseIds.join(','),
fetchLossList(this.actionTypes, {
...this.queryParams,
...this.baseQueryParams
...this.actionQueryParams
}),
listCoilWithIds({
selectType: 'product',
itemType: 'product',
fetchOutputList({
...this.queryParams,
...this.baseQueryParams,
warehouseIds: this.warehouseIds.join(','),
...this.queryParams,
...this.baseQueryParams
})
]).then(resList => {
const list = resList.flatMap(res => res.rows);
this.list = 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),
}
});
// this.loading = false;
this.getLossList()
// this.loading = false;
}).catch(err => {
console.error('查询失败:', err);
this.loading = false;
});
},
async getLossList() {
this.loading = true;
try {
const resultList = await Promise.all(this.actionTypes.map(actionType => {
return listPendingAction({
actionStatus: 2,
warehouseId: this.queryParams.planId,
actionType,
pageSize: 9999,
pageNum: 1,
startTime: this.queryParams.byCreateTimeStart,
endTime: this.queryParams.byCreateTimeEnd,
...this.actionQueryParams
});
}));
const actions = resultList.flatMap(item => item.rows);
const coilIds = actions.map(item => item.coilId).join(',');
if (!coilIds) {
this.$message({
message: '暂无数据',
type: 'warning'
});
this.lossList = [];
this.loading = false;
return;
}
const res = await listCoilWithIds({
...this.queryParams,
byCreateTimeStart: undefined,
byCreateTimeEnd: undefined,
coilIds: coilIds
});
this.lossList = res.rows.map(item => {
// 计算宽度和厚度,将规格按照*分割,*前的是厚度,*后的是宽度
const [thickness, width] = item.specification.split('*')
return {
...item,
computedThickness: parseFloat(thickness),
computedWidth: parseFloat(width),
}
});
this.loading = false;
} catch (err) {
console.error('查询失败:', err);
this.loading = false;
}
}),
]).then(([lossList, outputList]) => {
this.lossList = lossList
this.list = outputList
this.loading = false
})
},
exportData() {
if (this.list.length === 0) {
@@ -372,8 +303,7 @@ export default {
}
},
mounted() {
this.getList();
// this.getLossList();
this.handleQuery()
this.loadColumns();
}
};

View File

@@ -130,6 +130,7 @@ import WarehouseSelect from "@/components/KLPService/WarehouseSelect";
import { calcSummary, calcAbSummary, calcMSummary } from "@/views/wms/report/js/calc";
import ColumnsSetting from "@/views/wms/report/components/setting/columns.vue";
import CoilTable from "@/views/wms/report/components/coilTable/index.vue";
import { fetchLossList, fetchOutputList } from "@/views/wms/report/js/fetch";
export default {
name: 'YearTemplate',
@@ -264,84 +265,20 @@ export default {
},
// 统一查询入口(兼容回车和按钮点击)
handleQuery() {
this.getList()
// this.getLossList()
},
// 核心查询逻辑
getList() {
this.loading = true
Promise.all([
listCoilWithIds({
selectType: 'raw_material',
itemType: 'raw_material',
warehouseIds: this.warehouseIds.join(','),
fetchLossList(this.actionTypes, {
...this.queryParams,
...this.actionQueryParams
}),
fetchOutputList({
...this.queryParams,
...this.baseQueryParams,
}),
listCoilWithIds({
selectType: 'product',
itemType: 'product',
warehouseIds: this.warehouseIds.join(','),
...this.queryParams,
...this.baseQueryParams,
}),
]).then((resList) => {
const list = resList.flatMap(res => res.rows)
// 按照createTime 降序排序
this.list = list.sort(
(a, b) => new Date(b.createTime) - new Date(a.createTime)
).map(item => {
// 计算宽度和厚度,将规格按照*分割,*前的是厚度,*后的是宽度
const [thickness, width] = item.specification?.split('*') || [0, 0]
return {
...item,
computedThickness: parseFloat(thickness),
computedWidth: parseFloat(width),
}
})
this.getLossList()
})
},
async getLossList() {
this.loading = true
const resultList = await Promise.all(this.actionTypes.map(actionType => {
return listPendingAction({
actionStatus: 2,
warehouseId: this.queryParams.planId,
actionType,
pageSize: 99999,
pageNum: 1,
startTime: this.queryParams.byCreateTimeStart,
endTime: this.queryParams.byCreateTimeEnd,
...this.actionQueryParams,
})
}))
const actions = resultList.flatMap(item => item.rows)
const coilIds = actions.map(item => item.coilId).join(',')
if (!coilIds) {
this.$message({
message: '暂无数据',
type: 'warning',
})
this.lossList = []
this.loading = false
return
}
listCoilWithIds({
...this.queryParams,
byCreateTimeStart: undefined,
byCreateTimeEnd: undefined,
coilIds: coilIds,
}).then(res => {
this.lossList = res.rows.map(item => {
// 计算宽度和厚度,将规格按照*分割,*前的是厚度,*后的是宽度
const [thickness, width] = item.specification?.split('*') || [0, 0]
return {
...item,
computedThickness: parseFloat(thickness),
computedWidth: parseFloat(width),
}
})
]).then(([lossList, outputList]) => {
this.lossList = lossList
this.list = outputList
this.loading = false
})
},
@@ -366,8 +303,7 @@ export default {
},
},
mounted() {
this.getList()
// this.getLossList()
this.handleQuery()
this.loadColumns()
}
}