From e1f87494b737169c412ca723baf3085cb0c5706e Mon Sep 17 00:00:00 2001 From: QYF-GitLab1 <1940665526@qq.com> Date: 星期日, 24 八月 2025 11:28:24 +0800 Subject: [PATCH] 课程管理 --- src/views/classManage/index.vue | 133 +++++++++++++++++++++---------------------- 1 files changed, 65 insertions(+), 68 deletions(-) diff --git a/src/views/classManage/index.vue b/src/views/classManage/index.vue index 9a0405a..cdc925a 100644 --- a/src/views/classManage/index.vue +++ b/src/views/classManage/index.vue @@ -1,6 +1,5 @@ <template> - <div class="layoutBox"> - <Header class="header"></Header> + <div class="layoutBoxClass"> <div class="layoutContentBox clear"> <div class="classContentBox clear"> <div class="leftList fl"> @@ -50,126 +49,119 @@ </template> <script setup lang="ts"> -import { ref, watch, provide, onMounted, inject } from "vue"; -import { useRoute, useRouter, onBeforeRouteUpdate } from "vue-router"; -import Header from "./components/headerPage.vue"; -import { menu } from "./config"; -import { getPublicImage } from "@/assets/js/middleGround/tool.js"; -import defaultImg from "@/assets/images/default-book-img.png"; +import { ref, watch, provide, onMounted, inject } from 'vue' +import { useRoute, useRouter, onBeforeRouteUpdate } from 'vue-router' +import { menu } from './config' +import { getPublicImage } from '@/assets/js/middleGround/tool.js' +import defaultImg from '@/assets/images/default-book-img.png' -const router: any = useRouter(); -const route: any = useRoute(); -const MG: any = inject("MG"); -const config: any = inject("config"); -const routerVal = router.currentRoute.value; -const path = ref(routerVal.path); -const label = ref(""); -const classInfo: any = ref(); -const classIcon: any = ref(); -const listMenu = ref([]); -const activeIndex = ref(0); -const userData = ref(); +const router: any = useRouter() +const route: any = useRoute() +const MG: any = inject('MG') +const config: any = inject('config') +const routerVal = router.currentRoute.value +const path = ref(routerVal.path) +const label = ref('') +const classInfo: any = ref() +const classIcon: any = ref() +const listMenu = ref([]) +const activeIndex = ref(0) +const userData = ref() watch(router.currentRoute, (val) => { - path.value = val.path; + path.value = val.path if (val.query.classInfo) { - const data: any = val.query.classInfo; - const routerInfo: any = JSON.parse(data); - activeIndex.value = routerInfo.index; + const data: any = val.query.classInfo + const routerInfo: any = JSON.parse(data) + activeIndex.value = routerInfo.index } -}); +}) watch(classInfo, (val) => { if (val) { - activeIndex.value = val.index; + activeIndex.value = val.index } if (!val.index) { - activeIndex.value = 0; + activeIndex.value = 0 } -}); +}) onBeforeRouteUpdate(async (to, from) => { - path.value = to.path; -}); + path.value = to.path +}) onMounted(() => { - classInfo.value = JSON.parse(route.query.classInfo); - classIcon.value = classInfo.value.icon - ? getPublicImage(classInfo.value.icon, 200) - : defaultImg; + classInfo.value = JSON.parse(route.query.classInfo) + classIcon.value = classInfo.value.icon ? getPublicImage(classInfo.value.icon, 200) : defaultImg menu.forEach((item) => { - if ("/" + item.path === path.value) { - label.value = item.label; + if ('/' + item.path === path.value) { + label.value = item.label } - }); - const userCache: any = localStorage.getItem(config.userInfoKey); - const userInfo = JSON.parse(userCache); - userData.value = userInfo; + }) + const userCache: any = localStorage.getItem(config.userInfoKey) + const userInfo = JSON.parse(userCache) + userData.value = userInfo if (!userInfo) { router.push({ - path: "/", - }); - return false; + path: '/', + }) + return false } - if (userInfo.role != "Teacher") { + if (userInfo.role != 'Teacher') { const data: any = menu.filter( - (item: any) => item.path != "studentManage" && item.path != "jobAnalysis" - ); - listMenu.value = data; + (item: any) => item.path != 'studentManage' && item.path != 'jobAnalysis', + ) + listMenu.value = data } else { - const data: any = menu; + const data: any = menu // if (!classInfo.bookRefCode) { // // 铻嶅獟浣撳浘涔︼紝鏃犳暟瀛楅槄璇伙紝鏃犳硶璺宠浆 // const list: any = menu.filter((item: any) => item.path != 'teachingPlan') // listMenu.value = list; // return false // } - listMenu.value = data; + listMenu.value = data } -}); +}) const goRouter = (item: any, index: number) => { - activeIndex.value = index; - if ( - !localStorage.getItem(config.tokenKey) || - localStorage.getItem(config.tokenKey) == null - ) { + activeIndex.value = index + if (!localStorage.getItem(config.tokenKey) || localStorage.getItem(config.tokenKey) == null) { router.push({ - path: "/home", + path: '/home', query: { - showLogin: "1", + showLogin: '1', }, - }); + }) } else { - label.value = item.label; - classInfo.value.index = index; + label.value = item.label + classInfo.value.index = index if (item.key == 5) { router.push({ - path: userData.value.role != "Teacher" ? "/studentJob" : "/jobManage", + path: userData.value.role != 'Teacher' ? '/studentJob' : '/jobManage', query: { classInfo: JSON.stringify(classInfo.value), }, - }); + }) } else { router.push({ path: item.path, query: { classInfo: JSON.stringify(classInfo.value), }, - }); + }) } } -}; +} const goBack = () => { - router.go(-1); -}; + router.go(-1) +} </script> <style lang="less" scoped> -.layoutBox { +.layoutBoxClass { width: 100%; - height: 100vh; display: flex; flex-direction: column; background-color: #fff; @@ -255,7 +247,12 @@ } .activeItem { + background: linear-gradient(90deg, #019e58 0%, #144941 100%); background-size: 100% 100%; + color: #fff; + svg { + fill: #fff; + } } } } -- Gitblit v1.9.1