实现流水明细查询页面初始加载逻辑

This commit is contained in:
wkc
2026-03-10 16:47:32 +08:00
parent d95de8a692
commit ab1c06e631

View File

@@ -25,6 +25,36 @@ import {
getBankStatementDetail getBankStatementDetail
} from "@/api/ccdiProjectBankStatement"; } from "@/api/ccdiProjectBankStatement";
const createDefaultQueryParams = (projectId) => ({
projectId,
pageNum: 1,
pageSize: 10,
tabType: "all",
transactionStartTime: "",
transactionEndTime: "",
counterpartyName: "",
counterpartyNameEmpty: false,
userMemo: "",
userMemoEmpty: false,
ourSubjects: [],
ourBanks: [],
ourAccounts: [],
amountMin: "",
amountMax: "",
counterpartyAccount: "",
counterpartyAccountEmpty: false,
transactionType: "",
transactionTypeEmpty: false,
orderBy: "trxDate",
orderDirection: "desc",
});
const createEmptyOptionData = () => ({
ourSubjectOptions: [],
ourBankOptions: [],
ourAccountOptions: [],
});
export default { export default {
name: "DetailQuery", name: "DetailQuery",
props: { props: {
@@ -41,9 +71,91 @@ export default {
}), }),
}, },
}, },
data() {
return {
loading: false,
optionsLoading: false,
activeTab: "all",
dateRange: [],
list: [],
total: 0,
queryParams: createDefaultQueryParams(this.projectId),
optionData: createEmptyOptionData(),
};
},
created() {
this.getList();
this.getOptions();
},
watch: {
projectId() {
this.syncProjectId();
this.getOptions();
this.getList();
},
},
methods: { methods: {
getList() {}, async getList() {
getOptions() {}, this.syncProjectId();
if (!this.queryParams.projectId) {
this.list = [];
this.total = 0;
return;
}
this.loading = true;
try {
const res = await listBankStatement(this.queryParams);
this.list = res.rows || [];
this.total = res.total || 0;
} catch (error) {
this.list = [];
this.total = 0;
console.error("加载流水明细失败", error);
} finally {
this.loading = false;
}
},
async getOptions() {
this.syncProjectId();
if (!this.queryParams.projectId) {
this.optionData = createEmptyOptionData();
return;
}
this.optionsLoading = true;
try {
const res = await getBankStatementOptions(this.queryParams.projectId);
const data = res.data || {};
this.optionData = {
ourSubjectOptions: data.ourSubjectOptions || [],
ourBankOptions: data.ourBankOptions || [],
ourAccountOptions: data.ourAccountOptions || [],
};
} catch (error) {
this.optionData = createEmptyOptionData();
console.error("加载流水筛选项失败", error);
} finally {
this.optionsLoading = false;
}
},
syncProjectId() {
this.queryParams.projectId = this.projectId;
this.queryParams.tabType = this.activeTab;
},
handleQuery() {
this.queryParams.pageNum = 1;
this.queryParams.tabType = this.activeTab;
this.getList();
},
resetQuery() {
this.activeTab = "all";
this.dateRange = [];
this.queryParams = createDefaultQueryParams(this.projectId);
this.syncProjectId();
this.getOptions();
this.getList();
},
handleExport() { handleExport() {
void listBankStatement; void listBankStatement;
void getBankStatementOptions; void getBankStatementOptions;