WarningResponsePane.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <div class="warning-response-pane" :data-warning-panel="panelId" :data-event-mode="eventStore.mode">
  3. <div class="warning-response-pane__controls" role="group" aria-label="预警/报警和时间范围">
  4. <button
  5. v-for="option in modeOptions"
  6. :key="option.key"
  7. type="button"
  8. class="warning-response-pane__control"
  9. :class="{ 'is-active': option.key === eventStore.mode }"
  10. :aria-pressed="option.key === eventStore.mode"
  11. :data-event-switch="option.key"
  12. @click="eventStore.setMode(option.key)"
  13. >
  14. {{ option.label }}
  15. </button>
  16. <span class="warning-response-pane__divider" aria-hidden="true"></span>
  17. <button
  18. v-for="option in rangeOptions"
  19. :key="option.key"
  20. type="button"
  21. class="warning-response-pane__control"
  22. :class="{ 'is-active': option.key === eventStore.range }"
  23. :aria-pressed="option.key === eventStore.range"
  24. :data-event-range="option.key"
  25. @click="eventStore.setRange(option.key)"
  26. >
  27. {{ option.label }}
  28. </button>
  29. </div>
  30. <p class="warning-response-pane__range-status" role="status" aria-live="polite">
  31. {{ rangeLabel }} · {{ eventStore.loading ? '正在更新…' : '当前统计窗口' }}
  32. </p>
  33. <p v-if="!eventStore.loading && section && section.reason && /历史接口回显/.test(section.reason)" class="warning-response-pane__range-status" role="alert">{{ section.reason }}</p>
  34. <PanelBlocks v-if="view && !eventStore.loading" :key="`${panelId}-${eventStore.mode}-${eventStore.range}`" :view="view" @list-page="onListPage" @card-action="onCardAction" />
  35. </div>
  36. </template>
  37. <script setup>
  38. import { computed } from 'vue'
  39. import { EVENT_RANGES } from '../domain/warningResponsePanels.js'
  40. import { eventListSwitchOptions } from '../domain/eventList.js'
  41. import { panelView } from '../domain/panelViews.js'
  42. import { panelSideFor } from '../domain/panelCatalog.js'
  43. import { useEventStore } from '../stores/eventStore.js'
  44. import { useEntityDetailStore } from '../stores/entityDetailStore.js'
  45. import PanelBlocks from './PanelBlocks.vue'
  46. const props = defineProps({ panelId: { type: String, required: true } })
  47. const eventStore = useEventStore()
  48. const entityDetailStore = useEntityDetailStore()
  49. /** 详情浮层贴来源侧:本面板在哪一栏由目录单源给出,组件不自己判。 */
  50. const side = computed(() => panelSideFor('warningResponse', props.panelId) || 'right')
  51. const modeOptions = eventListSwitchOptions()
  52. const rangeOptions = EVENT_RANGES
  53. const rangeLabel = computed(() => EVENT_RANGES.find((item) => item.key === eventStore.range)?.label || '')
  54. const section = computed(() => eventStore.sections[props.panelId])
  55. const view = computed(() => {
  56. const current = section.value || { state: 'empty', loaded: false, data: null }
  57. // 票 65:把当前切换族交给 domain —— 预警效率面板要按族分流(预警不挂工单)。
  58. // 族是标量、跨重算稳定;`data.family`(后端回显)仍优先于它,见
  59. // `domain/warningResponsePanels.js` 的 `responseEfficiencyPanel`。
  60. // `workOrderList` 是报警模式「当前工单列表」块的数据源(另一个端点,见 store 注释)。
  61. // 票 71 返工:预警分析的「按事件类型」对报警族要用**事件名称**归类
  62. // (后端 EVENT_TYPE 对报警恒回未知桶,见 domain 的 alarmEventTypeRows),
  63. // 所以把已取到的历史事件行一并交给面板 —— 同窗口、同族、不发额外请求。
  64. const historyEvents = eventStore.sections.historyAnalysis && eventStore.sections.historyAnalysis.data
  65. ? eventStore.sections.historyAnalysis.data.events
  66. : null
  67. return panelView(props.panelId, current.data, current, {
  68. mode: eventStore.mode,
  69. workOrderList: eventStore.sections.workOrderList,
  70. historyEvents,
  71. })
  72. })
  73. /**
  74. * 服务端页码翻页出口(PanelBlocks 的 `serverPage` 块)。
  75. *
  76. * **按块标签分派,不按面板名一刀切**:同一个面板里现在有两块服务端分页块,
  77. * 它们背后是**两个不同端点、两个不同页码**——
  78. * · 历史分析:单窗范围的历史事件(多窗合并范围走块内前端集合分页,不经过这里);
  79. * · 报警效率:「报警列表」(票 71,随效率端点分页);
  80. * · 预警效率:「预警列表」(票 71,同一端点、同一个页码);
  81. * · 报警效率:「当前工单列表」(票 65,另一个端点 `/work-orders`)。
  82. * 早先这里只认 `historyAnalysis`,导致工单列表画出了翻页控件、点了却什么都没发生
  83. * —— 事件被 `return` 掉,页码根本没进 store(t65 的 H 组 + 变异 M27 钉住)。
  84. * 票 71 新增两块列表后,同样的坑会以「列表翻了工单页」的形式复现,所以这里改按标签判。
  85. */
  86. function onListPage(payload) {
  87. const target = payload && payload.page
  88. const label = String((payload && payload.label) || '')
  89. if (props.panelId === 'historyAnalysis') {
  90. eventStore.setHistoryPage(target)
  91. return
  92. }
  93. if (props.panelId === 'responseEfficiency') {
  94. // 工单列表的块标签是「当前工单列表」;其余两块是两族的事件列表(同一个页码)。
  95. if (label === '当前工单列表') eventStore.setWorkOrderPage(target)
  96. else eventStore.setEfficiencyPage(target)
  97. }
  98. }
  99. /** 历史事件与工单按显式身份分流,禁止把事件卡误开成工单。 */
  100. function onCardAction(action) {
  101. const row = (action && action.row) || {}
  102. // 工单卡的路由身份是后端 orderId(票 129);事件仍用业务编码。
  103. const id = (row.identityCode || action.identityCode || action.code) || ''
  104. if (!id) return false
  105. const prefill = row.identityPayload || row
  106. if (action.kind === 'event') {
  107. eventStore.closeEvent()
  108. return entityDetailStore.show({ kind: 'event', id, family: row.identityFamily || row.family || eventStore.mode }, prefill, { side: side.value })
  109. }
  110. if (action.kind === 'work-order') {
  111. return entityDetailStore.show({ kind: 'work-order', id }, prefill, { side: side.value })
  112. }
  113. return false
  114. }
  115. </script>
  116. <style scoped>
  117. .warning-response-pane,
  118. .warning-response-pane * {
  119. box-sizing: border-box;
  120. }
  121. .warning-response-pane {
  122. display: grid;
  123. gap: calc(6 * var(--u, 1px));
  124. min-height: 0;
  125. }
  126. .warning-response-pane__controls {
  127. display: flex;
  128. flex-wrap: wrap;
  129. align-items: center;
  130. gap: calc(3 * var(--u, 1px));
  131. }
  132. .warning-response-pane__control {
  133. padding: calc(1 * var(--u, 1px)) calc(8 * var(--u, 1px));
  134. border: 1px solid rgba(1, 171, 234, 0.32);
  135. border-radius: calc(8 * var(--u, 1px));
  136. background: rgba(0, 20, 72, 0.6);
  137. color: var(--text-2);
  138. font: inherit;
  139. font-size: var(--fs-caption, 10.5px);
  140. cursor: pointer;
  141. }
  142. .warning-response-pane__control.is-active,
  143. .warning-response-pane__control:hover,
  144. .warning-response-pane__control:focus-visible {
  145. border-color: rgba(0, 184, 255, 0.85);
  146. background: rgba(0, 82, 168, 0.72);
  147. color: var(--text-strong);
  148. }
  149. .warning-response-pane__divider {
  150. width: 1px;
  151. height: calc(16 * var(--u, 1px));
  152. margin: 0 calc(3 * var(--u, 1px));
  153. background: rgba(1, 171, 234, 0.45);
  154. }
  155. .warning-response-pane__range-status {
  156. margin: 0;
  157. color: var(--text-2);
  158. font-size: var(--fs-caption);
  159. }
  160. .is-updating { opacity: .45; transition: opacity .15s; }
  161. /* ---- 票 65:工单处置轨迹浮层 ---- */
  162. .warning-response-pane__modal {
  163. position: fixed;
  164. z-index: 30; /* 高于两侧面板栏,低于顶栏诊断浮层(20 的上级),保证能盖住卡片列表 */
  165. right: calc(var(--column-w) + 12 * var(--u, 1px));
  166. top: calc(120 * var(--u, 1px));
  167. width: min(420px, 92vw);
  168. max-height: 62vh;
  169. overflow: auto;
  170. padding: calc(10 * var(--u, 1px)) calc(12 * var(--u, 1px));
  171. border: 1px solid rgba(1, 171, 234, 0.5);
  172. border-radius: calc(8 * var(--u, 1px));
  173. background: rgba(2, 10, 20, 0.96);
  174. box-shadow: 0 10px 32px rgba(0, 0, 0, 0.6);
  175. }
  176. .warning-response-pane__modal-head {
  177. display: flex;
  178. align-items: center;
  179. gap: calc(8 * var(--u, 1px));
  180. }
  181. .warning-response-pane__modal-title {
  182. flex: 1;
  183. min-width: 0;
  184. overflow: hidden;
  185. text-overflow: ellipsis;
  186. white-space: nowrap;
  187. color: var(--text-strong);
  188. font-size: var(--fs-body);
  189. }
  190. .warning-response-pane__modal-close {
  191. padding: calc(2 * var(--u, 1px)) calc(8 * var(--u, 1px));
  192. border: 1px solid rgba(1, 171, 234, 0.4);
  193. border-radius: calc(6 * var(--u, 1px));
  194. background: rgba(0, 20, 72, 0.7);
  195. color: var(--text-2);
  196. font: inherit;
  197. font-size: var(--fs-caption);
  198. cursor: pointer;
  199. }
  200. .warning-response-pane__modal-close:hover,
  201. .warning-response-pane__modal-close:focus-visible {
  202. border-color: rgba(0, 184, 255, 0.85);
  203. color: var(--text-strong);
  204. }
  205. .warning-response-pane__modal-desc {
  206. margin: calc(6 * var(--u, 1px)) 0 0;
  207. color: var(--text-2);
  208. font-size: var(--fs-caption);
  209. line-height: 1.5;
  210. }
  211. .warning-response-pane__modal-hint {
  212. margin: calc(8 * var(--u, 1px)) 0 0;
  213. color: var(--text-2);
  214. font-size: var(--fs-caption);
  215. }
  216. </style>