收入明细网格结构优化

This commit is contained in:
WindowBird 2025-08-26 09:11:31 +08:00
parent 04e2fd29bc
commit 5e09db3d16

View File

@ -42,7 +42,7 @@
<view v-else-if="cardList.length === 0" class="empty-container"> <view v-else-if="cardList.length === 0" class="empty-container">
<text class="empty-text">暂无数据</text> <text class="empty-text">暂无数据</text>
</view> </view>
<cash-flow-card v-else v-for="(item, index) in cardList" :key="index" :cardData="item" /> <cash-flow-card v-for="(item, index) in cardList" v-else :key="index" :cardData="item" />
</view> </view>
<!-- 底部弹窗 --> <!-- 底部弹窗 -->
<uni-popup ref="popup" :mask-click="true" type="bottom"> <uni-popup ref="popup" :mask-click="true" type="bottom">
@ -91,11 +91,7 @@ export default {
date: currentDate, date: currentDate,
startDate: this.getDate('start'), startDate: this.getDate('start'),
endDate: this.getDate('end'), endDate: this.getDate('end'),
expenseTypes: [ expenseTypes: ['提现', '订单'],
'提现',
'订单',
'其他'
],
cardList: [], cardList: [],
loading: false, loading: false,
} }
@ -145,27 +141,27 @@ export default {
this.closePopup() this.closePopup()
this.loadBalanceLogData() this.loadBalanceLogData()
}, },
// //
async loadBalanceLogData() { async loadBalanceLogData() {
if (this.loading) return if (this.loading) return
this.loading = true this.loading = true
try { try {
// //
const now = new Date() const now = new Date()
const endTime = now.toISOString().slice(0, 19).replace('T', ' ') const endTime = now.toISOString().slice(0, 19).replace('T', ' ')
const params = { const params = {
beginCreateTime: this.date + ' 00:00:01', beginCreateTime: this.date + ' 00:00:01',
endCreateTime: endTime endCreateTime: endTime,
} }
console.log('查询参数:', { console.log('查询参数:', {
beginCreateTime: params.beginCreateTime, beginCreateTime: params.beginCreateTime,
endCreateTime: params.endCreateTime endCreateTime: params.endCreateTime,
}) })
// //
if (this.expenseType !== '全部类型') { if (this.expenseType !== '全部类型') {
if (this.expenseType === '提现') { if (this.expenseType === '提现') {
@ -180,94 +176,92 @@ export default {
} else { } else {
console.log('查询类型: 全部类型') console.log('查询类型: 全部类型')
} }
const response = await getBalanceLogList(params) const response = await getBalanceLogList(params)
console.log('API响应:', response) console.log('API响应:', response)
if (response.code === 200 && response.data) { if (response.code === 200 && response.data) {
this.processBalanceLogData(response.data) this.processBalanceLogData(response.data)
} else { } else {
console.error('获取数据失败:', response.msg) console.error('获取数据失败:', response.msg)
uni.showToast({ uni.showToast({
title: response.msg || '获取数据失败', title: response.msg || '获取数据失败',
icon: 'none' icon: 'none',
}) })
} }
} catch (error) { } catch (error) {
console.error('API调用失败:', error) console.error('API调用失败:', error)
uni.showToast({ uni.showToast({
title: '网络错误,请重试', title: '网络错误,请重试',
icon: 'none' icon: 'none',
}) })
} finally { } finally {
this.loading = false this.loading = false
} }
}, },
// //
processBalanceLogData(data) { processBalanceLogData(data) {
this.cardList = data.map(item => { this.cardList = data.map(item => {
// //
const totalExpense = Math.abs(item.totalExpense || 0) const totalExpense = Math.abs(item.totalExpense || 0)
const totalIncome = item.totalIncome || 0 const totalIncome = item.totalIncome || 0
// //
let items = item.balanceLogList.map(log => { let items = item.balanceLogList.map(log => {
const createTime = new Date(log.createTime) const createTime = new Date(log.createTime)
const time = createTime.toTimeString().substring(0, 5) // HH:mm const time = createTime.toTimeString().substring(0, 5) // HH:mm
return { return {
title: this.getTitleByBstType(log.bstType), title: this.getTitleByBstType(log.bstType),
status: this.getStatusByBstType(log.bstType), status: this.getStatusByBstType(log.bstType),
time: time, time: time,
orderNumber: log.id, orderNumber: log.id,
amount: log.amount, amount: log.amount,
bstType: log.bstType // bstType: log.bstType, //
} }
}) })
// "" // ""
if (this.expenseType === '其他') { if (this.expenseType === '其他') {
const originalCount = items.length const originalCount = items.length
items = items.filter(item => items = items.filter(item => item.bstType !== 'WITHDRAW' && item.bstType !== 'ORDER')
item.bstType !== 'WITHDRAW' && item.bstType !== 'ORDER'
)
console.log(`其他类型过滤: 原始${originalCount}条,过滤后${items.length}`) console.log(`其他类型过滤: 原始${originalCount}条,过滤后${items.length}`)
} }
// //
const date = this.formatDateForDisplay(item.createTime) const date = this.formatDateForDisplay(item.createTime)
return { return {
date: date, date: date,
outflow: totalExpense, outflow: totalExpense,
inflow: totalIncome, inflow: totalIncome,
items: items items: items,
} }
}) })
// //
this.updateTotalAmounts() this.updateTotalAmounts()
}, },
// //
getTitleByBstType(bstType) { getTitleByBstType(bstType) {
const titleMap = { const titleMap = {
'WITHDRAW': '提现', WITHDRAW: '提现',
'ORDER': '订单' ORDER: '订单',
} }
return titleMap[bstType] || '其他' return titleMap[bstType] || '其他'
}, },
// //
getStatusByBstType(bstType) { getStatusByBstType(bstType) {
const statusMap = { const statusMap = {
'WITHDRAW': '审核中', WITHDRAW: '审核中',
'ORDER': '' ORDER: '',
} }
return statusMap[bstType] || '' return statusMap[bstType] || ''
}, },
// //
formatDateForDisplay(dateString) { formatDateForDisplay(dateString) {
const date = new Date(dateString) const date = new Date(dateString)
@ -276,17 +270,17 @@ export default {
const day = date.getDate() const day = date.getDate()
return `${year}${month}${day}` return `${year}${month}${day}`
}, },
// //
updateTotalAmounts() { updateTotalAmounts() {
let totalExpense = 0 let totalExpense = 0
let totalIncome = 0 let totalIncome = 0
this.cardList.forEach(card => { this.cardList.forEach(card => {
totalExpense += card.outflow totalExpense += card.outflow
totalIncome += card.inflow totalIncome += card.inflow
}) })
this.expenditures = totalExpense.toFixed(2) this.expenditures = totalExpense.toFixed(2)
this.Recorded = totalIncome.toFixed(2) this.Recorded = totalIncome.toFixed(2)
}, },
@ -420,7 +414,7 @@ view {
} }
.type-item { .type-item {
width: 30%; width: 45%;
height: 100rpx; height: 100rpx;
background-color: #fff; background-color: #fff;
border-radius: 10rpx; border-radius: 10rpx;