作业删除

This commit is contained in:
lyc 2024-08-02 14:30:27 +08:00
parent 0ba717de6e
commit e53eab0c31
2 changed files with 94 additions and 61 deletions

View File

@ -1,7 +1,6 @@
<template> <template>
<el-dialog v-model="dialogVisible" center top="10vh" width="600px" :show-close="false" <el-dialog v-model="dialogVisible" center top="10vh" width="600px" :show-close="false" append-to-body
style="border-radius: 10px; padding: 10px 15px;"> style="border-radius: 10px; padding: 10px 15px;">
<template #header> <template #header>
<div class="homerwork-header flex"> <div class="homerwork-header flex">
<span>布置作业</span> <span>布置作业</span>
@ -9,14 +8,14 @@
</div> </div>
</template> </template>
<div> <div>
<el-form :model="form" label-width="80px"> <el-form :model="form" label-width="80px" ref="ruleForm" :rules="rules">
<el-form-item label="班级"> <el-form-item label="班级" prop="grade">
<el-scrollbar max-height="200px" style="width: 100%;"> <el-scrollbar max-height="200px" style="width: 100%;">
<el-tree ref="treeRef" :data="treeData" :props="defaultProps" :load="getLoad" node-key="id" <el-tree ref="treeRef" :data="gradeList" :props="defaultProps" :load="getLoad" node-key="id"
@check="handleCheckChange" lazy show-checkbox /> @check="handleCheckChange" lazy show-checkbox />
</el-scrollbar> </el-scrollbar>
</el-form-item> </el-form-item>
<el-form-item label="选中学生"> <el-form-item label="选中学生" prop="student">
<el-scrollbar max-height="200px"> <el-scrollbar max-height="200px">
<el-tag v-for="(tag, index) in studentList" :key="tag.studentid" closable type="primary" <el-tag v-for="(tag, index) in studentList" :key="tag.studentid" closable type="primary"
@close="delStudent(index)"> @close="delStudent(index)">
@ -24,17 +23,17 @@
</el-tag> </el-tag>
</el-scrollbar> </el-scrollbar>
</el-form-item> </el-form-item>
<el-form-item label="完成要求"> <el-form-item label="完成要求" prop="feedback">
<el-radio-group v-model="form.feedback"> <el-radio-group v-model="form.feedback">
<el-radio value="必做" size="large">必做</el-radio> <el-radio value="必做" size="large">必做</el-radio>
<el-radio value="选做" size="large">选做</el-radio> <el-radio value="选做" size="large">选做</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="截止时间"> <el-form-item label="截止时间" prop="deaddate">
<el-date-picker v-model="form.deaddate" value-format="YYYY-MM-DD HH:mm" format="YYYY-MM-DD HH:mm" <el-date-picker v-model="form.deaddate" value-format="YYYY-MM-DD HH:mm" format="YYYY-MM-DD HH:mm"
time-format="HH:mm" type="datetime" placeholder="请选择截止时间" @change="changeTime" /> time-format="HH:mm" type="datetime" placeholder="请选择截止时间" />
</el-form-item> </el-form-item>
<el-form-item label="推荐用时"> <el-form-item label="推荐用时" prop="timelength">
<el-input-number v-model="form.timelength" :min="1" :max="500" /> <el-input-number v-model="form.timelength" :min="1" :max="500" />
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -43,7 +42,7 @@
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">
<el-button @click="cloneDialog">取消</el-button> <el-button @click="cloneDialog">取消</el-button>
<el-button type="primary" @click="onSubmit"> <el-button type="primary" @click="onSubmit('ruleForm')">
确定 确定
</el-button> </el-button>
</div> </div>
@ -56,7 +55,8 @@ import { ElMessage } from 'element-plus'
import { listClassmain, listClassgroup } from '@/api/classManage/index' import { listClassmain, listClassgroup } from '@/api/classManage/index'
import { saveByClassWorkArray } from '@/api/teaching/classwork' import { saveByClassWorkArray } from '@/api/teaching/classwork'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import { uniqBy } from 'lodash' import { uniqBy, groupBy } from 'lodash'
export default { export default {
props: { props: {
modelValue: { modelValue: {
@ -71,6 +71,7 @@ export default {
} }
}, },
data() { data() {
return { return {
dialogVisible: false, dialogVisible: false,
defaultProps: { defaultProps: {
@ -94,6 +95,15 @@ export default {
deaddate: '', deaddate: '',
timelength: 1 timelength: 1
}, },
//
rules: {
grade: [
{ validator: this.validateGrade, trigger: 'blur' }
],
student: [
{ validator: this.validateStudent, trigger: 'blur' }
]
}
} }
}, },
@ -104,6 +114,7 @@ export default {
}, },
methods: { methods: {
// //
getGradeList() { getGradeList() {
listClassmain({ classuserid: this.userInfo.userId, pageSize: 100, status: 'open' }).then(res => { listClassmain({ classuserid: this.userInfo.userId, pageSize: 100, status: 'open' }).then(res => {
@ -117,11 +128,10 @@ export default {
el.classId = item.id el.classId = item.id
}) })
}) })
console.log(list)
this.gradeList = list this.gradeList = list
this.treeData = list
}) })
}, },
//
getLoad(node, resolve) { getLoad(node, resolve) {
if (node.level == 0) return resolve([]) if (node.level == 0) return resolve([])
// //
@ -161,18 +171,22 @@ export default {
} }
}, },
//
handleCheckChange(data, checked) { handleCheckChange(data, checked) {
this.studentList = [] this.studentList = []
// //
let checkNodes = checked.checkedNodes let checkNodes = checked.checkedNodes
let ary = [] let ary = []
checkNodes.forEach(item => { checkNodes.forEach(item => {
//
if (item.level == 0) { if (item.level == 0) {
ary = [...ary, ...(item.classstudentlist)] ary = [...ary, ...(item.classstudentlist)]
} }
//
if (item.level == 1) { if (item.level == 1) {
ary = [...ary, ...(item.children)] ary = [...ary, ...(item.children)]
} }
//
if (item.level == 2) { if (item.level == 2) {
ary = [...ary, item] ary = [...ary, item]
} }
@ -183,57 +197,59 @@ export default {
delStudent(index) { delStudent(index) {
this.studentList.splice(index, 1) this.studentList.splice(index, 1)
}, },
onSubmit(formName) {
// this.$refs[formName].validate(valid => {
changeTime(value) { if (valid) {
console.log(value, 100) /**
}, * 分班
onSubmit() { * studentList 为选中的所有学生 这些学生可能来自不同班级
*/
/** let gradeObj = groupBy(this.studentList, 'classId')
* studentlist //
* deaddate let ary = []
* feedtype for (const value in gradeObj) {
* timelength // AIx web
*/ let obj = {
// AIx web id: 0,
let ary = [ parentid: this.row.id,
{ classid: value,
id: 0, classcourseid: 0,
parentid: this.row.id, entpcourseid: this.entpcourseid,
classid: this.studentList[0].classId, studentlist: JSON.stringify(gradeObj[value]),
classcourseid: 0, feedback: this.form.feedback,
entpcourseid: this.entpcourseid, workkey: "",
studentlist: JSON.stringify(this.studentList), timelength: this.form.timelength,
feedback: this.form.feedback, weights: 1,
workkey: "", deaddate: this.form.deaddate,
timelength: this.form.timelength, workdate: this.getCurrentDate(),
weights: 1, uniquekey: this.row.uniquekey,
deaddate: this.form.deaddate, entpcourseworklist: "[" + this.row.entpcourseworklist + "]",
workdate: this.getCurrentDate(), needMsgNotifine: 'false',
uniquekey: this.row.id, msgkey: 'newclasswork',
entpcourseworklist: "[" + this.row.entpcourseworklist + "]", title: "作业任务",
needMsgNotifine: 'false', msgcontent: '',
msgkey: 'newclasswork', teachername: this.userInfo.nickName,
title: "作业任务", unixstamp: new Date().getTime(),
msgcontent: '', }
teachername: this.userInfo.nickName, ary.push(obj)
unixstamp: new Date().getTime(), }
saveByClassWorkArray({
classworkarray: JSON.stringify(ary)
}).then(() => {
ElMessage.success('操作成功')
this.cloneDialog()
})
} else {
return false
} }
]
let obj = {
classworkarray: JSON.stringify(ary)
}
saveByClassWorkArray(obj).then(() => {
ElMessage.success('操作成功')
this.cloneDialog()
}) })
}, },
// //
cloneDialog() { cloneDialog() {
this.$emit('on-close') this.$emit('on-close')
this.studentList = []
this.$refs['ruleForm'].resetFields();
}, },
// //
getCurrentDate() { getCurrentDate() {
@ -242,7 +258,23 @@ export default {
const month = now.getMonth() + 1; // 0+1 const month = now.getMonth() + 1; // 0+1
const day = now.getDate() const day = now.getDate()
return `${year}-${month.length == 2 ? month : '0' + month}-${day.length == 2 ? day : '0' + day}`; return `${year}-${month.length == 2 ? month : '0' + month}-${day.length == 2 ? day : '0' + day}`;
} },
validateGrade(rule, value, callback) {
if (this.studentList.length == 0) {
callback(new Error('请勾选班级或者学生'));
}
else {
callback()
}
},
validateStudent(rule, value, callback) {
if (this.studentList.length == 0) {
callback(new Error('学生不能为空'));
}
else {
callback()
}
},
}, },
watch: { watch: {
modelValue(val) { modelValue(val) {
@ -251,7 +283,8 @@ export default {
this.getGradeList() this.getGradeList()
} }
} }
} },
} }
</script> </script>

View File

@ -67,7 +67,7 @@
@on-set="openSet" @on-set="openSet"
@on-delhomework="delhomework" @on-delhomework="delhomework"
> >
<el-checkbox label="" :value="item" /> <el-checkbox label="" :value="item" v-if="!item.uniquekey"/>
</file-list-item> </file-list-item>
</el-checkbox-group> </el-checkbox-group>
<file-oper-batch <file-oper-batch