|
|
@@ -15,8 +15,8 @@ import {
|
|
|
import { FieldSpecialEffectType } from '@/types/tableText.ts'
|
|
|
|
|
|
import axiosInstance from '@/utils/axios/axiosInstance.ts'
|
|
|
-import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
-import { ref } from 'vue'
|
|
|
+import { type CheckboxValueType, ElMessage, ElMessageBox } from 'element-plus'
|
|
|
+import { ref, watch } from 'vue'
|
|
|
|
|
|
type CustomTableType = InstanceType<typeof CustomTable>
|
|
|
|
|
|
@@ -140,7 +140,7 @@ const tableConfig = ref<TableConfig>({
|
|
|
otherInfo: {
|
|
|
render: (val: string[]) => {
|
|
|
// console.log(val)
|
|
|
- if (!val || val.length === 0) return '超级管理员'
|
|
|
+ if (!val || val.length === 0 || val[0] === 'all') return '全部权限'
|
|
|
console.log(val)
|
|
|
return val.map((item) => getGameName(item)).join(',')
|
|
|
}
|
|
|
@@ -187,16 +187,23 @@ const editMember = (row: any) => {
|
|
|
isEdit.value = true
|
|
|
dialogTitle.value = '修改成员'
|
|
|
|
|
|
- console.log(allGameInfo)
|
|
|
+ console.log(row)
|
|
|
isAdmin.value = !row.permission
|
|
|
|
|
|
- console.log(isAdmin.value)
|
|
|
+ const permission: string[] = [...row.permission]
|
|
|
+
|
|
|
+ if (isAdmin.value || row.permission[0] === 'all') {
|
|
|
+ const allGid = allGameInfo.map((item) => item.gid)
|
|
|
+ permission.splice(0, permission.length, ...allGid)
|
|
|
+ isCheckAllPermission.value = true
|
|
|
+ console.log('执行')
|
|
|
+ }
|
|
|
memberForm.value = {
|
|
|
adminId: row.id, // 注意字段映射
|
|
|
account: row.account,
|
|
|
name: row.name,
|
|
|
password: row.password, // 编辑时密码保留为空
|
|
|
- permission: row.permission || allGameInfo.map((item) => item.gid)
|
|
|
+ permission
|
|
|
}
|
|
|
dialogVisible.value = true
|
|
|
}
|
|
|
@@ -222,6 +229,11 @@ const saveMember = async () => {
|
|
|
delete params.adminId // 确保新增时不发送adminId
|
|
|
}
|
|
|
|
|
|
+ // 特殊处理一下全选的情况
|
|
|
+ if (params.permission.length === allGameInfo.length) {
|
|
|
+ params.permission = ['all']
|
|
|
+ }
|
|
|
+
|
|
|
const res = (await axiosInstance.post(url, params)) as ResponseInfo
|
|
|
|
|
|
if (res.code !== 0) {
|
|
|
@@ -276,6 +288,27 @@ const closePasswordDialog = () => {
|
|
|
passwordDialogVisible.value = false
|
|
|
newPassword.value = ''
|
|
|
}
|
|
|
+
|
|
|
+const isCheckAllPermission = ref<boolean>(false)
|
|
|
+const handleCheckAll = (isAllCheck: CheckboxValueType) => {
|
|
|
+ console.log(isAllCheck)
|
|
|
+ console.log(memberForm.value)
|
|
|
+ if (isAllCheck) {
|
|
|
+ memberForm.value.permission = allGameInfo.map((item) => item.gid)
|
|
|
+ } else {
|
|
|
+ memberForm.value.permission = []
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+watch(
|
|
|
+ () => memberForm.value.permission,
|
|
|
+ (val: string[]) => {
|
|
|
+ isCheckAllPermission.value = val.length === allGameInfo.length
|
|
|
+ },
|
|
|
+ {
|
|
|
+ deep: true
|
|
|
+ }
|
|
|
+)
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
@@ -338,6 +371,11 @@ const closePasswordDialog = () => {
|
|
|
clearable
|
|
|
:disabled="isAdmin"
|
|
|
>
|
|
|
+ <template #header>
|
|
|
+ <el-checkbox v-model="isCheckAllPermission" @change="handleCheckAll">
|
|
|
+ 全选
|
|
|
+ </el-checkbox>
|
|
|
+ </template>
|
|
|
<el-option
|
|
|
v-for="item in allGameInfo"
|
|
|
:key="item.gid"
|