Merge pull request 'feat: 适配登录接口修改' (#184) from feat/changeLogin into test

Reviewed-on: #184
pull/185/head^2
刘释隆 1 year ago
commit 7fa2dc76b9

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

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

Loading…
Cancel
Save