ref:编辑用户导致角色修改逻辑修改
This commit is contained in:
parent
a0282c99f1
commit
e319578676
@ -24,12 +24,8 @@ const showModal = () => {
|
|||||||
const handleOk = () => {
|
const handleOk = () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
store.userSelectRole(currentRoleId.value)
|
store.userSelectRole(currentRoleId.value)
|
||||||
setTimeout(() => {
|
// 刷新组件 todo
|
||||||
loading.value = false
|
|
||||||
visible.value = false
|
visible.value = false
|
||||||
// 页面刷新-》 白屏
|
|
||||||
location.reload()
|
|
||||||
}, 1000)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
@ -46,7 +42,14 @@ defineExpose({
|
|||||||
<a-modal v-model:visible="visible" title="切换角色" @ok="handleOk">
|
<a-modal v-model:visible="visible" title="切换角色" @ok="handleOk">
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<a-button key="back" @click="handleCancel">取消</a-button>
|
<a-button key="back" @click="handleCancel">取消</a-button>
|
||||||
<a-button key="submit" type="primary" :loading="loading" @click="handleOk">确定</a-button>
|
<a-button
|
||||||
|
key="submit"
|
||||||
|
type="primary"
|
||||||
|
:loading="loading"
|
||||||
|
@click="handleOk"
|
||||||
|
:disabled="currentRoleId === store.userInfo.roles[0]['id']"
|
||||||
|
>确定</a-button
|
||||||
|
>
|
||||||
</template>
|
</template>
|
||||||
<span>选择角色:</span>
|
<span>选择角色:</span>
|
||||||
|
|
||||||
|
@ -91,6 +91,7 @@ export const userStore = defineStore(
|
|||||||
isLoading,
|
isLoading,
|
||||||
selectKey,
|
selectKey,
|
||||||
$reset,
|
$reset,
|
||||||
|
getUserData,
|
||||||
loginAction,
|
loginAction,
|
||||||
loadRoleRouter,
|
loadRoleRouter,
|
||||||
userSelectRole
|
userSelectRole
|
||||||
|
@ -8,7 +8,8 @@ import { getRoles } from '@/service/role'
|
|||||||
import { columns, addUserRules, putUserRules } from './conf'
|
import { columns, addUserRules, putUserRules } from './conf'
|
||||||
import { message } from 'ant-design-vue'
|
import { message } from 'ant-design-vue'
|
||||||
import { userStore } from '@/stores/user'
|
import { userStore } from '@/stores/user'
|
||||||
import router from '@/router'
|
|
||||||
|
const store = userStore()
|
||||||
|
|
||||||
/**查询表单响应式数据 */
|
/**查询表单响应式数据 */
|
||||||
const queryFormRef = ref()
|
const queryFormRef = ref()
|
||||||
@ -157,31 +158,32 @@ const putUserForm = reactive({
|
|||||||
const putId = ref()
|
const putId = ref()
|
||||||
|
|
||||||
//modal 事件
|
//modal 事件
|
||||||
const onOkPut = () => {
|
const onOkPut = async () => {
|
||||||
//校验数据
|
//校验数据
|
||||||
putUserFormRef.value.validateFields().then(() => {
|
putUserFormRef.value.validateFields().then(async () => {
|
||||||
//验证通过
|
//验证通过
|
||||||
const { nickname, password, roles } = putUserForm
|
const { nickname, password, roles } = putUserForm
|
||||||
let rids = roles.map((e, i) => ({ rid: e, status: i === 0 ? 5 : 1 }))
|
let rids = roles.map((e, i) => ({ rid: e, status: i === 0 ? 5 : 1 }))
|
||||||
putUser(putId.value, { nickname, password, roles: rids }).then((res) => {
|
const res = await putUser(putId.value, { nickname, password, roles: rids })
|
||||||
if (res.msg === '请求成功') {
|
if (res.msg === '请求成功') {
|
||||||
message.success('修改成功')
|
message.success('修改成功')
|
||||||
// 1. 关闭 modal
|
// 1. 关闭 modal
|
||||||
putVisible.value = !putVisible.value
|
putVisible.value = !putVisible.value
|
||||||
// 2. 重置响应式数据
|
// 2. 重置响应式数据
|
||||||
putUserFormRef.value.resetFields()
|
putUserFormRef.value.resetFields()
|
||||||
if (putId.value === userStore().userInfo.id) {
|
// 修改了自己
|
||||||
// 改了自己
|
if (putId.value === store.userInfo.id) {
|
||||||
message.warning('修改了自己,请重新登录')
|
// 并且修改了激活角色
|
||||||
userStore().$reset()
|
if (rids[0]['rid'] !== store.userInfo.roles[0]['id']) {
|
||||||
router.push('/login')
|
store.getUserData(putId.value)
|
||||||
|
// 刷新组件 todo
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// 3. 刷新页面数据
|
// 3. 刷新页面数据
|
||||||
getPageData()
|
getPageData()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const onCancelPut = () => {
|
const onCancelPut = () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user