feat:记账扣款余额判断

This commit is contained in:
dzc committed 2025-04-15 10:32:08 +08:00
1 parent 44b344dcec
commit 46b5d4aa46
1 file changed
+65 -4
@@ -23,13 +23,22 @@
>
<el-table-column type="index" label="#" align="center" width="60" />
<el-table-column prop="username" label="用户" align="center" width="120" />
<el-table-column prop="userAvatar" label="头像" align="center" width="120">
<el-table-column prop="userMobile" label="手机号" align="center" width="120" />
<el-table-column prop="bizType" label="充值类型" align="center" width="100">
<dict-tag :options="wallet_biz_recharge" :value="detail.bizType" />
</el-table-column>
<el-table-column prop="prenBalance" label="操作前余额" align="center" min-width="180">
<template #default="{ row }">
<preview-image :src="row.userAvatar" />
<span class="color-primary">{{ displayPrice(row.prenBalance) }}</span>
</template>
</el-table-column>
<el-table-column prop="userMobile" label="手机号" align="center" width="120" />
<el-table-column prop="currentImport_price" label="操作金额" align="center" min-width="250">
<el-table-column v-if="detail.bizType == 2" prop="discountBalance" label="记账扣款后余额" align="center" min-width="180">
<template #default="{ row }">
<div class="color-danger">{{ displayPrice(row.discountBalance) }}</div>
<div v-if="row.discountBalance < 0" class="color-danger">(余额不足记账扣款)</div>
</template>
</el-table-column>
<el-table-column prop="currentImport_price" label="操作金额" align="center" min-width="180">
<template #default="{ row }">
<div class="color-success">{{ displayPrice(row.currentImport_price) }}</div>
</template>
@@ -76,6 +85,10 @@ import * as walletRechargeApplyApi from "/@/api/wallet/wallet-recharge-apply"
import type { VNode } from "vue"
import type { TableColumnCtx } from "element-plus"
import { h } from "vue"
import { useDict } from "/@/hooks/dict"
// 定义查询字典
const { wallet_biz_recharge } = useDict("wallet_biz_recharge")
interface SummaryMethodProps<T = any> {
columns: TableColumnCtx<T>[]
@@ -88,6 +101,7 @@ onMounted(async () => {
const id = query.id as unknown as any
state.queryForm.id = id
getList()
getDetail()
})
const state = reactive<any>({
@@ -111,6 +125,8 @@ const data = reactive<any>({
tableListStr: [],
})
const detail = ref<any>({})
const sizeChangeHandle = (e: any) => {
state.pagination.size = e
getList()
@@ -121,6 +137,15 @@ const currentChangeHandle = (e: any) => {
getList()
}
const getDetail = async () => {
try {
const { data } = await walletRechargeApplyApi.getObj(state.queryForm.id)
detail.value = data ?? {}
} catch (error) {
console.log(error)
}
}
/** 查询列表 */
const getList = async () => {
state.loading = true
@@ -173,6 +198,42 @@ const getSummaries = (param: SummaryMethodProps) => {
} else {
sums[index] = "NaN"
}
} else if (column.property === "prenBalance") {
const values = data1.map((item) => Number(item[column.property]))
if (!values.every((value) => Number.isNaN(value))) {
sums[index] = h("span", { style: { color: "#2e5cf6" } }, [
displayPrice(
values.reduce((prev, curr) => {
const value = Number(curr)
if (!Number.isNaN(value)) {
return prev + curr
} else {
return prev
}
}, 0),
),
])
} else {
sums[index] = "NaN"
}
} else if (column.property === "discountBalance") {
const values = data1.map((item) => Number(item[column.property]))
if (!values.every((value) => Number.isNaN(value))) {
sums[index] = h("span", { style: { color: "#f56c6c" } }, [
displayPrice(
values.reduce((prev, curr) => {
const value = Number(curr)
if (!Number.isNaN(value)) {
return prev + curr
} else {
return prev
}
}, 0),
),
])
} else {
sums[index] = "NaN"
}
} else if (column.property === data.tableList[0]) {
sums[index] = displayPrice(
data.list.reduce((prev: any, curr: any) => {