⚡ 优化用户状态交互逻辑.
This commit is contained in:
@@ -38,7 +38,7 @@ public enum ErrorCode implements CodeInfo {
|
|||||||
|
|
||||||
PAYLOAD_TOO_LARGE(413, "请求过大"),
|
PAYLOAD_TOO_LARGE(413, "请求过大"),
|
||||||
|
|
||||||
LOCKED(423, "当前已被锁定"),
|
LOCKED(423, "当前操作已被锁定"),
|
||||||
|
|
||||||
TOO_MANY_REQUESTS(429, "请求过快"),
|
TOO_MANY_REQUESTS(429, "请求过快"),
|
||||||
|
|
||||||
@@ -48,11 +48,9 @@ public enum ErrorCode implements CodeInfo {
|
|||||||
|
|
||||||
USER_DISABLED(700, "当前用户已禁用"),
|
USER_DISABLED(700, "当前用户已禁用"),
|
||||||
|
|
||||||
USER_LOCKED(701, "当前用户已被锁定"),
|
USER_OTHER_DEVICE_LOGIN(701, "该账号于 {} 已在其他设备登录 {}({})"),
|
||||||
|
|
||||||
OTHER_DEVICE_LOGIN(702, "该账号于 {} 已在其他设备登录 {}({})"),
|
USER_OFFLINE(702, "该账号于 {} 已被强制下线 {}({})"),
|
||||||
|
|
||||||
SESSION_OFFLINE(703, "该账号于 {} 已被强制下线 {}({})"),
|
|
||||||
|
|
||||||
// -------------------- 自定义 - 通用 --------------------
|
// -------------------- 自定义 - 通用 --------------------
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class SystemUserDTO implements Serializable {
|
|||||||
@Schema(description = "邮箱")
|
@Schema(description = "邮箱")
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
@Schema(description = "用户状态 0停用 1启用 2锁定")
|
@Schema(description = "用户状态 0停用 1启用")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@Schema(description = "最后登录时间")
|
@Schema(description = "最后登录时间")
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class SystemUserDO extends BaseDO {
|
|||||||
@TableField("email")
|
@TableField("email")
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
@Schema(description = "用户状态 0停用 1启用 2锁定")
|
@Schema(description = "用户状态 0停用 1启用")
|
||||||
@TableField("status")
|
@TableField("status")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class UserInfoDTO implements LongCacheIdModel, Serializable {
|
|||||||
@Schema(description = "邮箱")
|
@Schema(description = "邮箱")
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
@Schema(description = "用户状态 0停用 1启用 2锁定")
|
@Schema(description = "用户状态 0停用 1启用")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class SystemUserQueryRequest extends PageRequest {
|
|||||||
@Schema(description = "邮箱")
|
@Schema(description = "邮箱")
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
@Schema(description = "用户状态 0停用 1启用 2锁定")
|
@Schema(description = "用户状态 0停用 1启用")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class SystemUserUpdateStatusRequest implements Serializable {
|
|||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Schema(description = "用户状态 0停用 1启用 2锁定")
|
@Schema(description = "用户状态 0停用 1启用")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class SystemUserVO implements Serializable {
|
|||||||
@Schema(description = "邮箱")
|
@Schema(description = "邮箱")
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
@Schema(description = "用户状态 0停用 1启用 2锁定")
|
@Schema(description = "用户状态 0停用 1启用")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@Schema(description = "最后登录时间")
|
@Schema(description = "最后登录时间")
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public enum LoginTokenStatusEnum {
|
|||||||
@Override
|
@Override
|
||||||
public RuntimeException toException(LoginTokenDTO token) {
|
public RuntimeException toException(LoginTokenDTO token) {
|
||||||
LoginTokenIdentityDTO override = token.getOverride();
|
LoginTokenIdentityDTO override = token.getOverride();
|
||||||
return ErrorCode.OTHER_DEVICE_LOGIN.exception(
|
return ErrorCode.USER_OTHER_DEVICE_LOGIN.exception(
|
||||||
Dates.format(new Date(override.getLoginTime()), Dates.MD_HM),
|
Dates.format(new Date(override.getLoginTime()), Dates.MD_HM),
|
||||||
override.getAddress(),
|
override.getAddress(),
|
||||||
override.getLocation());
|
override.getLocation());
|
||||||
@@ -47,7 +47,7 @@ public enum LoginTokenStatusEnum {
|
|||||||
@Override
|
@Override
|
||||||
public RuntimeException toException(LoginTokenDTO token) {
|
public RuntimeException toException(LoginTokenDTO token) {
|
||||||
LoginTokenIdentityDTO override = token.getOverride();
|
LoginTokenIdentityDTO override = token.getOverride();
|
||||||
return ErrorCode.SESSION_OFFLINE.exception(
|
return ErrorCode.USER_OFFLINE.exception(
|
||||||
Dates.format(new Date(override.getLoginTime()), Dates.MD_HM),
|
Dates.format(new Date(override.getLoginTime()), Dates.MD_HM),
|
||||||
override.getAddress(),
|
override.getAddress(),
|
||||||
override.getLocation());
|
override.getLocation());
|
||||||
|
|||||||
@@ -25,11 +25,6 @@ public enum UserStatusEnum {
|
|||||||
*/
|
*/
|
||||||
ENABLED(1),
|
ENABLED(1),
|
||||||
|
|
||||||
/**
|
|
||||||
* 2 锁定
|
|
||||||
*/
|
|
||||||
LOCKED(2),
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
private final Integer status;
|
private final Integer status;
|
||||||
@@ -55,9 +50,6 @@ public enum UserStatusEnum {
|
|||||||
if (UserStatusEnum.DISABLED.getStatus().equals(status)) {
|
if (UserStatusEnum.DISABLED.getStatus().equals(status)) {
|
||||||
// 禁用状态
|
// 禁用状态
|
||||||
throw ErrorCode.USER_DISABLED.exception();
|
throw ErrorCode.USER_DISABLED.exception();
|
||||||
} else if (UserStatusEnum.LOCKED.getStatus().equals(status)) {
|
|
||||||
// 锁定状态
|
|
||||||
throw ErrorCode.USER_LOCKED.exception();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -242,22 +242,6 @@ public class AuthenticationServiceImpl implements AuthenticationService {
|
|||||||
String failedCountKey = UserCacheKeyDefine.LOGIN_FAILED_COUNT.format(request.getUsername());
|
String failedCountKey = UserCacheKeyDefine.LOGIN_FAILED_COUNT.format(request.getUsername());
|
||||||
Long failedLoginCount = redisTemplate.opsForValue().increment(failedCountKey);
|
Long failedLoginCount = redisTemplate.opsForValue().increment(failedCountKey);
|
||||||
RedisUtils.setExpire(failedCountKey, appAuthenticationConfig.getLoginFailedLockTime(), TimeUnit.MINUTES);
|
RedisUtils.setExpire(failedCountKey, appAuthenticationConfig.getLoginFailedLockTime(), TimeUnit.MINUTES);
|
||||||
// // 锁定用户
|
|
||||||
// if (failedLoginCount >= appAuthenticationConfig.getLoginFailedLockCount()) {
|
|
||||||
// // 更新用户表
|
|
||||||
// SystemUserDO updateUser = new SystemUserDO();
|
|
||||||
// updateUser.setId(user.getId());
|
|
||||||
// updateUser.setStatus(UserStatusEnum.LOCKED.getStatus());
|
|
||||||
// systemUserDAO.updateById(updateUser);
|
|
||||||
// // 修改缓存状态
|
|
||||||
// String userInfoKey = UserCacheKeyDefine.USER_INFO.format(user.getId());
|
|
||||||
// String userInfoCache = redisTemplate.opsForValue().get(userInfoKey);
|
|
||||||
// if (userInfoCache != null) {
|
|
||||||
// LoginUser loginUser = JSON.parseObject(userInfoCache, LoginUser.class);
|
|
||||||
// loginUser.setStatus(UserStatusEnum.LOCKED.getStatus());
|
|
||||||
// RedisStrings.setJson(userInfoKey, UserCacheKeyDefine.USER_INFO, loginUser);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -130,11 +130,7 @@ public class SystemUserServiceImpl implements SystemUserService {
|
|||||||
if (id.equals(SecurityUtils.getLoginUserId())) {
|
if (id.equals(SecurityUtils.getLoginUserId())) {
|
||||||
throw ErrorCode.UNSUPPOETED.exception();
|
throw ErrorCode.UNSUPPOETED.exception();
|
||||||
}
|
}
|
||||||
// 检查状态
|
|
||||||
UserStatusEnum status = Valid.valid(UserStatusEnum::of, request.getStatus());
|
UserStatusEnum status = Valid.valid(UserStatusEnum::of, request.getStatus());
|
||||||
if (!status.equals(UserStatusEnum.DISABLED) && !status.equals(UserStatusEnum.ENABLED)) {
|
|
||||||
throw ErrorCode.BAD_REQUEST.exception();
|
|
||||||
}
|
|
||||||
// 查询用户
|
// 查询用户
|
||||||
SystemUserDO record = systemUserDAO.selectById(id);
|
SystemUserDO record = systemUserDAO.selectById(id);
|
||||||
Valid.notNull(record, ErrorMessage.USER_ABSENT);
|
Valid.notNull(record, ErrorMessage.USER_ABSENT);
|
||||||
@@ -146,8 +142,8 @@ public class SystemUserServiceImpl implements SystemUserService {
|
|||||||
// 更新用户
|
// 更新用户
|
||||||
int effect = systemUserDAO.updateById(updateRecord);
|
int effect = systemUserDAO.updateById(updateRecord);
|
||||||
log.info("SystemUserService-updateUserStatus effect: {}, updateRecord: {}", effect, JSON.toJSONString(updateRecord));
|
log.info("SystemUserService-updateUserStatus effect: {}, updateRecord: {}", effect, JSON.toJSONString(updateRecord));
|
||||||
// 如果之前是锁定则删除登录失败次数缓存
|
// 改为启用则删除登录失败次数缓存
|
||||||
if (UserStatusEnum.LOCKED.getStatus().equals(record.getStatus())) {
|
if (UserStatusEnum.ENABLED.equals(status)) {
|
||||||
RedisUtils.delete(UserCacheKeyDefine.LOGIN_FAILED_COUNT.format(record.getUsername()));
|
RedisUtils.delete(UserCacheKeyDefine.LOGIN_FAILED_COUNT.format(record.getUsername()));
|
||||||
}
|
}
|
||||||
// 更新用户缓存中的 status
|
// 更新用户缓存中的 status
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ axios.interceptors.response.use(
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
// 异常判断
|
// 异常判断
|
||||||
if ([401, 700, 701, 702, 703].includes(code)) {
|
if ([401, 700, 701, 702].includes(code)) {
|
||||||
// 提示
|
// 提示
|
||||||
Message.error({
|
Message.error({
|
||||||
content: res.msg || 'Error',
|
content: res.msg || 'Error',
|
||||||
|
|||||||
@@ -68,27 +68,27 @@
|
|||||||
</template>
|
</template>
|
||||||
<!-- 状态 -->
|
<!-- 状态 -->
|
||||||
<template #status="{ record }">
|
<template #status="{ record }">
|
||||||
<span class="circle" :style="{
|
<!-- 有修改权限 -->
|
||||||
background: getDictValue(roleStatusKey, record.status, 'color')
|
<a-switch v-if="hasPermission('infra:system-role:update-status')"
|
||||||
}" />
|
type="round"
|
||||||
{{ getDictValue(roleStatusKey, record.status) }}
|
v-model="record.status"
|
||||||
|
:disabled="record.code === AdminRoleCode"
|
||||||
|
:checked-text="getDictValue(roleStatusKey, RoleStatus.ENABLED)"
|
||||||
|
:unchecked-text="getDictValue(roleStatusKey, RoleStatus.DISABLED)"
|
||||||
|
:checked-value="RoleStatus.ENABLED"
|
||||||
|
:unchecked-value="RoleStatus.DISABLED"
|
||||||
|
:before-change="(s) => updateStatus(record.id, s as number)" />
|
||||||
|
<!-- 无修改权限 -->
|
||||||
|
<span v-else>
|
||||||
|
<span class="circle" :style="{
|
||||||
|
background: getDictValue(roleStatusKey, record.status, 'color')
|
||||||
|
}" />
|
||||||
|
{{ getDictValue(roleStatusKey, record.status) }}
|
||||||
|
</span>
|
||||||
</template>
|
</template>
|
||||||
<!-- 操作 -->
|
<!-- 操作 -->
|
||||||
<template #handle="{ record }">
|
<template #handle="{ record }">
|
||||||
<div class="table-handle-wrapper">
|
<div class="table-handle-wrapper">
|
||||||
<!-- 修改状态 -->
|
|
||||||
<a-popconfirm :content="`确定要${toggleDictValue(roleStatusKey, record.status, 'label')}当前角色吗?`"
|
|
||||||
position="left"
|
|
||||||
type="warning"
|
|
||||||
@ok="toggleRoleStatus(record)">
|
|
||||||
<a-button v-permission="['infra:system-role:delete']"
|
|
||||||
:disabled="record.code === AdminRoleCode"
|
|
||||||
:status="toggleDictValue(roleStatusKey, record.status, 'status')"
|
|
||||||
type="text"
|
|
||||||
size="mini">
|
|
||||||
{{ toggleDictValue(roleStatusKey, record.status, 'label') }}
|
|
||||||
</a-button>
|
|
||||||
</a-popconfirm>
|
|
||||||
<!-- 分配菜单 -->
|
<!-- 分配菜单 -->
|
||||||
<a-button v-permission="['infra:system-role:grant-menu']"
|
<a-button v-permission="['infra:system-role:grant-menu']"
|
||||||
:disabled="record.code === AdminRoleCode"
|
:disabled="record.code === AdminRoleCode"
|
||||||
@@ -136,8 +136,9 @@
|
|||||||
import { Message } from '@arco-design/web-vue';
|
import { Message } from '@arco-design/web-vue';
|
||||||
import useLoading from '@/hooks/loading';
|
import useLoading from '@/hooks/loading';
|
||||||
import columns from '../types/table.columns';
|
import columns from '../types/table.columns';
|
||||||
import { roleStatusKey } from '../types/const';
|
import { RoleStatus, roleStatusKey } from '../types/const';
|
||||||
import { usePagination } from '@/types/table';
|
import { usePagination } from '@/types/table';
|
||||||
|
import usePermission from '@/hooks/permission';
|
||||||
import { useDictStore } from '@/store';
|
import { useDictStore } from '@/store';
|
||||||
import { AdminRoleCode } from '@/types/const';
|
import { AdminRoleCode } from '@/types/const';
|
||||||
|
|
||||||
@@ -146,8 +147,9 @@
|
|||||||
const tableRenderData = ref<RoleQueryResponse[]>([]);
|
const tableRenderData = ref<RoleQueryResponse[]>([]);
|
||||||
|
|
||||||
const pagination = usePagination();
|
const pagination = usePagination();
|
||||||
|
const { hasPermission } = usePermission();
|
||||||
const { loading, setLoading } = useLoading();
|
const { loading, setLoading } = useLoading();
|
||||||
const { toOptions, getDictValue, toggleDictValue, toggleDict } = useDictStore();
|
const { toOptions, getDictValue } = useDictStore();
|
||||||
|
|
||||||
const formModel = reactive<RoleQueryRequest>({
|
const formModel = reactive<RoleQueryRequest>({
|
||||||
id: undefined,
|
id: undefined,
|
||||||
@@ -156,23 +158,13 @@
|
|||||||
status: undefined,
|
status: undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 修改状态
|
// 更新状态
|
||||||
const toggleRoleStatus = async (record: any) => {
|
const updateStatus = (id: number, status: number) => {
|
||||||
try {
|
return updateRoleStatus({
|
||||||
setLoading(true);
|
id, status
|
||||||
const toggleStatus = toggleDict(roleStatusKey, record.status);
|
}).then(() => {
|
||||||
// 调用修改接口
|
Message.success('已' + getDictValue(roleStatusKey, status, 'label'));
|
||||||
await updateRoleStatus({
|
});
|
||||||
id: record.id,
|
|
||||||
status: toggleStatus.value as number
|
|
||||||
});
|
|
||||||
Message.success(`${toggleStatus.label}成功`);
|
|
||||||
// 修改行状态
|
|
||||||
record.status = toggleStatus.value;
|
|
||||||
} catch (e) {
|
|
||||||
} finally {
|
|
||||||
setLoading(false);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 删除当前行
|
// 删除当前行
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ const columns = [
|
|||||||
dataIndex: 'code',
|
dataIndex: 'code',
|
||||||
slotName: 'code',
|
slotName: 'code',
|
||||||
}, {
|
}, {
|
||||||
title: '状态',
|
title: '角色状态',
|
||||||
dataIndex: 'status',
|
dataIndex: 'status',
|
||||||
slotName: 'status',
|
slotName: 'status',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
width: 84,
|
width: 128,
|
||||||
}, {
|
}, {
|
||||||
title: '创建时间',
|
title: '创建时间',
|
||||||
dataIndex: 'createTime',
|
dataIndex: 'createTime',
|
||||||
@@ -35,7 +35,7 @@ const columns = [
|
|||||||
}, {
|
}, {
|
||||||
title: '操作',
|
title: '操作',
|
||||||
slotName: 'handle',
|
slotName: 'handle',
|
||||||
width: 240,
|
width: 198,
|
||||||
align: 'center',
|
align: 'center',
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -77,37 +77,32 @@
|
|||||||
<template #username="{ record }">
|
<template #username="{ record }">
|
||||||
<span class="span-blue text-copy"
|
<span class="span-blue text-copy"
|
||||||
@click="copy(record.username)">
|
@click="copy(record.username)">
|
||||||
{{ record.username }}`
|
{{ record.username }}
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
<!-- 状态 -->
|
<!-- 状态 -->
|
||||||
<template #status="{ record }">
|
<template #status="{ record }">
|
||||||
<span class="circle" :style="{
|
<!-- 有修改权限 -->
|
||||||
background: getDictValue(userStatusKey, record.status, 'color')
|
<a-switch v-if="hasPermission('infra:system-user:update-status')"
|
||||||
}" />
|
type="round"
|
||||||
{{ getDictValue(userStatusKey, record.status) }}
|
v-model="record.status"
|
||||||
|
:disabled="record.id === userStore.id"
|
||||||
|
:checked-text="getDictValue(userStatusKey, UserStatus.ENABLED)"
|
||||||
|
:unchecked-text="getDictValue(userStatusKey, UserStatus.DISABLED)"
|
||||||
|
:checked-value="UserStatus.ENABLED"
|
||||||
|
:unchecked-value="UserStatus.DISABLED"
|
||||||
|
:before-change="(s) => updateStatus(record.id, s as number)" />
|
||||||
|
<!-- 无修改权限 -->
|
||||||
|
<span v-else>
|
||||||
|
<span class="circle" :style="{
|
||||||
|
background: getDictValue(userStatusKey, record.status, 'color')
|
||||||
|
}" />
|
||||||
|
{{ getDictValue(userStatusKey, record.status) }}
|
||||||
|
</span>
|
||||||
</template>
|
</template>
|
||||||
<!-- 操作 -->
|
<!-- 操作 -->
|
||||||
<template #handle="{ record }">
|
<template #handle="{ record }">
|
||||||
<div class="table-handle-wrapper">
|
<div class="table-handle-wrapper">
|
||||||
<!-- 启用/停用 -->
|
|
||||||
<a-popconfirm :content="`确定要${UserStatus.ENABLED === record.status
|
|
||||||
? getDictValue(userStatusKey, UserStatus.DISABLED)
|
|
||||||
: getDictValue(userStatusKey, UserStatus.ENABLED)}当前用户?`"
|
|
||||||
position="left"
|
|
||||||
type="warning"
|
|
||||||
@ok="updateStatus(record)">
|
|
||||||
<a-button v-permission="['infra:system-user:update-status']"
|
|
||||||
type="text"
|
|
||||||
size="mini"
|
|
||||||
:disabled="record.id === userStore.id">
|
|
||||||
{{
|
|
||||||
UserStatus.ENABLED === record.status
|
|
||||||
? getDictValue(userStatusKey, UserStatus.DISABLED)
|
|
||||||
: getDictValue(userStatusKey, UserStatus.ENABLED)
|
|
||||||
}}
|
|
||||||
</a-button>
|
|
||||||
</a-popconfirm>
|
|
||||||
<!-- 修改 -->
|
<!-- 修改 -->
|
||||||
<a-button type="text"
|
<a-button type="text"
|
||||||
size="mini"
|
size="mini"
|
||||||
@@ -167,12 +162,13 @@
|
|||||||
import { reactive, ref, onMounted } from 'vue';
|
import { reactive, ref, onMounted } from 'vue';
|
||||||
import { deleteUser, getUserPage, updateUserStatus } from '@/api/user/user';
|
import { deleteUser, getUserPage, updateUserStatus } from '@/api/user/user';
|
||||||
import { Message } from '@arco-design/web-vue';
|
import { Message } from '@arco-design/web-vue';
|
||||||
import useLoading from '@/hooks/loading';
|
|
||||||
import columns from '../types/table.columns';
|
import columns from '../types/table.columns';
|
||||||
import { userStatusKey, UserStatus } from '../types/const';
|
import { userStatusKey, UserStatus } from '../types/const';
|
||||||
|
import useLoading from '@/hooks/loading';
|
||||||
import { usePagination } from '@/types/table';
|
import { usePagination } from '@/types/table';
|
||||||
import { useDictStore, useUserStore } from '@/store';
|
import usePermission from '@/hooks/permission';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
|
import { useDictStore, useUserStore } from '@/store';
|
||||||
import { copy } from '@/hooks/copy';
|
import { copy } from '@/hooks/copy';
|
||||||
|
|
||||||
const emits = defineEmits(['openAdd', 'openUpdate', 'openResetPassword', 'openGrantRole']);
|
const emits = defineEmits(['openAdd', 'openUpdate', 'openResetPassword', 'openGrantRole']);
|
||||||
@@ -180,8 +176,9 @@
|
|||||||
const tableRenderData = ref<UserQueryResponse[]>([]);
|
const tableRenderData = ref<UserQueryResponse[]>([]);
|
||||||
|
|
||||||
const pagination = usePagination();
|
const pagination = usePagination();
|
||||||
|
const { hasPermission } = usePermission();
|
||||||
const { loading, setLoading } = useLoading();
|
const { loading, setLoading } = useLoading();
|
||||||
const { toOptions, getDictValue, getDict } = useDictStore();
|
const { toOptions, getDictValue } = useDictStore();
|
||||||
|
|
||||||
const formModel = reactive<UserQueryRequest>({
|
const formModel = reactive<UserQueryRequest>({
|
||||||
id: undefined,
|
id: undefined,
|
||||||
@@ -216,23 +213,12 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 更新状态
|
// 更新状态
|
||||||
const updateStatus = async (record: any) => {
|
const updateStatus = (id: number, status: number) => {
|
||||||
try {
|
return updateUserStatus({
|
||||||
setLoading(true);
|
id, status
|
||||||
// 更新状态
|
}).then(() => {
|
||||||
const newStatus = UserStatus.ENABLED === record.status
|
Message.success('已' + getDictValue(userStatusKey, status, 'label'));
|
||||||
? getDict(userStatusKey, UserStatus.DISABLED)
|
});
|
||||||
: getDict(userStatusKey, UserStatus.ENABLED);
|
|
||||||
await updateUserStatus({
|
|
||||||
id: record.id,
|
|
||||||
status: newStatus.value as number
|
|
||||||
});
|
|
||||||
Message.success(`${newStatus.label}成功`);
|
|
||||||
record.status = newStatus.value;
|
|
||||||
} catch (e) {
|
|
||||||
} finally {
|
|
||||||
setLoading(false);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 打开详情
|
// 打开详情
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ export const UserStatus = {
|
|||||||
DISABLED: 0,
|
DISABLED: 0,
|
||||||
// 启用
|
// 启用
|
||||||
ENABLED: 1,
|
ENABLED: 1,
|
||||||
// 锁定
|
|
||||||
LOCKED: 2,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 菜单配置值类型 字典项
|
// 菜单配置值类型 字典项
|
||||||
|
|||||||
@@ -34,11 +34,11 @@ const columns = [
|
|||||||
ellipsis: true,
|
ellipsis: true,
|
||||||
tooltip: true,
|
tooltip: true,
|
||||||
}, {
|
}, {
|
||||||
title: '状态',
|
title: '用户状态',
|
||||||
dataIndex: 'status',
|
dataIndex: 'status',
|
||||||
slotName: 'status',
|
slotName: 'status',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
width: 84
|
width: 128,
|
||||||
}, {
|
}, {
|
||||||
title: '最后登录时间',
|
title: '最后登录时间',
|
||||||
dataIndex: 'lastLoginTime',
|
dataIndex: 'lastLoginTime',
|
||||||
@@ -51,7 +51,7 @@ const columns = [
|
|||||||
}, {
|
}, {
|
||||||
title: '操作',
|
title: '操作',
|
||||||
slotName: 'handle',
|
slotName: 'handle',
|
||||||
width: 340,
|
width: 298,
|
||||||
align: 'center',
|
align: 'center',
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -669,7 +669,7 @@ CREATE TABLE `system_user`
|
|||||||
`avatar` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '头像地址',
|
`avatar` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '头像地址',
|
||||||
`mobile` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '手机号',
|
`mobile` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '手机号',
|
||||||
`email` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '邮箱',
|
`email` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '邮箱',
|
||||||
`status` tinyint(0) NULL DEFAULT 1 COMMENT '用户状态 0停用 1启用 2锁定',
|
`status` tinyint(0) NULL DEFAULT 1 COMMENT '用户状态 0停用 1启用',
|
||||||
`last_login_time` datetime(0) NULL DEFAULT NULL COMMENT '最后登录时间',
|
`last_login_time` datetime(0) NULL DEFAULT NULL COMMENT '最后登录时间',
|
||||||
`create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
`create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
`update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
|
`update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
|
||||||
|
|||||||
@@ -165,7 +165,6 @@ INSERT INTO `dict_value` VALUES (15, 8, 'dictValueType', 'BOOLEAN', '布尔值',
|
|||||||
INSERT INTO `dict_value` VALUES (16, 8, 'dictValueType', 'COLOR', '颜色', '{\"color\": \"magenta\"}', 50, '2023-10-27 01:55:05', '2023-10-27 01:56:39', '1', '1', 0);
|
INSERT INTO `dict_value` VALUES (16, 8, 'dictValueType', 'COLOR', '颜色', '{\"color\": \"magenta\"}', 50, '2023-10-27 01:55:05', '2023-10-27 01:56:39', '1', '1', 0);
|
||||||
INSERT INTO `dict_value` VALUES (17, 9, 'systemUserStatus', '0', '停用', '{\"color\": \"orange\"}', 10, '2023-10-27 12:13:08', '2023-10-27 12:13:08', '1', '1', 0);
|
INSERT INTO `dict_value` VALUES (17, 9, 'systemUserStatus', '0', '停用', '{\"color\": \"orange\"}', 10, '2023-10-27 12:13:08', '2023-10-27 12:13:08', '1', '1', 0);
|
||||||
INSERT INTO `dict_value` VALUES (18, 9, 'systemUserStatus', '1', '启用', '{\"color\": \"blue\"}', 20, '2023-10-27 12:13:17', '2023-10-27 12:13:17', '1', '1', 0);
|
INSERT INTO `dict_value` VALUES (18, 9, 'systemUserStatus', '1', '启用', '{\"color\": \"blue\"}', 20, '2023-10-27 12:13:17', '2023-10-27 12:13:17', '1', '1', 0);
|
||||||
INSERT INTO `dict_value` VALUES (19, 9, 'systemUserStatus', '2', '锁定', '{\"color\": \"orange\"}', 30, '2023-10-27 12:13:24', '2023-10-27 12:13:24', '1', '1', 0);
|
|
||||||
INSERT INTO `dict_value` VALUES (20, 10, 'systemRoleStatus', '0', '停用', '{\"color\": \"orange\", \"status\": \"danger\"}', 10, '2023-10-27 12:33:45', '2023-10-27 12:33:45', '1', '1', 0);
|
INSERT INTO `dict_value` VALUES (20, 10, 'systemRoleStatus', '0', '停用', '{\"color\": \"orange\", \"status\": \"danger\"}', 10, '2023-10-27 12:33:45', '2023-10-27 12:33:45', '1', '1', 0);
|
||||||
INSERT INTO `dict_value` VALUES (21, 10, 'systemRoleStatus', '1', '启用', '{\"color\": \"blue\", \"status\": \"default\"}', 20, '2023-10-27 12:33:56', '2023-10-31 01:23:23', '1', '1', 0);
|
INSERT INTO `dict_value` VALUES (21, 10, 'systemRoleStatus', '1', '启用', '{\"color\": \"blue\", \"status\": \"default\"}', 20, '2023-10-27 12:33:56', '2023-10-31 01:23:23', '1', '1', 0);
|
||||||
INSERT INTO `dict_value` VALUES (22, 11, 'hostSshAuthType', 'PASSWORD', '密码验证', '{}', 10, '2023-10-27 14:29:28', '2023-12-25 15:40:47', '1', '1', 0);
|
INSERT INTO `dict_value` VALUES (22, 11, 'hostSshAuthType', 'PASSWORD', '密码验证', '{}', 10, '2023-10-27 14:29:28', '2023-12-25 15:40:47', '1', '1', 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user