布置作业修改
This commit is contained in:
parent
b0d969546a
commit
2279bbb904
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<el-dialog v-model="model" center top="10vh" width="600px" :show-close="false" append-to-body
|
||||
style="border-radius: 10px; padding: 10px 15px;">
|
||||
<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">
|
||||
<template #header>
|
||||
<div class="homerwork-header flex">
|
||||
<span>{{ title }}</span>
|
||||
|
@ -10,9 +10,9 @@
|
|||
<div v-loading="setLoading">
|
||||
<el-form :model="form" label-width="80px" ref="ruleFormRef" :rules="rules">
|
||||
<el-form-item label="班级" prop="grade">
|
||||
<el-scrollbar max-height="200px" style="width: 100%;">
|
||||
<el-tree ref="treeRef" :props="defaultProps" :load="getLoad" node-key="id" :default-expanded-keys="defaultExpandedKeys"
|
||||
@check="handleCheckChange" lazy show-checkbox />
|
||||
<el-scrollbar max-height="200px" style="width: 100%">
|
||||
<el-tree :props="defaultProps" :load="getLoad" node-key="id" highlight-current @check="handleCheckChange"
|
||||
lazy show-checkbox />
|
||||
</el-scrollbar>
|
||||
</el-form-item>
|
||||
<el-form-item label="选中学生" prop="student">
|
||||
|
@ -37,14 +37,11 @@
|
|||
<el-input-number v-model="form.timelength" :min="1" :max="500" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
</div>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click.stop="cloneDialog(ruleFormRef)">取消</el-button>
|
||||
<el-button type="primary" @click.stop="onSubmit(ruleFormRef)">
|
||||
确定
|
||||
</el-button>
|
||||
<el-button type="primary" @click.stop="onSubmit(ruleFormRef)"> 确定 </el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
@ -58,6 +55,7 @@ import { saveByClassWorkArray } from '@/api/teaching/classwork'
|
|||
import useUserStore from '@/store/modules/user'
|
||||
import { uniqBy, groupBy } from 'lodash'
|
||||
|
||||
const model = defineModel({ type: Boolean, default: false })
|
||||
const props = defineProps({
|
||||
entpcourseid: {
|
||||
default: ''
|
||||
|
@ -71,18 +69,14 @@ const props = defineProps({
|
|||
}
|
||||
})
|
||||
const emit = defineEmits(['on-close', 'on-success'])
|
||||
|
||||
const model = defineModel({ type: Boolean, default: false })
|
||||
const ruleFormRef = ref('')
|
||||
// 配置项
|
||||
const defaultProps = {
|
||||
children: 'children',
|
||||
label: 'label',
|
||||
isLeaf: 'leaf',
|
||||
isLeaf: 'leaf'
|
||||
}
|
||||
const treeRef = ref(null);
|
||||
// 默认展开的节点
|
||||
const defaultExpandedKeys = ref([])
|
||||
|
||||
// loading
|
||||
const setLoading = ref(false)
|
||||
// 用户信息
|
||||
|
@ -100,40 +94,37 @@ const form = reactive({
|
|||
// 表单校验
|
||||
const validateGrade = (rule, value, callback) => {
|
||||
if (studentList.value.length == 0) {
|
||||
callback(new Error('请勾选班级或者学生'));
|
||||
}
|
||||
else {
|
||||
callback(new Error('请勾选班级或者学生'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
const validateStudent = (rule, value, callback)=>{
|
||||
const validateStudent = (rule, value, callback) => {
|
||||
if (studentList.value.length == 0) {
|
||||
callback(new Error('学生不能为空'));
|
||||
}
|
||||
else {
|
||||
callback(new Error('学生不能为空'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
const rules = reactive({
|
||||
grade: [
|
||||
{ validator: validateGrade, trigger: 'blur' }
|
||||
],
|
||||
student: [
|
||||
{ validator: validateStudent, trigger: 'blur' }
|
||||
]
|
||||
grade: [{ validator: validateGrade, trigger: 'blur' }],
|
||||
student: [{ validator: validateStudent, trigger: 'blur' }]
|
||||
})
|
||||
|
||||
|
||||
// 获取班级
|
||||
const getGradeList = async ()=> {
|
||||
let { rows } = await listClassmain({ classuserid: userInfo.userId, pageSize: 100, status: 'open' })
|
||||
rows.forEach(item => {
|
||||
const getGradeList = async () => {
|
||||
let { rows } = await listClassmain({
|
||||
classuserid: userInfo.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 => {
|
||||
item.classstudentlist = JSON.parse('[' + item.classstudentlist + ']')
|
||||
item.classstudentlist.forEach((el) => {
|
||||
el.classId = item.id
|
||||
})
|
||||
})
|
||||
|
@ -148,18 +139,18 @@ const getLoad = async (node, resolve) => {
|
|||
}
|
||||
// 获取二级节点 小组
|
||||
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) {
|
||||
let ary = []
|
||||
res.rows.forEach(item => {
|
||||
res.rows.forEach((item) => {
|
||||
if (item.parentid === 0) {
|
||||
//studentGroup 小组学生 为三级节点
|
||||
let studentGroup = JSON.parse("[" + item.studentlist + "]")
|
||||
studentGroup.forEach(el => {
|
||||
let studentGroup = JSON.parse('[' + item.studentlist + ']')
|
||||
studentGroup.forEach((el) => {
|
||||
el.label = el.name
|
||||
el.leaf = true
|
||||
el.level = 2
|
||||
el.id = el.studentid
|
||||
el.id = el.studentid
|
||||
el.classId = item.classid
|
||||
})
|
||||
ary.push({
|
||||
|
@ -173,11 +164,10 @@ const getLoad = async (node, resolve) => {
|
|||
}
|
||||
})
|
||||
resolve(ary)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// 班级下面没有小组 直接取学生
|
||||
let students = node.data.classstudentlist
|
||||
students.forEach(item =>{
|
||||
students.forEach((item) => {
|
||||
item.label = item.name
|
||||
item.level = 2
|
||||
item.leaf = true
|
||||
|
@ -190,22 +180,21 @@ const getLoad = async (node, resolve) => {
|
|||
if (node.level == 2) {
|
||||
resolve(node.data.children)
|
||||
}
|
||||
|
||||
}
|
||||
//节点勾选后触发 拿学生
|
||||
const handleCheckChange = (data, checked)=> {
|
||||
const handleCheckChange = (data, checked) => {
|
||||
studentList.value = []
|
||||
// 选中节点集合
|
||||
let checkNodes = checked.checkedNodes
|
||||
let ary = []
|
||||
checkNodes.forEach(item => {
|
||||
checkNodes.forEach((item) => {
|
||||
// 一级节点 班级
|
||||
if (item.level == 0) {
|
||||
ary = [...ary, ...(item.classstudentlist)]
|
||||
ary = [...ary, ...item.classstudentlist]
|
||||
}
|
||||
// 二级节点 班级下面的小组
|
||||
if (item.level == 1) {
|
||||
ary = [...ary, ...(item.children)]
|
||||
ary = [...ary, ...item.children]
|
||||
}
|
||||
// 三级节点 小组下面的学生
|
||||
if (item.level == 2) {
|
||||
|
@ -219,14 +208,14 @@ const delStudent = (index) => {
|
|||
studentList.value.splice(index, 1)
|
||||
}
|
||||
|
||||
const onSubmit = (formEl)=> {
|
||||
if(!formEl) return
|
||||
formEl.validate(valid => {
|
||||
const onSubmit = (formEl) => {
|
||||
if (!formEl) return
|
||||
formEl.validate((valid) => {
|
||||
if (valid) {
|
||||
/**
|
||||
* 根据学生列表中的classId分班
|
||||
* studentList 为选中的所有学生 这些学生可能来自不同班级
|
||||
*/
|
||||
* 根据学生列表中的classId分班
|
||||
* studentList 为选中的所有学生 这些学生可能来自不同班级
|
||||
*/
|
||||
let gradeObj = groupBy(studentList.value, 'classId')
|
||||
// 处理要提交的参数
|
||||
let ary = []
|
||||
|
@ -240,16 +229,16 @@ const onSubmit = (formEl)=> {
|
|||
entpcourseid: props.entpcourseid,
|
||||
studentlist: JSON.stringify(gradeObj[value]),
|
||||
feedback: form.feedback,
|
||||
workkey: "",
|
||||
workkey: '',
|
||||
timelength: form.timelength,
|
||||
weights: 1,
|
||||
deaddate: form.deaddate,
|
||||
workdate: getCurrentDate(),
|
||||
uniquekey: props.row.uniquekey,
|
||||
entpcourseworklist: "[" + props.row.entpcourseworklist + "]",
|
||||
entpcourseworklist: '[' + props.row.entpcourseworklist + ']',
|
||||
needMsgNotifine: 'false',
|
||||
msgkey: 'newclasswork',
|
||||
title: "作业任务",
|
||||
title: '作业任务',
|
||||
msgcontent: '',
|
||||
teachername: userInfo.nickName,
|
||||
unixstamp: new Date().getTime(),
|
||||
|
@ -260,44 +249,48 @@ const onSubmit = (formEl)=> {
|
|||
setLoading.value = true
|
||||
saveByClassWorkArray({
|
||||
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 {
|
||||
return false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const expandedKeys = ref([])
|
||||
const checkedKeys = ref([])
|
||||
// 关闭弹窗
|
||||
const cloneDialog = (formEl)=> {
|
||||
const cloneDialog = (formEl) => {
|
||||
studentList.value = []
|
||||
treeRef.value.setCheckedKeys([])
|
||||
defaultExpandedKeys.value = []
|
||||
checkedKeys.value = []
|
||||
expandedKeys.value = []
|
||||
formEl.resetFields()
|
||||
model.value = false
|
||||
}
|
||||
// 获取当前年月日
|
||||
const getCurrentDate = ()=> {
|
||||
const now = new Date();
|
||||
const year = now.getFullYear();
|
||||
let month = now.getMonth() + 1; // 月份是从0开始的,所以需要+1
|
||||
const getCurrentDate = () => {
|
||||
const now = new Date()
|
||||
const year = now.getFullYear()
|
||||
let month = now.getMonth() + 1 // 月份是从0开始的,所以需要+1
|
||||
let day = now.getDate()
|
||||
if(month < 10){
|
||||
if (month < 10) {
|
||||
month = '0' + month
|
||||
}
|
||||
if(day < 10){
|
||||
if (day < 10) {
|
||||
day = '0' + day
|
||||
}
|
||||
return `${year}-${month}-${day}`;
|
||||
return `${year}-${month}-${day}`
|
||||
}
|
||||
|
||||
onMounted(()=>{
|
||||
onMounted(() => {
|
||||
// 默认当前
|
||||
form.deaddate = getCurrentDate() + ' ' + '10:00:00'
|
||||
})
|
||||
|
@ -313,19 +306,18 @@ onMounted(()=>{
|
|||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.el-tag {
|
||||
margin-right: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.dialog-footer{
|
||||
padding-bottom: 10px
|
||||
|
||||
.dialog-footer {
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
:deep(.el-checkbox){
|
||||
transform : scale(1.3)
|
||||
:deep(.el-checkbox) {
|
||||
transform: scale(1.3);
|
||||
}
|
||||
|
||||
</style>
|
||||
</style>
|
|
@ -114,7 +114,6 @@
|
|||
v-model="setDialog"
|
||||
:entpcourseid="entpcourseid"
|
||||
:row="row"
|
||||
@on-close="closeHomework"
|
||||
/>
|
||||
</div>
|
||||
<reserv
|
||||
|
@ -143,7 +142,7 @@ import { toTimeText } from '@/utils/date'
|
|||
import { ElMessage } from 'element-plus'
|
||||
import { parseCataByNode, creatPPT, asyncLocalFile } from '@/utils/talkFile'
|
||||
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 { createWindow } from '@/utils/tool'
|
||||
import { cloneDeep } from 'lodash'
|
||||
|
@ -487,10 +486,6 @@ export default {
|
|||
this.isLoading = false
|
||||
})
|
||||
},
|
||||
closeHomework() {
|
||||
this.setDialog = false
|
||||
},
|
||||
|
||||
// 打开PDF-课件
|
||||
async navtoPdf() {
|
||||
// if (toolStore.isPdfWin) return this.$message.error('您当前已打开课本,请勿重复操作')
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
</el-scrollbar>
|
||||
</div>
|
||||
<SetHomework v-model="setDialog" :title="'推送作业'" :entpcourseid="entpcourseid" :row="curRow"
|
||||
@on-close="closeHomework" />
|
||||
@on-close="closeHomework" @on-success="successHomework"/>
|
||||
</div>
|
||||
<div class="homework flex" v-else>
|
||||
<div class="unit-top flex">
|
||||
|
@ -73,13 +73,12 @@
|
|||
import { ref, onMounted, toRaw } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import { getSmarttalkPage, getPrepareById } from '@/api/file'
|
||||
import SetHomework from '@/views/prepare/container/set-homework.vue'
|
||||
import { getSmarttalkPage } from '@/api/file'
|
||||
import SetHomework from '@/components/set-homework/index.vue'
|
||||
import FileImage from '@/components/file-image/index.vue'
|
||||
import { useGetHomework } from '@/hooks/useGetHomework'
|
||||
import { ipcMsgSend, ipcMsgInvoke } from '@/utils/tool'
|
||||
import { useToolState } from '@/store/modules/tool'
|
||||
import { asyncLocalFile } from '@/utils/talkFile'
|
||||
import Lesson from './lesson.vue';
|
||||
import { parseCataByNode } from '@/utils/talkFile'
|
||||
import outLink from '@/utils/linkConfig'
|
||||
|
@ -97,11 +96,9 @@ const dataList = ref([])
|
|||
const setDialog = ref(false)
|
||||
// 资源数据
|
||||
const resourceList = ref([])
|
||||
|
||||
//
|
||||
//当前点击的数据
|
||||
const curRow = ref('')
|
||||
|
||||
|
||||
const sendHomework = (row) => {
|
||||
curRow.value = row
|
||||
setTimeout(() => {
|
||||
|
@ -112,12 +109,13 @@ const sendHomework = (row) => {
|
|||
//
|
||||
const closeHomework = async() => {
|
||||
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 { res } = await useGetHomework(data)
|
||||
dataList.value = res
|
||||
|
|
|
@ -13,9 +13,8 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, nextTick, markRaw, toRaw } from 'vue'
|
||||
import { ref, onMounted, nextTick, toRaw } from 'vue'
|
||||
import { useToolState } from '@/store/modules/tool'
|
||||
import { parseCataByNode } from '@/utils/talkFile'
|
||||
|
||||
const emit = defineEmits(['changeChapter'])
|
||||
const toolStore = useToolState()
|
||||
|
|
Loading…
Reference in New Issue