作业布置:新增推送、批量推送

This commit is contained in:
白了个白 2024-10-10 09:53:45 +08:00
parent 68388b9c86
commit f0313653e6
2 changed files with 476 additions and 3 deletions

View File

@ -100,6 +100,17 @@ export const getCurrentTime = (format)=> {
if(format == 'MMDD'){
return `${month}${day}`;
}
if(format == 'HH'){
return `${hours}`;
}
if(format == 'HH+3'){
//往后延时3个小时
const hours = (now.getHours()+3).toString().padStart(2, '0');
return `${hours}`
}
if(format == 'mm'){
return `${minutes}`;
}
}
/**
*

View File

@ -92,7 +92,7 @@
<el-table-column v-if="props.initDataProps.queryType!=='single'" label="推送配置" align="left" min-width="16%">
<template #default="scope">
<div style="display: flex">
<el-button link icon="Setting" @click="scope.row.status == '10' ? openClassWorkConfigDialog(scope.row, -1,'item') : ''" :style="formatStyle(scope.row)" v-hasPermi="['teaching:classwork:edit']">{{scope.row.status == '10'? '推送' : '已推送'}}</el-button>
<el-button v-hasPermi="['teaching:classwork:edit']" link icon="Setting" :style="formatStyle(scope.row)" @click="scope.row.status == '10' ? openClassWorkConfigDialog(scope.row, -1,'item') : ''">{{scope.row.status == '10'? '推送' : '已推送'}}</el-button>
</div>
</template>
</el-table-column>
@ -149,21 +149,106 @@
@click="submitWorkTitle('submit')"> </el-button>
</div>
</el-dialog>
<!-- 推送作业的配置对话框 -->
<el-dialog v-model="workConfDialogOpen" title="作业布置推送配置" width="60%" append-to-body>
<el-row>
<el-col :span="24">
<!-- <div style="display: flex; justify-content: space-between; padding-bottom: 8px; border-bottom: 1px solid silver">
<div style="padding-left: 30px">作业布置配置详细参数</div>
</div> -->
<el-form ref="classWorkConfigFormRef" :model="classWorkConfigForm" label-width="100px" style="margin-top: 30px">
<el-row>
<el-col :span="24">
<el-form-item label="班级" prop="grade">
<el-scrollbar max-height="300px" style="width: 100%">
<el-tree
ref="treeRef" :props="defaultProps" :load="getLoad" node-key="id" highlight-current show-checkbox
lazy @check="handleCheckChange" />
</el-scrollbar>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item label="选中学生">
<div style="max-height: 150px; overflow: auto">
<template v-for="(item, index) in classWorkConfigForm.studentlist" :key="item" >
<el-tag :label="item.studentid" size="large" closable style="margin: 3px" @close="handleClassDialogClassStudentRemove(item, index)">{{ item.name }}</el-tag>
</template>
</div>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item label="完成要求">
<el-radio-group v-model="classWorkConfigForm.feedtype">
<el-radio label="必做">必做</el-radio>
<el-radio label="选做">选做</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="截止日期">
<el-date-picker v-model="classWorkConfigForm.deaddate" type="date" placeholder="选择日期"></el-date-picker>
</el-form-item>
</el-col>
<el-col :span="16">
<el-form-item label="截止时间">
<el-input-number v-model="classWorkConfigForm.deadhour" :min="8" :max="22"></el-input-number>
<el-input-number v-model="classWorkConfigForm.deadmin" :min="0" :max="60" :step="15" style="margin-left: 10px"></el-input-number>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="推荐用时">
<el-input-number v-model="classWorkConfigForm.timelength" :min="1"></el-input-number>分钟
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="分值" v-show="false">
<el-input-number v-model="classWorkConfigForm.weights" :min="1"></el-input-number>
</el-form-item>
</el-col>
</el-row>
<el-row>
</el-row>
</el-form>
</el-col>
</el-row>
<div slot="footer" class="dialog-footer" style="text-align: right">
<el-button @click="handleWorkConfigUpdate('cancel')">取消</el-button>
<!-- <el-button type="primary" @click="handleTaskAssignToAllClassType()" :loading="classWorkToStudent_Loading">{{classWorkToStudent_Loading?'推送中……':'推送'}}</el-button> -->
<el-button type="primary" @click="handleTaskAssignToAllClassType()" >{{'推送'}}</el-button>
</div>
</el-dialog>
</div>
</div>
</template>
<script setup>
import { onMounted, ref, toRaw,watch, reactive, getCurrentInstance } from 'vue'
import { onMounted, ref,watch, reactive, getCurrentInstance,nextTick } from 'vue'
import { useRouter } from 'vue-router'
import ChooseTextbook from '@/components/choose-textbook/index.vue'
import { homeworklist, delClasswork } from '@/api/teaching/classwork'
import { listEntpcoursework, listClassworkeval,updateClasswork,getEvaluationclue } from '@/api/classTask'
import { listClassmain, listClassgroup } from '@/api/classManage/index'
import { saveByClassWorkArray } from '@/api/teaching/classwork'
import { useGetHomework } from '@/hooks/useGetHomework'
import { processList } from '@/hooks/useProcessList'
import { uniqBy, groupBy } from 'lodash'
import { getCurrentTime } from '@/utils/date'
import useUserStore from '@/store/modules/user'
const userStore = useUserStore().user
@ -210,6 +295,22 @@ const workConfObj = reactive({
quizlist: [], // list
});
//
const defaultProps = ref({
children: 'children',
label: 'label',
isLeaf: 'leaf'
});
const gradeList = ref([]);//
const workConfDialogOpen = ref(false);//
const classWorkConfigForm = reactive({
formRowsType: '',//
formRowsList: null,
//
feedtype: '必做',
studentlist: [], //list
}); //
// ---------------------------------------------------
@ -579,6 +680,367 @@ const isJson = (str) => {
}
}
//
const getGradeList = async() => {
let { rows } = await listClassmain({
classuserid: userStore.userId,
pageSize: 100,
status: 'open'
})
rows.forEach((item) => {
item.label = item.caption
item.level = 0
item.leaf = false
item.children = []
item.classstudentlist = JSON.parse('[' + item.classstudentlist + ']')
item.classstudentlist.forEach((el) => {
el.classid = item.id
})
})
return rows
};
//
const getLoad = async (node, resolve) =>{
//
if (node.level == 0) {
gradeList.value = await getGradeList()
resolve(gradeList.value)
}
//
if (node.level == 1) {
listClassgroup({ classid: node.key, orderby: 'orderidx', pageSize: 100 }).then((res) => {
if (res.rows.length > 0) {
let ary = []
res.rows.forEach((item) => {
if (item.parentid === 0) {
//studentGroup
let studentGroup = JSON.parse('[' + item.studentlist + ']')
studentGroup.forEach((el) => {
el.label = el.name
el.leaf = true
el.level = 2
el.id = el.studentid
el.classid = item.classid
})
ary.push({
label: item.groupname,
leaf: false,
...item,
level: 1,
// children
children: studentGroup
})
}
})
resolve(ary)
} else {
//
let students = node.data.classstudentlist
students.forEach((item) => {
item.label = item.name
item.level = 2
item.leaf = true
})
resolve(students)
}
})
}
//
if (node.level == 2) {
resolve(node.data.children)
}
}
//
const handleCheckChange = (data, checked) => {
classWorkConfigForm.studentlist = [];
//
let checkNodes = checked.checkedNodes
let ary = []
checkNodes.forEach((item) => {
//
if (item.level == 0) {
ary = [...ary, ...item.classstudentlist]
}
//
if (item.level == 1) {
ary = [...ary, ...item.children]
}
//
if (item.level == 2) {
ary = [...ary, item]
}
})
classWorkConfigForm.studentlist = uniqBy(ary, 'studentid')
};
//
const handleClassDialogClassStudentRemove = (item,index) => {
classWorkConfigForm.studentlist.splice(index, 1);
// []]
proxy.$refs.treeRef.setChecked(item.id, false, true);
//TODO
// const ids = this.$refs.treeRef.getCheckedKeys();
// console.log(ids)
// console.log(ids.filter((_item)=>_item == item.id),'???????')
// if(ids&&ids.filter((_item)=>_item == item.id).length>0){
// console.log(ids,'?====?')
// console.log(item.id,'?=item.id===?')
// // ?
// this.$refs.treeRef.setChecked(item.id, false, true);
// // setCheckedKeys
// }
};
/**
* 处理在作业推送前的任务配置
*/
const openClassWorkConfigDialog = (row, configindex, type) => {
//
workConfDialogOpen.value = true;
classWorkConfigForm.formRowsType = '';//
classWorkConfigForm.formRowsList = null;
if(type == 'list'){
classWorkConfigForm.formRowsType = 'list';
classWorkConfigForm.formRowsList = row;
}else{
classWorkConfigForm.formRowsType = 'item';
classWorkConfigForm.formRowsList = [row];
}
// TODO
// if (configindex > -1) {
// this.handleClassDialogConfigShow(configindex, 0)
// }
classWorkConfigForm.deaddate = getCurrentTime('YYYY-MM-DD');
classWorkConfigForm.deadhour = getCurrentTime('HH+3');// 3
classWorkConfigForm.deadmin = getCurrentTime('mm');
classWorkConfigForm.timelength = 1;
};
/**
* 推送配置保存配置
* @param key 'cancel' or 'submit'
*/
const handleWorkConfigUpdate = (key,row) => {
if (key == 'cancel') {
workConfDialogOpen.value = false;
} else if (key == 'submit') {
// 2024-04-08, by jackyshen
// this.classWorkConfigForm.classlist
var clist = [];
var cidlist = [];
for (var i=0; i< classWorkConfigForm.studentlist.length; i++) {
if (cidlist.indexOf(classWorkConfigForm.studentlist[i].classid) == -1) {
// UI
var clsname = '';
for (var d = 0; d<gradeList.value.length; d++) {
if (gradeList.value[d].id == classWorkConfigForm.studentlist[i].classid) {
clsname = gradeList.value[d].caption;
}
}
clist.push({id: classWorkConfigForm.studentlist[i].classid, caption: clsname});
cidlist.push(classWorkConfigForm.studentlist[i].classid);
}
}
// 20240408207
// index > -1
//
//
//
// if (classWorkConfigForm.index > -1) {
// classWorkConfigForm.classWorkConfigList.splice(classWorkConfigForm.activeClassWorkIndex);
// }
//
var hh = classWorkConfigForm.deadhour;
hh = "0"+hh;
hh = hh.substr(hh.length-2, 2);
var mm = classWorkConfigForm.deadmin;
mm = "0"+mm;
mm = mm.substr(mm.length-2, 2);
//
classWorkConfigForm.deaddate = '' + classWorkConfigForm.deaddate;
if (isNaN(classWorkConfigForm.deaddate.substring(0,4))) {
var dd = new Date(classWorkConfigForm.deaddate);
var year = dd.getFullYear(); //
var month = dd.getMonth() + 1; //0-11
month = "0"+month;
month = month.substr(month.length-2,2);
var day = dd.getDate(); //131
day = "0"+day;
day = day.substr(day.length-2,2);
classWorkConfigForm.deaddate = year+'-'+month+'-'+day;
}
classWorkConfigForm.classWorkConfigList = [];
//
for (var i=0; i<clist.length; i++) {
classWorkConfigForm.classWorkConfigList.push({
id: 0,
classid: clist[i].id,
classcaption: clist[i].caption, //
parentid: 0,
worktype: '',
workkey: classWorkConfigForm.workkey,
worktag: '',
entpcourseid: 0,
evalid: 0,
edusubject: '',
edudegree: '',
workdate: '',
title: '',
workcodes: '',
studentlist: classWorkConfigForm.studentlist,
timelength: classWorkConfigForm.timelength,
weights: classWorkConfigForm.weights,
feedtype: classWorkConfigForm.feedtype,
deaddate: classWorkConfigForm.deaddate+' '+hh+":"+mm,
});
}
if(classWorkConfigForm.formRowsType == 'list'){
// list
for(var d=0;d<classWorkConfigForm.formRowsList.length;d++){
classWorkConfigForm.rowid = classWorkConfigForm.formRowsList[d].id;
// 20240308by jackyshen
// classWorkConfigForm.classWorkConfigListtaskList[i]
// classWorkConfigForm.classWorkConfigList
for (var i=0; i<taskList.value.length; i++) {
if (taskList.value[i].id == classWorkConfigForm.rowid) {
taskList.value[i].taskconfig = classWorkConfigForm.classWorkConfigList;
break;
}
}
}
}else{
// item
classWorkConfigForm.rowid = classWorkConfigForm.formRowsList[0].id;
// 20240308by jackyshen
// classWorkConfigForm.classWorkConfigListtaskList[i]
// classWorkConfigForm.classWorkConfigList
for (var i=0; i<taskList.value.length; i++) {
if (taskList.value[i].id == classWorkConfigForm.rowid) {
taskList.value[i].taskconfig = classWorkConfigForm.classWorkConfigList;
break;
}
}
}
//
classWorkConfigForm.id = 0;
classWorkConfigForm.index = -1;
classWorkConfigForm.selclassid = 0;
classWorkConfigForm.classlist = [];
classWorkConfigForm.studentlist = [];
classWorkConfigForm.feedtype = '必做';
classWorkConfigForm.workkey = '';
classWorkConfigForm.selgroupid = 0;
classWorkConfigForm.classGroups = [];
classWorkConfigForm.availableStudents = [];
classWorkConfigForm.deaddate = getCurrentTime('YYYY-MM-DD');
classWorkConfigForm.deadhour = getCurrentTime('HH+3');
classWorkConfigForm.deadmin = getCurrentTime('mm');
classWorkConfigForm.timelength = 1;
classWorkConfigForm.weights = 1;
}
};
/**
* 推送
*/
const handleTaskAssignToAllClassType = async() => {
if(classWorkConfigForm.studentlist.length == 0){
return proxy.$modal.msgWarning('请选择需要推送的学生!');
}
// this.classWorkToStudent_Loading = true;
//
handleWorkConfigUpdate('submit', '')
const { chapterId } = await useGetHomework(courseObj.node)
// this.entpcourseid = chapterId
console.log(taskList.value,'===============this.taskListthis.taskList')
var ttt = [];
for (var i=0; i<taskList.value.length; i++) {
// 20240408, by jackyshen
// taskconfig.classWorkList
for (var t=0; t<taskList.value[i].taskconfig.length; t++) {
if (taskList.value[i].taskconfig[t].id == 0) {
ttt.push({
id: 0,
parentid: taskList.value[i].id,
classid: taskList.value[i].taskconfig[t].classid,
classcourseid: 0,
entpcourseid: chapterId,
studentlist: JSON.stringify(taskList.value[i].taskconfig[t].studentlist),
feedback: taskList.value[i].taskconfig[t].feedtype,
workkey: taskList.value[i].taskconfig[t].workkey,
timelength: taskList.value[i].taskconfig[t].timelength,
weights: taskList.value[i].taskconfig[t].weights,
deaddate: taskList.value[i].taskconfig[t].deaddate,
workdate: getCurrentTime('YYYY-MM-DD'),
uniquekey: taskList.value[i].uniquekey,
entpcourseworklist: '['+taskList.value[i].entpcourseworklist+']', // JSON
needMsgNotifine: 'false',
msgkey: 'newclasswork',
title: taskList.value[i].title,
status:'1',
msgcontent: '', // classworkjson
teachername: userStore.nickName,
unixstamp: new Date().getTime(),
});
}
}
}
console.log(ttt,'===============ttt')
if(ttt.length == 0){
proxy.$modal.msgError('您还未进行作业配置,请配置后再推送');
return;
}
var wForm = {};
wForm.classworkarray = JSON.stringify(ttt);
saveByClassWorkArray(wForm).then(response => {
console.log(response,'===============response');
// this.classWorkToStudent_Loading = false;
workConfDialogOpen.value = false;
proxy.$modal.msgSuccess("作业推送成功");
//
proxy.$refs.treeRef.setCheckedKeys([]);
//
nextTick(() => {
getTaskList();
})
}).catch((error) =>{
// this.classWorkToStudent_Loading = false;
workConfDialogOpen.value = false;
});
};
/**
* 一键推送
*/
const handleTaskAssignToAllClass = () => {
let rows = proxy.$refs.taskTable.getSelectionRows();
if (rows.length > 0) {
proxy.$modal.confirm('是否确认推送选中的学习任务?').then(()=> {
}).then(() => {
//
openClassWorkConfigDialog(rows, -1,'list')
}).catch(() => {})
}else{
return proxy.$modal.alertWarning("请选择需要推送的任务!");
}
}
// -
const submitWorkTitle = () => {