作业批改:优化轮询机制

This commit is contained in:
白了个白 2024-09-10 11:30:45 +08:00
parent 0b6b0c318d
commit 6be4b3526e
2 changed files with 52 additions and 13 deletions

View File

@ -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 = () => {

View File

@ -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>