|
|
@@ -27,7 +27,7 @@
|
|
|
<a-col :span="12">
|
|
|
<a-form-item field="queryTime" label="乐跑时间">
|
|
|
<a-range-picker v-model="queryData.queryTime" show-time format="YYYY-MM-DD HH:mm" value-format="x"
|
|
|
- @ok="getRecords()" />
|
|
|
+ @ok="search" />
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
</a-row>
|
|
|
@@ -166,7 +166,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ref, reactive, onMounted, h } from 'vue'
|
|
|
+import { ref, reactive, onMounted, onUnmounted, h } from 'vue'
|
|
|
import { lepaoRecords } from '@/api/lepao'
|
|
|
import { Notification } from '@arco-design/web-vue'
|
|
|
import { IconSearch } from '@arco-design/web-vue/es/icon'
|
|
|
@@ -208,7 +208,7 @@ const pagination = reactive({
|
|
|
|
|
|
const search = () => {
|
|
|
pagination.current = 1
|
|
|
- getRecords()
|
|
|
+ getRecordsAsync()
|
|
|
}
|
|
|
|
|
|
const reset = () => {
|
|
|
@@ -218,7 +218,7 @@ const reset = () => {
|
|
|
queryData.email = ''
|
|
|
queryData.area = ''
|
|
|
queryData.queryTime = getSemesterTimestamps()
|
|
|
- getRecords()
|
|
|
+ getRecordsAsync()
|
|
|
}
|
|
|
|
|
|
const getRecordsAsync = async () => {
|
|
|
@@ -253,14 +253,14 @@ const getRecords = async () => {
|
|
|
// 分页 - 页码变化
|
|
|
const handlePageChange = (page) => {
|
|
|
pagination.current = page
|
|
|
- getRecords()
|
|
|
+ getRecordsAsync()
|
|
|
}
|
|
|
|
|
|
// 分页 - 每页条数变化
|
|
|
const handlePageSizeChange = (size) => {
|
|
|
pagination.pagesize = size
|
|
|
pagination.current = 1 // 页大小变化后回到第一页
|
|
|
- getRecords()
|
|
|
+ getRecordsAsync()
|
|
|
}
|
|
|
|
|
|
const stramptoTime = (time) => {
|
|
|
@@ -282,10 +282,35 @@ function formatSecondsToMinSec(totalSeconds) {
|
|
|
return `${minutes}分${seconds.toString().padStart(2, '0')}秒`;
|
|
|
}
|
|
|
|
|
|
-onMounted(() => {
|
|
|
+let timer = null
|
|
|
+
|
|
|
+// 轮询
|
|
|
+const startPolling = () => {
|
|
|
+ if (!timer) {
|
|
|
+ timer = setInterval(async () => {
|
|
|
+ await getAccounts()
|
|
|
+ }, 5000)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 停止轮询
|
|
|
+const stopPolling = () => {
|
|
|
+ if (timer) {
|
|
|
+ clearInterval(timer)
|
|
|
+ timer = null
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+onMounted(async () => {
|
|
|
queryData.queryTime = getSemesterTimestamps()
|
|
|
- getRecords()
|
|
|
+ getRecordsAsync()
|
|
|
GetNotice()
|
|
|
+ startPolling()
|
|
|
+})
|
|
|
+
|
|
|
+// 组件销毁时停止轮询
|
|
|
+onUnmounted(() => {
|
|
|
+ stopPolling()
|
|
|
})
|
|
|
</script>
|
|
|
|