作业批改:优化轮询机制

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" :key="index"
:item="item" :item="item"
:tabactive="tabActive" :tabactive="tabActive"
@click="itemDialogRef.openDialog(item)" @click="onClickItem(item)"
@delete-reserv="deleteReserv(item)" @delete-reserv="deleteReserv(item)"
></task-item> ></task-item>
<task-item <task-item
@ -24,16 +24,16 @@
:key="index" :key="index"
:item="item" :item="item"
:tabactive="tabActive" :tabactive="tabActive"
@click="itemDialogRef.openDialog(item)" @click="onClickItem(item)"
@delete-reserv="deleteReserv(item)" @delete-reserv="deleteReserv(item)"
></task-item> ></task-item>
</div> </div>
<item-dialog ref="itemDialogRef"></item-dialog> <item-dialog ref="itemDialogRef" @cle-click="closeDialog"></item-dialog>
</el-container> </el-container>
</template> </template>
<script setup> <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 { getSelfReserv } from '@/api/classManage'
import { listClassmain } from '@/api/classManage/index' import { listClassmain } from '@/api/classManage/index'
import { listClassworkdata } from '@/api/classTask' import { listClassworkdata } from '@/api/classTask'
@ -181,17 +181,36 @@ const escapeHtmlQuotes = (str) => {
// }) // })
} }
const pollingST = ref(null) // const pollingST = ref(null) //
onMounted(() => { onMounted(() => {
getData() // getData() //
// //
getStudentClassWorkDataPolling()
})
//
const getStudentClassWorkDataPolling = () => {
//
getStudentVisible()
//
pollingST.value = setInterval(() => { pollingST.value = setInterval(() => {
getStudentVisible() getStudentVisible()
}, 1000 * 60) }, 1000 * 10)
}) }
const closeDialog = () => {
console.log('关闭弹窗,开启作业进度轮询')
getStudentClassWorkDataPolling()
}
const onClickItem = (item) => {
console.log('开启弹窗,关闭作业进度轮询')
clearInterval(pollingST.value)
itemDialogRef.value.openDialog(item)
}
onUnmounted(() => { onUnmounted(() => {
clearInterval(pollingST.value) clearInterval(pollingST.value)
//clearInterval(this.classWorkActiveData.timerId) //
}) })
const getDateTime = () => { const getDateTime = () => {

View File

@ -8,6 +8,7 @@
top="8vh" top="8vh"
append-to-body append-to-body
destory-on-close destory-on-close
:before-close="onBeforeClose"
> >
<template #title> <template #title>
<div style="font-size: 18px; display: flex; flex-wrap: nowrap"> <div style="font-size: 18px; display: flex; flex-wrap: nowrap">
@ -46,7 +47,7 @@
<div <div
style="float: right; padding: 0 10px; cursor: pointer" style="float: right; padding: 0 10px; cursor: pointer"
icon="el-icon-close" icon="el-icon-close"
@click="classWorkAnalysis.open = false" @click="closeDialog"
> >
x x
</div> </div>
@ -153,8 +154,8 @@
</template> --> </template> -->
</el-dialog> </el-dialog>
</template> </template>
<script setup> <script setup name="itemDialogRef">
import { ref, defineExpose, onMounted, reactive, computed, watch, nextTick, getCurrentInstance } from 'vue' import { ref, defineExpose, onMounted, reactive, computed, watch, onUnmounted, nextTick, getCurrentInstance } from 'vue'
import { addSmartClassReserv, updateSmartClassReserv, listClassmain } from '@/api/classManage' import { addSmartClassReserv, updateSmartClassReserv, listClassmain } from '@/api/classManage'
import { listClassworkdata, listEntpcoursework, listClassworkeval } from '@/api/classTask' import { listClassworkdata, listEntpcoursework, listClassworkeval } from '@/api/classTask'
import useUserStore from '@/store/modules/user' 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' import ClassOverview from '@/views/classTask/container/classOverview.vue'
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
const emit = defineEmits(['addSuccess']) const emit = defineEmits(['cle-click'])
const props = defineProps({ const props = defineProps({
bookId: { bookId: {
type: Number, type: Number,
default: 0 default: 0
} },
}) })
const mainHeight = ref(document.documentElement.clientHeight - 110) const mainHeight = ref(document.documentElement.clientHeight - 110)
const classWorkAnalysis = reactive({ const classWorkAnalysis = reactive({
@ -619,9 +620,28 @@ const handleClassOverviewOpen = (type) =>{
//#endregion //#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({ defineExpose({
openDialog openDialog,
}) })
</script> </script>