|
@@ -1,329 +1,414 @@
|
|
|
<template>
|
|
|
- <div class="base-school-select">
|
|
|
- <div v-if="!joinSchools || !joinSchools.length">{{ noJoinSchoolContent }}</div>
|
|
|
- <div v-else>
|
|
|
- <!-- 学校切换 -->
|
|
|
- <Dropdown class="school-select" transfer @on-click="onSchoolSelect" trigger="click">
|
|
|
- <img class="school-logo" :src="curSchool.picture" style="width: 25px;" />
|
|
|
- <a href="javascript:void(0)" :class="['base-user-post', areaSchs && areaSchs.length === 1 ? 'single-school' : '']">
|
|
|
- {{ curSchool.name }}
|
|
|
- <Icon type="ios-arrow-down"></Icon>
|
|
|
- </a>
|
|
|
- <DropdownMenu slot="list">
|
|
|
- <div v-for="(item,index) in areaSchs" :key="index">
|
|
|
- <DropdownItem :name="index">
|
|
|
- <div class="school-item">
|
|
|
- <img class="school-item-img" :src="item.picture || defaultLogo" alt="" style="border-radius: 50%;">
|
|
|
- <span>{{ item.name }}</span>
|
|
|
- </div>
|
|
|
- </DropdownItem>
|
|
|
- </div>
|
|
|
- </DropdownMenu>
|
|
|
- </Dropdown>
|
|
|
- <!-- 学段切换 -->
|
|
|
- <Dropdown @on-click="onPeriodSelect" transfer v-show="periods.length > 1" style="margin-left: 20px;">
|
|
|
- <!-- <a href="javascript:void(0)" :class="['base-user-post', periods && periods.length === 1 ? 'single-school' : '']"> -->
|
|
|
- <!-- ( {{ curPeriod.name }} )
|
|
|
- <Icon type="ios-arrow-down"></Icon> -->
|
|
|
- <span class="period-select">
|
|
|
-
|
|
|
- {{ curPeriod.name }}
|
|
|
- <Icon type="md-arrow-dropdown" />
|
|
|
- </span>
|
|
|
- <!-- </a> -->
|
|
|
- <!-- <span class="period-select">{{ curPeriod.name }}</span> -->
|
|
|
- <DropdownMenu slot="list">
|
|
|
- <div v-for="(item,index) in periods" :key="index">
|
|
|
- <DropdownItem :name="index">
|
|
|
- <div class="school-item">
|
|
|
- <span>{{ item.name }}</span>
|
|
|
- </div>
|
|
|
- </DropdownItem>
|
|
|
- </div>
|
|
|
- </DropdownMenu>
|
|
|
- </Dropdown>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ <div class="base-school-select">
|
|
|
+ <div v-if="!joinSchools || !joinSchools.length">{{ noJoinSchoolContent }}</div>
|
|
|
+ <div v-else>
|
|
|
+ <!-- 学校切换 -->
|
|
|
+ <Dropdown class="school-select" transfer @on-click="onSchoolSelect" trigger="click">
|
|
|
+ <img class="school-logo" :src="curSchool.picture" style="width: 25px" />
|
|
|
+ <a href="javascript:void(0)" :class="['base-user-post', areaSchs && areaSchs.length === 1 ? 'single-school' : '']">
|
|
|
+ {{ curSchool.name }}
|
|
|
+ <Icon type="ios-arrow-down"></Icon>
|
|
|
+ </a>
|
|
|
+ <DropdownMenu slot="list">
|
|
|
+ <div v-for="(item, index) in areaSchs" :key="index">
|
|
|
+ <DropdownItem :name="index">
|
|
|
+ <div class="school-item">
|
|
|
+ <img class="school-item-img" :src="item.picture || defaultLogo" alt="" style="border-radius: 50%" />
|
|
|
+ <span>{{ item.name }}</span>
|
|
|
+ </div>
|
|
|
+ </DropdownItem>
|
|
|
+ </div>
|
|
|
+ </DropdownMenu>
|
|
|
+ </Dropdown>
|
|
|
+ <!-- 学段切换 -->
|
|
|
+ <Dropdown @on-click="onPeriodSelect" transfer style="margin-left: 20px">
|
|
|
+ <span class="period-select">
|
|
|
+
|
|
|
+ {{ curPeriod.name }}
|
|
|
+ <Icon type="md-arrow-dropdown" />
|
|
|
+ </span>
|
|
|
+ <DropdownMenu slot="list">
|
|
|
+ <div v-for="(item, index) in periods" :key="index">
|
|
|
+ <DropdownItem :name="index">
|
|
|
+ <div class="school-item">
|
|
|
+ <span>{{ item.name }}</span>
|
|
|
+ </div>
|
|
|
+ </DropdownItem>
|
|
|
+ </div>
|
|
|
+ </DropdownMenu>
|
|
|
+ </Dropdown>
|
|
|
+ <!-- 学期切换 -->
|
|
|
+ <Dropdown @on-click="onSemesterSelect" transfer style="margin-left: 20px" v-if="curSemester">
|
|
|
+ <span class="period-select">
|
|
|
+
|
|
|
+ {{ curSemester.year + $t('unit.year') + curSemester.name }}
|
|
|
+ <Icon type="md-arrow-dropdown" />
|
|
|
+ </span>
|
|
|
+ <DropdownMenu slot="list">
|
|
|
+ <div v-for="(item, index) in semesterList" :key="index">
|
|
|
+ <DropdownItem :name="index">
|
|
|
+ <div class="school-item">
|
|
|
+ <span :style="{ color: yearColorArr[getYearStatus(item.year)], fontWeight: getYearStatus(item.year) === 1 ? '600' : '400' }">{{ item.year + $t('unit.year') + item.name }}</span>
|
|
|
+ </div>
|
|
|
+ </DropdownItem>
|
|
|
+ </div>
|
|
|
+ </DropdownMenu>
|
|
|
+ </Dropdown>
|
|
|
+ <span style="margin-left: 10px;cursor: pointer;" @click="goNowSemester()" v-if="!isNowSemester" title="回到当前学期">
|
|
|
+ <Icon type="md-sync" color="#16b1f3"/>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { mapGetters } from 'vuex'
|
|
|
-import User from '@/service/User.js'
|
|
|
-export default {
|
|
|
- inject: ['reload'],
|
|
|
- data() {
|
|
|
- return {
|
|
|
- curSchool: {
|
|
|
- logo: ''
|
|
|
+ import { mapGetters } from "vuex";
|
|
|
+ import User from "@/service/User.js";
|
|
|
+ export default {
|
|
|
+ inject: ["reload"],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ yearColorArr:['#969696','#16b1f3','#19be6b'],
|
|
|
+ curSchool: {
|
|
|
+ logo: ""
|
|
|
+ },
|
|
|
+ defaultLogo: "",
|
|
|
+ user: {
|
|
|
+ schools: []
|
|
|
+ },
|
|
|
+ joinSchools: [],
|
|
|
+ areaSchs: [],
|
|
|
+ areaList: [],
|
|
|
+ periods: [],
|
|
|
+ curYear:new Date().getFullYear(),
|
|
|
+ curPeriod: {
|
|
|
+ name: ""
|
|
|
+ },
|
|
|
+ curSemester:null,
|
|
|
+ nowSemesterIndex: -1
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ console.log("BaseSelectSchool初始化");
|
|
|
+ console.log(this.userProfile);
|
|
|
+ this.defaultLogo = require("@/assets/icon/default_school.png");
|
|
|
+ // 获取本地存储中的 用户信息
|
|
|
+ let user = this.$store.state.user.userProfile || JSON.parse(decodeURIComponent(localStorage.user_profile, "utf-8"));
|
|
|
+ let schoolProfile = localStorage.school_profile ? JSON.parse(decodeURIComponent(localStorage.school_profile, "utf-8")) : undefined;
|
|
|
+ let localPeriodInfo = localStorage.curPeriod ? JSON.parse(localStorage.curPeriod) : null;
|
|
|
+ let localSemester = localStorage.curSemester ? JSON.parse(localStorage.curSemester) : null;
|
|
|
+ this.user.schools = user.schools;
|
|
|
+ let joinSchools = user.schools && user.schools.length ? user.schools.filter((i) => i.status === "join") : null;
|
|
|
+ console.log(joinSchools);
|
|
|
+ /* 如果加入的学校都没有归属区 则需要补充‘其他学校’区 */
|
|
|
+ if (joinSchools && joinSchools.length) {
|
|
|
+ joinSchools.forEach((i) => {
|
|
|
+ if (!i.area) {
|
|
|
+ i.area = {
|
|
|
+ name: this.$t("ability.otherSch"),
|
|
|
+ access: 0
|
|
|
+ };
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ this.joinSchools = joinSchools;
|
|
|
+ // 如果本地存储已经有保存学校信息 则刷新后会直接读取之前的学校信息
|
|
|
+ if (joinSchools && joinSchools.length) {
|
|
|
+ if (schoolProfile) {
|
|
|
+ this.curSchool = joinSchools.find((i) => i.schoolId === schoolProfile.school_base.id);
|
|
|
+ } else {
|
|
|
+ this.curSchool = user.defaultschool ? joinSchools.find((i) => i.schoolId === user.defaultschool) : joinSchools[0];
|
|
|
+ }
|
|
|
+ this.$store.commit("setSchoolCode", this.curSchool.schoolId);
|
|
|
+ this.areaList = [...new Set(this.joinSchools.map((i) => i.area).map((j) => j.name))];
|
|
|
+ this.areaSchs = this.joinSchools.filter((i) => i.area.name === this.curSchool.area.name);
|
|
|
+ this.periods = this.$store.state.user.schoolProfile.school_base.period;
|
|
|
+ this.periods && (this.curPeriod = this.periods[localPeriodInfo && localPeriodInfo.periodIndex ? localPeriodInfo.periodIndex : 0]);
|
|
|
+ if (!localPeriodInfo) {
|
|
|
+ this.curPeriod.periodIndex = 0;
|
|
|
+ // 保存Vuex
|
|
|
+ this.$store.commit("user/setCurPeriod", this.curPeriod);
|
|
|
+ // 保存Stroage
|
|
|
+ this.curSemester = this.getNowSemester()
|
|
|
+ console.error('默认设置学年期',this.curSemester)
|
|
|
+ localStorage.setItem("curPeriod", JSON.stringify(this.curPeriod));
|
|
|
+ this.$store.commit("user/setCurSemester", this.curSemester);
|
|
|
+ } else {
|
|
|
+ this.$store.commit("user/setCurPeriod", localPeriodInfo);
|
|
|
+ if(localSemester){
|
|
|
+ this.curSemester = localSemester
|
|
|
+ console.error('读取缓存学年期',localSemester)
|
|
|
+ this.$store.commit("user/setCurSemester", localSemester);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.refreshNowSemesterIndex()
|
|
|
+
|
|
|
+ } else {
|
|
|
+ this.$Message.warning(this.$t("utils.noShoolTip"));
|
|
|
+ }
|
|
|
+ console.log("当前区域学校 > ", this.areaSchs);
|
|
|
+ console.log("当前学校 > ", this.curSchool);
|
|
|
+ console.log("当前学段 > ", this.curPeriod);
|
|
|
+ console.log("vuex - school ====== ", this.$store.state.user.schoolProfile.school_base);
|
|
|
+ /* 判断学校基础信息是否初始化 true-则需要进入基础设置弹窗 false-不弹窗 */
|
|
|
+ let isInit = this.$store.state.user.schoolProfile.school_base.isinit;
|
|
|
+ if (isInit && this.$access.can("admin.*|schoolSetting-read|schoolSetting-upd")) {
|
|
|
+ this.$router.push({
|
|
|
+ name: "system",
|
|
|
+ params: {
|
|
|
+ from: "init"
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ this.$EventBus.$emit("homePageInit");
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async onSchoolSelect(val) {
|
|
|
+ /* 如果没有加入的学校或者加入的学校都没有归属区 */
|
|
|
+ if (this.joinSchools.length) {
|
|
|
+ this.joinSchools.forEach((i) => {
|
|
|
+ if (!i.area) {
|
|
|
+ i.area = {
|
|
|
+ name: this.$t("ability.otherSch")
|
|
|
+ };
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ let curAreaName = sessionStorage.getItem("areaName") || this.areaList[0];
|
|
|
+ this.joinSchools = this.user.schools.filter((i) => i.status === "join");
|
|
|
+ this.areaSchs = this.joinSchools.filter((i) => i.area.name === curAreaName);
|
|
|
+ this.curSchool = this.areaSchs[val];
|
|
|
+ let schoolCode = this.areaSchs[val].schoolId;
|
|
|
+ this.changeCurSchool(schoolCode);
|
|
|
+ },
|
|
|
+
|
|
|
+ /* 学段选择 */
|
|
|
+ onPeriodSelect(val) {
|
|
|
+ this.curPeriod = this.periods[val];
|
|
|
+ // 保存Vuex
|
|
|
+ this.$store.commit("user/setCurPeriod", this.curPeriod);
|
|
|
+ // 保存当前学段的下标 提供给部分模块的select使用
|
|
|
+ this.curPeriod.periodIndex = val;
|
|
|
+ // 默认切换到当前学段下的当前学期
|
|
|
+ this.curSemester = this.getNowSemester();
|
|
|
+ this.$store.commit("user/setCurSemester", this.curSemester);
|
|
|
+ this.refreshNowSemesterIndex()
|
|
|
+ },
|
|
|
+ /* 学期选择 */
|
|
|
+ onSemesterSelect(val){
|
|
|
+ this.curSemester = this.semesterList[val];
|
|
|
+ this.$store.commit("user/setCurSemester", this.curSemester);
|
|
|
+ console.error('xxxxxxxxxxxxxxxxxxx',this.$tools.getStTimeByYearAndSemester(this.curSemester.year,this.curSemester.index))
|
|
|
},
|
|
|
- defaultLogo: '',
|
|
|
- user: {
|
|
|
- schools: []
|
|
|
+ refreshNowSemesterIndex(){
|
|
|
+ let nowSemester = this.getNowSemester()
|
|
|
+ this.nowSemesterIndex = this.semesterList.findIndex(i => i.year === nowSemester.year && i.id === nowSemester.id)
|
|
|
},
|
|
|
- joinSchools: [],
|
|
|
- areaSchs: [],
|
|
|
- areaList: [],
|
|
|
- periods: [],
|
|
|
- curPeriod: {
|
|
|
- name: ''
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- created() {
|
|
|
- console.log('BaseSelectSchool初始化')
|
|
|
- console.log(this.userProfile)
|
|
|
- this.defaultLogo = require('@/assets/icon/default_school.png')
|
|
|
- // 获取本地存储中的 用户信息
|
|
|
- let user = this.$store.state.user.userProfile || JSON.parse(decodeURIComponent(localStorage.user_profile, "utf-8"));
|
|
|
- let schoolProfile = localStorage.school_profile ? JSON.parse(decodeURIComponent(localStorage.school_profile,
|
|
|
- "utf-8")) : undefined;
|
|
|
- let localPeriodInfo = localStorage.curPeriod ? JSON.parse(localStorage.curPeriod) : null
|
|
|
- this.user.schools = user.schools
|
|
|
- let joinSchools = user.schools && user.schools.length ? user.schools.filter(i => i.status === 'join') : null
|
|
|
- console.log(joinSchools);
|
|
|
- /* 如果加入的学校都没有归属区 则需要补充‘其他学校’区 */
|
|
|
- if (joinSchools && joinSchools.length) {
|
|
|
- joinSchools.forEach(i => {
|
|
|
- if (!i.area) {
|
|
|
- i.area = {
|
|
|
- name: this.$t('ability.otherSch'),
|
|
|
- access: 0
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- this.joinSchools = joinSchools
|
|
|
- // 如果本地存储已经有保存学校信息 则刷新后会直接读取之前的学校信息
|
|
|
- if (joinSchools && joinSchools.length) {
|
|
|
- if (schoolProfile) {
|
|
|
- this.curSchool = joinSchools.find(i => i.schoolId === schoolProfile.school_base.id)
|
|
|
- } else {
|
|
|
- this.curSchool = user.defaultschool ? joinSchools.find(i => i.schoolId === user.defaultschool) : joinSchools[0]
|
|
|
- }
|
|
|
- this.$store.commit('setSchoolCode', this.curSchool.schoolId)
|
|
|
- this.areaList = [...new Set(this.joinSchools.map(i => i.area).map(j => j.name))]
|
|
|
- this.areaSchs = this.joinSchools.filter(i => i.area.name === this.curSchool.area.name)
|
|
|
- this.periods = this.$store.state.user.schoolProfile.school_base.period
|
|
|
- this.periods && (this.curPeriod = this.periods[localPeriodInfo && localPeriodInfo.periodIndex ? localPeriodInfo.periodIndex : 0])
|
|
|
- if (!localPeriodInfo) {
|
|
|
- this.curPeriod.periodIndex = 0
|
|
|
- // 保存Vuex
|
|
|
- this.$store.commit('user/setCurPeriod', this.curPeriod)
|
|
|
- // 保存Stroage
|
|
|
- localStorage.setItem('curPeriod', JSON.stringify(this.curPeriod))
|
|
|
- } else {
|
|
|
- this.$store.commit('user/setCurPeriod', localPeriodInfo)
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.$Message.warning(this.$t('utils.noShoolTip'))
|
|
|
- }
|
|
|
- console.log('当前区域学校 > ', this.areaSchs)
|
|
|
- console.log('当前学校 > ', this.curSchool)
|
|
|
- console.log('当前学段 > ', this.curPeriod)
|
|
|
- console.log('vuex - school ====== ', this.$store.state.user.schoolProfile.school_base)
|
|
|
- /* 判断学校基础信息是否初始化 true-则需要进入基础设置弹窗 false-不弹窗 */
|
|
|
- let isInit = this.$store.state.user.schoolProfile.school_base.isinit
|
|
|
- if (isInit && this.$access.can('admin.*|schoolSetting-read|schoolSetting-upd')) {
|
|
|
- this.$router.push({
|
|
|
- name: 'system',
|
|
|
- params: {
|
|
|
- from: 'init'
|
|
|
+ /* 切换到当前学期 */
|
|
|
+ goNowSemester(){
|
|
|
+ this.onSemesterSelect(this.nowSemesterIndex)
|
|
|
+ },
|
|
|
+ /* 学校切换后针对当前学校CODE进行操作 */
|
|
|
+ changeCurSchool(schoolCode, routerInfo) {
|
|
|
+ // this.$EventBus.$emit('onChangeSchool', {
|
|
|
+ // schoolCode: schoolCode
|
|
|
+ // })
|
|
|
+ this.$EventBus.$emit("onGlobalLoading", true);
|
|
|
+ // 更新当前school_code
|
|
|
+ this.$store.dispatch("user/setSchoolCode", schoolCode);
|
|
|
+ // 更新当前school_profile以及access
|
|
|
+ this.$store.dispatch("user/checkSchoolProfile").then((res) => {
|
|
|
+ if (res) {
|
|
|
+ this.$User.freshLogin();
|
|
|
+ }
|
|
|
+ console.log("切换学校了", this.curSchool, schoolCode);
|
|
|
+ console.log("当前学校的学段信息", this.$store.state.user.schoolProfile.school_base.period);
|
|
|
+ // 将教师列表信息清空
|
|
|
+ this.$store.commit("user/setTeachers", undefined);
|
|
|
+ localStorage.removeItem("curSemester");
|
|
|
+ this.periods = this.$store.state.user.schoolProfile.school_base.period;
|
|
|
+ let vuexPeriod = this.$store.state.user.curPeriod;
|
|
|
+ let preSchoolCode = localStorage.getItem("cur_schoolCode");
|
|
|
+ // 判断之前已经选择了学段 并且从区级切换回来的是同一学校 则去读取存储的学段数据 否则默认读取第一个学段信息
|
|
|
+ if (vuexPeriod && preSchoolCode && preSchoolCode === schoolCode) {
|
|
|
+ this.onPeriodSelect(vuexPeriod.periodIndex);
|
|
|
+ } else {
|
|
|
+ this.onPeriodSelect(0);
|
|
|
+ }
|
|
|
+ localStorage.removeItem("cacheSchoolFiles");
|
|
|
+ localStorage.removeItem("bankFilterConds");
|
|
|
+ localStorage.setItem("cur_schoolCode", schoolCode);
|
|
|
+ this.$emit("onSchoolChange", schoolCode);
|
|
|
+ this.$EventBus.$emit("onSchoolChange");
|
|
|
+ setTimeout(() => {
|
|
|
+ this.$EventBus.$emit("onGlobalLoading", false);
|
|
|
+ }, 1500);
|
|
|
+ /* 判断学校基础信息是否初始化 */
|
|
|
+ let isInit = this.$store.state.user.schoolProfile.school_base.isinit;
|
|
|
+ // 如果学校还没有初始化 则默认跳转到 基础设置页面
|
|
|
+ if (isInit && this.$access.can("admin.*|schoolSetting-read|schoolSetting-upd")) {
|
|
|
+ routerInfo = { name: "system" };
|
|
|
+ }
|
|
|
+ routerInfo = routerInfo || { name: "home" };
|
|
|
+ this.$router.push(routerInfo);
|
|
|
+ if (routerInfo.name === this.$route.name) {
|
|
|
+ this.reload();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getNowSemester(){
|
|
|
+ let semesterRange = this.$tools.getSemesterTimeRange();
|
|
|
+ return {
|
|
|
+ year:semesterRange.year,
|
|
|
+ name: semesterRange.name,
|
|
|
+ index:semesterRange.semesterIndex,
|
|
|
+ id:semesterRange.semesterId
|
|
|
}
|
|
|
- })
|
|
|
- }
|
|
|
- this.$EventBus.$emit('homePageInit')
|
|
|
- },
|
|
|
- methods: {
|
|
|
- async onSchoolSelect(val) {
|
|
|
- /* 如果没有加入的学校或者加入的学校都没有归属区 */
|
|
|
- if (this.joinSchools.length) {
|
|
|
- this.joinSchools.forEach(i => {
|
|
|
- if (!i.area) {
|
|
|
- i.area = {
|
|
|
- name: this.$t('ability.otherSch')
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- let curAreaName = sessionStorage.getItem('areaName') || this.areaList[0]
|
|
|
- this.joinSchools = this.user.schools.filter(i => i.status === 'join')
|
|
|
- this.areaSchs = this.joinSchools.filter(i => i.area.name === curAreaName)
|
|
|
- // this.$EventBus.$emit('onGlobalLoading', true)
|
|
|
- this.curSchool = this.areaSchs[val]
|
|
|
- let schoolCode = this.areaSchs[val].schoolId
|
|
|
- this.changeCurSchool(schoolCode)
|
|
|
- },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ // 解绑之前的事件 防止多次触发
|
|
|
+ // this.$EventBus.$off('onChangeSchool')
|
|
|
+ // this.$EventBus.$on('onChangeSchool', params => {
|
|
|
+ // if (this.curSchool && params.schoolCode !== this.curSchool.schoolId && params.user) {
|
|
|
+ // console.log('检测到切换学校')
|
|
|
+ // console.log(params)
|
|
|
+ // this.user = params.user
|
|
|
+ // let joinSchools = params.user.schools.filter(i => i.status === 'join')
|
|
|
+ // this.onSchoolSelect(params.isFirst ? 0 : joinSchools.map(j => j.schoolId).indexOf(params.schoolCode))
|
|
|
+ // }
|
|
|
+ // })
|
|
|
|
|
|
- /* 学段选择 */
|
|
|
- onPeriodSelect(val) {
|
|
|
- this.curPeriod = this.periods[val]
|
|
|
- // 保存当前学段的下标 提供给部分模块的select使用
|
|
|
- this.curPeriod.periodIndex = val
|
|
|
- // 保存Vuex
|
|
|
- this.$store.commit('user/setCurPeriod', this.curPeriod)
|
|
|
- // 保存Stroage
|
|
|
- localStorage.setItem('curPeriod', JSON.stringify(this.curPeriod))
|
|
|
- },
|
|
|
+ // 监听区的切换
|
|
|
+ this.$EventBus.$off("onChangeArea");
|
|
|
+ this.$EventBus.$on("onChangeArea", (params) => {
|
|
|
+ console.log("区域切换", params);
|
|
|
+ console.log("区域切换", this.joinSchools);
|
|
|
+ if (this.joinSchools && this.joinSchools.length) {
|
|
|
+ this.areaSchs = this.joinSchools.filter((i) => i.area.name === params.areaName);
|
|
|
+ console.log(this.areaSchs);
|
|
|
+ this.curSchool = params.schoolCode ? this.areaSchs.find((i) => i.schoolId === params.schoolCode) : this.areaSchs[0];
|
|
|
+ let schoolCode = this.curSchool.schoolId;
|
|
|
+ this.changeCurSchool(schoolCode, params.routerInfo);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ noJoinSchoolContent() {
|
|
|
+ let inviteSchools = this.user.schools.filter((i) => i.status === "invite");
|
|
|
+ let requestSchools = this.user.schools.filter((i) => i.status === "request");
|
|
|
+ // return requestSchools.length ? `${requestSchools[0].name}(${this.$t('settings.status3')})` : (inviteSchools.length ? `${inviteSchools[0].name}(${this.$t('settings.status2')})` : this.$t('utils.noJoinSchool'))
|
|
|
+ return requestSchools.length ? `${requestSchools[0].name}(${this.$t("settings.status3")})` : inviteSchools.length ? `${inviteSchools[0].name}(${this.$t("settings.status2")})` : "";
|
|
|
+ },
|
|
|
+
|
|
|
+ /* 获取学期列表数据 */
|
|
|
+ semesterList(){
|
|
|
+ let curYear = new Date().getFullYear()
|
|
|
+ let semesterArr = this.curPeriod.semesters
|
|
|
+ let gradeCount = this.curPeriod.grades.length
|
|
|
+ let listYearCount = gradeCount + 1 // 可选年份范围是当前学段下年级数量 再往后推一年(可能会查看未来的排课表)
|
|
|
+ let oldYear = curYear - gradeCount
|
|
|
+ let arr = []
|
|
|
+ for (let i = 0; i <= listYearCount; i ++){
|
|
|
+ for(let j = 0; j < semesterArr.length; j++){
|
|
|
+ arr.push({
|
|
|
+ year:oldYear + i,
|
|
|
+ name: semesterArr[j].name,
|
|
|
+ index:j,
|
|
|
+ id:semesterArr[j].id
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return arr
|
|
|
+ },
|
|
|
|
|
|
- /* 学校切换后针对当前学校CODE进行操作 */
|
|
|
- changeCurSchool(schoolCode, routerInfo) {
|
|
|
- // this.$EventBus.$emit('onChangeSchool', {
|
|
|
- // schoolCode: schoolCode
|
|
|
- // })
|
|
|
- this.$EventBus.$emit('onGlobalLoading', true)
|
|
|
- // 更新当前school_code
|
|
|
- this.$store.dispatch('user/setSchoolCode', schoolCode)
|
|
|
- // 更新当前school_profile以及access
|
|
|
- this.$store.dispatch('user/checkSchoolProfile').then(res => {
|
|
|
- if (res) {
|
|
|
- this.$User.freshLogin()
|
|
|
- }
|
|
|
- console.log('切换学校了', this.curSchool, schoolCode)
|
|
|
- console.log('当前学校的学段信息', this.$store.state.user.schoolProfile.school_base.period)
|
|
|
- // 将教师列表信息清空
|
|
|
- this.$store.commit('user/setTeachers', undefined)
|
|
|
- this.periods = this.$store.state.user.schoolProfile.school_base.period
|
|
|
- let vuexPeriod = this.$store.state.user.curPeriod
|
|
|
- let preSchoolCode = localStorage.getItem('cur_schoolCode')
|
|
|
- // 判断之前已经选择了学段 并且从区级切换回来的是同一学校 则去读取存储的学段数据 否则默认读取第一个学段信息
|
|
|
- if (vuexPeriod && preSchoolCode && preSchoolCode === schoolCode) {
|
|
|
- this.onPeriodSelect(vuexPeriod.periodIndex)
|
|
|
- } else {
|
|
|
- this.onPeriodSelect(0)
|
|
|
+ /* 判断过去、现在和未来 */
|
|
|
+ getYearStatus(){
|
|
|
+ return year => {
|
|
|
+ return year === this.curYear ? 1 : year < this.curYear ? 0 : 2
|
|
|
}
|
|
|
- localStorage.removeItem('cacheSchoolFiles')
|
|
|
- localStorage.removeItem('bankFilterConds')
|
|
|
- localStorage.setItem('cur_schoolCode', schoolCode)
|
|
|
- this.$emit('onSchoolChange', schoolCode)
|
|
|
- this.$EventBus.$emit('onSchoolChange')
|
|
|
- setTimeout(() => {
|
|
|
- this.$EventBus.$emit('onGlobalLoading', false)
|
|
|
- }, 1500)
|
|
|
- /* 判断学校基础信息是否初始化 */
|
|
|
- let isInit = this.$store.state.user.schoolProfile.school_base.isinit
|
|
|
- // 如果学校还没有初始化 则默认跳转到 基础设置页面
|
|
|
- if (isInit && this.$access.can('admin.*|schoolSetting-read|schoolSetting-upd')) {
|
|
|
- routerInfo = { name: 'system' }
|
|
|
- }
|
|
|
- routerInfo = routerInfo || { name: 'home' }
|
|
|
- this.$router.push(routerInfo)
|
|
|
- if (routerInfo.name === this.$route.name) {
|
|
|
- this.reload()
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
- mounted() {
|
|
|
- // 解绑之前的事件 防止多次触发
|
|
|
- // this.$EventBus.$off('onChangeSchool')
|
|
|
- // this.$EventBus.$on('onChangeSchool', params => {
|
|
|
- // if (this.curSchool && params.schoolCode !== this.curSchool.schoolId && params.user) {
|
|
|
- // console.log('检测到切换学校')
|
|
|
- // console.log(params)
|
|
|
- // this.user = params.user
|
|
|
- // let joinSchools = params.user.schools.filter(i => i.status === 'join')
|
|
|
- // this.onSchoolSelect(params.isFirst ? 0 : joinSchools.map(j => j.schoolId).indexOf(params.schoolCode))
|
|
|
- // }
|
|
|
- // })
|
|
|
+ },
|
|
|
|
|
|
- // 监听区的切换
|
|
|
- this.$EventBus.$off('onChangeArea')
|
|
|
- this.$EventBus.$on('onChangeArea', params => {
|
|
|
- console.log('区域切换', params);
|
|
|
- console.log('区域切换', this.joinSchools);
|
|
|
- if (this.joinSchools && this.joinSchools.length) {
|
|
|
- this.areaSchs = this.joinSchools.filter(i => i.area.name === params.areaName)
|
|
|
- console.log(this.areaSchs);
|
|
|
- this.curSchool = params.schoolCode ? this.areaSchs.find(i => i.schoolId === params.schoolCode) : this.areaSchs[0]
|
|
|
- let schoolCode = this.curSchool.schoolId
|
|
|
- this.changeCurSchool(schoolCode, params.routerInfo)
|
|
|
+ /* 判断是否当前学期 */
|
|
|
+ isNowSemester(){
|
|
|
+ return this.nowSemesterIndex === this.semesterList.findIndex(i => i.year === this.curSemester.year && i.id === this.curSemester.id)
|
|
|
}
|
|
|
- })
|
|
|
- },
|
|
|
-
|
|
|
- computed: {
|
|
|
- noJoinSchoolContent() {
|
|
|
- let inviteSchools = this.user.schools.filter(i => i.status === 'invite')
|
|
|
- let requestSchools = this.user.schools.filter(i => i.status === 'request')
|
|
|
- // return requestSchools.length ? `${requestSchools[0].name}(${this.$t('settings.status3')})` : (inviteSchools.length ? `${inviteSchools[0].name}(${this.$t('settings.status2')})` : this.$t('utils.noJoinSchool'))
|
|
|
- return requestSchools.length ? `${requestSchools[0].name}(${this.$t('settings.status3')})` : (inviteSchools.length ? `${inviteSchools[0].name}(${this.$t('settings.status2')})` : '')
|
|
|
- },
|
|
|
- }
|
|
|
-}
|
|
|
+ }
|
|
|
+ };
|
|
|
</script>
|
|
|
|
|
|
<style lang="less">
|
|
|
-.base-school-select {
|
|
|
- // font-family: 'NotoSerif', '微软正黑体', 'Microsoft JhengHei UI', 'Microsoft JhengHei', Sans-serif;
|
|
|
- .ivu-dropdown {
|
|
|
- .ivu-select-dropdown {
|
|
|
- width: max-content;
|
|
|
- width: -webkit-max-content;
|
|
|
- left: -35%;
|
|
|
- }
|
|
|
+ .base-school-select {
|
|
|
+ .ivu-dropdown {
|
|
|
+ .ivu-select-dropdown {
|
|
|
+ width: max-content;
|
|
|
+ width: -webkit-max-content;
|
|
|
+ left: -35%;
|
|
|
+ }
|
|
|
|
|
|
- .ivu-dropdown-menu {
|
|
|
- max-height: 600px;
|
|
|
- overflow: auto;
|
|
|
- }
|
|
|
+ .ivu-dropdown-menu {
|
|
|
+ max-height: 600px;
|
|
|
+ overflow: auto;
|
|
|
+ }
|
|
|
|
|
|
- .ivu-dropdown-item:hover {
|
|
|
- background: #83d7ff;
|
|
|
- }
|
|
|
+ .ivu-dropdown-item:hover {
|
|
|
+ background: #83d7ff;
|
|
|
+ }
|
|
|
|
|
|
- a {
|
|
|
- color: var(--primary-textColor) !important;
|
|
|
+ a {
|
|
|
+ color: var(--primary-textColor) !important;
|
|
|
|
|
|
- &:hover {
|
|
|
- color: var(--primary-textColor) !important;
|
|
|
- }
|
|
|
|
|
|
- .ivu-icon {
|
|
|
- display: none;
|
|
|
- }
|
|
|
+ &:hover {
|
|
|
+ color: var(--primary-textColor) !important;
|
|
|
+ }
|
|
|
|
|
|
- &::after {
|
|
|
- content: "";
|
|
|
- display: inline-block;
|
|
|
- width: 0;
|
|
|
- height: 0;
|
|
|
- border-right: solid 6px transparent;
|
|
|
- border-left: solid 6px transparent;
|
|
|
- border-top: solid 6px #16b1f3;
|
|
|
- margin-left: 2px;
|
|
|
- margin-bottom: 3px;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ .ivu-icon {
|
|
|
+ display: none;
|
|
|
+ }
|
|
|
+
|
|
|
+ &::after {
|
|
|
+ content: "";
|
|
|
+ display: inline-block;
|
|
|
+ width: 0;
|
|
|
+ height: 0;
|
|
|
+ border-right: solid 6px transparent;
|
|
|
+ border-left: solid 6px transparent;
|
|
|
+ border-top: solid 6px #16b1f3;
|
|
|
+ margin-left: 2px;
|
|
|
+ margin-bottom: 3px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- .period-select {
|
|
|
- font-size: 16px;
|
|
|
- background: #1cc0f3;
|
|
|
- padding: 2px 5px;
|
|
|
- border-radius: 5px;
|
|
|
- cursor: pointer;
|
|
|
- }
|
|
|
+ .period-select {
|
|
|
+ font-size: 14px;
|
|
|
+ background: #0287af;
|
|
|
+ padding: 5px;
|
|
|
+ border-radius: 25px;
|
|
|
+ cursor: pointer;
|
|
|
+ }
|
|
|
|
|
|
- .single-school {
|
|
|
- &::after {
|
|
|
- display: none !important;
|
|
|
- }
|
|
|
- }
|
|
|
+ .single-school {
|
|
|
+ &::after {
|
|
|
+ display: none !important;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- .school-logo {
|
|
|
- width: 30px;
|
|
|
- border-radius: 50%;
|
|
|
- margin-right: 10px;
|
|
|
- margin-bottom: 5px;
|
|
|
- vertical-align: middle;
|
|
|
- }
|
|
|
-}
|
|
|
-.school-item {
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
-}
|
|
|
-.school-item-img {
|
|
|
- width: 30px;
|
|
|
- margin-right: 15px;
|
|
|
-}
|
|
|
+ .school-logo {
|
|
|
+ width: 30px;
|
|
|
+ border-radius: 50%;
|
|
|
+ margin-right: 10px;
|
|
|
+ margin-bottom: 5px;
|
|
|
+ vertical-align: middle;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .school-item {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ }
|
|
|
+ .school-item-img {
|
|
|
+ width: 30px;
|
|
|
+ margin-right: 15px;
|
|
|
+ }
|
|
|
</style>
|