焊接首页
This commit is contained in:
+24
-8
@@ -2,12 +2,13 @@ import {
|
||||
defineStore
|
||||
} from 'pinia'
|
||||
import {
|
||||
ref
|
||||
ref,
|
||||
watch
|
||||
} from 'vue'
|
||||
import {
|
||||
reqLogin
|
||||
} from '@/api/auth.js'
|
||||
|
||||
import { useMenuStore, useLargeStore } from '@/store'
|
||||
export const useUserStore = defineStore('user', () => {
|
||||
const token = ref("")
|
||||
const userInfo = ref(null)
|
||||
@@ -20,6 +21,20 @@ export const useUserStore = defineStore('user', () => {
|
||||
const projectList = ref([])
|
||||
const currentProject = ref(null)
|
||||
|
||||
// 监听 currentProject 变化,获取菜单权限
|
||||
watch(() => currentProject.value?.ProjectId, (newId) => {
|
||||
if (newId) {
|
||||
// 项目变化 请求菜单权限
|
||||
const menuStore = useMenuStore()
|
||||
const userId = userInfo.value?.PersonId
|
||||
menuStore.fetchMenuPowerList(userId, newId)
|
||||
// 项目变化 请求焊接首页数据
|
||||
const largeStore = useLargeStore()
|
||||
largeStore.fetchHJIndex(newId)
|
||||
|
||||
}
|
||||
}, { immediate: true })
|
||||
|
||||
|
||||
/**
|
||||
* 登出
|
||||
@@ -27,11 +42,11 @@ export const useUserStore = defineStore('user', () => {
|
||||
const logout = () => {
|
||||
token.value = ""
|
||||
userInfo.value = null
|
||||
loginForm.value = {
|
||||
account: '',
|
||||
password: '',
|
||||
Telephone: '',
|
||||
}
|
||||
// loginForm.value = {
|
||||
// account: '',
|
||||
// password: '',
|
||||
// Telephone: '',
|
||||
// }
|
||||
currentProject.value = null
|
||||
}
|
||||
|
||||
@@ -79,7 +94,8 @@ export const useUserStore = defineStore('user', () => {
|
||||
projectList,
|
||||
currentProject,
|
||||
setProjectList,
|
||||
setCurrentProject
|
||||
setCurrentProject,
|
||||
logout
|
||||
}
|
||||
}, {
|
||||
persist: {
|
||||
|
||||
Reference in New Issue
Block a user