|
@@ -106,6 +106,18 @@
|
|
|
@change="(checked) => onSendCountAutoApproveChange(record, checked)"
|
|
@change="(checked) => onSendCountAutoApproveChange(record, checked)"
|
|
|
/>
|
|
/>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
+ <template #is_banned_status="{ record }">
|
|
|
|
|
+ <a-tag v-if="isBanned(record)" color="red">已封禁</a-tag>
|
|
|
|
|
+ <a-tag v-else color="green">正常</a-tag>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <template #is_banned="{ record }">
|
|
|
|
|
+ <a-switch
|
|
|
|
|
+ :model-value="isBanned(record)"
|
|
|
|
|
+ :loading="banLoadingUuid === record.uuid"
|
|
|
|
|
+ checked-color="rgb(var(--red-6))"
|
|
|
|
|
+ @change="(checked) => onBanChange(record, checked)"
|
|
|
|
|
+ />
|
|
|
|
|
+ </template>
|
|
|
<template #optional="{ record }">
|
|
<template #optional="{ record }">
|
|
|
<a-button @click="changeCount(record)">更改次数</a-button>
|
|
<a-button @click="changeCount(record)">更改次数</a-button>
|
|
|
</template>
|
|
</template>
|
|
@@ -132,8 +144,8 @@
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
import { ref, reactive, onMounted } from 'vue'
|
|
import { ref, reactive, onMounted } from 'vue'
|
|
|
-import { adminGetUserList, adminChangeLepaoCount, adminSetSendCountAutoApprove } from '@/api/user'
|
|
|
|
|
-import { Notification, Message } from '@arco-design/web-vue'
|
|
|
|
|
|
|
+import { adminGetUserList, adminChangeLepaoCount, adminSetSendCountAutoApprove, adminSetUserBan } from '@/api/user'
|
|
|
|
|
+import { Notification, Message, Modal } from '@arco-design/web-vue'
|
|
|
|
|
|
|
|
const visible = ref(false)
|
|
const visible = ref(false)
|
|
|
const ok_loading = ref(false)
|
|
const ok_loading = ref(false)
|
|
@@ -159,8 +171,10 @@ const pagination = reactive({
|
|
|
const loading = ref(false)
|
|
const loading = ref(false)
|
|
|
const data = ref([])
|
|
const data = ref([])
|
|
|
const whitelistLoadingUuid = ref('')
|
|
const whitelistLoadingUuid = ref('')
|
|
|
|
|
+const banLoadingUuid = ref('')
|
|
|
|
|
|
|
|
const isSendCountAutoApprove = (record) => Number(record?.send_count_auto_approve) === 1
|
|
const isSendCountAutoApprove = (record) => Number(record?.send_count_auto_approve) === 1
|
|
|
|
|
+const isBanned = (record) => Number(record?.is_banned) === 1
|
|
|
|
|
|
|
|
const onSendCountAutoApproveChange = async (record, checked) => {
|
|
const onSendCountAutoApproveChange = async (record, checked) => {
|
|
|
if (!record?.uuid || whitelistLoadingUuid.value) return
|
|
if (!record?.uuid || whitelistLoadingUuid.value) return
|
|
@@ -190,6 +204,48 @@ const onSendCountAutoApproveChange = async (record, checked) => {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+const setUserBan = async (record, next) => {
|
|
|
|
|
+ banLoadingUuid.value = record.uuid
|
|
|
|
|
+ try {
|
|
|
|
|
+ const res = await adminSetUserBan({
|
|
|
|
|
+ userid: record.uuid,
|
|
|
|
|
+ is_banned: next
|
|
|
|
|
+ })
|
|
|
|
|
+ if (!res || res.code !== 0) {
|
|
|
|
|
+ Notification.error({
|
|
|
|
|
+ title: '操作失败',
|
|
|
|
|
+ content: res?.msg ?? '请稍后再试'
|
|
|
|
|
+ })
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ record.is_banned = next
|
|
|
|
|
+ Message.success(next ? '已封禁该用户' : '已解除封禁')
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ Notification.error({
|
|
|
|
|
+ title: '操作失败',
|
|
|
|
|
+ content: error.message || '请稍后再试'
|
|
|
|
|
+ })
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ banLoadingUuid.value = ''
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const onBanChange = async (record, checked) => {
|
|
|
|
|
+ if (!record?.uuid || banLoadingUuid.value) return
|
|
|
|
|
+ const next = checked === true ? 1 : 0
|
|
|
|
|
+ if (next === 1) {
|
|
|
|
|
+ Modal.confirm({
|
|
|
|
|
+ title: '确认封禁',
|
|
|
|
|
+ content: `确定封禁用户「${record.username || record.uuid}」?封禁后该用户将立即下线且无法登录。`,
|
|
|
|
|
+ onOk: async () => {
|
|
|
|
|
+ await setUserBan(record, next)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ await setUserBan(record, 0)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const columns = [
|
|
const columns = [
|
|
|
|
|
|
|
|
{
|
|
{
|
|
@@ -235,6 +291,14 @@ const columns = [
|
|
|
title: '赠送免审',
|
|
title: '赠送免审',
|
|
|
slotName: 'send_count_auto_approve',
|
|
slotName: 'send_count_auto_approve',
|
|
|
width: 110,
|
|
width: 110,
|
|
|
|
|
+ }, {
|
|
|
|
|
+ title: '账号状态',
|
|
|
|
|
+ slotName: 'is_banned_status',
|
|
|
|
|
+ width: 100,
|
|
|
|
|
+ }, {
|
|
|
|
|
+ title: '封禁',
|
|
|
|
|
+ slotName: 'is_banned',
|
|
|
|
|
+ width: 80,
|
|
|
}, {
|
|
}, {
|
|
|
title: '操作',
|
|
title: '操作',
|
|
|
slotName: 'optional',
|
|
slotName: 'optional',
|