baigl #261

Merged
baigl merged 14 commits from baigl into main 2024-09-24 16:34:39 +08:00
4 changed files with 684 additions and 235 deletions
Showing only changes of commit 96098c899f - Show all commits

View File

@ -62,3 +62,12 @@ export function updateClassworkdata(data) {
data: data
})
}
// 修改classwork
export function updateClasswork(data) {
return request({
url: '/education/classwork',
method: 'put',
data: data
})
}

View File

@ -1,8 +1,10 @@
<template>
<div class="page-typeview flex">
<el-form ref="classWorkForm" :model="classWorkForm" label-width="90" style="height: calc(100% - 55px);display: flex;flex-direction: column;">
<div class="page-typeview">
<el-form ref="classWorkFormRef" :model="classWorkForm" label-width="90" style=" height: 100%;overflow: hidden;">
<!-- 标题 -->
<el-row>
<div class="container">
<!-- 作业类型 -->
<el-row class="top">
<el-col :span="24">
<el-form-item label="作业类型:">
<el-radio-group v-model="formType" @change="changeFormType">
@ -12,11 +14,16 @@
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="24">
</el-row>
<!-- 作业资源 -->
<el-row class="middle">
<el-col :span="24" style="height: 100%; overflow: hidden;">
<el-form-item label="作业资源:" class="el-form-work-list">
<el-col :span="15" class="work-left">
<!-- 习题训练 -->
<div v-if="classWorkForm.worktype=='习题训练'" style="height: 100%; display: flex; flex-direction: column;">
<el-row :gutter="10">
<!-- 习题筛选1 -->
<el-row :gutter="10" class="top">
<el-col :span="6">
<el-form-item label="题型" label-width="70">
<el-select v-model="entpCourseWorkQueryParams.worktype" placeholder="请选择" >
@ -48,7 +55,8 @@
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="10" style="margin-top: 4px">
<!-- 习题筛选2 -->
<el-row :gutter="10" style="margin-top: 4px" class="top">
<el-col :span="6">
<el-form-item label="年份" label-width="70">
<el-select v-model="entpCourseWorkQueryParams.yearStr" placeholder="请选择" >
@ -67,8 +75,9 @@
</el-form-item>
</el-col>
</el-row>
<el-table :data="workResource.entpCourseWorkList" style="width: 100%;">
<!-- 习题表格 -->
<div class="middle" >
<el-table :data="workResource.entpCourseWorkList" style="width: 100%; height: 100%;">
<el-table-column type="index" width="60" />
<el-table-column align="left" >
<template #header>
@ -93,8 +102,9 @@
</template>
</el-table-column>
</el-table>
<div style="height: 55px;">
<!-- 分页 -->
</div>
<!-- 分页 这里不用-->
<!-- <div style="height: 55px;">
<pagination
v-show="entpCourseWorkTotal > 0"
v-model:page="paginationParams.pageNum"
@ -102,7 +112,7 @@
:total="entpCourseWorkTotal"
:style="{ position: 'relative', 'margin-top': '5px' }"
@pagination="getPaginationList" />
</div>
</div> -->
</div>
<!-- <div v-if="classWorkForm.worktype!='习题训练'">
<div :style="{ 'overflow': 'auto'}">
@ -186,7 +196,7 @@
</div>
</div> -->
</el-col>
<el-col :span="8" style="padding: 0 0 0 5px;height: 60vh; overflow: auto; line-height: 26px">
<el-col :span="9" class="work-right">
<div v-if="classWorkForm.worktype=='习题训练'" :style="{ 'overflow': 'auto', 'border':'1px dotted blue','border-radius':'5px', 'background-color': '#f7f7f7'}">
<template v-for="(item,index) in classWorkForm.quizlist" :key="item.id">
<div style="margin: 5px; background-color: white">
@ -226,25 +236,49 @@
</el-form-item>
</el-col>
</el-row>
<!-- 作业说明 -->
<el-row class="bottom">
<el-col :span="12">
<el-form-item label="作业说明" style="margin: 10px 0;">
<el-col :span="15" style="padding: 0px">
<!-- <el-input v-model="classWorkForm.title" type="textarea" :rows="1" placeholder="请输入作业说明"/> -->
<el-input v-model="classWorkForm.title" style="width: 400px" placeholder="请输入作业说明"/>
</el-col>
</el-form-item>
</el-col>
<el-col :span="12">
<el-button type="primary" @click="handleClassWorkSave"> </el-button>
</el-col>
</el-row>
</div>
</el-form>
</div>
</template>
<script setup>
import { onMounted, ref, toRaw,watch, reactive } from 'vue'
import { onMounted, ref, nextTick, watch, reactive, getCurrentInstance } from 'vue'
import { ElMessage } from 'element-plus'
import { useToolState } from '@/store/modules/tool'
import { getCurrentTime } from '@/utils/date'
import { processList } from '@/hooks/useProcessList'
import {listEntpcoursework, listEntpcourseworkNew} from '@/api/education/entpCourseWork'
import {listEntpcoursework, listEntpcourseworkNew, getEntpcoursework} from '@/api/education/entpCourseWork'
import { updateClasswork } from '@/api/classTask'
import { useGetHomework } from '@/hooks/useGetHomework'
import useUserStore from '@/store/modules/user'
const userStore = useUserStore().user
const { proxy } = getCurrentInstance()
const props = defineProps({
bookobj: {
type: Object,
default: () => ({})
},
uniquekey: {
type: String,
default: ''
}
})
@ -253,7 +287,9 @@ const toolStore = useToolState()
const openDialog = () => {
isDialogOpen.value = true
}
const classWorkFormRef = ref(null);
const formType = ref('习题训练')
const newWorkSpaceEdit = ref(false); //
// ---------------------------------------------------
const listWorkType = ref(['习题训练', '框架梳理', '课堂展示', '常规作业']); //
@ -318,15 +354,15 @@ const workResource = reactive({
quiztype: '',
queryForm: {},
classWorkList: [], //
entpCourseWorkList: [],
entpCourseWorkList: [], //
entpCourseWorkTotal: 0, //
}); //
const classWorkForm = reactive({
let classWorkForm = reactive({
uniquekey: props.uniquekey, //
worktype: '习题训练', //
// uniquekey: userStore.edusubject+'-' + getCurrentTime('MMDD')+'-'+(this.taskList.length+1),
title: '',//
quizlist: [], //
})
const entpCourseWorkList = ref([]); //
const entpCourseWorkTotal = ref(0); //
@ -335,7 +371,7 @@ const entpCourseWorkTotal = ref(0); // 习题总数
*/
const changeFormType = (val) => {
console.log(val)
classWorkForm.value.worktype = val;
classWorkForm.worktype = val;
}
const queryForm = reactive({
@ -372,7 +408,7 @@ const queryForm = reactive({
* 1 - 按条件查询
* 2 - 按关键词查询
*/
const handleQueryFromEntpCourseWork= (queryType) => {
const handleQueryFromEntpCourseWork= (queryType) => {
//queryForm.pageNum = this.paginationParams.pageNum;
//queryForm.pageSize = this.paginationParams.pageSize;
@ -382,8 +418,6 @@ const queryForm = reactive({
// queryForm.edusubject = '';
// }
console.log(queryForm)
listEntpcourseworkNew(queryForm).then(entpcourseworkres => {
// if (queryType == 1 && this.entpCourseWorkQueryParams.worktype == '') {
// // ,
@ -394,57 +428,462 @@ const queryForm = reactive({
// } else {
// workResource.entpCourseWorkList = entpcourseworkres.rows;
// }
if(entpcourseworkres.data == null) {
workResource.entpCourseWorkList = [];
entpCourseWorkTotal.value = 0
return;
}
entpCourseWorkList.value = entpcourseworkres.data;
if(entpcourseworkres.data&&entpcourseworkres.data.length>0){
workResource.entpCourseWorkList = entpcourseworkres.data;
workResource.entpCourseWorkTotal = entpcourseworkres.data.length;
workResource.entpCourseWorkList.forEach(item=> {
if (item.worktype == '选择题') {
item.worktype = '单选题'
}
})
//
entpCourseWorkTotal.value = 0;
if (entpcourseworkres.data.length > 0) {
entpCourseWorkTotal.value = entpcourseworkres.data.length;
}
if()
//
processList(workResource.entpCourseWorkList);
}else{
workResource.entpCourseWorkList = [];
workResource.entpCourseWorkTotal = 0
}
})
}
/**
* 添加资源
* @param fromsrc - 试题来源
* @param entpcourseworkid
*/
const handleClassWorkQuizAdd = (fromsrc, entpcourseworkid) => {
var exist = false;
for (var i=0; i< classWorkForm.quizlist.length; i++) {
if (classWorkForm.quizlist[i].id == entpcourseworkid) {
exist = true;
break;
}
}
if (exist == false) {
getEntpcoursework(entpcourseworkid).then(res => {
//res.data.titletext = res.data.title.replace(/<[^>]+>/g, '');
//
if(res.data.score == null){
res.data.score = 4;
}
classWorkForm.quizlist.push(res.data);
//
processList(classWorkForm.quizlist);
})
} else {
ElMessage('试题已经存在')
}
};
/**
* 作业设计-提交
*/
const handleClassWorkSave = async () => {
await nextTick(); // DOM
proxy.$refs["classWorkFormRef"].validate(async valid => {
if (valid) {
if (classWorkForm.id != null) {
// []
updateClasswork(classWorkForm).then(response => {
ElMessage("修改成功");
// this.workConfDialogOpen = false;
//
// this.getClassWorkAllList(); //
});
} else {
// [] newWorkSpaceEdit true
if(newWorkSpaceEdit.value ) {
// 0.
if (this.currentTag == '习题训练') {
if (this.classWorkForm.quizlist.length == 0) {
ElMessage.error('请先添加作业资源!');
return;
}
}
else if (this.currentTag == '课堂展示' || this.currentTag == '常规作业') {
//
}
else {
if (this.chooseWorkLists.length == 0) {
ElMessage.error('请先添加作业资源!');
return;
}
}
//
let classWorkParams = {
id: this.currentTask.id,
uniquekey: this.classWorkForm.uniquekey, // []
//title: classWorkForm.title, // []
}
//
if (this.currentTag=='习题训练'){
// console.log(this.workConfObj.quizlist);
// console.log(this.currentTask);
// console.log(this.classWorkList);
// 1.
let needUplEval = false;
if (this.classWorkForm.quizlist.length !== this.currentTask.entpcourseworklistarray.length) {
needUplEval = true;
}
else {
//
// for (let cur of this.classWorkForm.quizlist){
// let isSame = false;
// for (let last of this.currentTask.entpcourseworklistarray) {
// if (last.id === cur.id && last.score === cur.score){
// isSame = true;
// break;
// }
// }
// if (!isSame) {
// needUplEval = true;
// break;
// }
// }
needUplEval = this.classWorkForm.quizlist.some(cur =>
!this.currentTask.entpcourseworklistarray.some(last =>
last.id === cur.id && last.score === cur.score
)
);
}
// 2.eval
if (needUplEval) {
// : , ,
// 2.1.workidid
let arrEvalids = [];
const wevalres = await listClassworkeval({'workid': this.currentTask.id});
wevalres.rows.forEach(element => {
arrEvalids.push(element.id);
});
const ids = arrEvalids.join(',');
// 2.2.
const delRes = await delClassworkeval(ids);
// 2.3.
for(let i=0; i<this.classWorkForm.quizlist.length; i++){
const addRes = await addClassworkeval({
'workid': this.currentTask.id,
'entpcourseworkid': this.classWorkForm.quizlist[i].id,
'workdataid': 0,
'score': this.classWorkForm.quizlist[i].score}
);
}
}
// 3.
// const evalid = this.homeworkLesson.length==0 ? '' : this.homeworkLesson.length==1 ? this.homeworkLesson[0] : this.homeworkLesson[1];
// const formObj = {
// id: this.currentTask.id,
// uniquekey: this.classWorkForm.uniquekey, // []
// // warn:
// //evalid = evalid, // []
// }
// let res = await updateClasswork(formObj);
}
else if (this.currentTag=='框架梳理') {
// 1.workidid
const wevalres = await listClassworkeval({'workid': this.currentTask.id});
if (wevalres.rows.length == 0) {
ElMessage.error('未找到原框架梳理任务,请或退出重试');
return;
}
// 2.
let needUplEval = false;
if (this.chooseWorkLists.length !== this.currentTask.entpcourseworklistarray.length) {
needUplEval = true;
}
else {
//
needUplEval = this.chooseWorkLists.some(cur =>
!this.currentTask.entpcourseworklistarray.some(last =>
last.id === cur.id && last.score === cur.score
)
);
}
if (needUplEval) {
const uplParams = {
id: wevalres.rows[0].id,
entpcourseworkid: this.chooseWorkLists[0].id,
score: this.chooseWorkLists[0].score,
}
let res = await updateClassworkeval(uplParams);
}
}
else if (this.currentTag=='课堂展示') {
}
else if (this.currentTag=='常规作业') {
// 1. (, )
classWorkParams.workcodes = JSON.stringify(this.fileHomeworkList);
}
// 3.
let res = await updateClasswork(classWorkParams);
this.fileHomeworkList = [];
this.chooseWorkLists = [];
// 4.
this.getClassWorkAllList();
this.classWorkForm.worktype = "习题训练";
this.newWorkSpace = false;
this.newWorkSpaceEdit = false;
this.workEdit = false;
return;
}
const { res, chapterId } = await useGetHomework(this.currentNode)
// this.entpcourseid = chapterId
if (classWorkForm.worktype === "课堂展示") {
this.boardLoading = true
let canvasJson = this.$refs.boardref.getCanvasJson()
let canvasBase64 = await this.$refs.boardref.getCanvasBase64()
var formObj = {};
formObj.id = 0;
formObj.workdate = this.classWorkForm.workdate;
formObj.deaddate = '';
formObj.entpid = this.userStore.deptId;
formObj.level = 1;
formObj.parentid = 0;
formObj.worktype = this.classWorkForm.worktype;
formObj.workkey = '';
formObj.worktag = this.question;
formObj.uniquekey = this.classWorkForm.uniquekey;
formObj.classid = 0;
formObj.classcourseid = 0;
formObj.entpcourseid = this.courseObj.id;
formObj.slideid = 0;
formObj.title = this.classWorkForm.title;
formObj.workcodes = JSON.stringify({json: canvasJson, base64: canvasBase64});
formObj.edusubject = this.courseObj.edusubject;
formObj.evalid = this.courseObj.evalid;
formObj.edustage = this.userStore.edustage;
formObj.status = '10'; //2024-09-11
formObj.edituserid = this.userStore.id;
formObj.entpcourseworklist = JSON.stringify([{'id':-1, 'score': '10'}]);
try {
addClassworkReturnId(formObj).then(() => {
this.classWorkForm.worktype = "习题训练";
this.chooseWorkLists = [];
this.whiteboardObj = '';
// refresh the list
this.getClassWorkAllList();
this.newWorkSpace = false;
this.newWorkSpaceEdit = false;
this.workEdit = false;
})
} finally {
this.boardLoading = false
}
}
else if(classWorkForm.worktype === "常规作业"){
this.fileLoading = true
var formObj = {};
formObj.id = 0;
formObj.workdate = this.classWorkForm.workdate;
formObj.deaddate = '';
formObj.entpid = this.userStore.deptId;
formObj.level = 1;
formObj.parentid = 0;
formObj.worktype = this.classWorkForm.worktype;
formObj.workkey = '';
formObj.worktag = '';
formObj.uniquekey = this.classWorkForm.uniquekey;
formObj.classid = 0;
formObj.classcourseid = 0;
formObj.entpcourseid = this.courseObj.id;
formObj.slideid = 0;
formObj.title = this.classWorkForm.title;
formObj.workcodes = JSON.stringify(this.fileHomeworkList);
formObj.edusubject = this.courseObj.edusubject;
formObj.evalid = this.courseObj.evalid;
formObj.edustage = this.userStore.edustage;
formObj.status = '10'; //2024-09-11
formObj.edituserid = this.userStore.id;
formObj.entpcourseworklist = JSON.stringify([{'id':-2, 'score': '10'}]);
try {
addClassworkReturnId(formObj).then(() => {
this.classWorkForm.worktype = "习题训练";
this.chooseWorkLists = [];
this.fileHomeworkList = []
this.whiteboardObj = '';
// refresh the list
this.getClassWorkAllList();
this.newWorkSpace = false;
this.newWorkSpaceEdit = false;
this.workEdit = false;
})
} finally {
this.fileLoading = false
}
}
else {
//
var ll = [];
if (classWorkForm.worktype === "习题训练") {
for (var i=0; i< classWorkForm.quizlist.length; i++) {
//
ll.push({'id': classWorkForm.quizlist[i].id, 'score': classWorkForm.quizlist[i].score});
}
}else {
// TODO ------------
// this.chooseWorkLists.filter((item, index) => {
// if (item.worktype === this.classWorkForm.worktype) {
// ll.push({'id':item.id, 'score': item.score});
// }
// })
}
console.log(userStore,'userStoreuserStoreuserStore')
const cform = {
id: 0,
workdate: classWorkForm.workdate, // //
deaddate: '', //
entpid: userStore.deptId, //
level: 1,
parentid: 0,
worktype: classWorkForm.worktype, //
workkey: '',
worktag: '',
uniquekey: classWorkForm.uniquekey,//
classid: 0,
classcourseid: 0,
entpcourseid: chapterId, //
slideid: 0,
title: classWorkForm.title, //
workcodes: JSON.stringify(classWorkForm.workcodes), //
edusubject: userStore.edusubject, //
evalid: props.bookobj.levelSecondId, //userStore.evalid, // // ID
edustage: userStore.edustage, // ,,
status: '10', //2024-09-11
edituserid: userStore.userId, // id
};
if (ll.length > 0) {
cform.entpcourseworklist = JSON.stringify(ll);
} else {
cform.entpcourseworklist = '';
}
if(cform.entpcourseworklist == '') return ElMessage({ type: 'warning', message: '请先添加作业资源!'});
console.log(cform,'提交的数据');
// addClassworkReturnId(cform).then(workres => {
// this.classWorkForm.worktype = "";
// this.chooseWorkLists = [];
// this.whiteboardObj = '';
// // refresh the list
// this.getClassWorkAllList();
// // 使 240603
// // var slist = [];
// // for (var i=0; i<this.classStudentList.length; i++) {
// // slist.push({studentid: this.classStudentList[i].studentid, name: this.classStudentList[i].name});
// // }
// // var quizll = [];
// // for (var i=0; i<this.classWorkForm.quizlist.length; i++) {
// // quizll.push({id: this.classWorkForm.quizlist[i].id});
// // }
// // var ttt = {
// // id: workres,
// // studentlist: slist,
// // entpcourseworklist: quizll
// // }
// // var wForm = {};
// // wForm.classworkarray = '['+JSON.stringify(ttt)+']';
// //pushClassWorkByArray(wForm).then(response => {});
// this.newWorkSpace = false;
// this.newWorkSpaceEdit = false;
// this.workEdit = false;
// })
}
}
}
});
};
onMounted(() => {
handleQueryFromEntpCourseWork(0);
})
// watch(() => sourceStore.query.fileSource,() => {
// sourceStore.query.fileSource === ''?isThird.value = true:isThird.value = false
// })
watch(() => props.bookobj.levelSecondId, (newVal) => {
console.log(props.bookobj,'课程选择')
queryForm.eid = props.bookobj.levelSecondId,
queryForm.sectionName = props.bookobj.coursetitle,
handleQueryFromEntpCourseWork(0);
})
</script>
<style lang="scss" scoped>
.page-typeview{
padding-top: 10px;
// padding-top: 10px;
height: 100%;
.container {
display: flex;
flex-direction: column;
height: 100%;
}
.top, .bottom {
flex: 0 0 auto;
}
.middle {
flex: 1;
height: 100%;
overflow: hidden;
}
.el-form-work-list{
height: 100%;
margin-bottom: 0px;
overflow: hidden;
:deep(.el-form-item__content){
align-items: normal;
}
.work-left{
height: 50vh;
height: 100%;
background-color: white;
padding-right: 0;
padding-left: 0;
border:1px dotted blue;
border-radius:5px;
overflow: hidden;
}
.work-right {
height: 100%;
padding: 0 0 0 5px;
overflow: auto;
line-height: 26px;
overflow: hidden;
}

View File

@ -1,19 +1,19 @@
<template>
<div class="page-resource flex">
<div class="page-newcalsetask flex">
<el-menu
default-active="1"
class="el-menu-vertical-demo"
:collapse="isCollapse"
>
<!--左侧 教材 目录-->
<div v-if="!isCollapse">
<div v-if="!isCollapse" style="height: 100%;overflow: hidden;">
<ChooseTextbook @change-book="getData" @node-click="getData" />
</div>
</el-menu>
<div class="page-right" :style="{'margin-left': isCollapse ? '0' : '20px'}">
<!-- 标题 -->
<el-row style="align-items: center; margin-bottom: 0px">
<el-row style="align-items: center; margin-bottom: 0px; flex: 0 0 auto">
<el-col :span="12" style="padding-left: 20px; text-align: left;">
<div class="unit-top-left" @click="isCollapse = !isCollapse">
<i v-if="!isCollapse" class="iconfont icon-xiangzuo"></i>
@ -30,7 +30,7 @@
</el-col>
</el-row>
<!-- 作业类型:内容 -->
<task-type-view :bookobj="courseObj" />
<task-type-view :bookobj="courseObj" :uniquekey="classWorkForm.uniquekey" style="flex: 1; overflow: hidden;"/>
</div>
</div>
</template>
@ -116,9 +116,10 @@ const init = () => {
</script>
<style lang="scss" scoped>
.page-resource {
.page-newcalsetask {
padding-top: 10px;
height: 100%;
overflow: hidden;
.el-menu--collapse {
width: 0px;

View File

@ -106,9 +106,9 @@ const menuList = [{
{
name: '作业设计',
icon: 'icon-jiaoxuefansi',
isOuter: true,
path: '/teaching/classtaskassign?titleName=作业布置&openDialog=newClassTask'
//path: '/newClassTask'
// isOuter: true,
//path: '/teaching/classtaskassign?titleName=&openDialog=newClassTask'
path: '/newClassTask'
//path: '/classTaskAssign'
//isOuter: true,
//path: '/teaching/classtaskassign?titleName=&&openDialog=newClassTask'