Files
pj_admin_cloud/src/views/wallet/wallet-manage/index.vue
T
2025-01-08 11:00:54 +08:00

169 lines
6.8 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-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 :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="40" />
<el-table-column 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="deptName" 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="cardNumber" label="饭卡卡号" show-overflow-tooltip />
<el-table-column prop="balance" label="余额" show-overflow-tooltip>
<template #default="{ row }">
<div class="color-primary">{{ displayPrice(row.balance) }}</div>
</template>
</el-table-column>
<el-table-column prop="totalExpense" label="累计支出" show-overflow-tooltip>
<template #default="{ row }">
<div class="color-danger">{{ displayPrice(row.totalExpense) }}</div>
</template>
</el-table-column>
<el-table-column prop="totalRecharge" label="累计充值" show-overflow-tooltip>
<template #default="{ row }">
<div class="color-success">{{ displayPrice(row.totalRecharge) }}</div>
</template>
</el-table-column>
<el-table-column prop="isFreeze" width="120" label="是否冻结饭卡" show-overflow-tooltip>
<template #default="{ row }">
<dict-tag :options="yes_no_type" :value="row.isFreeze" />
</template>
</el-table-column>
<el-table-column prop="activeBindStatus" width="120" label="饭卡绑定状态" show-overflow-tooltip />
<el-table-column prop="createTime" width="200" label="创建时间" show-overflow-tooltip />
<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_walletManage_edit'"
@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('./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/walletManage/export', Object.assign(state.queryForm, { ids: selectObjs }), 'walletManage.xlsx')
}
// 多选事件
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>