229 lines
9.2 KiB
Vue
229 lines
9.2 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="cardNumber">
|
|
<el-input v-model="state.queryForm.cardNumber" placeholder="饭卡卡号" clearable />
|
|
</el-form-item>
|
|
<el-form-item style="width: 200px" label="饭卡类型" prop="walletTypeId">
|
|
<select-wallet-type v-model="state.queryForm.walletTypeId" placeholder="饭卡类型" clearable />
|
|
</el-form-item>
|
|
<el-form-item style="width: 340px" label="钱包余额小于等于" prop="walletBalance">
|
|
<el-input v-model="state.queryForm.leBalance" type="number" placeholder="请输入金额" clearable>
|
|
<template #append>元</template>
|
|
</el-input>
|
|
</el-form-item>
|
|
</SearchPanel>
|
|
<el-row>
|
|
<div class="mb8" style="width: 100%">
|
|
<el-button plain :disabled="multiple" icon="Delete" type="primary"
|
|
v-auth="'wallet_walletManage_del'" @click="handleDelete(selectObjs)">
|
|
删除
|
|
</el-button>
|
|
<right-toolbar v-model:showSearch="showSearch" :export="'wallet_walletManage_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 :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 prop="username" width="100" label="用户" />
|
|
<el-table-column prop="userAvatar" width="80" label="头像">
|
|
<template #default="{ row }">
|
|
<preview-image :src="row.userAvatar" />
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="userMobile" width="120" label="手机号" />
|
|
<el-table-column prop="deptName" label="部门" width="200" />
|
|
<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="cardNumber" width="150" label="饭卡卡号" />
|
|
<el-table-column prop="balance" align="center" width="100" label="余额">
|
|
<template #default="{ row }">
|
|
<div class="color-primary">{{ displayPrice(row.balance) }}</div>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="totalExpense" align="center" width="100" label="累计支出">
|
|
<template #default="{ row }">
|
|
<div class="color-danger">{{ displayPrice(row.totalExpense) }}</div>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="totalRecharge" align="center" width="100" label="累计充值">
|
|
<template #default="{ row }">
|
|
<div class="color-success">{{ displayPrice(row.totalRecharge) }}</div>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="isFreeze" width="120" label="是否冻结饭卡">
|
|
<template #default="{ row }">
|
|
<dict-tag :options="yes_no_type" :value="row.isFreeze" />
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column v-if="false" prop="activeBindStatus" width="120" label="饭卡绑定状态" />
|
|
<el-table-column prop="createTime" width="200" label="创建时间" />
|
|
<el-table-column label="操作" fixed="right" width="250" v-auths="[
|
|
'wallet_walletManage_edit',
|
|
'wallet_walletTransaction_update_balance',
|
|
'wallet_walletRuleTransaction_transfer_accounts',
|
|
]">
|
|
<template #default="{ row }">
|
|
<div class="flex items-start">
|
|
<el-button icon="InfoFilled" text type="primary" v-auth="'wallet_walletManage_edit'"
|
|
@click="formDialogRef.openDialog(row.id)">
|
|
详情
|
|
</el-button>
|
|
<el-button icon="Money" text type="primary"
|
|
v-auth="'wallet_walletTransaction_update_balance'"
|
|
@click="changeBalanceRef.openDialog(row.userId, row.id)">
|
|
充值/扣款
|
|
</el-button>
|
|
<el-button v-if="row.isRule == 1" icon="SwitchFilled" text type="primary"
|
|
v-auth="'wallet_walletRuleTransaction_transfer'"
|
|
@click="doTransferAccounts(row)">
|
|
转账
|
|
</el-button>
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle"
|
|
v-bind="state.pagination" />
|
|
</template>
|
|
</DraggableDepTree>
|
|
</div>
|
|
<transaction-list ref="formDialogRef" @refresh="getDataList(false)" />
|
|
<change-balance ref="changeBalanceRef" @refresh="getDataList(false)" />
|
|
<transfer-accounts ref="transferAccountsRef" @refresh="getDataList(false)" />
|
|
<async-task-progress-component ref="exportProgressRef" :config="exportTaskConfig" @success="handleExportSuccess"
|
|
@failure="handleExportFailure" />
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts" name="systemWalletManage">
|
|
import { BasicTableProps, useTable } from "/@/hooks/table"
|
|
import * as walletManage from "/@/api/wallet/wallet-manage"
|
|
import { useMessage, useMessageBox } from "/@/hooks/message"
|
|
import { useDict } from "/@/hooks/dict"
|
|
import { displayPrice } from "/@/utils/formatMoney"
|
|
import { useBatchExport } from "/@/hooks/batchExport"
|
|
import AsyncTaskProgressComponent from "/@/components/AsyncTaskProgress.vue"
|
|
|
|
// 引入组件
|
|
const TransactionList = defineAsyncComponent(() => import("../components/transaction-list.vue"))
|
|
const ChangeBalance = defineAsyncComponent(() => import("./change-balance.vue"))
|
|
const TransferAccounts = defineAsyncComponent(() => import("./transfer-accounts.vue"))
|
|
// 定义查询字典
|
|
const { wallet_type, yes_no_type } = useDict("wallet_type", "yes_no_type")
|
|
// 定义变量内容
|
|
const formDialogRef = ref()
|
|
const changeBalanceRef = ref()
|
|
const draggableDepTreeRef = ref()
|
|
const transferAccountsRef = ref()
|
|
// 搜索变量
|
|
const queryRef = ref()
|
|
const showSearch = ref(true)
|
|
// 多选变量
|
|
const selectObjs = ref([]) as any
|
|
const multiple = ref(true)
|
|
const state: BasicTableProps = reactive<BasicTableProps>({
|
|
queryForm: {
|
|
leBalance: null,
|
|
},
|
|
pageList: walletManage.fetchListJoin,
|
|
})
|
|
|
|
// table hook
|
|
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, tableStyle } = useTable(state)
|
|
|
|
// 清空搜索条件
|
|
const resetQuery = () => {
|
|
// 清空搜索条件
|
|
queryRef.value?.resetFields()
|
|
// 清空多选
|
|
selectObjs.value = []
|
|
state.queryForm.deptId = ""
|
|
state.queryForm.deptIds = []
|
|
draggableDepTreeRef.value.resetData()
|
|
getDataList()
|
|
}
|
|
|
|
// 导出excel
|
|
const { exportProgressRef, exportTaskConfig, submitExport, handleExportSuccess, handleExportFailure } = useBatchExport({
|
|
progressUrl: "/wallet/async-task/progress", redisKey: "wallet:export:manage",
|
|
taskName: "电子钱包导出", fileName: "电子钱包.xlsx", submitTask: walletManage.submitExport,
|
|
})
|
|
|
|
const exportExcel = () => submitExport({ ...state.queryForm })
|
|
|
|
// 转账
|
|
const doTransferAccounts = (row: any) => {
|
|
// 检查配置是否正确
|
|
transferAccountsRef.value.openDialog(row.userId, row.id)
|
|
}
|
|
|
|
const getSummaries = (param: any) => {
|
|
const { columns, data } = param
|
|
const totalColumns = ["balance", "totalExpense", "totalRecharge"]
|
|
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 selectionChangHandle = (objs: { id: string }[]) => {
|
|
selectObjs.value = objs.map(({ id }) => id)
|
|
multiple.value = !objs.length
|
|
}
|
|
|
|
// 树节点选择时
|
|
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()
|
|
}
|
|
|
|
// 删除操作
|
|
const handleDelete = async (ids: string[]) => {
|
|
try {
|
|
await useMessageBox().confirm("此操作将永久删除")
|
|
} catch {
|
|
return
|
|
}
|
|
|
|
try {
|
|
await walletManage.delObjs(ids)
|
|
getDataList()
|
|
useMessage().success("删除成功")
|
|
} catch (err: any) {
|
|
useMessage().error(err.msg)
|
|
}
|
|
}
|
|
</script>
|