调整学生选择逻辑,避免重复弹窗选择
This commit is contained in:
parent
55c62cc033
commit
e392903194
@ -60,7 +60,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useUserStore } from "@/store/modules/user";
|
import { useUserStore } from "@/store/modules/user";
|
||||||
const { getUser, setCurXs, getCurXs } = useUserStore();
|
const { getUser, setCurXs, getCurXs, getXsPickerInitialized, setXsPickerInitialized } = useUserStore();
|
||||||
|
|
||||||
// 接收外部传入属性
|
// 接收外部传入属性
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
@ -96,11 +96,22 @@ const setCurrentStudent = (xs: any) => {
|
|||||||
|
|
||||||
// 如果是bar形式,则默认打开选择器
|
// 如果是bar形式,则默认打开选择器
|
||||||
if (props.isBar) {
|
if (props.isBar) {
|
||||||
if (getUser.xsList.length > 1 ) {
|
// 检查是否已经初始化过
|
||||||
showPicker();
|
if (getXsPickerInitialized) {
|
||||||
|
// 已经初始化过,直接使用当前选中的学生,不显示选择器
|
||||||
|
if (getUser.xsList.length > 0) {
|
||||||
|
setCurrentStudent(getCurXs);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// 只有一个学生时,直接设置但不显示提示
|
// 首次初始化
|
||||||
setCurrentStudent(getUser.xsList[0]);
|
if (getUser.xsList.length > 1) {
|
||||||
|
showPicker();
|
||||||
|
} else {
|
||||||
|
// 只有一个学生时,直接设置但不显示提示
|
||||||
|
setCurrentStudent(getUser.xsList[0]);
|
||||||
|
}
|
||||||
|
// 标记为已初始化
|
||||||
|
setXsPickerInitialized(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -16,9 +16,12 @@ import XsPicker from "@/pages/base/components/XsPicker/index.vue"
|
|||||||
import { useDataStore } from "@/store/modules/data";
|
import { useDataStore } from "@/store/modules/data";
|
||||||
import { useUserStore } from "@/store/modules/user";
|
import { useUserStore } from "@/store/modules/user";
|
||||||
const { getGlobal } = useDataStore();
|
const { getGlobal } = useDataStore();
|
||||||
const { checkXqk, checkJlb } = useUserStore();
|
const { checkXqk, checkJlb, setXsPickerInitialized } = useUserStore();
|
||||||
|
|
||||||
const switchXs = (xs: any) => {
|
const switchXs = (xs: any) => {
|
||||||
|
// 设置学生选择器已初始化标记
|
||||||
|
setXsPickerInitialized(true);
|
||||||
|
|
||||||
if (getGlobal.type == 1) {
|
if (getGlobal.type == 1) {
|
||||||
checkXqk();
|
checkXqk();
|
||||||
} else if (getGlobal.type == 2) {
|
} else if (getGlobal.type == 2) {
|
||||||
|
|||||||
@ -19,6 +19,7 @@ interface UserState {
|
|||||||
changeTime: string; // 权限变更时间
|
changeTime: string; // 权限变更时间
|
||||||
ws: any;
|
ws: any;
|
||||||
wsCallback: any;
|
wsCallback: any;
|
||||||
|
xsPickerInitialized: boolean; // 学生选择器是否已初始化
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useUserStore = defineStore({
|
export const useUserStore = defineStore({
|
||||||
@ -36,7 +37,8 @@ export const useUserStore = defineStore({
|
|||||||
refreshInterval: 7 * 24 * 60 * 60 * 1000, // 刷新间隔(毫秒)
|
refreshInterval: 7 * 24 * 60 * 60 * 1000, // 刷新间隔(毫秒)
|
||||||
changeTime: '', // 权限变更时间
|
changeTime: '', // 权限变更时间
|
||||||
ws: null,
|
ws: null,
|
||||||
wsCallback: defWsCallback
|
wsCallback: defWsCallback,
|
||||||
|
xsPickerInitialized: false // 学生选择器是否已初始化
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
getToken(): string {
|
getToken(): string {
|
||||||
@ -59,6 +61,9 @@ export const useUserStore = defineStore({
|
|||||||
},
|
},
|
||||||
getChangeTime(): string {
|
getChangeTime(): string {
|
||||||
return this.changeTime;
|
return this.changeTime;
|
||||||
|
},
|
||||||
|
getXsPickerInitialized(): boolean {
|
||||||
|
return this.xsPickerInitialized;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
@ -83,6 +88,9 @@ export const useUserStore = defineStore({
|
|||||||
setChangeTime(changeTime: string) {
|
setChangeTime(changeTime: string) {
|
||||||
this.changeTime = changeTime;
|
this.changeTime = changeTime;
|
||||||
},
|
},
|
||||||
|
setXsPickerInitialized(initialized: boolean) {
|
||||||
|
this.xsPickerInitialized = initialized;
|
||||||
|
},
|
||||||
// 更新学生信息
|
// 更新学生信息
|
||||||
updateStudentInfo(studentInfo: any) {
|
updateStudentInfo(studentInfo: any) {
|
||||||
this.setCurXs(studentInfo);
|
this.setCurXs(studentInfo);
|
||||||
@ -186,6 +194,8 @@ export const useUserStore = defineStore({
|
|||||||
} else {
|
} else {
|
||||||
this.setCurXs({})
|
this.setCurXs({})
|
||||||
}
|
}
|
||||||
|
// 重置学生选择器初始化标记
|
||||||
|
this.setXsPickerInitialized(false);
|
||||||
if (value[AUTH_KEY]) {
|
if (value[AUTH_KEY]) {
|
||||||
this.setToken(value[AUTH_KEY])
|
this.setToken(value[AUTH_KEY])
|
||||||
}
|
}
|
||||||
@ -389,6 +399,7 @@ export const useUserStore = defineStore({
|
|||||||
this.setUser('')
|
this.setUser('')
|
||||||
this.setCurXs({})
|
this.setCurXs({})
|
||||||
this.setAuth([])
|
this.setAuth([])
|
||||||
|
this.setXsPickerInitialized(false); // 注销时重置学生选择器状态
|
||||||
if (this.ws) {
|
if (this.ws) {
|
||||||
this.ws.closeConnect();
|
this.ws.closeConnect();
|
||||||
this.ws = null;
|
this.ws = null;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user