|
|
@@ -61,8 +61,8 @@ const pagination = reactive({
|
|
|
// 角色选项
|
|
|
const roleOptions = [
|
|
|
{ label: '管理员', value: 'admin' },
|
|
|
+ { label: '专家', value: 'expert' },
|
|
|
{ label: '普通用户', value: 'user' },
|
|
|
- // { label: '访客', value: 'guest' }
|
|
|
]
|
|
|
|
|
|
// 是否编辑模式
|
|
|
@@ -80,6 +80,43 @@ const handleReset = () => {
|
|
|
handleSearch()
|
|
|
}
|
|
|
|
|
|
+const balanceDialog = reactive({
|
|
|
+ visible: false,
|
|
|
+ userId: 0,
|
|
|
+ userName: '',
|
|
|
+ amount: 100,
|
|
|
+ loading: false,
|
|
|
+})
|
|
|
+
|
|
|
+async function openBalanceDialog(row: UserVo) {
|
|
|
+ balanceDialog.userId = Number(row.id)
|
|
|
+ balanceDialog.userName = row.username ?? ''
|
|
|
+ balanceDialog.amount = 100
|
|
|
+ balanceDialog.visible = true
|
|
|
+}
|
|
|
+
|
|
|
+async function confirmBalance() {
|
|
|
+ balanceDialog.loading = true
|
|
|
+ try {
|
|
|
+ const { getWalletController } = await import('../api/wallet-controller')
|
|
|
+ const res = await getWalletController().adminRecharge({
|
|
|
+ userId: balanceDialog.userId,
|
|
|
+ amount: balanceDialog.amount,
|
|
|
+ remark: '管理员调整余额',
|
|
|
+ })
|
|
|
+ if (res.code === 200) {
|
|
|
+ ElMessage.success('余额调整成功')
|
|
|
+ balanceDialog.visible = false
|
|
|
+ } else {
|
|
|
+ ElMessage.error('调整失败')
|
|
|
+ }
|
|
|
+ } catch {
|
|
|
+ ElMessage.error('调整失败')
|
|
|
+ } finally {
|
|
|
+ balanceDialog.loading = false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// 获取数据
|
|
|
const fetchData = async () => {
|
|
|
loading.value = true
|
|
|
@@ -358,11 +395,14 @@ fetchData()
|
|
|
<el-avatar v-else :size="40">{{ row.username?.charAt(0) || '?' }}</el-avatar>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="操作" width="180" align="center" fixed="right">
|
|
|
+ <el-table-column label="操作" width="280" align="center" fixed="right">
|
|
|
<template #default="{ row }">
|
|
|
<el-button type="primary" link @click="handleEdit(row)">
|
|
|
<el-icon><Edit /></el-icon>编辑
|
|
|
</el-button>
|
|
|
+ <el-button type="warning" link @click="openBalanceDialog(row)">
|
|
|
+ <el-icon><Edit /></el-icon>余额
|
|
|
+ </el-button>
|
|
|
<el-button type="danger" link @click="handleDelete(row)">
|
|
|
<el-icon><Delete /></el-icon>删除
|
|
|
</el-button>
|
|
|
@@ -408,6 +448,19 @@ fetchData()
|
|
|
<el-button type="primary" @click="handleSave">确定</el-button>
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
+
|
|
|
+ <el-dialog v-model="balanceDialog.visible" title="调整余额" width="400px">
|
|
|
+ <p>用户:{{ balanceDialog.userName }}</p>
|
|
|
+ <el-form>
|
|
|
+ <el-form-item label="金额">
|
|
|
+ <el-input-number v-model="balanceDialog.amount" :min="1" :max="999999" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <el-button @click="balanceDialog.visible = false">取消</el-button>
|
|
|
+ <el-button type="primary" :loading="balanceDialog.loading" @click="confirmBalance">确认</el-button>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|