Browse Source

fix:表格加loading增加用户体验

pull/57/head
肖晋飞 2 weeks ago
parent
commit
072c699d54
  1. 14
      src/views/dashboard/demo/components/ParameterInfo.vue

14
src/views/dashboard/demo/components/ParameterInfo.vue

@ -1,6 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { Card } from 'ant-design-vue' import { Card } from 'ant-design-vue'
import { onBeforeUpdate, onMounted, onUpdated, toRefs, watch } from 'vue' import { onBeforeUpdate, onMounted, onUpdated, ref, toRefs, watch } from 'vue'
import { BasicTable, useTable } from '@/components/Table' import { BasicTable, useTable } from '@/components/Table'
import { getExaNow } from '@/api/alert/exa' import { getExaNow } from '@/api/alert/exa'
@ -10,6 +10,9 @@ const props = defineProps({
default: () => {}, default: () => {},
}, },
}) })
const loading = ref(false)
watch( watch(
() => props.data, () => props.data,
(newValue, oldValue) => { (newValue, oldValue) => {
@ -40,6 +43,8 @@ const [registerTable, { setTableData }] = useTable({
}) })
// //
onBeforeUpdate(async () => { onBeforeUpdate(async () => {
loading.value = true
try {
const rr = [] as any[] const rr = [] as any[]
const rows = props.data.Content || [] const rows = props.data.Content || []
for (const item of rows) { for (const item of rows) {
@ -68,8 +73,11 @@ onBeforeUpdate(async () => {
catch (e) { catch (e) {
} }
} }
setTableData(rr) setTableData(rr)
}
finally {
loading.value = false
}
}) })
</script> </script>
@ -80,7 +88,7 @@ onBeforeUpdate(async () => {
更多 更多
</a-button> </a-button>
</template> --> </template> -->
<BasicTable style="min-height:30vh" @register="registerTable"> <BasicTable style="min-height:30vh" :loading="loading" @register="registerTable">
<template #threshold="{ record }"> <template #threshold="{ record }">
<span>{{ getInterval(record) }}</span> <span>{{ getInterval(record) }}</span>
</template> </template>

Loading…
Cancel
Save