钱包管理
This commit is contained in:
1 parent
69b54f260b
commit
143c69e4fc
4 files changed
+411
-115
No files matched your search
@@ -1,113 +0,0 @@
|
||||
<template>
|
||||
<!-- 关联采购申请单对话框 -->
|
||||
<el-dialog v-model="linkCgCodeDialogVisible" title="选择采购单" width="70%" :close-on-click-modal="false" draggable @close="onClose">
|
||||
<vxe-table
|
||||
v-show="step === 0"
|
||||
ref="linkCgPlanTableRef"
|
||||
border
|
||||
v-loading="linkCodeLoading"
|
||||
:row-config="{ isCurrent: true, isHover: true }"
|
||||
:radio-config="{ labelField: '', trigger: 'row' }"
|
||||
:data="cgddPage"
|
||||
@radio-change="radioChangeEvent"
|
||||
>
|
||||
<vxe-column type="radio" width="60" align="center"></vxe-column>
|
||||
<vxe-column field="id" title="id" align="center" width="200"></vxe-column>
|
||||
<vxe-column field="planCode" title="编号" align="center" width="200"></vxe-column>
|
||||
<vxe-column field="planDate" title="单据日期" align="center" width="200"></vxe-column>
|
||||
<vxe-column field="handlerUserId" title="经办人" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="checkStatus" title="审批状态" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="remark" title="备注" show-overflow align="center" min-width="100"></vxe-column>
|
||||
</vxe-table>
|
||||
<!-- <pagination
|
||||
@size-change="sizeChangeHandle"
|
||||
@current-change="currentChangeHandle"
|
||||
v-model:current-page="foodQueryForm.current"
|
||||
v-model:page-size="foodQueryForm.size"
|
||||
:total="total"
|
||||
/> -->
|
||||
<vxe-table
|
||||
v-show="step === 1"
|
||||
ref="linkCgPlanSpuTableRef"
|
||||
border
|
||||
:row-config="{ isCurrent: true, isHover: true }"
|
||||
:checkbox-config="{ trigger: 'row' }"
|
||||
:data="currRadioRowItems"
|
||||
>
|
||||
<vxe-column type="checkbox" width="60" align="center"></vxe-column>
|
||||
<vxe-column field="erpSpuId" title="erpSpuId" align="center" width="200"></vxe-column>
|
||||
<vxe-column field="unit" title="包装单位" align="center" width="200"></vxe-column>
|
||||
<vxe-column field="quantity" title="数量" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="purchasePrice" title="进价" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="unitPrice" title="进价" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="totalAmount" title="累计总金额" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="remark" title="备注" show-overflow align="center" min-width="100"></vxe-column>
|
||||
</vxe-table>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="linkCgCodeDialogVisible = false">取消</el-button>
|
||||
<el-button v-show="step === 1" type="primary" @click="step--">上一步</el-button>
|
||||
<el-button v-show="step === 0" type="primary" @click="step++" :disabled="currRadioRowItems.length <= 0">下一步</el-button>
|
||||
<el-button v-show="step === 1" type="primary" @click="getSelectedRowData" :disabled="linkCodeLoading">确认</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="linkCgCodeDialog">
|
||||
import { ref } from "vue"
|
||||
import { VxeTableEvents } from "vxe-table"
|
||||
|
||||
const linkCgCodeDialogVisible = defineModel()
|
||||
const emit = defineEmits(["getSelectedCgPlan"])
|
||||
|
||||
const linkCodeLoading = ref(false) // 关联采购申请单对话框加载状态
|
||||
const linkCgPlanTableRef = ref() // 关联补货单对话框表格1ref
|
||||
const linkCgPlanSpuTableRef = ref() // 关联补货单对话框表格2ref
|
||||
const cgddPage = ref([]) // 采购申请列表数据
|
||||
const currRadioRowItems = ref([]) // 当前单选的表格行的items
|
||||
const step = ref(0) // 选择步骤
|
||||
|
||||
// 打开关联补货单对话框
|
||||
const openLinkCodeDialog = async () => {
|
||||
linkCgCodeDialogVisible.value = true
|
||||
step.value = 0
|
||||
linkCodeLoading.value = true
|
||||
try {
|
||||
const res = await getCgInventoryPage({}).finally(() => (linkCodeLoading.value = false))
|
||||
if (res.code === 0) {
|
||||
cgddPage.value = res.data.records
|
||||
}
|
||||
} catch (error) {
|
||||
cgddPage.value = []
|
||||
linkCodeLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 单选时
|
||||
const radioChangeEvent: VxeTableEvents.RadioChange<any> = ({ row }) => (currRadioRowItems.value = row.items)
|
||||
|
||||
// 获取选择的关联补货单对话框表格行数据
|
||||
const getSelectedRowData = () => {
|
||||
const $table = linkCgPlanTableRef.value
|
||||
const $SpuTable = linkCgPlanSpuTableRef.value
|
||||
if ($table && $SpuTable) {
|
||||
const currRadioRow = $table.getRadioRecord()
|
||||
console.log("currRadioRow", currRadioRow)
|
||||
const currSpuRows = $SpuTable.getCheckboxRecords()
|
||||
console.log("currSpuRows", currSpuRows)
|
||||
|
||||
emit("getSelectedCgPlan", { ...currRadioRow, items: currSpuRows })
|
||||
}
|
||||
}
|
||||
|
||||
// 对话框关闭
|
||||
const onClose = () => {
|
||||
linkCgCodeDialogVisible.value = false
|
||||
currRadioRowItems.value = []
|
||||
cgddPage.value = []
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
openLinkCodeDialog,
|
||||
})
|
||||
</script>
|
||||
@@ -171,8 +171,14 @@
|
||||
@getSelectedSpuRows="getSelectedSpuRows"
|
||||
/>
|
||||
|
||||
<linkCodeDialog ref="linkCgPlanDialogRef" v-model="state.linkCgPlanDialogVisible" title="关联采购订单"
|
||||
:getTableData="getCgInventoryPage({inventoryType: "3"})" @getSelectedLinkCode="getSelectedLinkCode" />
|
||||
<linkCodeDialog
|
||||
ref="linkCgPlanDialogRef"
|
||||
v-model="state.linkCgPlanDialogVisible"
|
||||
title="关联采购订单"
|
||||
:getTableData="getCgInventoryPage"
|
||||
@getSelectedLinkCode="getSelectedLinkCode"
|
||||
/>
|
||||
<!-- {inventoryType: "3"} -->
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
<template>
|
||||
<el-dialog title="修改余额" v-model="visible" width="30%" :close-on-click-modal="false" draggable>
|
||||
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="120px" v-loading="loading">
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="用户编号" prop="id">
|
||||
<el-input v-model="form.id" placeholder="" disabled />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="用户昵称" prop="nickname">
|
||||
<el-input v-model="form.nickname" placeholder="" disabled />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="变动前余额(元)" prop="balance">
|
||||
<el-input v-model="form.balance" placeholder="" disabled />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="变动类型" prop="changeType">
|
||||
<el-radio-group v-model="form.changeType">
|
||||
<el-radio :label="1">充值</el-radio>
|
||||
<el-radio :label="-1">减少</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="变动余额(元)" prop="changeBalance">
|
||||
<el-input-number v-model="form.changeBalance" :min="0" :precision="2" :step="0.1" class="!w-240px" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="变动后余额(元)" prop="balanceResult">
|
||||
<el-input v-model="balanceResult" placeholder="" disabled />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" @click="onSubmit" :disabled="loading">确认</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="WalletManageDialog">
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
import { useMessage } from "/@/hooks/message"
|
||||
import * as walletApi from "/@/api/wallet/wallet-manage"
|
||||
import * as walletTransactionApi from "/@/api/wallet/wallet-transaction"
|
||||
import * as AdminUserApi from "/@/api/admin/user"
|
||||
import { rule } from "/@/utils/validate"
|
||||
import { displayPrice } from "/@/utils/formatMoney"
|
||||
import { convertToInteger } from "/@/utils/convert"
|
||||
const emit = defineEmits(["refresh"])
|
||||
|
||||
// 定义变量内容
|
||||
const dataFormRef = ref()
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
// 定义字典
|
||||
|
||||
// 提交表单数据
|
||||
const form = reactive<any>({
|
||||
id: undefined,
|
||||
walletId: undefined,
|
||||
nickname: undefined,
|
||||
balance: "0",
|
||||
changeBalance: 0,
|
||||
changeType: 1,
|
||||
})
|
||||
|
||||
/** 变动后的余额 */
|
||||
const balanceResult = computed(() =>
|
||||
displayPrice(convertToInteger(form.balance) + convertToInteger(form.changeBalance) * form.changeType),
|
||||
)
|
||||
|
||||
// 定义校验规则
|
||||
const dataRules = ref({
|
||||
changeBalance: [{ required: true, message: "变动余额不能为空", trigger: "blur" }],
|
||||
})
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = (userId: string, id: string) => {
|
||||
visible.value = true
|
||||
form.id = ""
|
||||
// 重置表单数据
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields()
|
||||
})
|
||||
// 获取walletManage信息
|
||||
if (id) {
|
||||
form.id = id
|
||||
getwalletManageData(userId, id)
|
||||
}
|
||||
}
|
||||
|
||||
// 提交
|
||||
const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {})
|
||||
if (!valid) return false
|
||||
if (form.changeBalance <= 0) {
|
||||
useMessage().error("变动余额不能为零")
|
||||
return
|
||||
}
|
||||
if (convertToInteger(balanceResult.value) < 0) {
|
||||
useMessage().error("变动后的余额不能小于 0")
|
||||
return
|
||||
}
|
||||
try {
|
||||
loading.value = true
|
||||
const pa = {
|
||||
...form,
|
||||
userId: form.id,
|
||||
walletId: form.walletId,
|
||||
balance: form.changeBalance * 100,
|
||||
}
|
||||
if (pa.changeType == -1) {
|
||||
pa.balance = -1 * pa.balance
|
||||
}
|
||||
await walletTransactionApi.updateBalance(pa)
|
||||
useMessage().success("操作成功")
|
||||
visible.value = false
|
||||
emit("refresh")
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化表单数据
|
||||
const getwalletManageData = async (userId: string, id: string) => {
|
||||
// 获取数据
|
||||
loading.value = true
|
||||
try {
|
||||
const { data: user } = await AdminUserApi.getObj(userId)
|
||||
const { data: wallet } = await walletApi.getObj(id)
|
||||
form.id = user.userId
|
||||
form.walletId = wallet.id
|
||||
form.nickname = user.nickname
|
||||
form.balance = displayPrice(wallet.balance, "")
|
||||
form.changeType = 1
|
||||
form.changeBalance = 0
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 暴露变量
|
||||
defineExpose({
|
||||
openDialog,
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,241 @@
|
||||
<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"
|
||||
>
|
||||
<template #default>
|
||||
<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="userId">
|
||||
<select-user v-model="state.queryForm.userId" />
|
||||
</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" />
|
||||
</template>
|
||||
</DraggableDepTree>
|
||||
</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 draggableDepTreeRef = 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, 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",
|
||||
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 handleGetSelectNode = (curClickedNode: any, checkedTreeNodes: any, isDeepTree: any) => {
|
||||
state.queryForm.deptId = curClickedNode.id
|
||||
state.queryForm.deptIds = checkedTreeNodes.map((item: any) => item.id)
|
||||
state.queryForm.isDeepDept = 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>
|
||||
Reference in new issue
Block a user