mirror of
https://gitee.com/java110/MicroCommunityWeb.git
synced 2026-02-23 21:36:37 +08:00
优化代码
This commit is contained in:
parent
1a8a946d49
commit
4c6155bee3
@ -19,6 +19,8 @@ export function queryReportFeeSummary(params) {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询楼栋费用汇总数据
|
||||
* @param {Object} params 查询参数
|
||||
|
||||
@ -246,14 +246,52 @@ export default {
|
||||
params.configIds = this.reportFeeSummaryInfo.configIds.join(',');
|
||||
}
|
||||
|
||||
const { data } = await queryReportFeeSummary(params)
|
||||
this.reportFeeSummaryInfo.fees = data
|
||||
// 定义需要查询的字段类型
|
||||
const queryTypes = [
|
||||
'roomCount',
|
||||
'feeRoomCount',
|
||||
'oweRoomCount',
|
||||
'hisOweFee',
|
||||
'curOweFee',
|
||||
'curReceivableFee',
|
||||
'hisReceivedFee',
|
||||
'preReceivedFee',
|
||||
'receivedFee'
|
||||
]
|
||||
|
||||
// Notify child components
|
||||
this.$refs.floorFeeSummary.notify(params)
|
||||
this.$refs.configFeeSummary.notify(params)
|
||||
// 合并结果的对象
|
||||
const mergedResult = {}
|
||||
|
||||
// 串行查询每个字段
|
||||
for (const queryType of queryTypes) {
|
||||
try {
|
||||
const queryParams = { ...params, queryType }
|
||||
const { data } = await queryReportFeeSummary(queryParams)
|
||||
if (data && data.length > 0 && data[0]) {
|
||||
// 将返回的数据合并到结果对象中
|
||||
Object.assign(mergedResult, data[0])
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Failed to query ${queryType}:`, error)
|
||||
// 如果某个字段查询失败,设置为默认值
|
||||
const fieldName = queryType === 'roomCount' || queryType === 'feeRoomCount' || queryType === 'oweRoomCount' ? queryType : queryType
|
||||
mergedResult[fieldName] = queryType.includes('Count') ? 0 : 0.00
|
||||
}
|
||||
}
|
||||
|
||||
// 将合并后的结果放入数组中(因为表格期望数组格式)
|
||||
this.reportFeeSummaryInfo.fees = [mergedResult]
|
||||
|
||||
// 通知子组件查询(子组件内部自己查询)
|
||||
if (this.$refs.floorFeeSummary) {
|
||||
this.$refs.floorFeeSummary.notify(params)
|
||||
}
|
||||
if (this.$refs.configFeeSummary) {
|
||||
this.$refs.configFeeSummary.notify(params)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to query fee summary:', error)
|
||||
this.$message.error(this.$t('reportFeeSummary.queryFailed') || '查询失败,请稍后重试')
|
||||
}
|
||||
},
|
||||
async _loadStaffCommunitys() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user