From 0b67ca30f84d95df16a6bf14f99d121516f389aa Mon Sep 17 00:00:00 2001 From: lyc Date: Mon, 12 Aug 2024 15:55:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/hooks/useGetHomework.js | 124 ++++++++++++++++++ src/renderer/src/store/modules/tool.js | 5 +- .../views/prepare/container/set-homework.vue | 3 +- src/renderer/src/views/prepare/index.vue | 5 +- .../src/views/tool/components/homework.vue | 48 +++++-- .../src/views/tool/components/lesson.vue | 82 ++++++++---- 6 files changed, 223 insertions(+), 44 deletions(-) create mode 100644 src/renderer/src/hooks/useGetHomework.js diff --git a/src/renderer/src/hooks/useGetHomework.js b/src/renderer/src/hooks/useGetHomework.js new file mode 100644 index 0000000..fb358d5 --- /dev/null +++ b/src/renderer/src/hooks/useGetHomework.js @@ -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 + }) +} diff --git a/src/renderer/src/store/modules/tool.js b/src/renderer/src/store/modules/tool.js index a07b10e..ac4e440 100644 --- a/src/renderer/src/store/modules/tool.js +++ b/src/renderer/src/store/modules/tool.js @@ -9,7 +9,10 @@ export const useToolState = defineStore('tool', { showBoardAll: false, // 全屏画板-是否显示 isPdfWin: false, // pdf窗口是否打开 isToolWin: false, // 工具窗口是否打开 - curSubjectNode: {} // 当前教材节点 (包含当前教材 单元) + curSubjectNode: { + data: {}, // 当前教材节点 (包含当前教材 单元) + querySearch: {} // 查询资源所需参数 + } }), actions: { } diff --git a/src/renderer/src/views/prepare/container/set-homework.vue b/src/renderer/src/views/prepare/container/set-homework.vue index f591826..c607e43 100644 --- a/src/renderer/src/views/prepare/container/set-homework.vue +++ b/src/renderer/src/views/prepare/container/set-homework.vue @@ -1,6 +1,6 @@