This commit is contained in:
白了个白 2024-09-25 10:10:29 +08:00
commit d247d22288
10 changed files with 145 additions and 179 deletions

View File

@ -16,6 +16,12 @@ const defaultData = {
curSubjectNode: {
data: {}, // 当前教材节点 (包含当前教材 单元)
querySearch: {} // 查询资源所需参数
},
subject: {
bookList: null, // 教材列表
curBook: null, // 当前选中的教材
curNode: null, // 当前选中的节点
defaultExpandedKeys: [], //展开的节点
}
},
local: { // 本地(永久localStorage)

View File

@ -44,11 +44,12 @@
<script setup>
import { onMounted, ref, nextTick, toRaw, reactive } from 'vue';
import { cloneDeep } from 'lodash'
import { sessionStore } from '@/utils/store'
import { useGetSubject } from '@/hooks/useGetSubject'
const BaseUrl = import.meta.env.VITE_APP_BUILD_BASE_PATH
// emit
const emit = defineEmits(['nodeClick', 'changeBook'])
const emit = defineEmits(['nodeClick'])
let useSubject = null
const subjectList = ref([])
const dialogVisible = ref(false)
@ -74,8 +75,7 @@ const defaultExpandedKeys = ref([])
//
const changeBook = (data) => {
curBook.data = data
localStorage.setItem('curBook', JSON.stringify(data))
sessionStore.set('subject.curBook', data)
treeData.value = useSubject.getTreeData(data.id)
//
@ -83,9 +83,7 @@ const changeBook = (data) => {
defaultExpandedKeys.value = [treeData.value[0].id]
curNode.data = getLastLevelData(treeData.value)[0]
localStorage.setItem('defaultExpandedKeys', JSON.stringify(defaultExpandedKeys.value))
localStorage.setItem('curNode',JSON.stringify(curNode.data))
emitChangeBook()
handleNodeClick(curNode.data)
})
//
setTimeout(() => {
@ -93,40 +91,6 @@ const changeBook = (data) => {
}, 100);
}
const emitChangeBook = async () => {
let curData = cloneDeep(toRaw(curNode.data))
let parentNode = findParentByChildId(treeData.value, curData.id)
curData.parentNode = toRaw(parentNode)
//label label
curData.label = curData.itemtitle
const data = {
textBook: {
curBookId: curBook.data.id,
curBookName: curBook.data.itemtitle,
curBookImg: BaseUrl + curBook.data.avartar,
curBookPath: curBook.data.fileurl
},
node: curData
}
/**
* 临时用 后续删除 unitId
*/
let levelFirstId = null
let levelSecondId = null
let bookeId = curBook.data.id
if (curData.parentNode) {
levelFirstId = curData.parentNode.id
levelSecondId = curData.id
} else {
levelFirstId = curData.id
levelSecondId = ''
}
localStorage.setItem('unitId', JSON.stringify({ levelFirstId, levelSecondId, bookeId}))
emit('changeBook', data)
}
const getLastLevelData = (tree) => {
let lastLevelData = [];
//
@ -171,25 +135,22 @@ const findParentByChildId = (treeData, targetNodeId) => {
}
const handleNodeClick = (data, node) => {
const handleNodeClick = (data) => {
/**
* data : 当前节点数据
* node : 当前节点对象 包含当前节点所有数据 parent属性 指向父节点Node对象
*/
let nodeData = cloneDeep(toRaw(data));
//label label
nodeData.label = nodeData.itemtitle
const parentNode = node.parent.data;
// parentNode
if (Array.isArray(parentNode)) {
//
nodeData.parentNode = null
}
else {
// parentNode
nodeData.parentNode = toRaw(parentNode)
}
//label label
nodeData.label = nodeData.itemtitle
// null
let parent = {
id: nodeData.parentid,
label: nodeData.parenttitle,
itemtitle: nodeData.parenttitle
}
const parentNode = nodeData.parentid ? parent : null
nodeData.parentNode = parentNode
let curData = {
textBook: {
curBookId: curBook.data.id,
@ -197,63 +158,40 @@ const handleNodeClick = (data, node) => {
curBookImg: BaseUrl + curBook.data.avartar,
curBookPath: curBook.data.fileurl
},
node: toRaw(nodeData)
node: nodeData
}
localStorage.setItem('defaultExpandedKeys', parentNode ? JSON.stringify([parentNode.id]) : JSON.stringify([data.id]))
localStorage.setItem('curNode', JSON.stringify(nodeData))
/**
* 临时用 后续删除 unitId
*/
let levelFirstId = null
let levelSecondId = null
let bookeId = curBook.data.id
if (nodeData.parentNode) {
levelFirstId = nodeData.parentNode.id
levelSecondId = nodeData.id
} else {
levelFirstId = nodeData.id
levelSecondId = ''
}
localStorage.setItem('unitId', JSON.stringify({ levelFirstId, levelSecondId, bookeId}))
// :electron-store
let defaultExpandedKeys = parentNode ? [parentNode.id] : [nodeData.id]
sessionStore.set('subject.defaultExpandedKeys', defaultExpandedKeys)
sessionStore.set('subject.curNode', nodeData)
emit('nodeClick', curData)
}
onMounted( async () => {
treeLoading.value = true
try{
useSubject = await useGetSubject()
subjectList.value = useSubject.subjectList
let book = localStorage.getItem('curBook')
if(book){
book = JSON.parse(book)
curBook.data = book
treeData.value = useSubject.getTreeData(book.id)
subjectList.value = sessionStore.get('subject.bookList')
//
if(sessionStore.get('subject.curBook')){
curBook.data = sessionStore.get('subject.curBook')
}
else{
curBook.data = useSubject.subjectList[0]
localStorage.setItem('curBook', JSON.stringify(curBook.data))
treeData.value = useSubject.treeData
curBook.data = subjectList.value[0]
}
//
// ""
treeData.value = useSubject.getTreeData(curBook.data.id)
nextTick(() =>{
//
let node = localStorage.getItem('curNode')
if(node){
curNode.data = JSON.parse(node)
defaultExpandedKeys.value = JSON.parse(localStorage.getItem('defaultExpandedKeys'))
}
else{
//
if(sessionStore.get('subject.curNode')){
defaultExpandedKeys.value = sessionStore.get('subject.defaultExpandedKeys')
curNode.data = sessionStore.get('subject.curNode')
}else{
defaultExpandedKeys.value = [treeData.value[0].id]
curNode.data = getLastLevelData(treeData.value)[0]
//
localStorage.setItem('defaultExpandedKeys', JSON.stringify(defaultExpandedKeys.value))
localStorage.setItem('curNode', JSON.stringify(curNode.data))
}
emitChangeBook()
handleNodeClick(curNode.data)
})
} finally{

View File

@ -1,13 +1,13 @@
import { ref } from 'vue'
import useUserStore from '@/store/modules/user'
import { listEvaluation } from '@/api/subject'
import { sessionStore } from '@/utils/store'
export const useGetSubject = async () =>{
// user store
const userStore = useUserStore()
const { edustage, edusubject, userId } = userStore.user
const BaseUrl = import.meta.env.VITE_APP_BUILD_BASE_PATH
const { edustage, edusubject } = userStore.user
// 章节List
const unitList = ref([])
// 教材List
@ -15,12 +15,10 @@ export const useGetSubject = async () =>{
// 单元章节树结构
let treeData = null
// 根据 学科 + 学段 获取所有单元章节
// 根据学科 + 学段 获取所有单元章节
const getSubjectUnit = async () =>{
let strUnit = localStorage.getItem('unitList')
if(strUnit){
unitList.value = JSON.parse(strUnit)
if(sessionStore.get('subject.unitList')){
unitList.value = sessionStore.get('subject.unitList')
}
else{
const unitParams = {
@ -32,18 +30,16 @@ export const useGetSubject = async () =>{
}
const { rows } = await listEvaluation(unitParams)
unitList.value = rows
localStorage.setItem('unitList', JSON.stringify(rows))
sessionStore.set('subject.unitList', rows)
}
await getSubject()
}
// 获取 学科 + 学段 获取教材
// 根据学科 + 学段 获取教材
const getSubject = async () =>{
let strSubject = localStorage.getItem('subjectList')
if(strSubject){
subjectList = JSON.parse(strSubject)
if(sessionStore.get('subject.bookList')){
subjectList = sessionStore.get('subject.bookList')
}
else{
const subjectParams = {
@ -55,13 +51,19 @@ export const useGetSubject = async () =>{
}
const { rows } = await listEvaluation(subjectParams)
subjectList = rows
localStorage.setItem('subjectList', JSON.stringify(rows))
sessionStore.set('subject.bookList', rows)
treeData = getTreeData(subjectList[0].id)
// 设置一个默认的curNode
let curNode
if(treeData[0].children){
curNode = treeData[0].children[0]
}
else{
curNode = treeData[0]
}
sessionStore.set('subject.curNode', curNode)
}
// 默认选中第一个教材
if(subjectList && subjectList.length){
treeData = getTreeData(subjectList[0].id)
}
}
// 单元章节数据转为“树”结构
@ -71,6 +73,7 @@ export const useGetSubject = async () =>{
data.forEach( item => {
item.children = unitList.value.filter( item2 => item2.parentid == item.id && item2.level == 2)
})
sessionStore.set('subject.subjectTree', data)
return data
}

View File

@ -86,30 +86,6 @@ const currentRoute = ref('')
const dev_api = ref(import.meta.env.VITE_APP_BASE_API)
const userSubjectList = ref([])
const handleOutLink = (path, type, name) => {
if (!path) return
if (type === 'hash') {
router.push(path)
} else {
// key linkConfig.js
let configObj = outLink().getBaseData()
let fullPath = configObj.fullPath + path
fullPath = fullPath.replaceAll('//', '/')
const { levelFirstId, levelSecondId } = JSON.parse(localStorage.getItem('unitId'))
let unitId = levelSecondId ? levelSecondId : levelFirstId
if (name == '教材分析' || name == '考试分析') {
fullPath += `?unitId=${unitId}`
}
//
ipcRenderer.send('openWindow', {
key: path,
fullPath: fullPath,
cookieData: { ...configObj.data }
})
}
}
const activeId = ref('/home')
const headerMenus = [
{

View File

@ -647,13 +647,15 @@ defineExpose({
})
</script>
<style src="@/assets/styles/JYStyle.css"></style>
<style scoped lang="scss">
// :deep(.reserv-date-pick) {
// width: 140px;
// }
// :deep(.reserv-time-pick) {
// width: 240px;
// }
/*:deep(.reserv-date-pick) {
width: 140px;
}
:deep(.reserv-time-pick) {
width: 240px;
}*/
.clwk_dialog {
.clwk_dialog_view {
display: flex;
@ -669,7 +671,7 @@ defineExpose({
.view_teachrting {
flex: 1;
height: 100%;
// overflow-y: auto;
/*overflow-y: auto; */
overflow: hidden;
}
}

View File

@ -45,7 +45,8 @@ import { useRouter } from 'vue-router'
import workTrend from './container/work-trend.vue'
import outLink from '@/utils/linkConfig'
import * as echarts from 'echarts'
import { useGetClassWork } from '@/hooks/useGetClassWork'
import { useGetSubject } from '@/hooks/useGetSubject'
import { sessionStore } from '@/utils/store'
const router = useRouter()
const { ipcRenderer } = window.electron || {}
@ -171,13 +172,12 @@ const clickMenu = ({isOuter, path, disabled, id}) =>{
let fullPath = configObj.fullPath + path
if(id == '1-2' || id == '2-1' || id == '2-2' ){
// ID
const { levelFirstId, levelSecondId, bookeId } = JSON.parse(localStorage.getItem('unitId'))
let unitId = levelSecondId ? levelSecondId : levelFirstId
const { id, rootid } = sessionStore.get('subject.curNode')
if(fullPath.indexOf('?') == -1){
fullPath += `?unitId=${unitId}&bookeId=${bookeId}`
fullPath += `?unitId=${id}&bookeId=${rootid}`
}
else{
fullPath += `&unitId=${unitId}&bookeId=${bookeId}`
fullPath += `&unitId=${id}&bookeId=${rootid}`
}
}
fullPath = fullPath.replaceAll('//', '/')
@ -193,6 +193,8 @@ const clickMenu = ({isOuter, path, disabled, id}) =>{
}
onMounted(async ()=>{
await useGetSubject()
// DOM
await nextTick()
chartInstance = echarts.init(chartDom.value)
@ -238,21 +240,10 @@ onMounted(async ()=>{
]
}
chartInstance.setOption(option);
// +
getSubjectInit();
})
const getSubjectInit = async () => {
//
let unitId = localStorage.getItem('unitId')
if(unitId){
//
} else{
// +
useGetClassWork();
}
}
</script>

View File

@ -207,8 +207,8 @@ export default {
},
openFileWin(items) {
if (items.fileFlag === 'apt') {
let curBook = JSON.parse(localStorage.getItem('curBook'))
const path="/teaching/aptindex?id="+items.fileId + "&unitId=" + this.curNode.id + "&bookId=" + curBook.id;
const { id, rootid } = sessionStore.get('subject.curNode')
const path="/teaching/aptindex?id="+items.fileId + "&unitId=" + id + "&bookId=" + rootid;
let configObj = outLink().getBaseData()
let fullPath = configObj.fullPath + path
fullPath = fullPath.replaceAll('//', '/')

View File

@ -1,6 +1,6 @@
<template>
<div v-loading="isLoading" class="page-resource flex">
<ChooseTextbook @change-book="nodeClick" @node-click="nodeClick" />
<ChooseTextbook @node-click="nodeClick" />
<div class="page-center-wrap">
<el-tabs v-model="activeAptTab" style="height: 100%;">
<el-tab-pane label="教学课件" name="教学课件" class="prepare-center-jxkj">

View File

@ -2,7 +2,7 @@
<div class="page-resource flex">
<!--左侧 教材 目录-->
<Third v-if="isThird" @node-click="getDataOther"></Third>
<ChooseTextbook v-else @change-book="getData" @node-click="getData" />
<ChooseTextbook v-else @node-click="getData" />
<div class="page-right">
<!-- 搜索 -->

View File

@ -4,14 +4,14 @@
<div class="page-con-left">
<div class="stand-head" ref="headref">
<div class="stand-head-left">
<el-image class="imges" src="https://file.ysaix.com:7868//src/assets/images/高中语文必修上册.jpg" />
<el-image class="imges" :src="bookInfo ? bookInfo.avartar : ''" />
</div>
<div class="stand-head-right">
<div class="stand-head-right-tit">{{booktitle}}</div>
<i class="iconfont icon-yidongdaozu stand-head-right-icon" @click="dialogVisible = true"></i>
<div class="stand-head-right-row">
<div class="stand-head-right-row-time">更新2024.9.10</div>
<el-switch class="stand-head-right-row-switch" v-model="isOpenClass" inline-prompt active-text="公开" inactive-text="非公" />
<!-- <el-switch class="stand-head-right-row-switch" v-model="isOpenClass" inline-prompt active-text="公开" inactive-text="非公" /> -->
</div>
</div>
</div>
@ -68,8 +68,10 @@
</div>
</div>
</div>
<el-dialog v-model="dialogVisible" append-to-body :show-close="false" width="550">
<ChooseTextbook @change-book="getData" @node-click="getData" />
<el-dialog v-model="dialogVisible" title="切换教材" append-to-body width="550">
<div class="booklist">
<div :class="{'item': true,'active': booksel === idx}" v-for="item,idx in bookList" :key="idx" @click="bookChange(item)">{{item.edustage + item.edusubject}}</div>
</div>
</el-dialog>
</div>
</template>
@ -82,7 +84,7 @@ import { listEvaluationclue } from '@/api/teaching/classwork'
import { uploadServer, getJSONFile } from '@/utils/common'
import { ElNotification } from 'element-plus'
import ChooseTextbook from "@/components/choose-textbook/index.vue";
import { listEvaluation } from '@/api/classManage/index'
import useUserStore from '@/store/modules/user'
const userStore = useUserStore()
const sourceStore = useResoureStore()
@ -101,6 +103,10 @@ const searchref = ref(null);
const listHeight = ref(0);
const dialogVisible = ref(false);
const booktitle = ref('');
const bookInfo = ref(null);
const booksel = ref(0);
const bookList = ref([])
const searchOptions = [{
value: '0',
@ -109,7 +115,7 @@ const searchOptions = [{
value: '1',
label: '按内容量',
}];
const standList = ref([])
const standList = ref([]);
const showData = ref([]);
//
@ -234,16 +240,41 @@ const getData = (data) => {
// ID
localStorage.setItem('unitId', JSON.stringify({ levelFirstId, levelSecondId}))
}
onMounted(() => {
//
const getAllSubject = async () => {
const { rows } = await listEvaluation({ itemkey: "subject", pageSize: 500 })
const { edustage, edusubject } = userStore.user;
rows && rows.map(item => {
if(item.edustage === edustage && item.edusubject === edusubject){
bookInfo.value = {...item,avartar: import.meta.env.VITE_APP_BUILD_BASE_PATH + item.avartar}
}
if(item.fileurl !== ''){
bookList.value.push({...item,avartar: import.meta.env.VITE_APP_BUILD_BASE_PATH + item.avartar})
}
})
booksel.value = bookList.value.findIndex(item => item.edustage === edustage && item.edusubject === edusubject)
}
const bookChange = async (item, idx) => {
booksel.value = idx
bookInfo.value = {...item}
booktitle.value = `${item.edustage + item.edusubject}课程标准`
pdfUrl.value = '';
const filepath = import.meta.env.VITE_APP_RES_FILE_PATH + item.fileurl.replace('.txt','.pdf')
await loadPdfAnimation(filepath)
dialogVisible.value = false
}
const loadPdfAnimation = (path) => {
const timer = setTimeout(() => {
pdfUrl.value = path
clearTimeout(timer);
},2000)
}
onMounted(async () => {
await getAllSubject();
const { edustage, edusubject } = userStore.user;
booktitle.value = `${edustage + edusubject}课程标准`
const filePath = `${import.meta.env.VITE_APP_RES_FILE_PATH}${edustage}-${edusubject}-课标.pdf`
const timer = setTimeout(() => {
pdfUrl.value = filePath
clearTimeout(timer);
},2000)
await loadPdfAnimation(filePath)
if(cardref.value && headref.value){
const cardH = cardref.value.offsetHeight;
const headh = headref.value.offsetHeight;
@ -492,4 +523,23 @@ onMounted(() => {
}
}
}
.booklist{
width: 100%;
height: 500px;
padding-top: 1px;
overflow: auto;
.item{
width: 100%;
height: auto;
padding: 8px 16px;
background-color: #ffffff;
border-top: 1px solid #f1f1f1;
font-size: 14px;
color: #3b3b3b;
}
.active{
background-color: #409eff;
color: #ffffff;
}
}
</style>