修改切换账号功能
This commit is contained in:
parent
c301c6f428
commit
50538c9284
|
@ -0,0 +1,80 @@
|
|||
<template>
|
||||
<BasicModal v-bind="$attrs" @register="registerModal" :title="title" @ok="handleSubmit" width="600px">
|
||||
<row>
|
||||
<a-col style="margin-top: 150px;"> <span style="margin-left: 50px;">账号:</span><a-input v-model:value="qhuserName" style="width:70%;"></a-input> </a-col>
|
||||
</row>
|
||||
</BasicModal>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { ref, unref } from 'vue';
|
||||
import { rules } from '/@/utils/helper/validator';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import BasicForm from '/@/components/Form/src/BasicForm.vue';
|
||||
import { useForm } from '/@/components/Form/src/hooks/useForm';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { useLocaleStore } from '/@/store/modules/locale';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
import { useUserStoreWithOut } from '/@/store/modules/user';
|
||||
const $message = useMessage();
|
||||
|
||||
const localeStore = useLocaleStore();
|
||||
const { t } = useI18n();
|
||||
// 声明Emits
|
||||
const emit = defineEmits(['register']);
|
||||
const formRef = ref();
|
||||
const username = ref('');
|
||||
const qhuserName = ref('');
|
||||
// update-begin--author:liaozhiyang---date:20240124---for:【QQYUN-7970】国际化
|
||||
const title = ref(t('layout.changePassword.dropdownItemZhanghao'));
|
||||
//表单配置
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner();
|
||||
//表单提交事件
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
//提交表单
|
||||
let params = { username: qhuserName.value };
|
||||
console.log('🙄', params);
|
||||
await defHttp.post({ url: '/sys/qhlogin', params }, { isTransformResponse: false }).then((res) => {
|
||||
console.log('👩🦲', res);
|
||||
if (res.success) {
|
||||
$message.createMessage.success(res.message);
|
||||
|
||||
const userStore = useUserStoreWithOut();
|
||||
userStore.setToken(undefined);
|
||||
userStore.setToken(res.result.token);
|
||||
userStore.setUserInfo(res.result.userInfo);
|
||||
window.location.reload();
|
||||
//关闭弹窗
|
||||
closeModal();
|
||||
} else {
|
||||
$message.createMessage.warning(res.message);
|
||||
}
|
||||
});
|
||||
|
||||
// const { token, userInfo } = data;
|
||||
// // save token
|
||||
// this.setToken(token);
|
||||
// this.setTenant(userInfo.loginTenantId);
|
||||
// this.afterLoginAction(goHome, data);
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
|
||||
async function show(name) {
|
||||
if (!name) {
|
||||
$message.createMessage.warning('当前系统无登录用户!');
|
||||
return;
|
||||
} else {
|
||||
username.value = name;
|
||||
await setModalProps({ visible: true });
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
title,
|
||||
show,
|
||||
});
|
||||
</script>
|
|
@ -16,7 +16,8 @@
|
|||
<MenuItem key="account" :text="t('layout.header.dropdownItemSwitchAccount')" icon="ant-design:setting-outlined" />
|
||||
<MenuItem key="password" :text="t('layout.header.dropdownItemSwitchPassword')" icon="ant-design:edit-outlined" />
|
||||
<MenuItem key="depart" :text="t('layout.header.dropdownItemSwitchDepart')" icon="ant-design:cluster-outlined" />
|
||||
<MenuItem key="cache" :text="t('layout.header.dropdownItemRefreshCache')" icon="ion:sync-outline" />
|
||||
<MenuItem key="qhzh" :text="t('layout.header.dropdownItemSwitchUser')" icon="ant-design:cluster-outlined" />
|
||||
<MenuItem key="cache" v-if="adminRole" :text="t('layout.header.dropdownItemRefreshCache')" icon="ion:sync-outline" />
|
||||
<!-- <MenuItem
|
||||
v-if="getUseLockPage"
|
||||
key="lock"
|
||||
|
@ -30,6 +31,7 @@
|
|||
<LockAction @register="register" />
|
||||
<DepartSelect ref="loginSelectRef" />
|
||||
<UpdatePassword ref="updatePasswordRef" />
|
||||
<Qiehuanzhanghao ref="qiehuanzhanghaoRef" />
|
||||
</template>
|
||||
<script lang="ts">
|
||||
// components
|
||||
|
@ -56,6 +58,8 @@
|
|||
import { DB_DICT_DATA_KEY } from '/src/enums/cacheEnum';
|
||||
import { removeAuthCache, setAuthCache } from '/src/utils/auth';
|
||||
import { getFileAccessHttpUrl } from '/@/utils/common/compUtils';
|
||||
import Qiehuanzhanghao from './Qiehuanzhanghao.vue';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
|
||||
type MenuEvent = 'logout' | 'doc' | 'lock' | 'cache' | 'depart';
|
||||
const { createMessage } = useMessage();
|
||||
|
@ -69,6 +73,7 @@
|
|||
LockAction: createAsyncComponent(() => import('../lock/LockModal.vue')),
|
||||
DepartSelect: createAsyncComponent(() => import('./DepartSelect.vue')),
|
||||
UpdatePassword: createAsyncComponent(() => import('./UpdatePassword.vue')),
|
||||
Qiehuanzhanghao: createAsyncComponent(() => import('./Qiehuanzhanghao.vue')),
|
||||
},
|
||||
props: {
|
||||
theme: propTypes.oneOf(['dark', 'light']),
|
||||
|
@ -79,6 +84,7 @@
|
|||
const { getShowDoc, getUseLockPage } = useHeaderSetting();
|
||||
const userStore = useUserStore();
|
||||
const go = useGo();
|
||||
const adminRole = ref(false);
|
||||
|
||||
const getUserInfo = computed(() => {
|
||||
const { realname = '', avatar, desc } = userStore.getUserInfo || {};
|
||||
|
@ -99,6 +105,19 @@
|
|||
* 多部门弹窗逻辑
|
||||
*/
|
||||
const loginSelectRef = ref();
|
||||
|
||||
defHttp.get({ url: '/sys/user/queryUserRole',params:{userid:userStore.getUserInfo.id} }).then((res) => {
|
||||
console.log('--->',res);
|
||||
if (res.length>0) {
|
||||
res.forEach((item=>{
|
||||
if(item == 'f6817f48af4fb3af11b9e8bf182f618b'){
|
||||
adminRole.value = true;
|
||||
}
|
||||
}))
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
function handleLock() {
|
||||
openModal(true);
|
||||
}
|
||||
|
@ -129,6 +148,15 @@
|
|||
function updateCurrentDepart() {
|
||||
loginSelectRef.value.show();
|
||||
}
|
||||
// 切换账号
|
||||
const qiehuanzhanghaoRef = ref();
|
||||
// 切换账号
|
||||
function updateQhzh() {
|
||||
console.log(`🚀 ~ updateQhzh ~ updateQhzh:切换账号`)
|
||||
qiehuanzhanghaoRef.value.title = "切换账号";
|
||||
qiehuanzhanghaoRef.value.show(userStore.getUserInfo.username);
|
||||
}
|
||||
|
||||
// 修改密码
|
||||
const updatePasswordRef = ref();
|
||||
function updatePassword() {
|
||||
|
@ -160,6 +188,9 @@
|
|||
go(`/system/usersetting`);
|
||||
//update-end---author:wangshuai ---date:20221125 for:进入用户设置页面--------------
|
||||
break;
|
||||
case 'qhzh':
|
||||
updateQhzh();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,6 +205,7 @@
|
|||
getUseLockPage,
|
||||
loginSelectRef,
|
||||
updatePasswordRef,
|
||||
qiehuanzhanghaoRef,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
|
|
@ -6,6 +6,7 @@ export default {
|
|||
dropdownItemLoginOut: '退出系统',
|
||||
dropdownItemSwitchPassword: '密码修改',
|
||||
dropdownItemSwitchDepart: '切换部门',
|
||||
dropdownItemSwitchUser: '切换账号',
|
||||
dropdownItemRefreshCache: '刷新缓存',
|
||||
dropdownItemSwitchAccount: '账户设置',
|
||||
|
||||
|
|
Loading…
Reference in New Issue