From 480f1e02edd5f5981d06b9660d8f5c0e5c4555eb Mon Sep 17 00:00:00 2001 From: Echo <1711788888@qq.com> Date: Sat, 10 May 2025 08:35:43 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=20=E7=94=A8=E6=88=B7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E6=96=B0=E5=A2=9E=E4=BF=AE=E6=94=B9=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BD=99=E9=A2=9D=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/user/index.js | 9 ++++ src/view/user/user/index.vue | 83 +++++++++++++++++++++++++++++++++++- 2 files changed, 90 insertions(+), 2 deletions(-) diff --git a/src/api/user/index.js b/src/api/user/index.js index f5675f8..e794d06 100644 --- a/src/api/user/index.js +++ b/src/api/user/index.js @@ -38,3 +38,12 @@ export const register = (data) => { data }) } + +// 修改用户余额 +export const setBalance = (data) => { + return service({ + url: '/app_user/setBalance', + method: 'put', + data + }) +} diff --git a/src/view/user/user/index.vue b/src/view/user/user/index.vue index da0d2b6..b89b76d 100644 --- a/src/view/user/user/index.vue +++ b/src/view/user/user/index.vue @@ -61,12 +61,46 @@ + + + + + {{ currentUser.balance }} + + + + + + + + import searchForm from '@/components/searchForm/index.vue' import Content from '@/components/content/index.vue' - import {list, status, getUserDetail, register} from '@/api/user/index.js' + import {list, status, getUserDetail, register, setBalance} from '@/api/user/index.js' import { ref, onMounted } from 'vue' import {formatDate} from '@/utils/format' import { USER_SEARCH_CONFIG, USER_TABLE_CONFIG } from '@/config' @@ -278,6 +312,51 @@ } }) } + + const balanceDialogVisible = ref(false) + const balanceFormRef = ref(null) + const currentUser = ref({}) + const balanceForm = ref({ + ID: '', + balance: 0 + }) + + const balanceRules = { + balance: [ + { required: true, message: '请输入余额', trigger: 'blur' }, + { type: 'number', min: 0, message: '余额不能小于0', trigger: 'blur' } + ] + } + + function handleBalance(row) { + currentUser.value = row + balanceForm.value = { + ID: row.ID, + balance: row.balance + } + balanceDialogVisible.value = true + } + + function handleBalanceClose() { + balanceDialogVisible.value = false + balanceFormRef.value?.resetFields() + } + + async function submitBalance() { + if (!balanceFormRef.value) return + await balanceFormRef.value.validate(async (valid) => { + if (valid) { + const res = await setBalance(balanceForm.value) + if (res.code === 0) { + ElMessage.success('修改成功') + handleBalanceClose() + getList() + } else { + ElMessage.error(res.msg || '修改失败') + } + } + }) + }