上课里面的章节,教材edit

This commit is contained in:
lyc 2024-09-26 16:38:29 +08:00
parent 8a60ce4ef9
commit 3b84a340aa
6 changed files with 61 additions and 125 deletions

View File

@ -14,14 +14,14 @@ const defaultData = {
isPdfWin: false, // pdf窗口是否打开 isPdfWin: false, // pdf窗口是否打开
isToolWin: false, // 工具窗口是否打开 isToolWin: false, // 工具窗口是否打开
curSubjectNode: { curSubjectNode: {
data: {}, // 当前教材节点 (包含当前教材 单元)
querySearch: {} // 查询资源所需参数 querySearch: {} // 查询资源所需参数
}, },
subject: { subject: { // 不走同步 Pinia
bookList: null, // 教材列表 bookList: null, // 教材列表
curBook: null, // 当前选中的教材 curBook: null, // 当前选中的教材
curNode: null, // 当前选中的节点 curNode: null, // 当前选中的节点
defaultExpandedKeys: [], //展开的节点 defaultExpandedKeys: [], //展开的节点
subjectTree: [] // "树结构" 章节
} }
}, },
local: { // 本地(永久localStorage) local: { // 本地(永久localStorage)

View File

@ -181,6 +181,8 @@ onMounted( async () => {
// "" // ""
treeData.value = useSubject.getTreeData(curBook.data.id) treeData.value = useSubject.getTreeData(curBook.data.id)
sessionStore.set('subject.subjectTree',useSubject.getTreeData(curBook.data.id))
nextTick(() =>{ nextTick(() =>{
// //
if(sessionStore.get('subject.curNode')){ if(sessionStore.get('subject.curNode')){

View File

@ -6,6 +6,9 @@ import { sessionStore } from '@/utils/store'
// 默认数据 // 默认数据
const defData = sessionStore.store || {} const defData = sessionStore.store || {}
const exArrs = ['subject']
exArrs.forEach(k => Object.keys(defData).includes(k) && (delete defData[k]))
// 延时 // 延时
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)) const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
@ -16,7 +19,6 @@ export const useToolState = defineStore('tool', {
isPdfWin: false, // pdf窗口是否打开 isPdfWin: false, // pdf窗口是否打开
isToolWin: false, // 工具窗口是否打开 isToolWin: false, // 工具窗口是否打开
curSubjectNode: { curSubjectNode: {
data: {}, // 当前教材节点 (包含当前教材 单元)
querySearch: {} // 查询资源所需参数 querySearch: {} // 查询资源所需参数
}, },
...defData // 默认数据-覆盖上面的配置(不要删除, 会导致新窗口-获取状态失败) ...defData // 默认数据-覆盖上面的配置(不要删除, 会导致新窗口-获取状态失败)

View File

@ -583,11 +583,7 @@ export default {
this.uploadData.levelSecondId = cata[1] this.uploadData.levelSecondId = cata[1]
this.uploadData.levelThirdId = cata[2] this.uploadData.levelThirdId = cata[2]
this.uploadData.textbookId = data.textBook.curBookId this.uploadData.textbookId = data.textBook.curBookId
toolStore.curSubjectNode.data = data
//
this.$nextTick(() => {
toolStore.curSubjectNode.querySearch = this.uploadData toolStore.curSubjectNode.querySearch = this.uploadData
})
this.initHomeWork() this.initHomeWork()
await this.asyncAllFile() await this.asyncAllFile()
}, },

View File

@ -62,7 +62,7 @@
<span class="unit-top-center">选择目录</span> <span class="unit-top-center">选择目录</span>
</div> </div>
<div class="unit-content"> <div class="unit-content">
<Lesson @changeChapter="changeChapter" /> <Lesson @changeChapter="changeChapter" :curNode="curNode.data" />
</div> </div>
</div> </div>
</transition> </transition>
@ -70,19 +70,20 @@
</template> </template>
<script setup> <script setup>
import { ref, onMounted, toRaw } from 'vue'; import { ref, onMounted, toRaw, nextTick, reactive } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import { getSmarttalkPage } from '@/api/file' import { getSmarttalkPage } from '@/api/file'
import SetHomework from '@/components/set-homework/index.vue' import SetHomework from '@/components/set-homework/index.vue'
import FileImage from '@/components/file-image/index.vue' import FileImage from '@/components/file-image/index.vue'
import { useGetHomework } from '@/hooks/useGetHomework' import { useGetHomework } from '@/hooks/useGetHomework'
import { ipcMsgSend, ipcMsgSend2, ipcMsgInvoke } from '@/utils/tool' import { ipcMsgSend, ipcMsgInvoke } from '@/utils/tool'
import { useToolState } from '@/store/modules/tool' import { useToolState } from '@/store/modules/tool'
import Lesson from './lesson.vue'; import Lesson from './lesson.vue';
import { parseCataByNode } from '@/utils/talkFile' import { parseCataByNode } from '@/utils/talkFile'
import MsgEnum from '@/plugins/imChat/msgEnum' // import MsgEnum from '@/plugins/imChat/msgEnum' //
import { createHomework } from '../createHomework' import { createHomework } from '../createHomework'
import { sessionStore } from '@/utils/store'
const route = useRoute(); const route = useRoute();
const usertore = useUserStore().user const usertore = useUserStore().user
@ -99,6 +100,10 @@ const resourceList = ref([])
// //
const curRow = ref('') const curRow = ref('')
const curNode = reactive({
data: {}
})
const sendHomework = (row) => { const sendHomework = (row) => {
curRow.value = row curRow.value = row
setTimeout(() => { setTimeout(() => {
@ -118,6 +123,7 @@ const successHomework = (data)=>{
} }
// change // change
const changeChapter = async (data)=>{ const changeChapter = async (data)=>{
curNode.data = data
const { res } = await useGetHomework(data) const { res } = await useGetHomework(data)
dataList.value = res dataList.value = res
let cata = parseCataByNode(data) let cata = parseCataByNode(data)
@ -177,10 +183,10 @@ const getResource = () => {
// //
const getHomework = async () => { const getHomework = async () => {
const data = toRaw(toolStore.curSubjectNode).data.node
loading.value = true loading.value = true
try { try {
const { res } = await useGetHomework(data) const { res } = await useGetHomework(curNode.data)
dataList.value = res dataList.value = res
} finally { } finally {
loading.value = false loading.value = false
@ -203,13 +209,16 @@ function leave(el, done) {
done(); done();
} }
onMounted(() => { onMounted(async () => {
await nextTick()
entpcourseid.value = route.query.entpcourseid entpcourseid.value = route.query.entpcourseid
lesson.value = route.query.label lesson.value = route.query.label
setTimeout(()=>{ // mounted
curNode.data = sessionStore.get('subject.curNode')
getHomework() getHomework()
getResource() getResource()
},200)
}) })
</script> </script>

View File

@ -2,7 +2,7 @@
<el-scrollbar> <el-scrollbar>
<el-tree ref="refTree" :data="treeData" :props="defaultProps" node-key="id" <el-tree ref="refTree" :data="treeData" :props="defaultProps" node-key="id"
:default-expanded-keys="defaultExpandedKeys" :current-node-key="currentNodeId" highlight-current :default-expanded-keys="defaultExpandedKeys" :current-node-key="currentNode.data.id" highlight-current
@node-click="handleNodeClick"> @node-click="handleNodeClick">
<template #default="{ node }"> <template #default="{ node }">
<span :title="node.label" class="tree-label">{{ node.label }}</span> <span :title="node.label" class="tree-label">{{ node.label }}</span>
@ -13,133 +13,60 @@
</template> </template>
<script setup> <script setup>
import { ref, onMounted, nextTick, toRaw } from 'vue' import { ref, reactive, onMounted, toRaw, watch } from 'vue'
import { useToolState } from '@/store/modules/tool' import { useToolState } from '@/store/modules/tool'
import { sessionStore } from '@/utils/store'
import { cloneDeep } from 'lodash'
const emit = defineEmits(['changeChapter']) const emit = defineEmits(['changeChapter'])
const props = defineProps(['curNode'])
const toolStore = useToolState() const toolStore = useToolState()
const treeData = ref([]) const treeData = ref([])
const defaultProps = { const defaultProps = {
children: 'children', children: 'children',
label: 'label', label: 'itemtitle',
class: 'textbook-tree' class: 'textbook-tree'
} }
// ID const currentNode = reactive({
const currentNodeId = ref(0) data: {}
// })
const currentNodeName = ref('')
watch(() => props.curNode , (newVal) =>{
currentNode.data = newVal
console.log(currentNode.data)
},
{deep: true, immediate: true})
// //
const defaultExpandedKeys = ref([]) const defaultExpandedKeys = ref([])
// tree // tree
const refTree = ref(null) const refTree = ref(null)
// ID
const curBookId = ref('')
//
const evaluationList = ref([])
const getTreeData = () => { const handleNodeClick = (data) => {
evaluationList.value = JSON.parse(localStorage.getItem('unitList'))
//
/**
* 不区分上下册
* 2024/08/20调整
*/
let volumeOne = evaluationList.value.filter(item => item.level == 1)
//
let upData = transData(volumeOne)
if(upData.length){
treeData.value = [...upData]
}
else{
treeData.value = []
return
}
nextTick(() => {
let defaultKey
if(toolStore.curSubjectNode.querySearch.levelSecondId){
defaultKey = toolStore.curSubjectNode.querySearch.levelSecondId
}
else{
defaultKey = toolStore.curSubjectNode.querySearch.levelFirstId
}
currentNodeId.value = defaultKey
})
}
const handleNodeClick = (data, node) => {
/** /**
* data : 当前节点数据 * data : 当前节点数据
* node : 当前节点对象 包含当前节点所有数据 parent属性 指向父节点Node对象
*/ */
currentNode.data = data
let nodeData = cloneDeep(toRaw(data));
const nodeData = data; //label label
const parentNode = node.parent.data; nodeData.label = nodeData.itemtitle
// null
if (Array.isArray(parentNode)) { let parent = {
nodeData.parentNode = null id: nodeData.parentid,
label: nodeData.parenttitle,
itemtitle: nodeData.parenttitle
} }
else { const parentNode = nodeData.parentid ? parent : null
nodeData.parentNode = parentNode nodeData.parentNode = parentNode
}
emit('changeChapter', toRaw(nodeData)) emit('changeChapter', nodeData)
} }
// ID ID
const getChapterId = () => {
return listEntpcourse({
evalid: this.uploadData.levelSecondId,
edituserid: this.userStore.userId,
pageSize: 500
})
}
const transData = (data) => {
let ary = []
data.forEach(item => {
let obj = {}
if (item.rootid == curBookId.value) {
obj.label = item.itemtitle
obj.id = item.id
obj.itemtitle = item.itemtitle
obj.edudegree = item.edudegree
obj.edustage = item.edustage
obj.edusubject = item.edusubject
let ary2 = []
evaluationList.value.forEach(el => {
let obj2 = {}
if (item.id == el.parentid) {
obj2 = {
label: el.itemtitle,
id: el.id,
itemtitle : el.itemtitle,
edudegree : el.edudegree,
edustage : el.edustage,
edusubject : el.edusubject,
}
ary2.push(obj2)
}
obj.children = ary2
})
ary.push(obj)
}
})
return ary
}
onMounted(()=>{ onMounted(()=>{
setTimeout(()=>{ treeData.value = sessionStore.get('subject.subjectTree')
let data = toRaw(toolStore.curSubjectNode) defaultExpandedKeys.value = sessionStore.get('subject.defaultExpandedKeys')
curBookId.value = data.data.textBook.curBookId
getTreeData()
},500)
}) })
</script> </script>