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

@@ -181,13 +181,11 @@
</div> </div>
</div> </div>
<el-button v-if="item.dataType == 1 && item.status == 0" <el-button v-if="item.dataType == 1 && item.status == 0"
style="position: absolute; bottom: 10px; right: 10px;" type="success" icon="el-icon-refresh" style="position: absolute; bottom: 10px; right: 10px;" type="success" icon="el-icon-refresh" size="mini"
size="mini" @click="handleRestoreMaterial(item)" :loading="item.cancelling" @click="handleRestoreMaterial(item)" :loading="item.cancelling" class="action-btn">回滚</el-button>
class="action-btn">回滚</el-button>
<el-button v-if="item.dataType == 10 && item.status == 0" <el-button v-if="item.dataType == 10 && item.status == 0"
style="position: absolute; bottom: 10px; right: 10px;" type="success" icon="el-icon-refresh" style="position: absolute; bottom: 10px; right: 10px;" type="success" icon="el-icon-refresh" size="mini"
size="mini" @click="handleForceInMaterial(item)" :loading="item.cancelling" @click="handleForceInMaterial(item)" :loading="item.cancelling" class="action-btn">强制入库</el-button>
class="action-btn">强制入库</el-button>
</div> </div>
<div class="card-footer"> <div class="card-footer">
@@ -207,7 +205,8 @@
@click="handleDeleteAction">删除</el-button> @click="handleDeleteAction">删除</el-button>
<el-button type="warning" plain icon="el-icon-refresh" size="mini" @click="handleRefreshAction" <el-button type="warning" plain icon="el-icon-refresh" size="mini" @click="handleRefreshAction"
:disabled="buttonLoading" v-loading="buttonLoading">刷新</el-button> :disabled="buttonLoading" v-loading="buttonLoading">刷新</el-button>
<el-checkbox style="margin-left: 10px;" v-model="rubbish" label="1" @change="getActionList">查看被删除操作</el-checkbox> <el-checkbox style="margin-left: 10px;" v-model="rubbish" label="1"
@change="getActionList">查看被删除操作</el-checkbox>
</div> </div>
</div> </div>
@@ -215,7 +214,8 @@
<el-form :model="actionQueryParams" ref="actionQueryForm" size="small" :inline="true" class="query-form mb10"> <el-form :model="actionQueryParams" ref="actionQueryForm" size="small" :inline="true" class="query-form mb10">
<el-form-item label="操作类型" prop="actionType"> <el-form-item label="操作类型" prop="actionType">
<el-select v-model="actionQueryParams.actionType" placeholder="请选择操作类型" clearable filterable> <el-select v-model="actionQueryParams.actionType" placeholder="请选择操作类型" clearable filterable>
<el-option v-for="item in dict.type.action_type" :key="item.value" :label="item.label" :value="item.value" /> <el-option v-for="item in dict.type.action_type" :key="item.value" :label="item.label"
:value="item.value" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="操作状态" prop="actionStatus"> <el-form-item label="操作状态" prop="actionStatus">
@@ -249,7 +249,8 @@
<el-table-column label="操作状态" align="center" prop="actionStatus" width="120"> <el-table-column label="操作状态" align="center" prop="actionStatus" width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<el-select v-model="scope.row.actionStatus" placeholder="请选择操作状态" @change="handleStatusChange(scope.row)"> <el-select v-model="scope.row.actionStatus" placeholder="请选择操作状态"
@change="handleStatusChange(scope.row)">
<el-option label="待处理" :value="0" /> <el-option label="待处理" :value="0" />
<el-option label="处理中" :value="1" /> <el-option label="处理中" :value="1" />
<el-option label="已完成" :value="2" /> <el-option label="已完成" :value="2" />
@@ -286,8 +287,10 @@
<el-table-column label="操作人" align="center" prop="updateBy" width="100" /> <el-table-column label="操作人" align="center" prop="updateBy" width="100" />
<el-table-column label="创建人" align="center" prop="createByName" width="140"> <el-table-column label="创建人" align="center" prop="createByName" width="140">
<template slot-scope="scope"> <template slot-scope="scope">
<el-select @change="handleProcessTimeChange(scope.row)" v-model="scope.row.createBy" placeholder="请选择创建人" filterable> <el-select @change="handleProcessTimeChange(scope.row)" v-model="scope.row.createBy"
<el-option v-for="item in userList" :key="item.userId" :label="item.nickName" :value="item.userName" /> placeholder="请选择创建人" filterable>
<el-option v-for="item in userList" :key="item.userId" :label="item.nickName"
:value="item.userName" />
</el-select> </el-select>
</template> </template>
</el-table-column> </el-table-column>
@@ -570,6 +573,7 @@ export default {
{ required: true, message: '请选择操作类型', trigger: 'change' } { required: true, message: '请选择操作类型', trigger: 'change' }
] ]
}, },
coilIds: ''
} }
}, },
computed: { computed: {
@@ -663,20 +667,13 @@ export default {
}); });
}, },
/** 查看操作记录 */
handleViewActions(row) {
this.currentCoilId = row.coilId;
this.actionDialogVisible = true;
this.actionQueryParams.pageNum = 1;
this.getActionList();
},
/** 查询操作记录 */ /** 查询操作记录 */
getActionList() { getActionList() {
this.actionLoading = true; this.actionLoading = true;
const payload = { const payload = {
...this.materialQueryParams,
...this.actionQueryParams, ...this.actionQueryParams,
coilId: this.currentCoilId, coilIds: this.coilIds,
includeDeleted: this.rubbish ? 2 : 0 includeDeleted: this.rubbish ? 2 : 0
}; };
listPendingAction(payload).then(response => { listPendingAction(payload).then(response => {
@@ -724,7 +721,7 @@ export default {
// 如果有钢卷数据,自动获取第一个钢卷的操作记录 // 如果有钢卷数据,自动获取第一个钢卷的操作记录
if (this.materialCoilList.length > 0) { if (this.materialCoilList.length > 0) {
this.currentCoilId = this.materialCoilList[0].coilId; this.coilIds = this.materialCoilList.map(item => item.coilId).join(',');
this.getActionList(); this.getActionList();
} else { } else {
// 清空操作记录 // 清空操作记录
@@ -749,10 +746,10 @@ export default {
this.getMaterialCoil(); this.getMaterialCoil();
// 同时获取操作记录 // 同时获取操作记录
if (this.materialCoilList.length > 0) { // if (this.materialCoilList.length > 0) {
this.currentCoilId = this.materialCoilList[0].coilId; // this.currentCoilId = this.materialCoilList[0].coilId;
this.getActionList(); // this.getActionList();
} // }
}, },
/** 重置物料搜索 */ /** 重置物料搜索 */

View File

@@ -0,0 +1,324 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="开始日期" prop="reportStartDate">
<el-date-picker clearable
v-model="queryParams.reportStartDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择报表日期">
</el-date-picker>
</el-form-item>
<el-form-item label="结束日期" prop="reportEndDate">
<el-date-picker clearable
v-model="queryParams.reportEndDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择报表日期">
</el-date-picker>
</el-form-item>
<el-form-item label="产线类型" prop="productionLine">
<el-select
v-model="queryParams.productionLine"
placeholder="请选择产线类型"
clearable
@keyup.enter.native="handleQuery"
>
<el-option v-for="item in dict.type.sys_lines" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="报表类型" prop="reportType">
<el-select
v-model="queryParams.reportType"
placeholder="请选择报表类型"
clearable
@keyup.enter.native="handleQuery"
>
<el-option v-for="item in reportTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="reportResultStorageList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="报表日期" align="center" prop="reportDate" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.reportDate, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="报表类型" align="center" prop="reportType" />
<el-table-column label="产线类型" align="center" prop="productionLine" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改报结果存储JSON+横向对比专用对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="报表日期" prop="reportDate">
<el-date-picker clearable
v-model="form.reportDate"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="请选择报表日期">
</el-date-picker>
</el-form-item>
<el-form-item label="产线类型" prop="productionLine">
<el-select v-model="form.productionLine" placeholder="请选择产线类型">
<el-option v-for="item in dict.type.sys_lines" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="报表类型" prop="reportType">
<el-select v-model="form.reportType" placeholder="请选择报表类型">
<el-option v-for="item in reportTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listReportResultStorage, getReportResultStorage, delReportResultStorage, addReportResultStorage, updateReportResultStorage } from "@/api/wms/reportResultStorage";
export default {
name: "ReportResultStorage",
dicts: ['sys_lines'],
data() {
// 默认选中当前月的第一天到最后一天使用parseTime函数格式化日期{y}-{m}-{d}
const now = new Date();
const firstDay = new Date(now.getFullYear(), now.getMonth(), 1);
const lastDay = new Date(now.getFullYear(), now.getMonth() + 1, 0);
const startDate = this.parseTime(firstDay, '{y}-{m}-{d}');
const endDate = this.parseTime(lastDay, '{y}-{m}-{d}');
return {
// 按钮loading
buttonLoading: false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 报结果存储JSON+横向对比专用)表格数据
reportResultStorageList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
reportStartDate: startDate,
reportEndDate: endDate,
reportType: undefined,
productionLine: undefined,
reportJson: undefined,
},
// 表单参数
form: {},
// 表单校验
rules: {
reportDate: [
{ required: true, message: "报表日期不能为空", trigger: "blur" }
],
reportType: [
{ required: true, message: "报表类型不能为空", trigger: "change" }
],
productionLine: [
{ required: true, message: "产线类型不能为空", trigger: "blur" }
],
},
reportTypeOptions: [
{ label: '产出消耗统计信息', value: '产出消耗统计信息' },
{ label: '产出消耗统计信息(处理M)', value: '产出消耗统计信息(处理M)' },
{ label: '产出异常信息', value: '产出异常信息' },
{ label: '班组产出汇总', value: '班组产出汇总' },
]
};
},
created() {
this.getList();
},
methods: {
/** 查询报结果存储JSON+横向对比专用)列表 */
getList() {
this.loading = true;
listReportResultStorage(this.queryParams).then(response => {
this.reportResultStorageList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
storageId: undefined,
reportDate: undefined,
reportType: undefined,
productionLine: undefined,
reportJson: undefined,
remark: undefined,
delFlag: undefined,
createTime: undefined,
createBy: undefined,
updateTime: undefined,
updateBy: undefined
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.storageId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加报结果存储JSON+横向对比专用)";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.loading = true;
this.reset();
const storageId = row.storageId || this.ids
getReportResultStorage(storageId).then(response => {
this.loading = false;
this.form = response.data;
this.open = true;
this.title = "修改报结果存储JSON+横向对比专用)";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.buttonLoading = true;
if (this.form.storageId != null) {
updateReportResultStorage(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
} else {
addReportResultStorage(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const storageIds = row.storageId || this.ids;
this.$modal.confirm('是否确认删除报结果存储JSON+横向对比专用)编号为"' + storageIds + '"的数据项?').then(() => {
this.loading = true;
return delReportResultStorage(storageIds);
}).then(() => {
this.loading = false;
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {
}).finally(() => {
this.loading = false;
});
},
/** 导出按钮操作 */
handleExport() {
this.download('wms/reportResultStorage/export', {
...this.queryParams
}, `reportResultStorage_${new Date().getTime()}.xlsx`)
}
}
};
</script>

View File

@@ -38,12 +38,6 @@
<muti-select style="width: 200px;" v-model="queryParams.itemManufacturer" <muti-select style="width: 200px;" v-model="queryParams.itemManufacturer"
:options="dict.type.coil_manufacturer" placeholder="请选择厂家" clearable @keyup.enter.native="handleQuery" /> :options="dict.type.coil_manufacturer" placeholder="请选择厂家" clearable @keyup.enter.native="handleQuery" />
</el-form-item> </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-form-item prop="endTime">
<el-button type="primary" @click="getList">查询</el-button> <el-button type="primary" @click="getList">查询</el-button>
<el-button type="primary" @click="exportData">导出</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 { listDeliveryPlan } from '@/api/wms/deliveryPlan'
import ColumnsSetting from "@/views/wms/report/components/setting/columns.vue"; import ColumnsSetting from "@/views/wms/report/components/setting/columns.vue";
import CoilTable from "@/views/wms/report/components/coilTable/index.vue"; import CoilTable from "@/views/wms/report/components/coilTable/index.vue";
import { fetchLossList } from "@/views/wms/report/js/fetch";
export default { export default {
name: 'LossTemplate', name: 'LossTemplate',
@@ -186,44 +182,11 @@ export default {
}, },
async getList() { async getList() {
this.loading = true this.loading = true
const resultList = await Promise.all(this.actionTypes.map(actionType => { fetchLossList(this.actionTypes, {
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({
...this.queryParams, ...this.queryParams,
byCreateTimeStart: undefined, ...this.actionQueryParams,
byCreateTimeEnd: undefined,
actionIds: actionIds,
}).then(res => { }).then(res => {
this.list = res.rows.map(item => { this.list = res
// 计算宽度和厚度,将规格按照*分割,*前的是厚度,*后的是宽度
const [thickness, width] = item.specification?.split('*') || [undefined, undefined]
return {
...item,
computedThickness: parseFloat(thickness),
computedWidth: parseFloat(width),
}
})
this.loading = false this.loading = false
}) })
}, },

View File

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

View File

@@ -40,7 +40,7 @@
:options="dict.type.coil_manufacturer" placeholder="请选择厂家" clearable @keyup.enter.native="handleQuery" /> :options="dict.type.coil_manufacturer" placeholder="请选择厂家" clearable @keyup.enter.native="handleQuery" />
</el-form-item> </el-form-item>
<el-form-item prop="endTime"> <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="exportData">导出</el-button>
<el-button type="primary" @click="settingVisible = true">列设置</el-button> <el-button type="primary" @click="settingVisible = true">列设置</el-button>
</el-form-item> </el-form-item>
@@ -76,6 +76,8 @@ import MutiSelect from "@/components/MutiSelect";
import WarehouseSelect from "@/components/KLPService/WarehouseSelect"; import WarehouseSelect from "@/components/KLPService/WarehouseSelect";
import ColumnsSetting from "@/views/wms/report/components/setting/columns.vue"; import ColumnsSetting from "@/views/wms/report/components/setting/columns.vue";
import CoilTable from "@/views/wms/report/components/coilTable/index.vue"; import CoilTable from "@/views/wms/report/components/coilTable/index.vue";
import { fetchOutputList } from "@/views/wms/report/js/fetch";
export default { export default {
name: 'OutTemplate', name: 'OutTemplate',
@@ -160,7 +162,7 @@ export default {
handler(newVal, oldVal) { handler(newVal, oldVal) {
if (newVal !== oldVal) { if (newVal !== oldVal) {
this.warehouseIds = newVal.map(item => item.value) this.warehouseIds = newVal.map(item => item.value)
this.getList() this.handleQuery()
} }
}, },
immediate: true, immediate: true,
@@ -186,40 +188,13 @@ export default {
}, },
// 统一查询入口 // 统一查询入口
handleQuery() { handleQuery() {
this.getList()
},
getList() {
this.loading = true this.loading = true
Promise.all([ fetchOutputList({
listCoilWithIds({ ...this.queryParams,
selectType: 'raw_material', ...this.baseQueryParams,
itemType: 'raw_material', warehouseIds: this.warehouseIds.join(','),
warehouseIds: this.warehouseIds.join(','), }).then((resList) => {
...this.queryParams, this.list = resList
...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),
}
})
this.loading = false this.loading = false
}) })
}, },
@@ -231,7 +206,7 @@ export default {
}, },
}, },
mounted() { mounted() {
this.getList() this.handleQuery()
this.loadColumns() 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 { calcSummary, calcAbSummary, calcTeamSummary, calcMSummary } from "@/views/wms/report/js/calc";
import ColumnsSetting from "@/views/wms/report/components/setting/columns.vue"; import ColumnsSetting from "@/views/wms/report/components/setting/columns.vue";
import CoilTable from "@/views/wms/report/components/coilTable/index.vue"; import CoilTable from "@/views/wms/report/components/coilTable/index.vue";
import { fetchLossList, fetchOutputList } from "@/views/wms/report/js/fetch";
export default { export default {
name: 'TeamTemplate', name: 'TeamTemplate',
@@ -263,94 +264,24 @@ export default {
this.lossColumns = JSON.parse(localStorage.getItem('preference-tableColumns-coil-report-loss') || '[]') || [] this.lossColumns = JSON.parse(localStorage.getItem('preference-tableColumns-coil-report-loss') || '[]') || []
this.outputColumns = JSON.parse(localStorage.getItem('preference-tableColumns-coil-report-output') || '[]') || [] this.outputColumns = JSON.parse(localStorage.getItem('preference-tableColumns-coil-report-output') || '[]') || []
}, },
// 统一查询入口(兼容回车和按钮点击)
handleQuery() { handleQuery() {
this.getList(); this.loading = true
// this.getLossList();
},
getList() {
this.loading = true;
Promise.all([ Promise.all([
listCoilWithIds({ fetchLossList(this.actionTypes, {
selectType: 'raw_material',
itemType: 'raw_material',
warehouseIds: this.warehouseIds.join(','),
...this.queryParams, ...this.queryParams,
...this.baseQueryParams ...this.actionQueryParams
}), }),
listCoilWithIds({ fetchOutputList({
selectType: 'product', ...this.queryParams,
itemType: 'product', ...this.baseQueryParams,
warehouseIds: this.warehouseIds.join(','), warehouseIds: this.warehouseIds.join(','),
...this.queryParams, }),
...this.baseQueryParams ]).then(([lossList, outputList]) => {
}) this.lossList = lossList
]).then(resList => { this.list = outputList
const list = resList.flatMap(res => res.rows); this.loading = false
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;
}
}, },
exportData() { exportData() {
if (this.list.length === 0) { if (this.list.length === 0) {
@@ -372,8 +303,7 @@ export default {
} }
}, },
mounted() { mounted() {
this.getList(); this.handleQuery()
// this.getLossList();
this.loadColumns(); 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 { calcSummary, calcAbSummary, calcMSummary } from "@/views/wms/report/js/calc";
import ColumnsSetting from "@/views/wms/report/components/setting/columns.vue"; import ColumnsSetting from "@/views/wms/report/components/setting/columns.vue";
import CoilTable from "@/views/wms/report/components/coilTable/index.vue"; import CoilTable from "@/views/wms/report/components/coilTable/index.vue";
import { fetchLossList, fetchOutputList } from "@/views/wms/report/js/fetch";
export default { export default {
name: 'YearTemplate', name: 'YearTemplate',
@@ -264,84 +265,20 @@ export default {
}, },
// 统一查询入口(兼容回车和按钮点击) // 统一查询入口(兼容回车和按钮点击)
handleQuery() { handleQuery() {
this.getList()
// this.getLossList()
},
// 核心查询逻辑
getList() {
this.loading = true this.loading = true
Promise.all([ Promise.all([
listCoilWithIds({ fetchLossList(this.actionTypes, {
selectType: 'raw_material', ...this.queryParams,
itemType: 'raw_material', ...this.actionQueryParams
warehouseIds: this.warehouseIds.join(','), }),
fetchOutputList({
...this.queryParams, ...this.queryParams,
...this.baseQueryParams, ...this.baseQueryParams,
}),
listCoilWithIds({
selectType: 'product',
itemType: 'product',
warehouseIds: this.warehouseIds.join(','), warehouseIds: this.warehouseIds.join(','),
...this.queryParams,
...this.baseQueryParams,
}), }),
]).then((resList) => { ]).then(([lossList, outputList]) => {
const list = resList.flatMap(res => res.rows) this.lossList = lossList
// 按照createTime 降序排序 this.list = outputList
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),
}
})
this.loading = false this.loading = false
}) })
}, },
@@ -366,8 +303,7 @@ export default {
}, },
}, },
mounted() { mounted() {
this.getList() this.handleQuery()
// this.getLossList()
this.loadColumns() this.loadColumns()
} }
} }