布置作业修改

This commit is contained in:
lyc 2024-08-22 10:43:05 +08:00
parent b0d969546a
commit 2279bbb904
4 changed files with 85 additions and 101 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<el-dialog v-model="model" center top="10vh" width="600px" :show-close="false" append-to-body <el-dialog v-model="model" center top="10vh" width="600px" :show-close="false" destroy-on-close 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>{{ title }}</span> <span>{{ title }}</span>
@ -10,9 +10,9 @@
<div v-loading="setLoading"> <div v-loading="setLoading">
<el-form :model="form" label-width="80px" ref="ruleFormRef" :rules="rules"> <el-form :model="form" label-width="80px" ref="ruleFormRef" :rules="rules">
<el-form-item label="班级" prop="grade"> <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" :props="defaultProps" :load="getLoad" node-key="id" :default-expanded-keys="defaultExpandedKeys" <el-tree :props="defaultProps" :load="getLoad" node-key="id" highlight-current @check="handleCheckChange"
@check="handleCheckChange" lazy show-checkbox /> lazy show-checkbox />
</el-scrollbar> </el-scrollbar>
</el-form-item> </el-form-item>
<el-form-item label="选中学生" prop="student"> <el-form-item label="选中学生" prop="student">
@ -37,14 +37,11 @@
<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>
</div> </div>
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">
<el-button @click.stop="cloneDialog(ruleFormRef)">取消</el-button> <el-button @click.stop="cloneDialog(ruleFormRef)">取消</el-button>
<el-button type="primary" @click.stop="onSubmit(ruleFormRef)"> <el-button type="primary" @click.stop="onSubmit(ruleFormRef)"> 确定 </el-button>
确定
</el-button>
</div> </div>
</template> </template>
</el-dialog> </el-dialog>
@ -58,6 +55,7 @@ import { saveByClassWorkArray } from '@/api/teaching/classwork'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import { uniqBy, groupBy } from 'lodash' import { uniqBy, groupBy } from 'lodash'
const model = defineModel({ type: Boolean, default: false })
const props = defineProps({ const props = defineProps({
entpcourseid: { entpcourseid: {
default: '' default: ''
@ -71,18 +69,14 @@ const props = defineProps({
} }
}) })
const emit = defineEmits(['on-close', 'on-success']) const emit = defineEmits(['on-close', 'on-success'])
const model = defineModel({ type: Boolean, default: false })
const ruleFormRef = ref('') const ruleFormRef = ref('')
// //
const defaultProps = { const defaultProps = {
children: 'children', children: 'children',
label: 'label', label: 'label',
isLeaf: 'leaf', isLeaf: 'leaf'
} }
const treeRef = ref(null);
//
const defaultExpandedKeys = ref([])
// loading // loading
const setLoading = ref(false) const setLoading = ref(false)
// //
@ -100,40 +94,37 @@ const form = reactive({
// //
const validateGrade = (rule, value, callback) => { const validateGrade = (rule, value, callback) => {
if (studentList.value.length == 0) { if (studentList.value.length == 0) {
callback(new Error('请勾选班级或者学生')); callback(new Error('请勾选班级或者学生'))
} } else {
else {
callback() callback()
} }
} }
const validateStudent = (rule, value, callback)=>{ const validateStudent = (rule, value, callback) => {
if (studentList.value.length == 0) { if (studentList.value.length == 0) {
callback(new Error('学生不能为空')); callback(new Error('学生不能为空'))
} } else {
else {
callback() callback()
} }
} }
const rules = reactive({ const rules = reactive({
grade: [ grade: [{ validator: validateGrade, trigger: 'blur' }],
{ validator: validateGrade, trigger: 'blur' } student: [{ validator: validateStudent, trigger: 'blur' }]
],
student: [
{ validator: validateStudent, trigger: 'blur' }
]
}) })
// //
const getGradeList = async ()=> { const getGradeList = async () => {
let { rows } = await listClassmain({ classuserid: userInfo.userId, pageSize: 100, status: 'open' }) let { rows } = await listClassmain({
rows.forEach(item => { classuserid: userInfo.userId,
pageSize: 100,
status: 'open'
})
rows.forEach((item) => {
item.label = item.caption item.label = item.caption
item.level = 0 item.level = 0
item.leaf = false item.leaf = false
item.children = [] item.children = []
item.classstudentlist = JSON.parse("[" + item.classstudentlist + "]") item.classstudentlist = JSON.parse('[' + item.classstudentlist + ']')
item.classstudentlist.forEach(el => { item.classstudentlist.forEach((el) => {
el.classId = item.id el.classId = item.id
}) })
}) })
@ -148,18 +139,18 @@ const getLoad = async (node, resolve) => {
} }
// //
if (node.level == 1) { if (node.level == 1) {
listClassgroup({ classid: node.key, orderby: 'orderidx', pageSize: 100 }).then(res => { listClassgroup({ classid: node.key, orderby: 'orderidx', pageSize: 100 }).then((res) => {
if (res.rows.length > 0) { if (res.rows.length > 0) {
let ary = [] let ary = []
res.rows.forEach(item => { res.rows.forEach((item) => {
if (item.parentid === 0) { if (item.parentid === 0) {
//studentGroup //studentGroup
let studentGroup = JSON.parse("[" + item.studentlist + "]") let studentGroup = JSON.parse('[' + item.studentlist + ']')
studentGroup.forEach(el => { studentGroup.forEach((el) => {
el.label = el.name el.label = el.name
el.leaf = true el.leaf = true
el.level = 2 el.level = 2
el.id = el.studentid el.id = el.studentid
el.classId = item.classid el.classId = item.classid
}) })
ary.push({ ary.push({
@ -173,11 +164,10 @@ const getLoad = async (node, resolve) => {
} }
}) })
resolve(ary) resolve(ary)
} } else {
else {
// //
let students = node.data.classstudentlist let students = node.data.classstudentlist
students.forEach(item =>{ students.forEach((item) => {
item.label = item.name item.label = item.name
item.level = 2 item.level = 2
item.leaf = true item.leaf = true
@ -190,22 +180,21 @@ const getLoad = async (node, resolve) => {
if (node.level == 2) { if (node.level == 2) {
resolve(node.data.children) resolve(node.data.children)
} }
} }
// //
const handleCheckChange = (data, checked)=> { const handleCheckChange = (data, checked) => {
studentList.value = [] studentList.value = []
// //
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) {
@ -219,14 +208,14 @@ const delStudent = (index) => {
studentList.value.splice(index, 1) studentList.value.splice(index, 1)
} }
const onSubmit = (formEl)=> { const onSubmit = (formEl) => {
if(!formEl) return if (!formEl) return
formEl.validate(valid => { formEl.validate((valid) => {
if (valid) { if (valid) {
/** /**
* 根据学生列表中的classId分班 * 根据学生列表中的classId分班
* studentList 为选中的所有学生 这些学生可能来自不同班级 * studentList 为选中的所有学生 这些学生可能来自不同班级
*/ */
let gradeObj = groupBy(studentList.value, 'classId') let gradeObj = groupBy(studentList.value, 'classId')
// //
let ary = [] let ary = []
@ -240,16 +229,16 @@ const onSubmit = (formEl)=> {
entpcourseid: props.entpcourseid, entpcourseid: props.entpcourseid,
studentlist: JSON.stringify(gradeObj[value]), studentlist: JSON.stringify(gradeObj[value]),
feedback: form.feedback, feedback: form.feedback,
workkey: "", workkey: '',
timelength: form.timelength, timelength: form.timelength,
weights: 1, weights: 1,
deaddate: form.deaddate, deaddate: form.deaddate,
workdate: getCurrentDate(), workdate: getCurrentDate(),
uniquekey: props.row.uniquekey, uniquekey: props.row.uniquekey,
entpcourseworklist: "[" + props.row.entpcourseworklist + "]", entpcourseworklist: '[' + props.row.entpcourseworklist + ']',
needMsgNotifine: 'false', needMsgNotifine: 'false',
msgkey: 'newclasswork', msgkey: 'newclasswork',
title: "作业任务", title: '作业任务',
msgcontent: '', msgcontent: '',
teachername: userInfo.nickName, teachername: userInfo.nickName,
unixstamp: new Date().getTime(), unixstamp: new Date().getTime(),
@ -260,44 +249,48 @@ const onSubmit = (formEl)=> {
setLoading.value = true setLoading.value = true
saveByClassWorkArray({ saveByClassWorkArray({
classworkarray: JSON.stringify(ary) classworkarray: JSON.stringify(ary)
}).then(() => {
setLoading.value = false
ElMessage.success('操作成功')
emit('on-success')
cloneDialog(formEl)
}).catch(()=>{
setLoading.value = false
}) })
.then(() => {
setLoading.value = false
ElMessage.success('操作成功')
emit('on-success')
cloneDialog(formEl)
})
.catch(() => {
setLoading.value = false
})
} else { } else {
return false return false
} }
}) })
} }
const expandedKeys = ref([])
const checkedKeys = ref([])
// //
const cloneDialog = (formEl)=> { const cloneDialog = (formEl) => {
studentList.value = [] studentList.value = []
treeRef.value.setCheckedKeys([]) checkedKeys.value = []
defaultExpandedKeys.value = [] expandedKeys.value = []
formEl.resetFields() formEl.resetFields()
model.value = false model.value = false
} }
// //
const getCurrentDate = ()=> { const getCurrentDate = () => {
const now = new Date(); const now = new Date()
const year = now.getFullYear(); const year = now.getFullYear()
let month = now.getMonth() + 1; // 0+1 let month = now.getMonth() + 1 // 0+1
let day = now.getDate() let day = now.getDate()
if(month < 10){ if (month < 10) {
month = '0' + month month = '0' + month
} }
if(day < 10){ if (day < 10) {
day = '0' + day day = '0' + day
} }
return `${year}-${month}-${day}`; return `${year}-${month}-${day}`
} }
onMounted(()=>{ onMounted(() => {
// //
form.deaddate = getCurrentDate() + ' ' + '10:00:00' form.deaddate = getCurrentDate() + ' ' + '10:00:00'
}) })
@ -313,19 +306,18 @@ onMounted(()=>{
font-size: 20px; font-size: 20px;
cursor: pointer; cursor: pointer;
} }
} }
.el-tag { .el-tag {
margin-right: 10px; margin-right: 10px;
margin-bottom: 10px; margin-bottom: 10px;
} }
.dialog-footer{
padding-bottom: 10px .dialog-footer {
padding-bottom: 10px;
} }
:deep(.el-checkbox){ :deep(.el-checkbox) {
transform : scale(1.3) transform: scale(1.3);
} }
</style> </style>

View File

@ -114,7 +114,6 @@
v-model="setDialog" v-model="setDialog"
:entpcourseid="entpcourseid" :entpcourseid="entpcourseid"
:row="row" :row="row"
@on-close="closeHomework"
/> />
</div> </div>
<reserv <reserv
@ -143,7 +142,7 @@ import { toTimeText } from '@/utils/date'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import { parseCataByNode, creatPPT, asyncLocalFile } from '@/utils/talkFile' import { parseCataByNode, creatPPT, asyncLocalFile } from '@/utils/talkFile'
import FileOperBatch from '@/views/prepare/container/file-oper-batch.vue' import FileOperBatch from '@/views/prepare/container/file-oper-batch.vue'
import SetHomework from './container/set-homework.vue' import SetHomework from '@/components/set-homework/index.vue'
import outLink from '@/utils/linkConfig' import outLink from '@/utils/linkConfig'
import { createWindow } from '@/utils/tool' import { createWindow } from '@/utils/tool'
import { cloneDeep } from 'lodash' import { cloneDeep } from 'lodash'
@ -487,10 +486,6 @@ export default {
this.isLoading = false this.isLoading = false
}) })
}, },
closeHomework() {
this.setDialog = false
},
// PDF- // PDF-
async navtoPdf() { async navtoPdf() {
// if (toolStore.isPdfWin) return this.$message.error('') // if (toolStore.isPdfWin) return this.$message.error('')

View File

@ -51,7 +51,7 @@
</el-scrollbar> </el-scrollbar>
</div> </div>
<SetHomework v-model="setDialog" :title="'推送作业'" :entpcourseid="entpcourseid" :row="curRow" <SetHomework v-model="setDialog" :title="'推送作业'" :entpcourseid="entpcourseid" :row="curRow"
@on-close="closeHomework" /> @on-close="closeHomework" @on-success="successHomework"/>
</div> </div>
<div class="homework flex" v-else> <div class="homework flex" v-else>
<div class="unit-top flex"> <div class="unit-top flex">
@ -73,13 +73,12 @@
import { ref, onMounted, toRaw } from 'vue'; import { ref, onMounted, toRaw } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import { getSmarttalkPage, getPrepareById } from '@/api/file' import { getSmarttalkPage } from '@/api/file'
import SetHomework from '@/views/prepare/container/set-homework.vue' import SetHomework from '@/components/set-homework/index.vue'
import FileImage from '@/components/file-image/index.vue' import FileImage from '@/components/file-image/index.vue'
import { useGetHomework } from '@/hooks/useGetHomework' import { useGetHomework } from '@/hooks/useGetHomework'
import { ipcMsgSend, ipcMsgInvoke } from '@/utils/tool' import { ipcMsgSend, ipcMsgInvoke } from '@/utils/tool'
import { useToolState } from '@/store/modules/tool' import { useToolState } from '@/store/modules/tool'
import { asyncLocalFile } from '@/utils/talkFile'
import Lesson from './lesson.vue'; import Lesson from './lesson.vue';
import { parseCataByNode } from '@/utils/talkFile' import { parseCataByNode } from '@/utils/talkFile'
import outLink from '@/utils/linkConfig' import outLink from '@/utils/linkConfig'
@ -97,11 +96,9 @@ const dataList = ref([])
const setDialog = ref(false) const setDialog = ref(false)
// //
const resourceList = ref([]) const resourceList = ref([])
//
//
const curRow = ref('') const curRow = ref('')
const sendHomework = (row) => { const sendHomework = (row) => {
curRow.value = row curRow.value = row
setTimeout(() => { setTimeout(() => {
@ -112,12 +109,13 @@ const sendHomework = (row) => {
// //
const closeHomework = async() => { const closeHomework = async() => {
ipcMsgSend('tool-sphere:set:ignore', true) ipcMsgSend('tool-sphere:set:ignore', true)
// im-(app|)
await ipcMsgInvoke('im-chat:msg', curRow.value.id, MsgEnum.HEADS.MSG_0016)
setDialog.value = false
} }
//
const successHomework = ()=>{
// im-(app|)
ipcMsgInvoke('im-chat:msg', curRow.value.id, MsgEnum.HEADS.MSG_0016)
}
// change
const changeChapter = async (data)=>{ const changeChapter = async (data)=>{
const { res } = await useGetHomework(data) const { res } = await useGetHomework(data)
dataList.value = res dataList.value = res

View File

@ -13,9 +13,8 @@
</template> </template>
<script setup> <script setup>
import { ref, onMounted, nextTick, markRaw, toRaw } from 'vue' import { ref, onMounted, nextTick, toRaw } from 'vue'
import { useToolState } from '@/store/modules/tool' import { useToolState } from '@/store/modules/tool'
import { parseCataByNode } from '@/utils/talkFile'
const emit = defineEmits(['changeChapter']) const emit = defineEmits(['changeChapter'])
const toolStore = useToolState() const toolStore = useToolState()