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 || '修改失败')
+ }
+ }
+ })
+ }