feat:导出

This commit is contained in:
dzc committed 2025-12-17 14:32:57 +08:00
1 parent 0e204406d2
commit 5bc7de8913
5 files changed
+245 -40

No files matched your search

+24
View File
@@ -35,6 +35,30 @@ export function pageCz(query?: any) {
})
}
export function pageCzTotal(query?: any) {
return request({
url: "/wallet/wallet-transaction/page-cz-total",
method: "post",
params: {
current: query.current,
size: query.size,
},
data: query,
})
}
export function listDeptCzTotal(query?: any) {
return request({
url: "/wallet/wallet-transaction/page-cz-dept-total",
method: "post",
params: {
current: query.current,
size: query.size,
},
data: query,
})
}
export function czTotal(data?: any) {
return request({
url: "/wallet/wallet-transaction/cz-total",
@@ -283,7 +283,7 @@ const submitData = async () => {
// 点击继续添加
const onContinueAdd = async () => {
;(await baseFormValidate()) && (await itemTableFormValidate()) && (await submitData()) && clearData() && emit("refresh")
(await baseFormValidate()) && (await itemTableFormValidate()) && (await submitData()) && clearData() && emit("refresh")
}
// 点击保存
+1 -1
View File
@@ -115,7 +115,7 @@ onMounted(() => {
watch(
() => props.groupId,
(val) => {
if (!!val) {
if (val) {
form.value.groupId = parseInt(val);
}
}
+16 -38
View File
@@ -20,38 +20,22 @@
<el-row>
<div class="mb8" style="width: 100%">
<el-button icon="RefreshLeft" type="primary" class="ml10" @click="syncAll"> 同步全部 </el-button>
<el-button icon="folder-add" type="primary" class="ml10" @click="formDialogRef.openDialog()" v-auth="'wallet_mchDeptUser_add'">
<el-button icon="folder-add" type="primary" class="ml10" @click="formDialogRef.openDialog()"
v-auth="'wallet_mchDeptUser_add'">
新 增
</el-button>
<el-button
plain
:disabled="multiple"
icon="Delete"
type="primary"
v-auth="'wallet_mchDeptUser_del'"
@click="handleDelete(selectObjs)"
>
<el-button plain :disabled="multiple" icon="Delete" type="primary" v-auth="'wallet_mchDeptUser_del'"
@click="handleDelete(selectObjs)">
删除
</el-button>
<right-toolbar
v-model:showSearch="showSearch"
:export="'wallet_mchDeptUser_export'"
@exportExcel="exportExcel"
class="ml10 mr20"
style="float: right"
@queryTable="getDataList"
></right-toolbar>
<right-toolbar v-model:showSearch="showSearch" :export="'wallet_mchDeptUser_export'"
@exportExcel="exportExcel" class="ml10 mr20" style="float: right"
@queryTable="getDataList"></right-toolbar>
</div>
</el-row>
<el-table
:data="state.dataList"
v-loading="state.loading"
border
:cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle"
@selection-change="selectionChangHandle"
@sort-change="sortChangeHandle"
>
<el-table :data="state.dataList" v-loading="state.loading" border :cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle" @selection-change="selectionChangHandle"
@sort-change="sortChangeHandle">
<el-table-column type="selection" width="40" align="center" />
<el-table-column type="index" label="#" width="80" />
<el-table-column label="商户">
@@ -64,21 +48,15 @@
</el-table-column>
<el-table-column label="操作" width="150">
<template #default="scope">
<el-button
icon="edit-pen"
text
type="primary"
v-auth="'wallet_mchDeptUser_edit'"
@click="formDialogRef.openDialog(scope.row.id)"
>编辑</el-button
>
<el-button icon="delete" text type="primary" v-auth="'wallet_mchDeptUser_del'" @click="handleDelete([scope.row.id])"
>删除</el-button
>
<el-button icon="edit-pen" text type="primary" v-auth="'wallet_mchDeptUser_edit'"
@click="formDialogRef.openDialog(scope.row.id)">编辑</el-button>
<el-button icon="delete" text type="primary" v-auth="'wallet_mchDeptUser_del'"
@click="handleDelete([scope.row.id])">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle"
v-bind="state.pagination" />
</div>
<!-- 编辑、新增 -->
+203
View File
@@ -0,0 +1,203 @@
<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">
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
<el-row>
<el-form-item style="width: 300px" label="充值金额(元)" prop="price">
<el-input v-model="state.queryForm.price" placeholder="请输入充值金额(元)" />
</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 v-if="false" style="width: 200px" label="充值类型" prop="type">
<dict-select v-model="state.queryForm.type" dict-code="wallet_biz_recharge" />
</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>
<el-form-item>
<el-button icon="Search" type="primary" @click="getDataList">
{{ $t("common.queryBtn") }}
</el-button>
<el-button icon="Refresh" @click="resetQuery">
{{ $t("common.resetBtn") }}
</el-button>
</el-form-item>
</el-row>
</el-form>
<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">
</right-toolbar>
</div>
</el-row>
<el-table :data="state.dataList" v-loading="state.loading" border :cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle" :summary-method="getSummaries" :show-summary="true"
row-class-name="success-row" @selection-change="selectionChangHandle"
@sort-change="sortChangeHandle" @expand-change="tableExpandChange">
<el-table-column type="expand" width="60">
<template #default="{ row }">
<div class="ml-[60px] my-2">
<el-table :data="getTableChildrenMap(row.mchId)" border
:cell-style="tableStyle.cellStyle" :header-cell-style="tableStyle.headerCellStyle"
row-class-name="warning-row">
<el-table-column type="index" label="#" width="60" />
<el-table-column label="部门" align="center" width="250" prop="deptName" />
<el-table-column label="充值金额" align="center" width="250" prop="price">
<template #default="{ row }">
<span>{{ displayPrice(row.price) }}</span>
</template>
</el-table-column>
<el-table-column label="充值人数" align="center" width="250" prop="personCount">
<template #default="{ row }">
<span class="color-primary">{{ row.personCount || 0 }}人</span>
</template>
</el-table-column>
<el-table-column label="充值次数" align="center" prop="timeCount">
<template #default="{ row }">
<span class="color-success">{{ row.timeCount || 0 }}次</span>
</template>
</el-table-column>
</el-table>
</div>
</template>
</el-table-column>
<el-table-column type="index" label="#" width="60" />
<el-table-column label="所属食堂" align="center" width="250" prop="mchName" />
<el-table-column label="充值金额" align="center" width="250" prop="price">
<template #default="{ row }">
<span>{{ displayPrice(row.price) }}</span>
</template>
</el-table-column>
<el-table-column label="充值人数" align="center" width="250" prop="personCount">
<template #default="{ row }">
<span class="color-primary">{{ row.personCount || 0 }}人</span>
</template>
</el-table-column>
<el-table-column label="充值次数" align="center" prop="timeCount">
<template #default="{ row }">
<span class="color-success">{{ row.timeCount || 0 }}次</span>
</template>
</el-table-column>
</el-table>
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle"
v-bind="state.pagination" />
</DraggableDepTree>
</div>
</div>
</template>
<script setup lang="ts" name="systemWalletRecharge">
import { BasicTableProps, useTable } from "/@/hooks/table"
import * as walletTransactionApi from "/@/api/wallet/wallet-transaction"
import { useDict } from "/@/hooks/dict"
import { displayPrice } from "/@/utils/formatMoney"
const state: BasicTableProps = reactive<BasicTableProps>({
isPage: false,
queryForm: {},
pageList: walletTransactionApi.pageCzTotal,
})
// 搜索变量
const queryRef = ref()
const showSearch = ref(true)
// 多选变量
const selectObjs = ref([]) as any
const multiple = ref(true)
const draggableDepTreeRef = ref()
const tableChildrenMap = ref(new Map<string, any>())
// 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()
}
// 点击table展开行
const tableExpandChange = async (e: any) => {
try {
const { data } = await walletTransactionApi.listDeptCzTotal({
mchId: e.mchId,
...state.queryForm
})
if (data && data.length) {
tableChildrenMap.value.set(e.mchId, data)
}
} catch (error: any) {
console.error(error);
}
}
const getTableChildrenMap = (key: string) => {
return tableChildrenMap.value.get(key)
}
// 树节点选择时
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()
}
// 导出excel
const exportExcel = () => {
postDownBlobFile(
"/wallet/export-cz-total",
Object.assign(state.queryForm, { current: state.pagination?.current, size: state.pagination?.size }),
"钱包充值统计.xlsx",
)
}
// 多选事件
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", "personCount", "timeCount"]
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) => Number(pren) + Number(next), 0)
if (i.property === "price") {
totalRow[index] = displayPrice(total)
} else {
totalRow[index] = total
}
}
})
return totalRow
}
</script>
<style>
.el-table .warning-row {
--el-table-tr-bg-color: var(--el-color-warning-light-9);
}
.el-table .success-row {
--el-table-tr-bg-color: var(--el-color-success-light-9);
}
</style>