Files
pj_admin_cloud/src/views/wallet/wallet-xf/index.vue
T
2026-09-08 15:25:06 +08:00

305 lines
10 KiB
Vue

<template>
<div class="layout-padding">
<div class="layout-padding-auto layout-padding-view">
<DraggableDepTree
ref="draggableDepTreeRef"
placeholder="请输入部门名称"
:show-expand="true"
@getSelectNode="handleGetSelectNode"
switch-inactive-text="包含"
switch-active-text="不包含"
:defaultTreeWidth="20"
:nodeClickable="false"
>
<template #default>
<SearchPanel
v-show="showSearch"
ref="queryRef"
:model="state.queryForm"
:loading="Boolean(state.loading)"
:search-text="$t('common.queryBtn')"
:reset-text="$t('common.resetBtn')"
@search="getDataList"
@reset="resetQuery"
>
<el-form-item style="width: 300px" label="用户" prop="userId">
<select-user v-model="state.queryForm.userId" />
</el-form-item>
<el-form-item style="width: 200px" label="充值方式" prop="bizType">
<dict-select v-model="state.queryForm.bizType" dict-code="wallet_biz" />
</el-form-item>
<el-form-item style="width: 250px" label="钱包类型" prop="walletTypeIdList">
<select-wallet-type multiple v-model="state.queryForm.walletTypeIdList" placeholder="饭卡类型" clearable />
</el-form-item>
<el-form-item style="width: 300px" label="消费时间" prop="createTimeList">
<el-date-picker v-model="state.queryForm.createTimeList" value-format="YYYY-MM-DD" type="daterange" />
</el-form-item>
</SearchPanel>
<el-row>
<div class="mb8" style="width: 100%">
<right-toolbar
:search="false"
v-model:showSearch="showSearch"
:export="'wallet_walletTransaction_export'"
@exportExcel="exportExcel"
class="ml10 mr20"
style="float: right"
@queryTable="getDataList"
>
<el-button icon="DataLine" circle @click="viewBalanceStatistics" />
</right-toolbar>
</div>
</el-row>
<el-table
:data="state.dataList"
v-loading="state.loading"
border
:summary-method="getSummaries"
show-summary
:cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle"
@selection-change="selectionChangHandle"
@sort-change="sortChangeHandle"
>
<el-table-column type="index" label="#" width="60" />
<el-table-column width="120" prop="username" label="用户" show-overflow-tooltip />
<el-table-column prop="userAvatar" label="头像" show-overflow-tooltip>
<template #default="{ row }">
<preview-image :src="row.userAvatar" />
</template>
</el-table-column>
<el-table-column prop="userMobile" width="120" label="手机号" show-overflow-tooltip />
<el-table-column prop="walletTypeUniqueCode" width="200" label="饭卡类型">
<template #default="{ row }">
<div class="flex items-center justify-center">
<div class="color-primary">{{ row.walletTypeName }}</div>
<div class="flex items-center just ml5">
<dict-tag :options="wallet_type" :value="row.walletTypeUniqueCode" />
</div>
</div>
</template>
</el-table-column>
<el-table-column prop="wallet_biz" width="200" label="交易类型">
<template #default="{ row }">
<dict-tag :options="wallet_biz" :value="row.bizType" />
</template>
</el-table-column>
<el-table-column prop="price" align="center" width="200" label="消费金额">
<template #default="{ row }">
<div class="color-danger">{{ displayPrice(row.price) }}</div>
</template>
</el-table-column>
<el-table-column prop="remark" label="备注" min-width="180" show-overflow-tooltip />
<el-table-column prop="createTime" width="200" label="消费时间" />
<el-table-column label="操作" width="240" fixed="right" class-name="wallet-tx-actions-col">
<template #default="{ row }">
<div class="row-actions">
<el-button icon="InfoFilled" link type="primary" @click="doRefund(row)"> 详情 </el-button>
<el-button
icon="EditPen"
link
type="primary"
v-auth="'wallet_walletTransaction_edit'"
@click="remarkFormRef?.openDialog(row)"
>修改备注</el-button
>
<el-button
icon="Edit"
link
type="primary"
v-auth="'wallet_walletTransaction_update_info'"
@click="infoFormRef?.openDialog(row)"
>修改信息</el-button
>
</div>
</template>
</el-table-column>
</el-table>
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
</template>
</DraggableDepTree>
</div>
<!-- 编辑、新增 -->
<form-dialog ref="formDialogRef" @refresh="getDataList(false)" />
<transaction-remark-form ref="remarkFormRef" @refresh="getDataList(false)" />
<transaction-info-form ref="infoFormRef" @refresh="getDataList(false)" />
<el-drawer v-model="showDrawer" @closed="drawerClose">
<el-table :data="[balanceStatistics]" style="width: 100%">
<el-table-column align="center" label="充值统计">
<el-table-column align="center" prop="total" label="充值金额">
<template #default="{ row }">
{{ displayPrice(row.totalPrice) }}
</template>
</el-table-column>
<el-table-column align="center" prop="eatTotalPrice" label="饭卡钱包充值金额">
<template #default="{ row }">
{{ displayPrice(row.eatTotalPrice) }}
</template>
</el-table-column>
<el-table-column align="center" prop="xfTotalPrice" label="消费钱包充值金额">
<template #default="{ row }">
{{ displayPrice(row.xfTotalPrice) }}
</template>
</el-table-column>
<el-table-column align="center" prop="xfTotalPrice" label="充值钱包记账扣款金额">
<template #default="{ row }">
{{ displayPrice(row.topupTotalPrice) }}
</template>
</el-table-column>
</el-table-column>
</el-table>
</el-drawer>
</div>
</template>
<script setup lang="ts" name="systemWalletRecharge">
import dayjs from "dayjs"
import { BasicTableProps, useTable } from "/@/hooks/table"
import { pageXf, xfTotal } from "/@/api/wallet/wallet-transaction"
import { useMessage } from "/@/hooks/message"
import { useDict } from "/@/hooks/dict"
import { displayPrice } from "/@/utils/formatMoney"
import { deptTree } from "/@/api/admin/dept"
const { push } = useRouter()
const showDrawer = ref(false)
const balanceStatisticsLoading = ref(false)
const balanceStatistics = reactive<any>({})
// 引入组件
const FormDialog = defineAsyncComponent(() => import("./form.vue"))
// 所有钱包流水列表共用的备注编辑表单。
const TransactionRemarkForm = defineAsyncComponent(() => import("../components/transaction-remark-form.vue"))
// 所有钱包流水列表共用的流水信息编辑表单(部门、创建时间)。
const TransactionInfoForm = defineAsyncComponent(() => import("../components/transaction-info-form.vue"))
// 定义查询字典
const { wallet_type, wallet_biz } = useDict("wallet_type", "wallet_biz")
// 定义变量内容
const formDialogRef = ref()
// 通用流水备注编辑弹窗引用。
const remarkFormRef = ref()
// 通用流水信息编辑弹窗引用。
const infoFormRef = ref()
// 搜索变量
const queryRef = ref()
const showSearch = ref(true)
// 多选变量
const selectObjs = ref([]) as any
const multiple = ref(true)
const draggableDepTreeRef = ref() // 树组件ref引用
const defaultCreateTimeList = [
dayjs().subtract(3, "month").startOf("day").format("YYYY-MM-DD"),
dayjs().hour(23).minute(23).second(23).format("YYYY-MM-DD"),
]
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {
createTimeList: defaultCreateTimeList,
},
pageList: pageXf,
})
// table hook
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, postDownBlobFile, tableStyle } = useTable(state)
// 清空搜索条件
const resetQuery = () => {
// 清空搜索条件
queryRef.value?.resetFields()
// 清空多选
selectObjs.value = []
state.queryForm.deptId = ""
state.queryForm.deptIds = []
draggableDepTreeRef.value.resetData()
getDataList()
}
// 关闭抽屉
const drawerClose = () => {
for (const key in balanceStatistics) {
balanceStatistics[key] = 0
}
}
const viewBalanceStatistics = async () => {
showDrawer.value = true
balanceStatisticsLoading.value = true
try {
const { code, data } = await xfTotal({ ...state.queryForm })
if (code == 0) {
Object.assign(balanceStatistics, data)
return
}
return useMessage().error(data.msg || "获取数据失败")
} catch (error: any) {
useMessage().error(error.msg)
} finally {
balanceStatisticsLoading.value = false
}
}
// 导出excel
const exportExcel = () => {
postDownBlobFile(
"/wallet/wallet-transaction/export-xf",
Object.assign(state.queryForm, { current: state.pagination?.current, size: state.pagination?.size }),
"消费记录.xlsx",
)
}
const doRefund = (row: any) => {
push({ path: "/hard/hard-after-sale/order-refund", query: { id: row.bizId, type: "view" } })
}
// 多选事件
const selectionChangHandle = (objs: { id: string }[]) => {
selectObjs.value = objs.map(({ id }) => id)
multiple.value = !objs.length
}
const getSummaries = (param: any) => {
const { columns, data } = param
const totalColumns = ["price"]
const totalRow = Array.from({ length: columns.length })
columns.forEach((i: any, index: number) => {
if (totalColumns.includes(i.property)) {
const total = data
.filter((v: any) => v[i.property] != null)
.map((v: any) => v[i.property])
.reduce((pren: number, next: number) => pren + next, 0)
totalRow[index] = displayPrice(total)
}
})
return totalRow
}
// 树节点选择时
const handleGetSelectNode = (curClickedNode: any, checkedTreeNodes: any, isDeepTree: any) => {
state.queryForm.deptId = curClickedNode.id
state.queryForm.deptIds = checkedTreeNodes.map((item: any) => item.id)
state.queryForm.isInclude = !isDeepTree
getDataList()
}
</script>
<style scoped lang="scss">
/* 操作列按钮改为紧凑 flex 布局并收窄单元格内边距,避免按钮换行和两侧留白。 */
.row-actions {
display: flex;
align-items: center;
justify-content: center;
gap: 4px;
white-space: nowrap;
:deep(.el-button + .el-button) {
margin-left: 0;
}
}
:deep(.wallet-tx-actions-col .cell) {
padding: 0 6px;
}
</style>