This commit is contained in:
lyc 2024-08-12 15:55:50 +08:00
parent d690a4ae70
commit 0b67ca30f8
6 changed files with 223 additions and 44 deletions

View File

@ -0,0 +1,124 @@
import useUserStore from '@/store/modules/user'
import { homeworklist, listEntpcourse } from '@/api/teaching/classwork'
const userStore = useUserStore()
// 当前选中教材章节节点
let curNode = null
// 查询作业列表所需要的ID
let chapterId = null
export const useGetHomework = async (node) => {
/**
* node
*/
if (!node) return
curNode = node
// 获取查询作业列表所需ID
let { rows } = await getChapterId()
if (rows.length > 0) {
chapterId = rows[0].id
} else {
// 没有则 传教新的entpcourse 再次查询
await createEntpcourse()
let { rows } = await getChapterId()
chapterId = rows[0].id
}
return await getHomeWorkList()
}
// 根据教材章节ID 查询作业列表所需ID
const getChapterId = () => {
return listEntpcourse({
evalid: curNode.id ? curNode.id : curNode.parentNode.id,
edituserid: userStore.user.userId,
pageSize: 500
})
}
// 创建新的entpcourse
const createEntpcourse = () => {
// 参照 web AIx 传入参数
var cform = {}
cform.entpid = userStore.deptId
cform.level = 1
cform.parentid = 0
cform.dictid = 0
cform.evalid = curNode.id
cform.evalparentid = 0
cform.edusubject = curNode.edusubject
cform.edudegree = curNode.edudegree
cform.edustage = curNode.edustage
cform.coursetype = '课标学科'
cform.coursetitle = curNode.itemtitle
cform.coursedesc = ''
cform.status = ''
cform.dflag = 0
cform.edituserid = userStore.userId
cform.createblankfile = 'yes'
return addEntpcourse(cform)
}
const getHomeWorkList = async () => {
return await homeworklist({
entpcourseid: chapterId,
edituserid: userStore.user.userId,
pageSize: 100
}).then((res) => {
//以下代码 参照AIx web端 作业布置
let list = []
for (var i = 0; i < res.rows.length; i++) {
res.rows[i].taskconfig = []
// 找child
for (var j = 0; j < res.rows.length; j++) {
if (res.rows[j].parentid == res.rows[i].id) {
var ss = []
if (res.rows[j].classworkdatastudentids != null) {
ss = JSON.parse('[' + res.rows[j].classworkdatastudentids + ']')
}
var js = {
id: res.rows[j].id,
classid: res.rows[j].classid,
classcaption: res.rows[j].classcaption,
parentid: 0,
worktype: '',
workkey: res.rows[j].workkey,
worktag: '',
entpcourseid: 0,
evalid: 0,
edusubject: '',
edudegree: '',
workdate: '',
title: '',
workcodes: '',
studentlist: ss,
deaddate: res.rows[j].deaddate,
timelength: res.rows[j].timelength,
weights: res.rows[j].weights,
feedtype: res.rows[j].feedtype
}
res.rows[i].taskconfig.push(js)
}
}
res.rows[i].fileShowName = res.rows[i].uniquekey
// 注意slideid>0的这一些作业是添加到PPT页面的所以在作业管理中不能出现
// 2024-05-15酉阳jackyshen
if (res.rows[i].classid == 0 && res.rows[i].slideid == 0) {
list.push(res.rows[i])
}
// 如果是习题训练任务,则检查一共有多少道
if (res.rows[i].entpcourseworklist != '') {
res.rows[i].entpcourseworklistarray = JSON.parse('[' + res.rows[i].entpcourseworklist + ']')
} else {
res.rows[i].entpcourseworklistarray = []
}
}
return list
})
}

View File

@ -9,7 +9,10 @@ export const useToolState = defineStore('tool', {
showBoardAll: false, // 全屏画板-是否显示
isPdfWin: false, // pdf窗口是否打开
isToolWin: false, // 工具窗口是否打开
curSubjectNode: {} // 当前教材节点 (包含当前教材 单元)
curSubjectNode: {
data: {}, // 当前教材节点 (包含当前教材 单元)
querySearch: {} // 查询资源所需参数
}
}),
actions: {
}

View File

@ -1,6 +1,6 @@
<template>
<el-dialog v-model="dialogVisible" center top="10vh" width="600px" :show-close="false" append-to-body
:z-index="999999" style="border-radius: 10px; padding: 10px 15px;">
style="border-radius: 10px; padding: 10px 15px;">
<template #header>
<div class="homerwork-header flex">
<span>{{ title }}</span>
@ -288,7 +288,6 @@ export default {
modelValue(val) {
this.dialogVisible = val
if (val) {
console.log(this.row,10000)
this.getGradeList()
}
}

View File

@ -355,6 +355,9 @@ export default {
this.uploadData.levelSecondId = cata[1]
this.uploadData.levelThirdId = cata[2]
this.uploadData.textbookId = data.textBook.curBookId
const toolStore = useToolState()
toolStore.curSubjectNode.data = data
toolStore.curSubjectNode.querySearch = this.uploadData
this.initHomeWork()
await this.asyncAllFile()
@ -431,7 +434,7 @@ export default {
createTimer() {
this.timerId = setInterval(() => {
this.getHomeWorkList()
}, 1500)
}, 2500)
},
//
getHomeWorkList() {

View File

@ -8,7 +8,7 @@
<h3 class="title">{{ lesson }}</h3>
<div class="grade">{{ usertore.edusubject }}</div>
</div>
<!-- <i class="iconfont icon-xiangyou"></i> -->
<i class="iconfont icon-xiangyou" @click="showLeft = !showLeft"></i>
</div>
<div class="homework-list" v-loading="loading">
<el-scrollbar height="360px">
@ -48,16 +48,16 @@
<SetHomework v-model="setDialog" :title="'推送作业'" :entpcourseid="entpcourseid" :row="curRow"
@on-close="closeHomework" />
</div>
<div class="homework" @click="showLeft = !showLeft" v-else>
<div class="homework flex" v-else>
<div class="unit-top flex">
<div class="unit-top-left">
<div class="unit-top-left" @click="showLeft = !showLeft">
<i class="iconfont icon-xiangzuo"></i>
<span>返回</span>
</div>
<span class="unit-top-center">选择目录</span>
</div>
<div>
<!-- <Lesson/> -->
<div class="unit-content">
<Lesson @changeChapter="changeChapter" />
</div>
</div>
</transition>
@ -72,10 +72,12 @@ import { homeworklist } from '@/api/teaching/classwork'
import { getSmarttalkPage, getPrepareById } from '@/api/file'
import SetHomework from '@/views/prepare/container/set-homework.vue'
import FileImage from '@/components/file-image/index.vue'
import { useGetHomework } from '@/hooks/useGetHomework'
import { ipcMsgSend } from '@/utils/tool'
import { useToolState } from '@/store/modules/tool'
import { asyncLocalFile } from '@/utils/talkFile'
import Lesson from './lesson.vue';
import { parseCataByNode } from '@/utils/talkFile'
const { ipcRenderer } = window.electron || {}
const route = useRoute();
@ -108,13 +110,28 @@ const closeHomework = () => {
setDialog.value = false
}
const changeChapter = async (data)=>{
const res = await useGetHomework(data)
dataList.value = res
let cata = parseCataByNode(data)
toolStore.curSubjectNode.querySearch.levelFirstId = cata[0]
toolStore.curSubjectNode.querySearch.levelSecondId = cata[1]
lesson.value = data.label
showLeft.value = !showLeft.value
getResource()
}
//
const getResource = () => {
let data = toRaw(toolStore.curSubjectNode)
data.orderByColumn = 'uploadTime'
data.isAsc = 'desc'
data.pageSize = 500
getSmarttalkPage(data).then(res => {
let querySearch = toRaw(toolStore.curSubjectNode).querySearch
querySearch.orderByColumn = 'uploadTime'
querySearch.isAsc = 'desc'
querySearch.pageSize = 500
getSmarttalkPage(querySearch).then(res => {
resourceList.value = res.rows
})
@ -224,8 +241,9 @@ onMounted(() => {
.homework {
width: 100%;
height: 100%;
position: absolute;
flex-direction: column;
}
.homework-content {
@ -317,6 +335,8 @@ onMounted(() => {
.unit-top-center{
margin: 0 auto;
}
}
.unit-content{
height: calc(100% - 50px);
}
</style>

View File

@ -1,5 +1,6 @@
<template>
<div>
<el-scrollbar>
<el-tree ref="refTree" :data="treeData" :props="defaultProps" node-key="id"
:default-expanded-keys="defaultExpandedKeys" :current-node-key="currentNodeId" highlight-current
@node-click="handleNodeClick">
@ -7,14 +8,16 @@
<span :title="node.label" class="tree-label">{{ node.label }}</span>
</template>
</el-tree>
</div>
</el-scrollbar>
</template>
<script setup>
import { ref, onMounted, nextTick, markRaw, toRaw } from 'vue'
import { useToolState } from '@/store/modules/tool'
import { parseCataByNode } from '@/utils/talkFile'
const emit = defineEmits(['changeChapter'])
const toolStore = useToolState()
const treeData = ref([])
const defaultProps = {
@ -43,12 +46,9 @@ const getTreeData = () => {
//
let volumeTwo = evaluationList.value.filter(item => item.level == 1 && item.semester == '下册')
//
console.log(volumeOne,1)
console.log(volumeTwo,2)
let upData = transData(volumeOne)
let downData = transData(volumeTwo)
console.log(upData)
console.log(downData)
if(upData.length && downData.length){
treeData.value = [...upData,...downData]
}
@ -61,28 +61,50 @@ const getTreeData = () => {
}
nextTick(() => {
let defaultKey
if(toolStore.curSubjectNode.levelSecondId){
defaultKey = toolStore.curSubjectNode.levelSecondId
if(toolStore.curSubjectNode.querySearch.levelSecondId){
defaultKey = toolStore.curSubjectNode.querySearch.levelSecondId
}
else{
defaultKey = toolStore.curSubjectNode.levelFirstId
defaultKey = toolStore.curSubjectNode.querySearch.levelFirstId
}
defaultExpandedKeys.value = defaultKey
// currentNode.data = getLastLevelData(treeData.value)[0]
// currentNodeId.value = getLastLevelData(treeData.value)[0].id
// currentNodeName.value = getLastLevelData(treeData.value)[0].label
currentNodeId.value = defaultKey
})
}
const handleNodeClick = ()=>{}
const handleNodeClick = (data, node) => {
/**
* data : 当前节点数据
* node : 当前节点对象 包含当前节点所有数据 parent属性 指向父节点Node对象
*/
const nodeData = data;
const parentNode = node.parent.data;
if (Array.isArray(parentNode)) {
nodeData.parentNode = null
}
else {
nodeData.parentNode = parentNode
}
emit('changeChapter', toRaw(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 = {}
console.log(item.rootid, '==========>',curBookId.value)
if (item.rootid == curBookId.value) {
obj.label = item.itemtitle
obj.id = item.id
@ -114,23 +136,22 @@ const transData = (data) => {
onMounted(()=>{
// console.log(toolStore.curSubjectNode,111)
// let data = toRaw(toolStore.curSubjectNode)
// console.log(data,222)
// curBookId.value = toolStore.curSubjectNode.textbookId
// getTreeData()
setTimeout(()=>{
let data = toRaw(toolStore.curSubjectNode)
curBookId.value = data.data.textBook.curBookId
getTreeData()
},500)
})
</script>
<style lang="scss" scoped>
.el-tree{
background-color: #121212
}
:deep(.el-tree-node) {
.el-tree-node__content {
height: 45px;
border-radius: 10px;
color: #EFEFEF;
//#368FFF
&:hover {
@ -138,4 +159,13 @@ onMounted(()=>{
}
}
}
:deep(.el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content) {
background-color: #121212 !important;
color: #409EFF
}
:deep(.el-scrollbar__view){
height: 100%;
}
</style>