feat: 适配登录接口修改

pull/184/head
刘释隆 1 year ago
parent 197b6cc288
commit d722e6fc1d

@ -1,92 +1,92 @@
<script lang="ts" setup>
import { computed, inject, onMounted, ref } from "vue";
import { useRoute, useRouter } from "vue-router";
import { useUser } from "@/store/modules/user";
import { getImgUrl } from "@/utils/urlUtils";
import defaultAvatar from '@/assets/icons/avatar.svg';
import { computed, inject, onMounted, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useUser } from '@/store/modules/user'
import { getImgUrl } from '@/utils/urlUtils'
import defaultAvatar from '@/assets/icons/avatar.svg'
const emit = defineEmits<{
(e: "logout"): void;
}>();
(e: 'logout'): void
}>()
const router = useRouter();
const router = useRouter()
const userStore = useUser();
const userStore = useUser()
const useInfo = userStore.getUserInfo;
const useInfo = userStore.getUserInfo
const aiDisabled = ref(false);
const aiDisabled = ref(false)
function handleSelect(row) {
userStore.updateTenantId(row.key);
location.reload();
userStore.updateTenantId(row.key)
location.reload()
}
function logIt(e) {
return false;
return false
}
//
function goHome(e) {
router.push({ name: "home" });
router.push({ name: 'home' })
}
//
function goTask(e) {
router.push({ name: "task-main" });
router.push({ name: 'task-main' })
}
// AI
function goWorksheet(e) {
router.push({ name: "worksheet-main" });
router.push({ name: 'worksheet-main' })
}
//
function goFinal(e) {
router.push({ name: "final-main" });
router.push({ name: 'final-main' })
}
const mousetrap = inject("mousetrap") as any;
const mousetrap = inject('mousetrap') as any
onMounted(() => {
mousetrap.bind("g h", goHome);
mousetrap.bind("g t", goTask);
mousetrap.bind("g a", goWorksheet);
mousetrap.bind("g e", goFinal);
});
mousetrap.bind('g h', goHome)
mousetrap.bind('g t', goTask)
mousetrap.bind('g a', goWorksheet)
mousetrap.bind('g e', goFinal)
})
const showPopover = ref(false);
const popRef = ref(null);
const changeFlag = ref(false);
const showPopover = ref(false)
const popRef = ref(null)
const changeFlag = ref(false)
const iconName = computed(() => {
return showPopover.value ? "expand" : "collapse";
});
return showPopover.value ? 'expand' : 'collapse'
})
function handleUpdateShow(show: boolean) {
showPopover.value = show;
showPopover.value = show
}
function logOut() {
(popRef.value as any).setShow(false);
emit("logout");
(popRef.value as any).setShow(false)
emit('logout')
}
const currentCompanyName = computed(() => {
const tenantList = useInfo.tenantList;
const currentId = userStore.getTenantId;
const current = tenantList.find((item) => item.id === currentId);
return current.name || "name";
});
const deptlist = useInfo.deptlist
const currentId = userStore.getTenantId
const current = deptlist.find(item => item.id === currentId)
return current.name || 'name'
})
const options = computed(() => {
const tenantList = useInfo.tenantList;
return tenantList.map((item) => {
const deptlist = useInfo.deptlist
return deptlist.map((item) => {
return {
label: item.name,
key: item.id,
};
});
});
label: item.departname,
key: item.deptno,
}
})
})
</script>
<template>
@ -119,24 +119,28 @@ const options = computed(() => {
</div>
<div class="trigger">
<span>{{ currentCompanyName }}</span>
<span @click="changeFlag = !changeFlag" style="cursor: pointer"><SvgIcon name="switchCompany" size="24" /></span>
<span style="cursor: pointer" @click="changeFlag = !changeFlag"><SvgIcon name="switchCompany" size="24" /></span>
</div>
<div class="item">
<span>AI设置开关</span>
<n-switch v-model:value="aiDisabled" />
</div>
<div class="trigger">联系我们</div>
<div class="trigger">
联系我们
</div>
<n-divider style="margin-top: 0px; margin-bottom: 10px; padding: 0 22px" />
<div class="trigger" @click="logOut">退</div>
<div class="trigger" @click="logOut">
退出登录
</div>
<div
class="container sub-container"
v-show="changeFlag"
class="container sub-container"
style="position: absolute; right: 17vw; width: 11.5vw; padding: 24px 0"
>
<div
class="trigger"
v-for="option in options"
:key="option.key"
class="trigger"
@click="handleSelect(option)"
>
{{ option.label }}

@ -15,7 +15,7 @@ const TOKEN_REFRESH_SECONDS = 20 * 60
export interface UserInfoType {
token: string
tenantList: any[]
deptlist: any[]
userInfo: any
}
@ -122,8 +122,8 @@ export const useUserStore = defineStore({
if (code === ResultEnum.SUCCESS) {
const ex = 7 * 24 * 60 * 60
// 默认设置为第一个租户
const firstTenant = data.tenantList.length > 0 ? data.tenantList[0] : null
const tenantId = firstTenant ? firstTenant.id : ''
const firstTenant = data.deptlist.length > 0 ? data.deptlist[0] : null
const tenantId = firstTenant ? firstTenant.deptno : ''
data.frontmenuTList.forEach((ele) => {
if (ele.description === 'AI工单')
ele.description = '图审审批'
@ -175,7 +175,7 @@ export const useUserStore = defineStore({
// 登出
async logout() {
this.setPermissions([])
this.setUserInfo({ tenantList: [], userInfo: {}, token: '' })
this.setUserInfo({ deptlist: [], userInfo: {}, token: '' })
this.setTenantId('')
storage.remove(USER_ACCESS_TOKEN)
storage.remove(CURRENT_USER)

Loading…
Cancel
Save