作业批改:优化轮询机制
This commit is contained in:
parent
0b6b0c318d
commit
6be4b3526e
|
@ -15,7 +15,7 @@
|
|||
:key="index"
|
||||
:item="item"
|
||||
:tabactive="tabActive"
|
||||
@click="itemDialogRef.openDialog(item)"
|
||||
@click="onClickItem(item)"
|
||||
@delete-reserv="deleteReserv(item)"
|
||||
></task-item>
|
||||
<task-item
|
||||
|
@ -24,16 +24,16 @@
|
|||
:key="index"
|
||||
:item="item"
|
||||
:tabactive="tabActive"
|
||||
@click="itemDialogRef.openDialog(item)"
|
||||
@click="onClickItem(item)"
|
||||
@delete-reserv="deleteReserv(item)"
|
||||
></task-item>
|
||||
</div>
|
||||
<item-dialog ref="itemDialogRef"></item-dialog>
|
||||
<item-dialog ref="itemDialogRef" @cle-click="closeDialog"></item-dialog>
|
||||
</el-container>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, onUnmounted, computed, watch } from 'vue'
|
||||
import { ref, onMounted, onUnmounted, computed, watch, reactive } from 'vue'
|
||||
import { getSelfReserv } from '@/api/classManage'
|
||||
import { listClassmain } from '@/api/classManage/index'
|
||||
import { listClassworkdata } from '@/api/classTask'
|
||||
|
@ -181,17 +181,36 @@ const escapeHtmlQuotes = (str) => {
|
|||
// })
|
||||
}
|
||||
const pollingST = ref(null) //轮询定时器标识
|
||||
|
||||
onMounted(() => {
|
||||
getData() // 加载数据
|
||||
// 轮询查询
|
||||
getStudentClassWorkDataPolling()
|
||||
})
|
||||
|
||||
// 轮询查询 学生作业进度
|
||||
const getStudentClassWorkDataPolling = () => {
|
||||
// 先查询一次后,
|
||||
getStudentVisible()
|
||||
// 在轮询
|
||||
pollingST.value = setInterval(() => {
|
||||
getStudentVisible()
|
||||
}, 1000 * 60)
|
||||
})
|
||||
}, 1000 * 10)
|
||||
}
|
||||
|
||||
const closeDialog = () => {
|
||||
console.log('关闭弹窗,开启作业进度轮询')
|
||||
getStudentClassWorkDataPolling()
|
||||
}
|
||||
const onClickItem = (item) => {
|
||||
console.log('开启弹窗,关闭作业进度轮询')
|
||||
clearInterval(pollingST.value)
|
||||
itemDialogRef.value.openDialog(item)
|
||||
}
|
||||
|
||||
|
||||
onUnmounted(() => {
|
||||
clearInterval(pollingST.value)
|
||||
//clearInterval(this.classWorkActiveData.timerId) // 关闭定时器 作业概况的
|
||||
})
|
||||
|
||||
const getDateTime = () => {
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
top="8vh"
|
||||
append-to-body
|
||||
destory-on-close
|
||||
:before-close="onBeforeClose"
|
||||
>
|
||||
<template #title>
|
||||
<div style="font-size: 18px; display: flex; flex-wrap: nowrap">
|
||||
|
@ -46,7 +47,7 @@
|
|||
<div
|
||||
style="float: right; padding: 0 10px; cursor: pointer"
|
||||
icon="el-icon-close"
|
||||
@click="classWorkAnalysis.open = false"
|
||||
@click="closeDialog"
|
||||
>
|
||||
x
|
||||
</div>
|
||||
|
@ -153,8 +154,8 @@
|
|||
</template> -->
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, defineExpose, onMounted, reactive, computed, watch, nextTick, getCurrentInstance } from 'vue'
|
||||
<script setup name="itemDialogRef">
|
||||
import { ref, defineExpose, onMounted, reactive, computed, watch, onUnmounted, nextTick, getCurrentInstance } from 'vue'
|
||||
import { addSmartClassReserv, updateSmartClassReserv, listClassmain } from '@/api/classManage'
|
||||
import { listClassworkdata, listEntpcoursework, listClassworkeval } from '@/api/classTask'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
|
@ -167,12 +168,12 @@ import quizStats from '@/views/classTask/container/quizStats.vue'
|
|||
import ClassOverview from '@/views/classTask/container/classOverview.vue'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const emit = defineEmits(['addSuccess'])
|
||||
const emit = defineEmits(['cle-click'])
|
||||
const props = defineProps({
|
||||
bookId: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
},
|
||||
})
|
||||
const mainHeight = ref(document.documentElement.clientHeight - 110)
|
||||
const classWorkAnalysis = reactive({
|
||||
|
@ -619,9 +620,28 @@ const handleClassOverviewOpen = (type) =>{
|
|||
|
||||
//#endregion
|
||||
|
||||
const onBeforeClose = () =>{
|
||||
console.log('非正常关闭dialog?esc、dialog外部区域')
|
||||
closeDialog()
|
||||
}
|
||||
const closeDialog = () => {
|
||||
classWorkAnalysis.open = false
|
||||
emit('cle-click')
|
||||
}
|
||||
|
||||
watch(classWorkAnalysis, (newVal, oldVal) => {
|
||||
if(newVal.view != 'quizStats'){
|
||||
console.log('关闭zdg: 定时执行')
|
||||
clearInterval(classWorkActiveData.timerId) // 关闭定时器 作业概况的
|
||||
}
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
clearInterval(classWorkActiveData.timerId) // 关闭定时器 作业概况的
|
||||
})
|
||||
|
||||
defineExpose({
|
||||
openDialog
|
||||
openDialog,
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Reference in New Issue