213 lines
7.1 KiB
Vue
213 lines
7.1 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>
|
|
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
|
|
<el-row>
|
|
<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="walletTypeId">
|
|
<select-wallet-type v-model="state.queryForm.walletTypeId" placeholder="饭卡类型" clearable />
|
|
</el-form-item>
|
|
<el-form-item style="width: 200px" label="月份" prop="walletRecordMonth">
|
|
<el-date-picker
|
|
v-model="state.queryForm.walletRecordMonth"
|
|
value-format="YYYY-MM"
|
|
type="month"
|
|
:clearable="false"
|
|
placeholder="选择月份"
|
|
/>
|
|
</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%">
|
|
<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_walletRecord_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 v-auth="'wallet_walletManage_del'" 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="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="lastTopUpTime" width="200" label="最后充值时间">
|
|
<template #default="{ row }">
|
|
<span v-if="row.lastTopUpTime">{{ row.lastTopUpTime }}</span>
|
|
<span v-else class="color-danger">本月未充值</span>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
|
|
</template>
|
|
</DraggableDepTree>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts" name="systemWalletManage">
|
|
import { BasicTableProps, useTable } from "/@/hooks/table"
|
|
import { fetchListJoinQb, delObjs } from "/@/api/wallet/wallet-manage"
|
|
import { useMessage, useMessageBox } from "/@/hooks/message"
|
|
import { useDict } from "/@/hooks/dict"
|
|
import { displayPrice } from "/@/utils/formatMoney"
|
|
import { formatDate } from "/@/utils/formatTime"
|
|
|
|
const { wallet_type, yes_no_type } = useDict("wallet_type", "yes_no_type")
|
|
// 定义变量内容
|
|
const draggableDepTreeRef = ref()
|
|
// 搜索变量
|
|
const queryRef = ref()
|
|
const showSearch = ref(true)
|
|
// 多选变量
|
|
const selectObjs = ref([]) as any
|
|
const multiple = ref(true)
|
|
|
|
const state: BasicTableProps = reactive<BasicTableProps>({
|
|
queryForm: {
|
|
walletRecordMonth: formatDate(new Date(), "YYYY-mm"),
|
|
},
|
|
pageList: fetchListJoinQb,
|
|
})
|
|
|
|
// 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()
|
|
}
|
|
|
|
// 导出excel
|
|
const exportExcel = () => {
|
|
postDownBlobFile(
|
|
"/wallet/wallet-manage/export-qb",
|
|
Object.assign(state.queryForm, { current: state.pagination?.current, size: state.pagination?.size }),
|
|
"钱包记录.xlsx",
|
|
)
|
|
}
|
|
|
|
const getSummaries = (param: any) => {
|
|
const { columns, data } = param
|
|
const totalColumns = ["balance"]
|
|
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 delObjs(ids)
|
|
getDataList()
|
|
useMessage().success("删除成功")
|
|
} catch (err: any) {
|
|
useMessage().error(err.msg)
|
|
}
|
|
}
|
|
</script>
|