|
|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <div class="warning-response-pane" :data-warning-panel="panelId" :data-event-mode="eventStore.mode">
|
|
|
+ <div ref="rootRef" class="warning-response-pane" :data-warning-panel="panelId" :data-event-mode="eventStore.mode">
|
|
|
<div class="warning-response-pane__controls" role="group" aria-label="预警/报警和时间范围">
|
|
|
<button
|
|
|
v-for="option in modeOptions"
|
|
|
@@ -36,7 +36,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { computed } from 'vue'
|
|
|
+import { computed, nextTick, ref, watch } from 'vue'
|
|
|
import { EVENT_RANGES } from '../domain/warningResponsePanels.js'
|
|
|
import { eventListSwitchOptions } from '../domain/eventList.js'
|
|
|
import { panelView } from '../domain/panelViews.js'
|
|
|
@@ -73,6 +73,43 @@ const view = computed(() => {
|
|
|
})
|
|
|
})
|
|
|
|
|
|
+const rootRef = ref(null)
|
|
|
+let savedScrollTop = 0
|
|
|
+let savedScrollKey = ''
|
|
|
+let stableScrollKey = ''
|
|
|
+
|
|
|
+function scrollHost() {
|
|
|
+ return rootRef.value && rootRef.value.closest ? rootRef.value.closest('.cockpit-panel__body') : null
|
|
|
+}
|
|
|
+
|
|
|
+function scrollContextKey() {
|
|
|
+ const current = section.value || {}
|
|
|
+ const pagination = current.data && current.data.pagination
|
|
|
+ return [props.panelId, eventStore.mode, eventStore.range, current.state, pagination && pagination.page].join('|')
|
|
|
+}
|
|
|
+
|
|
|
+watch(() => scrollContextKey(), (next) => {
|
|
|
+ if (!eventStore.loading) stableScrollKey = next
|
|
|
+}, { immediate: true })
|
|
|
+
|
|
|
+/** 刷新重取时保留本面板滚动位置;换族/换范围/翻页后按新上下文从顶部开始。 */
|
|
|
+watch(() => eventStore.loading, (loading, previous) => {
|
|
|
+ if (loading && !previous) {
|
|
|
+ savedScrollTop = scrollHost() ? scrollHost().scrollTop : 0
|
|
|
+ savedScrollKey = stableScrollKey || scrollContextKey()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!loading && previous) {
|
|
|
+ const top = savedScrollTop
|
|
|
+ const key = savedScrollKey
|
|
|
+ nextTick(() => {
|
|
|
+ if (key !== scrollContextKey()) return
|
|
|
+ const host = scrollHost()
|
|
|
+ if (host) host.scrollTop = top
|
|
|
+ })
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
/**
|
|
|
* 服务端页码翻页出口(PanelBlocks 的 `serverPage` 块)。
|
|
|
*
|
|
|
@@ -124,7 +161,7 @@ function onCardAction(action) {
|
|
|
/** 详情打开后顺手重取当前事件:外部管理端刚改完状态时,列表不会停留在旧快照。 */
|
|
|
function refreshAfterOpen(opened) {
|
|
|
Promise.resolve(opened)
|
|
|
- .then((ok) => { if (ok) return eventStore.loadCurrentEvents() })
|
|
|
+ .then((ok) => { if (ok) return eventStore.loadPanels() })
|
|
|
.catch(() => {})
|
|
|
}
|
|
|
|