refactor(wms): 优化单据明细报表检索逻辑传递flag参数控制是否计算汇总数量
This commit is contained in:
parent
6997c003d0
commit
0486b30874
@ -17,7 +17,7 @@
|
||||
</input-multiple-select-dialog>
|
||||
<basic-container style="margin-top: -20px">
|
||||
<c-top-bar :offset="50">
|
||||
<el-button type="text" icon="el-icon-search" @click="doRetrieve()">检索</el-button>
|
||||
<el-button type="text" icon="el-icon-search" @click="doRetrieve(true)">检索</el-button>
|
||||
<el-divider direction="vertical"></el-divider>
|
||||
<el-button type="text" icon="el-icon-circle-close" @click="doClear()">清除</el-button>
|
||||
<el-divider direction="vertical"></el-divider>
|
||||
@ -491,6 +491,7 @@ import {
|
||||
this.doRetrieve();
|
||||
},
|
||||
|
||||
// 检索按钮
|
||||
async doRetrieve(flag) {
|
||||
let me = this;
|
||||
if (flag) {
|
||||
@ -524,15 +525,24 @@ import {
|
||||
};
|
||||
showLoading();
|
||||
try {
|
||||
// 根据flag条件决定是否执行汇总数量计算
|
||||
let promises = [
|
||||
pageDocumentDetailed(Object.assign(params, me.page))
|
||||
];
|
||||
console.log(flag);
|
||||
if (flag) {
|
||||
// 只有当flag为true时才添加汇总数量的异步请求
|
||||
promises.push(totalAsyncFunction(Object.assign(params)));
|
||||
}
|
||||
|
||||
// 并行执行多个异步请求
|
||||
const [documentResponse, totalResponse] = await Promise.all([
|
||||
pageDocumentDetailed(Object.assign(params, me.page)),
|
||||
// 异步计算汇总数量
|
||||
totalAsyncFunction(Object.assign(params)),
|
||||
]);
|
||||
const results = await Promise.all(promises);
|
||||
|
||||
hideLoading();
|
||||
|
||||
const documentResponse = results[0];
|
||||
const totalResponse = flag ? results[1] : null;
|
||||
|
||||
// 处理 pageDocumentDetailed 的响应
|
||||
if (!documentResponse.data.data || documentResponse.data.data.length === 0) {
|
||||
this.$message.error('检索无数据');
|
||||
@ -543,15 +553,17 @@ import {
|
||||
me.page.total = documentResponse.data.data.total;
|
||||
me.page.current = documentResponse.data.data.current;
|
||||
|
||||
// 处理汇总数量的响应数据
|
||||
me.formObj.totalQty = totalResponse.data.data
|
||||
|
||||
// 处理汇总数量的响应数据(仅当flag为true时)
|
||||
if (flag && totalResponse) {
|
||||
me.formObj.totalQty = totalResponse.data.data;
|
||||
}
|
||||
} catch (error) {
|
||||
hideLoading();
|
||||
console.error(error);
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
getMultipleField(ref) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user