Merge pull request 'feat:修改固定住自己所选的学科学段;' (#154) from yangws into main
Reviewed-on: #154
This commit is contained in:
commit
0ad99e9ac2
|
@ -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 = {
|
||||||
|
|
|
@ -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>
|
||||||
|
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -88,6 +88,10 @@ export const gradeList = [
|
||||||
]
|
]
|
||||||
//课件类别
|
//课件类别
|
||||||
export const coursewareTypeList = [
|
export const coursewareTypeList = [
|
||||||
|
{
|
||||||
|
label:'全部',
|
||||||
|
value:''
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label:'课件',
|
label:'课件',
|
||||||
value:3
|
value:3
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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: {
|
||||||
|
|
Loading…
Reference in New Issue