219 lines
7.3 KiB
Vue
219 lines
7.3 KiB
Vue
<template>
|
|
<div class="layout-padding">
|
|
<div class="layout-padding-auto layout-padding-view">
|
|
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
|
|
<el-row :gutter="24">
|
|
<el-col :span="4">
|
|
<el-form-item class="w100" label="用户" prop="userIds">
|
|
<select-user v-model="state.queryForm.userIds" />
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="4">
|
|
<el-form-item class="w100" label="饭卡卡号" prop="cardNumber">
|
|
<el-input v-model="state.queryForm.cardNumber" placeholder="饭卡卡号" clearable />
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="4">
|
|
<el-form-item class="w100" label="饭卡类型" prop="walletTypeId">
|
|
<select-wallet-type v-model="state.queryForm.walletTypeId" placeholder="饭卡类型" clearable />
|
|
</el-form-item>
|
|
</el-col>
|
|
<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%">
|
|
<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="selection" width="40" align="center" />
|
|
<el-table-column type="index" label="#" width="80" />
|
|
<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="200">
|
|
<template #default="{ row }">
|
|
<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
|
|
>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
|
|
</div>
|
|
<transaction-list ref="formDialogRef" @refresh="getDataList(false)" />
|
|
<change-balance ref="changeBalanceRef" @refresh="getDataList(false)" />
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts" name="systemWalletManage">
|
|
import { BasicTableProps, useTable } from "/@/hooks/table"
|
|
import { fetchList, fetchListJoin, delObjs } from "/@/api/wallet/wallet-manage"
|
|
import { useMessage, useMessageBox } from "/@/hooks/message"
|
|
import { useDict } from "/@/hooks/dict"
|
|
import { displayPrice } from "/@/utils/formatMoney"
|
|
|
|
// 引入组件
|
|
const TransactionList = defineAsyncComponent(() => import("../components/transaction-list.vue"))
|
|
const ChangeBalance = defineAsyncComponent(() => import("./change-balance.vue"))
|
|
// 定义查询字典
|
|
const { wallet_type, yes_no_type } = useDict("wallet_type", "yes_no_type")
|
|
// 定义变量内容
|
|
const formDialogRef = ref()
|
|
const changeBalanceRef = ref()
|
|
// 搜索变量
|
|
const queryRef = ref()
|
|
const showSearch = ref(true)
|
|
// 多选变量
|
|
const selectObjs = ref([]) as any
|
|
const multiple = ref(true)
|
|
|
|
const state: BasicTableProps = reactive<BasicTableProps>({
|
|
queryForm: {},
|
|
pageList: fetchListJoin,
|
|
})
|
|
|
|
// table hook
|
|
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } =
|
|
useTable(state)
|
|
|
|
// 清空搜索条件
|
|
const resetQuery = () => {
|
|
// 清空搜索条件
|
|
queryRef.value?.resetFields()
|
|
// 清空多选
|
|
selectObjs.value = []
|
|
getDataList()
|
|
}
|
|
|
|
// 导出excel
|
|
const exportExcel = () => {
|
|
downBlobFile(
|
|
"/wallet/wallet-manage/export",
|
|
Object.assign(state.queryForm, { current: state.pagination?.current, size: state.pagination?.size }),
|
|
"walletManage.xlsx",
|
|
)
|
|
}
|
|
|
|
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 handleDelete = async (ids: string[]) => {
|
|
try {
|
|
await useMessageBox().confirm("此操作将永久删除")
|
|
} catch {
|
|
return
|
|
}
|
|
|
|
try {
|
|
await delObjs(ids)
|
|
getDataList()
|
|
useMessage().success("删除成功")
|
|
} catch (err: any) {
|
|
useMessage().error(err.msg)
|
|
}
|
|
}
|
|
</script>
|