This commit is contained in:
zk
2023-12-18 18:34:19 +08:00
parent 2cc8886c2d
commit 580a4fc5c6
50 changed files with 2343 additions and 223 deletions
@@ -23,18 +23,23 @@
</div>
</template>
<script lang="ts" setup>
import { onMounted, onUnmounted, ref } from 'vue';
import { onMounted, onUnmounted, ref, watch } from 'vue';
import PublicTitle from '/@/components/publicTitle.vue';
import { getMonitorList } from '/@/components/secondaryScreen/commonApi.ts';
import { monitorColumns } from '/@/components/secondaryScreen/screen-right/screenRightHooks.ts';
import $bus from '/@/utils/bus.ts';
import { earlyWarning } from '/@/utils/busConstant.ts';
import { useRefresh } from '/@/hooks/autoRefresh';
const props = defineProps({
orgCode: String,
type: String,
});
const tableHeight = ref(0);
const dataSource = ref([]);
const pagination = ref({
current: 1,
pageSize: 10,
pageSize: 2,
total: 0,
onChange: pageChange,
});
@@ -45,23 +50,31 @@
$bus.emit(earlyWarning, record);
}
onMounted(() => {
init(1);
setHeight();
window.addEventListener('resize', setHeight);
interval();
});
watch(
props,
() => {
init(1);
tableHeight.value == 0 && setHeight();
window.addEventListener('resize', setHeight);
timer.value && clearInterval(timer.value);
// interval();
},
{ immediate: true }
);
onUnmounted(() => {
window.removeEventListener('resize', setHeight);
});
function setHeight() {
let dom = document.querySelector('.inner-screen');
if (!dom) return;
tableHeight.value = document.querySelector('.inner-screen').getBoundingClientRect().height - 60;
}
async function init(page) {
const { pageSize, current } = pagination.value;
const { code, result } = await getMonitorList({ pageSize, pageNo: page });
const { code, result } = await getMonitorList({ pageSize, pageNo: page, orgCode: props.orgCode });
if (code == 200) {
dataSource.value = result.records;
pagination.value.total = result.total;
@@ -77,12 +90,16 @@
}
function interval() {
timer.value = setInterval(() => {
let page = pagination.value.current < pages.value ? pagination.value.current + 1 : 1;
init(page);
}, 10000);
console.log(55555);
// timer.value = setInterval(() => {
let page = pagination.value.current < pages.value ? pagination.value.current + 1 : 1;
init(page);
// }, 3000);
}
const { refreshState } = useRefresh(3000, () => {
interval();
});
onUnmounted(() => {
clearInterval(timer.value);
});