feat(常量): 添加超级管理员ID和启用状态常量
在核心常量文件中添加 SUPERADMIN_USER_ID 和 EnableStatus 常量 在用户管理页面中使用新常量替代硬编码值
This commit is contained in:
parent
35c96b3a9e
commit
b84eabf1c9
@ -10,6 +10,7 @@ import { computed, ref } from 'vue';
|
||||
|
||||
import { useAccess } from '@vben/access';
|
||||
import { Page, useVbenDrawer, useVbenModal } from '@vben/common-ui';
|
||||
import { EnableStatus, SUPERADMIN_USER_ID } from '@vben/constants';
|
||||
import { $t } from '@vben/locales';
|
||||
import { preferences } from '@vben/preferences';
|
||||
|
||||
@ -204,7 +205,7 @@ async function handleChangeStatus(checked: boolean, row: User) {
|
||||
console.log(checked);
|
||||
await userStatusChange({
|
||||
userId: row.userId,
|
||||
status: checked ? '0' : '1',
|
||||
status: checked ? EnableStatus.Enable : EnableStatus.Disable,
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@ -258,16 +259,17 @@ async function handleChangeStatus(checked: boolean, row: User) {
|
||||
<template #status="{ row }">
|
||||
<!-- value只能接收boolean值 -->
|
||||
<ApiSwitch
|
||||
:value="row.status === '0'"
|
||||
:value="row.status === EnableStatus.Enable"
|
||||
:api="(checked) => handleChangeStatus(checked, row)"
|
||||
:disabled="
|
||||
row.userId === 1 || !hasAccessByCodes(['system:user:edit'])
|
||||
row.userId === SUPERADMIN_USER_ID ||
|
||||
!hasAccessByCodes(['system:user:edit'])
|
||||
"
|
||||
@reload="() => tableApi.query()"
|
||||
/>
|
||||
</template>
|
||||
<template #action="{ row }">
|
||||
<template v-if="row.userId !== 1">
|
||||
<template v-if="row.userId !== SUPERADMIN_USER_ID">
|
||||
<Space>
|
||||
<ghost-button
|
||||
v-access:code="['system:user:edit']"
|
||||
|
||||
@ -36,3 +36,16 @@ export const BUSINESS_SUCCESS_CODE = 200;
|
||||
* 未授权 状态码(登录超时)
|
||||
*/
|
||||
export const UNAUTHORIZED_CODE = 401;
|
||||
|
||||
/**
|
||||
* 超管用户ID
|
||||
*/
|
||||
export const SUPERADMIN_USER_ID = 1;
|
||||
|
||||
/**
|
||||
* 对应 字典-S系统开关的状态
|
||||
*/
|
||||
export const EnableStatus = {
|
||||
Enable: '0',
|
||||
Disable: '1',
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user