feat:修改固定住自己所选的学科学段;

This commit is contained in:
yangws 2024-08-23 11:28:26 +08:00
parent b922219602
commit be222a2ba6
6 changed files with 43 additions and 29 deletions

View File

@ -5,8 +5,9 @@
<el-dropdown style="width: 100%;height: 100%"> <el-dropdown style="width: 100%;height: 100%">
<div class="el-dropdown-link flex" style="width: 100%;height: 100%;justify-content: space-between;align-items: center"> <div class="el-dropdown-link flex" style="width: 100%;height: 100%;justify-content: space-between;align-items: center">
<span>{{titleName}}</span> <span>{{titleName}}</span>
<i class="iconfont icon-xiangyou"></i> <!-- <i class="iconfont icon-xiangyou"></i>-->
</div> </div>
<!-- 学科学段选择-->
<template #dropdown> <template #dropdown>
<div style="width: 300px;padding: 20px"> <div style="width: 300px;padding: 20px">
<ThirdIndex @getVertion="getVertion"></ThirdIndex> <ThirdIndex @getVertion="getVertion"></ThirdIndex>
@ -29,10 +30,12 @@ import ThirdIndex from './third/index.vue'
import {nextTick, reactive, ref,onMounted,watch} from 'vue' import {nextTick, reactive, ref,onMounted,watch} from 'vue'
import {getBook, getTextbook} from '@/api/file/third' import {getBook, getTextbook} from '@/api/file/third'
import useThirdStore from '@/store/modules/thirdTextbook' import useThirdStore from '@/store/modules/thirdTextbook'
import useUserStore from '@/store/modules/user'
const useThird = useThirdStore() const useThird = useThirdStore()
const useStore = useUserStore()
const emit = defineEmits(['nodeClick']) const emit = defineEmits(['nodeClick'])
const titleName = ref('小学-语文') const titleName = ref('')
// //
const treeData = ref([]) const treeData = ref([])
// //
@ -158,16 +161,12 @@ const handleNodeClick = (data,node) => {
} }
// //
onMounted(() => { onMounted(() => {
const info = localStorage.getItem('selectBookInfo') titleName.value = `${useStore.user.edustage}-${useStore.user.edusubject}`
if(info){
const {gradeName,subjectName} = JSON.parse(info)
titleName.value = `${gradeName}-${subjectName}`
}
treeLoading.value = true treeLoading.value = true
}) })
// //
watch(() => useThird,() => { watch(() => useThird,() => {
titleName.value = `${useThird.gradeName}-${useThird.subjectName}` titleName.value = `${useStore.user.edustage}-${useStore.user.edusubject}`
},{deep:true}) },{deep:true})
const defaultProps = { const defaultProps = {

View File

@ -14,10 +14,12 @@ import { gradeList } from '@/utils/resourceDict'
import SelectSubject from './selectSubject.vue' import SelectSubject from './selectSubject.vue'
import {getSubjects,getTextbookVersion} from '@/api/file/third' import {getSubjects,getTextbookVersion} from '@/api/file/third'
import useThirdStore from '@/store/modules/thirdTextbook' import useThirdStore from '@/store/modules/thirdTextbook'
import useUserStore from '@/store/modules/user'
const useThird = useThirdStore() const useThird = useThirdStore()
const useStore = useUserStore()
const emit = defineEmits(['getVertion']) const emit = defineEmits(['getVertion'])
const active = ref(useThird.activeGrade || gradeList[0].value) const active = ref(1)
// //
const subjectList = ref([]) const subjectList = ref([])
//id //id
@ -27,9 +29,17 @@ const handleClick = (tab) => {
} }
// //
const getSubject = (value) => { const getSubject = (value) => {
const currentIndex = gradeList.findIndex(item => item.value === value)
getSubjects({stage:value}).then(res => { getSubjects({stage:value}).then(res => {
if(res.code === 200){ if(res.code === 200){
subjectList.value = [...res.data] subjectList.value = res.data.map(item => {
return {
...item,
gradeName:gradeList[currentIndex].label
}
})
const nameIndex = subjectList.value.findIndex(item => item.subjectName === useStore.user.edusubject)
getTagId({subjectId:subjectList.value[nameIndex].subjectId,subjectName:subjectList.value[nameIndex].subjectName})
if(textbookVersionId.value === 0){ if(textbookVersionId.value === 0){
getTagId(subjectList.value[0]) getTagId(subjectList.value[0])
} }
@ -44,21 +54,14 @@ const getTagId = (item) => {
if(res.code === 200){ if(res.code === 200){
emit('getVertion',res.data) emit('getVertion',res.data)
useThird.getSelectBookInfo({...item,activeGrade:active.value,gradeName:gradeList[currentIndex].label}) useThird.getSelectBookInfo({...item,activeGrade:active.value,gradeName:gradeList[currentIndex].label})
localStorage.setItem('selectBookInfo',JSON.stringify({...item,activeGrade:active.value,gradeName:gradeList[currentIndex].label}))
} }
}) })
} }
onMounted(() => { onMounted(() => {
const currentIndex = gradeList.findIndex(item => item.label === useStore.user.edustage)
// //
handleClick(active.value) getSubject(gradeList[currentIndex].value)
// active.value = gradeList[currentIndex].value
const info = localStorage.getItem('selectBookInfo')
if(info){
const {activeGrade,subjectId,subjectName} = JSON.parse(info)
active.value = activeGrade
//
getTagId({subjectId:subjectId,subjectName:subjectName})
}
}) })
</script> </script>

View File

@ -1,11 +1,11 @@
<template> <template>
<template v-for="item in subjectList" :key="item.subjectId"> <template v-for="item in subjectList" :key="item.subjectId">
<el-tag <el-tag
type="primary" :type="useStore.user.edusubject === item.subjectName && useStore.user.edustage === item.gradeName ? 'primary' : 'info'"
effect="dark" effect="dark"
round round
style="cursor: pointer;margin-right: 5px;margin-top: 5px;" class="tagItem"
@click="clickTag(item)" :style="useStore.user.edusubject === item.subjectName && useStore.user.edustage === item.gradeName ? {'cursor': 'pointer'} : {'cursor': 'no-Drop'}"
> >
{{ item.subjectName }} {{ item.subjectName }}
</el-tag> </el-tag>
@ -13,6 +13,8 @@
</template> </template>
<script setup name="selectSubject"> <script setup name="selectSubject">
import useUserStore from "@/store/modules/user";
const useStore = useUserStore()
const props = defineProps({ const props = defineProps({
subjectList: { subjectList: {
type: Array, type: Array,
@ -20,11 +22,14 @@ const props = defineProps({
} }
}) })
const emit = defineEmits(['clickTag']) const emit = defineEmits(['clickTag'])
const clickTag = (item) => { // const clickTag = (item) => {
emit('clickTag',item) // emit('clickTag',item)
} // }
</script> </script>
<style scoped> <style scoped>
.tagItem{
margin-right: 5px;
margin-top: 5px;
}
</style> </style>

View File

@ -88,6 +88,10 @@ export const gradeList = [
] ]
//课件类别 //课件类别
export const coursewareTypeList = [ export const coursewareTypeList = [
{
label:'全部',
value:''
},
{ {
label:'课件', label:'课件',
value:3 value:3

View File

@ -53,7 +53,7 @@
</template> </template>
<script setup> <script setup>
import {watch,ref} from 'vue' import {watch,ref,onMounted} from 'vue'
import useResoureStore from '../store' import useResoureStore from '../store'
import {coursewareTypeList} from '@/utils/resourceDict' import {coursewareTypeList} from '@/utils/resourceDict'
const isThird = ref(false) const isThird = ref(false)
@ -71,6 +71,9 @@ const debouncedChangeName = debounce(sourceStore.changeName, 300);
const onchangeInput = () => { const onchangeInput = () => {
debouncedChangeName() debouncedChangeName()
} }
onMounted(() => {
sourceStore.query.fileSource = '平台'
})
watch(() => sourceStore.query.fileSource,() => { watch(() => sourceStore.query.fileSource,() => {
sourceStore.query.fileSource === '第三方'?isThird.value = true:isThird.value = false sourceStore.query.fileSource === '第三方'?isThird.value = true:isThird.value = false

View File

@ -69,7 +69,7 @@ export default defineStore('resource', {
bookId:0, bookId:0,
stage:0, stage:0,
subjectId:0, subjectId:0,
type:3, type:'',
title:'' title:''
}, },
result: { result: {