Archived
forked from admin/userbase
This commit is contained in:
@@ -60,6 +60,7 @@
|
||||
<script lang="ts" setup>
|
||||
import { ref, computed } from "vue";
|
||||
import { Message } from "view-ui-plus";
|
||||
import { useDefaultStore } from "@/store";
|
||||
import useCurrentInstance from "@/utils/hook/useCurrentInstance";
|
||||
import MyConfirm from "@/components/MyConfirm";
|
||||
import TablePageAlovaNew from '@/components/TablePageAlovaNew.vue';
|
||||
@@ -149,26 +150,28 @@ const tableApi = (params: { pageIndex: number; pageSize: number }) => {
|
||||
const tableHeight = ref($utils.useTableHeight({ isOperat: false, isPage: true, isSearch: true }))
|
||||
|
||||
/* ================= 用户身份(roles[])展示 ================= */
|
||||
const userTypeMap: Record<number, string> = {
|
||||
1: '管理员', 2: '老师', 3: '校领导', 4: '局领导',
|
||||
5: '学生', 6: '家长', 7: '工作号',
|
||||
};
|
||||
const roleMap: Record<number, string> = {
|
||||
1: '超级管理员', 2: '学校管理员', 3: '普通用户',
|
||||
// 唯一真源:后端 SysRoleEnum(经 GetSysDict.sysrole 下发),杜绝前端硬编码漂移。
|
||||
// roles 中仅存放 SysRoleEnum 的 key(1=老师 … 7=管理员),不再混用 UserTypeEnum。
|
||||
const SYS_ROLE_MAP_FALLBACK: Record<number, string> = {
|
||||
1: '老师', 2: '校领导', 3: '学生', 4: '家长',
|
||||
5: '局领导', 6: '工作号', 7: '管理员',
|
||||
};
|
||||
const store = useDefaultStore();
|
||||
const userTypeMap = computed<Record<number, string>>(() => {
|
||||
const sysrole = (store.getSysDict as any)?.sysrole;
|
||||
if (Array.isArray(sysrole) && sysrole.length) {
|
||||
const m: Record<number, string> = {};
|
||||
sysrole.forEach((it: any) => { m[Number(it.k)] = it.v; });
|
||||
return m;
|
||||
}
|
||||
return SYS_ROLE_MAP_FALLBACK;
|
||||
});
|
||||
function describeRoles(roles: any): string {
|
||||
if (!Array.isArray(roles) || roles.length === 0) return '-';
|
||||
const userTypes: string[] = [];
|
||||
const specificRoles: string[] = [];
|
||||
roles.forEach((r: any) => {
|
||||
const n = Number(r);
|
||||
if (userTypeMap[n]) userTypes.push(userTypeMap[n]);
|
||||
else if (roleMap[n]) specificRoles.push(roleMap[n]);
|
||||
});
|
||||
const parts: string[] = [];
|
||||
if (userTypes.length) parts.push(userTypes.join('/'));
|
||||
if (specificRoles.length) parts.push(specificRoles.join('/'));
|
||||
return parts.length ? parts.join(' · ') : '-';
|
||||
const names = roles
|
||||
.map((r: any) => userTypeMap.value[Number(r)])
|
||||
.filter((n: string) => !!n);
|
||||
return names.length ? names.join('/') : '-';
|
||||
}
|
||||
|
||||
/* ================= 表格列 ================= */
|
||||
|
||||
Reference in New Issue
Block a user