index.vue 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049
  1. <script lang="ts" setup>
  2. import { ref, reactive, onMounted, onUnmounted } from 'vue'
  3. import { Graph } from '@antv/x6'
  4. import air from './air.vue'
  5. const containerRef = ref<HTMLDivElement>()
  6. const graph = ref<Graph | null>(null)
  7. let timer: number | null = null
  8. // === 看板模拟数据 ===
  9. const overviewData = reactive({
  10. totalFlow: 12450,
  11. pressure: 24.5,
  12. temperature: 35.2,
  13. efficiency: 92.4
  14. })
  15. const wellData = reactive({
  16. wellheadPressure: 32.1,
  17. dailyInjection: 4500,
  18. cumulative: 1250
  19. })
  20. const alarmLogs = reactive([
  21. { time: '14:20:15', msg: '#4空压机例行停机维护', level: 'info' },
  22. { time: '13:45:00', msg: '增压橇出口压力小幅波动', level: 'warn' },
  23. { time: '11:10:22', msg: '系统能效自动优化完成', level: 'info' },
  24. { time: '09:05:11', msg: '2号通讯模块重连成功', level: 'info' }
  25. ])
  26. const gasComposition = reactive([
  27. { name: 'N2 (氮气)', value: 95.0, color: 'bg-blue-500' },
  28. { name: 'O2 (氧气)', value: 3.0, color: 'bg-cyan-500' },
  29. { name: 'CO2 (二氧化碳)', value: 1.5, color: 'bg-teal-500' },
  30. { name: '其他', value: 0.5, color: 'bg-slate-500' }
  31. ])
  32. // === 核心改造:所有设备统一数据源 (驱动面板、X6节点、Tooltip) ===
  33. // 我们额外存储一个 defaultParams 用于设备恢复启动时参考
  34. const deviceData = reactive([
  35. {
  36. id: 'ac5',
  37. name: '#5 空压机',
  38. status: 'running',
  39. x: 250,
  40. y: 130,
  41. width: 400,
  42. height: 220,
  43. img: 'ac.svg',
  44. refX: 0.78,
  45. refY: 0,
  46. params: [
  47. { label: '负载率', value: 90, unit: '%' },
  48. { label: '排温', value: 70, unit: '°C' }
  49. ],
  50. defaultParams: [90, 70]
  51. },
  52. {
  53. id: 'ac4',
  54. name: '#4 空压机',
  55. status: 'stopped',
  56. x: 200,
  57. y: 200,
  58. width: 400,
  59. height: 220,
  60. img: 'ac.svg',
  61. refX: 0.78,
  62. refY: 0,
  63. params: [
  64. { label: '负载率', value: 0, unit: '%' },
  65. { label: '排温', value: 25, unit: '°C' }
  66. ],
  67. defaultParams: [85, 65]
  68. },
  69. {
  70. id: 'ac3',
  71. name: '#3 空压机',
  72. status: 'running',
  73. x: 150,
  74. y: 270,
  75. width: 400,
  76. height: 220,
  77. img: 'ac.svg',
  78. refX: 0.78,
  79. refY: 0,
  80. params: [
  81. { label: '负载率', value: 88, unit: '%' },
  82. { label: '排温', value: 68, unit: '°C' }
  83. ],
  84. defaultParams: [88, 68]
  85. },
  86. {
  87. id: 'ac2',
  88. name: '#2 空压机',
  89. status: 'running',
  90. x: 100,
  91. y: 340,
  92. width: 400,
  93. height: 220,
  94. img: 'ac.svg',
  95. refX: 0.78,
  96. refY: 0,
  97. params: [
  98. { label: '负载率', value: 82, unit: '%' },
  99. { label: '排温', value: 62, unit: '°C' }
  100. ],
  101. defaultParams: [82, 62]
  102. },
  103. {
  104. id: 'ac1',
  105. name: '#1 空压机',
  106. status: 'running',
  107. x: 50,
  108. y: 410,
  109. width: 400,
  110. height: 220,
  111. img: 'ac.svg',
  112. refX: 0.78,
  113. refY: 0,
  114. params: [
  115. { label: '负载率', value: 85, unit: '%' },
  116. { label: '排温', value: 65, unit: '°C' }
  117. ],
  118. defaultParams: [85, 65]
  119. },
  120. {
  121. id: 'air',
  122. name: '空气处理橇',
  123. status: 'running',
  124. x: 850,
  125. y: 270,
  126. width: 400,
  127. height: 320,
  128. img: 'air.svg',
  129. event: 'node:detail',
  130. refX: 0.6,
  131. refY: 0,
  132. params: [
  133. { label: '处理量', value: 1200, unit: 'm³/h' },
  134. { label: '露点', value: -40, unit: '°C' }
  135. ],
  136. defaultParams: [1200, -40]
  137. },
  138. {
  139. id: 'nit',
  140. name: '制氮橇',
  141. status: 'running',
  142. x: 1520,
  143. y: 310,
  144. width: 600,
  145. height: 240,
  146. img: 'nit.svg',
  147. refX: 0.8,
  148. refY: 0,
  149. params: [
  150. { label: '产氮量', value: 1000, unit: 'Nm³/h' },
  151. { label: '纯度', value: 95.5, unit: '%' }
  152. ],
  153. defaultParams: [1000, 95.5]
  154. },
  155. {
  156. id: 'supercharge',
  157. name: '增压橇',
  158. status: 'running',
  159. x: 1420,
  160. y: -140,
  161. width: 700,
  162. height: 300,
  163. img: 'supercharge.svg',
  164. refX: 0.8,
  165. refY: 0.3,
  166. params: [
  167. { label: '入口压', value: 0.8, unit: 'MPa' },
  168. { label: '出口压', value: 25.4, unit: 'MPa' }
  169. ],
  170. defaultParams: [0.8, 25.4]
  171. },
  172. {
  173. id: 'oli',
  174. name: '抽油机',
  175. status: 'running',
  176. x: 2350,
  177. y: -880,
  178. width: 1000,
  179. height: 800,
  180. img: 'oli.svg',
  181. refX: 0.8,
  182. refY: 0,
  183. params: [
  184. { label: '冲程', value: 3.5, unit: 'm' },
  185. { label: '冲次', value: 6, unit: '次/分' }
  186. ],
  187. defaultParams: [3.5, 6]
  188. },
  189. {
  190. id: 'fillwater1',
  191. name: '#1 注水泵',
  192. status: 'stopped',
  193. x: 2610,
  194. y: 250,
  195. width: 320,
  196. height: 260,
  197. img: 'fillwater.svg',
  198. refX: 0.8,
  199. refY: 0,
  200. params: [
  201. { label: '泵压', value: 0, unit: 'MPa' },
  202. { label: '流量', value: 0, unit: 'm³/h' }
  203. ],
  204. defaultParams: [15.2, 45]
  205. },
  206. {
  207. id: 'fillwater2',
  208. name: '#2 注水泵',
  209. status: 'running',
  210. x: 3240,
  211. y: 250,
  212. width: 320,
  213. height: 260,
  214. img: 'fillwater.svg',
  215. refX: 0.8,
  216. refY: 0,
  217. params: [
  218. { label: '泵压', value: 15.2, unit: 'MPa' },
  219. { label: '流量', value: 45, unit: 'm³/h' }
  220. ],
  221. defaultParams: [15.2, 45]
  222. },
  223. {
  224. id: 'water1',
  225. name: '#1 水罐',
  226. status: 'running',
  227. x: 2690,
  228. y: 600,
  229. width: 260,
  230. height: 260,
  231. img: 'water.svg',
  232. refX: 0.8,
  233. refY: 0,
  234. params: [{ label: '液位', value: 3.2, unit: 'm' }],
  235. defaultParams: [3.2]
  236. },
  237. {
  238. id: 'water2',
  239. name: '#2 水罐',
  240. status: 'running',
  241. x: 3310,
  242. y: 600,
  243. width: 260,
  244. height: 260,
  245. img: 'water.svg',
  246. refX: 0.8,
  247. refY: 0,
  248. params: [{ label: '液位', value: 4.5, unit: 'm' }],
  249. defaultParams: [4.5]
  250. }
  251. ])
  252. const hoveredNodeId = ref<string | null>(null)
  253. const nodeTooltip = reactive({
  254. visible: false,
  255. x: 0,
  256. y: 0
  257. })
  258. const toggleDevice = (dev: any) => {
  259. dev.status = dev.status === 'running' ? 'stopped' : 'running'
  260. alarmLogs.unshift({
  261. time: new Date().toTimeString().split(' ')[0],
  262. msg: `手动${dev.status === 'running' ? '开启' : '关闭'} ${dev.name}`,
  263. level: dev.status === 'running' ? 'info' : 'warn'
  264. })
  265. if (alarmLogs.length > 10) alarmLogs.pop()
  266. if (dev.status === 'running') {
  267. dev.params.forEach((p: any, idx: number) => {
  268. if (p.value <= 0.1) p.value = dev.defaultParams[idx]
  269. })
  270. }
  271. if (graph.value) {
  272. const edgeId = `${dev.id}-edge`
  273. const edge = graph.value.getCellById(edgeId)
  274. if (edge) {
  275. if (dev.status === 'running') {
  276. edge.attr('line/style/animation', 'edge-dash-flow 1.2s infinite linear')
  277. edge.attr('fill/stroke', '#0F5BB5')
  278. } else {
  279. edge.attr('line/style/animation', 'none')
  280. edge.attr('fill/stroke', '#B50F0F')
  281. }
  282. }
  283. }
  284. }
  285. const updateDeviceBaseStats = () => {
  286. deviceData.forEach((dev) => {
  287. if (dev.status === 'running') {
  288. dev.params.forEach((p) => {
  289. // 排除掉由工艺链计算的“处理量”、“压力”等核心参数,只对排温、负载等进行基础波动
  290. if (['排温', '负载率', '冲程', '冲次', '液位'].includes(p.label)) {
  291. const range = Math.max(0.1, p.value * 0.01)
  292. p.value = Number((p.value + (Math.random() - 0.5) * range).toFixed(1))
  293. }
  294. })
  295. } else {
  296. // 停机状态下参数缓慢归零/降至环境值
  297. dev.params.forEach((p) => {
  298. const target = p.label === '排温' ? 25 : 0 // 温度降至25度,其余归0
  299. if (p.value > target) {
  300. p.value = Number((p.value * 0.8 + target * 0.2).toFixed(1))
  301. if (Math.abs(p.value - target) < 0.2) p.value = target
  302. }
  303. })
  304. }
  305. })
  306. }
  307. const startRealtimeSimulation = () => {
  308. timer = window.setInterval(() => {
  309. // === 第一步:计算空压机源头输出 ===
  310. const runningACs = deviceData.filter((d) => d.id.startsWith('ac') && d.status === 'running')
  311. const totalACFlow = runningACs.length * 250 // 每台提供250单位流量
  312. // === 第二步:空气处理橇联动 (依赖空压机) ===
  313. const airDevice = deviceData.find((d) => d.id === 'air')!
  314. const airInflow = totalACFlow
  315. // 处理量:如果自身开启,则等于进气量;如果自身关闭,处理量为0
  316. const airOutflow = airDevice.status === 'running' ? airInflow : 0
  317. airDevice.params[0].value = airOutflow // 处理量
  318. // === 第三步:制氮橇联动 (依赖空气处理) ===
  319. const nitDevice = deviceData.find((d) => d.id === 'nit')!
  320. const nitParam_Flow = nitDevice.params.find((p) => p.label === '产氮量')!
  321. const nitParam_Purity = nitDevice.params.find((p) => p.label === '纯度')!
  322. if (nitDevice.status === 'running' && airOutflow > 100) {
  323. // 正常产氮,纯度稳定
  324. nitParam_Flow.value = Number((airOutflow * 0.85).toFixed(1))
  325. nitParam_Purity.value = Number((95.5 + (Math.random() - 0.5) * 0.2).toFixed(1))
  326. } else {
  327. // 没气或者关机,产氮量归零,纯度下降
  328. nitParam_Flow.value = Number((nitParam_Flow.value * 0.7).toFixed(1))
  329. nitParam_Purity.value = Math.max(0, Number((nitParam_Purity.value * 0.9).toFixed(1)))
  330. }
  331. // === 第四步:注水泵系统 (独立分支) ===
  332. const waterPumps = deviceData.filter((d) => d.id.startsWith('fillwater'))
  333. let totalWaterFlow = 0
  334. waterPumps.forEach((pump) => {
  335. if (pump.status === 'running') {
  336. pump.params[0].value = Number((15.2 + (Math.random() - 0.5)).toFixed(1)) // 泵压
  337. pump.params[1].value = Number((45 + (Math.random() - 0.5)).toFixed(1)) // 流量
  338. totalWaterFlow += pump.params[1].value
  339. } else {
  340. pump.params[0].value = Number((pump.params[0].value * 0.5).toFixed(1))
  341. pump.params[1].value = 0
  342. }
  343. })
  344. // === 第五步:增压橇 (综合气+水压力) ===
  345. const superDevice = deviceData.find((d) => d.id === 'supercharge')!
  346. const gasIn = nitParam_Flow.value
  347. const superInPress = superDevice.params.find((p) => p.label === '入口压')!
  348. const superOutPress = superDevice.params.find((p) => p.label === '出口压')!
  349. // 入口压由气源决定
  350. superInPress.value = Number(((gasIn / 1200) * 0.8).toFixed(2))
  351. if (superDevice.status === 'running' && gasIn > 10) {
  352. // 增压至25MPa左右
  353. superOutPress.value = Number((25.4 + (Math.random() - 0.5) * 0.5).toFixed(1))
  354. } else {
  355. superOutPress.value = Math.max(0, Number((superOutPress.value * 0.8).toFixed(1)))
  356. }
  357. // === 第六步:大屏看板 & 井口数据联动 ===
  358. // 1. 场站总览
  359. overviewData.totalFlow = Math.floor(gasIn)
  360. overviewData.pressure = superOutPress.value
  361. overviewData.efficiency = gasIn > 0 ? Number((90 + Math.random() * 5).toFixed(1)) : 0
  362. overviewData.temperature = gasIn > 0 ? Number((35 + Math.random() * 5).toFixed(1)) : 25
  363. // 2. 井口数据
  364. wellData.wellheadPressure = Number((overviewData.pressure * 0.98).toFixed(1))
  365. if (wellData.wellheadPressure > 2) {
  366. // 只有压力够才算注气成功
  367. wellData.dailyInjection += Math.floor(gasIn / 3600)
  368. wellData.cumulative = Number((wellData.cumulative + 0.0001).toFixed(4))
  369. }
  370. // 3. 气体成分随产量微调 (模拟)
  371. if (gasIn > 10) {
  372. gasComposition[0].value = Number((95 + (Math.random() - 0.5) * 0.5).toFixed(1))
  373. gasComposition[1].value = Number((100 - gasComposition[0].value - 2).toFixed(1))
  374. }
  375. // 处理排温等基础属性波动
  376. updateDeviceBaseStats()
  377. }, 1000)
  378. }
  379. const renderGroundAndFence = () => {
  380. if (!graph.value) return
  381. const baseX = -1190
  382. const baseY = -810
  383. const wallHeight = 400
  384. graph.value.addNode({
  385. id: 'station-ground',
  386. shape: 'polygon',
  387. x: baseX,
  388. y: baseY,
  389. width: 6800,
  390. height: 2400,
  391. points: '1200,0 4500,0 3600,1800 0,1800',
  392. zIndex: -10,
  393. attrs: {
  394. body: {
  395. fill: 'rgba(0, 229, 255, 0.04)',
  396. stroke: 'rgba(0, 229, 255, 0.5)',
  397. strokeWidth: 2,
  398. strokeDasharray: '15, 10',
  399. filter: 'drop-shadow(0 0 20px rgba(0,229,255,0.2))'
  400. }
  401. }
  402. })
  403. const wallAttrs = {
  404. body: {
  405. fill: 'rgba(0, 229, 255, 0.08)',
  406. stroke: 'rgba(0, 229, 255, 0.6)',
  407. strokeWidth: 2,
  408. strokeDasharray: '5, 5',
  409. filter: 'drop-shadow(0 0 10px rgba(0,229,255,0.3))'
  410. }
  411. }
  412. graph.value.addNode({
  413. id: 'station-fence-back',
  414. shape: 'polygon',
  415. x: baseX + 1813.3,
  416. y: baseY - wallHeight,
  417. width: 4986.7,
  418. height: wallHeight,
  419. points: `0,${wallHeight} 4986.7,${wallHeight} 4986.7,0 0,0`,
  420. zIndex: -9,
  421. attrs: wallAttrs
  422. })
  423. graph.value.addNode({
  424. id: 'station-fence-left',
  425. shape: 'polygon',
  426. x: baseX,
  427. y: baseY - wallHeight,
  428. width: 1813.3,
  429. height: 2800,
  430. points: `0,2800 1813.3,${wallHeight} 1813.3,0 0,2400`,
  431. zIndex: -8,
  432. attrs: { body: { ...wallAttrs.body, fill: 'rgba(0, 229, 255, 0.12)' } }
  433. })
  434. graph.value.addNode({
  435. id: 'station-fence-right',
  436. shape: 'polygon',
  437. x: baseX + 5440,
  438. y: baseY - wallHeight,
  439. width: 1360,
  440. height: 2800,
  441. points: `1360,${wallHeight} 0,2800 0,2400 1360,0`,
  442. zIndex: -8,
  443. attrs: { body: { ...wallAttrs.body, fill: 'rgba(0, 229, 255, 0.12)' } }
  444. })
  445. graph.value.addNode({
  446. id: 'station-fence-front',
  447. shape: 'polygon',
  448. x: baseX,
  449. y: baseY + 2400 - wallHeight,
  450. width: 5440,
  451. height: wallHeight,
  452. points: `0,${wallHeight} 5440,${wallHeight} 5440,0 0,0`,
  453. zIndex: 10,
  454. attrs: {
  455. body: { ...wallAttrs.body, fill: 'rgba(0, 229, 255, 0.03)', stroke: 'rgba(0, 229, 255, 0.8)' }
  456. }
  457. })
  458. }
  459. const edgeAttrs = {
  460. markup: [
  461. { tagName: 'path', selector: 'fill' },
  462. { tagName: 'path', selector: 'line' }
  463. ],
  464. attrs: {
  465. fill: {
  466. connection: true,
  467. strokeWidth: 20,
  468. stroke: '#0F5BB5',
  469. strokeLinecap: 'round',
  470. fill: 'none'
  471. },
  472. line: {
  473. connection: true,
  474. strokeWidth: 10,
  475. stroke: '#fff',
  476. strokeDasharray: '20, 30',
  477. strokeLinecap: 'round',
  478. targetMarker: null,
  479. fill: 'none',
  480. filter: 'drop-shadow(0 0 3px #fff)'
  481. }
  482. }
  483. }
  484. const edgeDatas = [
  485. {
  486. id: 'ac1-edge',
  487. source: { x: 425, y: 600 },
  488. vertices: [{ x: 725, y: 600 }],
  489. target: { x: 760, y: 540 }
  490. },
  491. { id: 'ac2-edge', source: { x: 475, y: 530 }, target: { x: 900, y: 530 } },
  492. { id: 'ac3-edge', source: { x: 520, y: 460 }, target: { x: 900, y: 460 } },
  493. {
  494. id: 'ac5-edge',
  495. source: { x: 620, y: 322 },
  496. vertices: [{ x: 860, y: 322 }],
  497. target: { x: 820, y: 388 }
  498. },
  499. { id: 'ac4-edge', source: { x: 570, y: 392 }, target: { x: 920, y: 392 } },
  500. { id: 'air-edge', source: { x: 1190, y: 480 }, target: { x: 1540, y: 480 } },
  501. {
  502. id: 'nit-edge',
  503. source: { x: 2110, y: 480 },
  504. vertices: [
  505. { x: 2280, y: 480 },
  506. { x: 2245, y: 250 },
  507. { x: 1280, y: 250 },
  508. { x: 1345, y: 95 }
  509. ],
  510. target: { x: 1425, y: 95 }
  511. },
  512. {
  513. id: 'water1-edge',
  514. source: { x: 2935, y: 800 },
  515. vertices: [
  516. { x: 3075, y: 800 },
  517. { x: 3000, y: 450 }
  518. ],
  519. target: { x: 2900, y: 450 }
  520. },
  521. {
  522. id: 'water2-edge',
  523. source: { x: 3345, y: 800 },
  524. vertices: [
  525. { x: 3220, y: 800 },
  526. { x: 3140, y: 450 }
  527. ],
  528. target: { x: 3275, y: 450 }
  529. },
  530. {
  531. id: 'fillwater1-edge',
  532. source: { x: 2640, y: 450 },
  533. vertices: [{ x: 2480, y: 450 }],
  534. target: { x: 2420, y: 95 }
  535. },
  536. {
  537. id: 'fillwater2-edge',
  538. source: { x: 3535, y: 450 },
  539. vertices: [{ x: 3710, y: 450 }],
  540. target: { x: 3600, y: 95 }
  541. },
  542. {
  543. id: 'supercharge-edge',
  544. source: { x: 2090, y: 95 },
  545. vertices: [
  546. { x: 3800, y: 95 },
  547. { x: 3700, y: -194 }
  548. ],
  549. target: { x: 3330, y: -191 }
  550. }
  551. ]
  552. const nodeWithTitleMarkup = [
  553. { tagName: 'image', selector: 'image' },
  554. { tagName: 'rect', selector: 'titleBg' },
  555. { tagName: 'text', selector: 'titleText' }
  556. ]
  557. const getTechTextAttrs = (
  558. title: string,
  559. options: { width?: number; refX?: number; refY?: number } = {}
  560. ) => {
  561. const { width = 160, refX = 0.8, refY = 0.18 } = options
  562. const height = 32
  563. return {
  564. titleBg: {
  565. refX,
  566. refY,
  567. width,
  568. height,
  569. x: -(width / 2),
  570. y: -(height / 2),
  571. fill: 'rgba(11, 17, 32, 0.8)',
  572. stroke: '#00E5FF',
  573. strokeWidth: 1,
  574. rx: 4,
  575. ry: 4
  576. },
  577. titleText: {
  578. text: title,
  579. fill: '#00E5FF',
  580. fontSize: 15,
  581. fontWeight: 'bold',
  582. letterSpacing: 2,
  583. refX,
  584. refY,
  585. textAnchor: 'middle',
  586. textVerticalAnchor: 'middle',
  587. filter: 'drop-shadow(0px 2px 4px rgba(0,0,0,0.8))'
  588. }
  589. }
  590. }
  591. const airDialogRef = ref()
  592. const initGraph = () => {
  593. if (!containerRef.value) return
  594. graph.value = new Graph({
  595. container: containerRef.value,
  596. interacting: false,
  597. autoResize: true,
  598. panning: true,
  599. mousewheel: { enabled: true, zoomAtMousePosition: true, modifiers: ['ctrl', 'meta'] },
  600. background: { color: 'transparent' },
  601. grid: { size: 10, visible: true, type: 'dot', args: { color: '#1E2E4A', thickness: 1 } }
  602. })
  603. graph.value.on('node:mouseenter', ({ node, e }) => {
  604. hoveredNodeId.value = node.id
  605. nodeTooltip.x = e.clientX + 15
  606. nodeTooltip.y = e.clientY + 15
  607. nodeTooltip.visible = true
  608. })
  609. graph.value.on('node:mouseleave', () => {
  610. hoveredNodeId.value = null
  611. nodeTooltip.visible = false
  612. })
  613. graph.value.on('node:detail', () => {
  614. if (airDialogRef.value) {
  615. airDialogRef.value.handleOpen()
  616. }
  617. })
  618. }
  619. const renderEdges = () => {
  620. edgeDatas.forEach((edgeData) => {
  621. const edge = graph.value?.addEdge({ ...edgeData, ...edgeAttrs })
  622. const deviceId = edgeData.id.replace('-edge', '')
  623. const dev = deviceData.find((d) => d.id === deviceId)
  624. if (dev && dev.status === 'stopped' && edge) {
  625. edge.attr('line/style/animation', 'none')
  626. edge.attr('fill/stroke', '#B50F0F')
  627. } else if (edge) {
  628. edge.attr('line/style/animation', 'edge-dash-flow 1.2s infinite linear')
  629. edge.attr('fill/stroke', '#0F5BB5')
  630. }
  631. })
  632. }
  633. const renderNodes = () => {
  634. deviceData.forEach((n) => {
  635. graph.value?.addNode({
  636. id: n.id,
  637. x: n.x,
  638. y: n.y,
  639. width: n.width,
  640. height: n.height,
  641. shape: 'image',
  642. imageUrl: `src/views/test/image/${n.img}`,
  643. markup: nodeWithTitleMarkup,
  644. attrs: {
  645. image: { preserveAspectRatio: 'none', refWidth: '100%', refHeight: '100%', event: n.event },
  646. ...getTechTextAttrs(n.name, { width: 170, refX: n.refX, refY: n.refY })
  647. }
  648. })
  649. })
  650. }
  651. onMounted(() => {
  652. initGraph()
  653. renderGroundAndFence()
  654. renderEdges()
  655. renderNodes()
  656. if (graph.value) {
  657. graph.value.zoomTo(0.35)
  658. graph.value.translate(437, 530.65)
  659. }
  660. startRealtimeSimulation()
  661. })
  662. onUnmounted(() => {
  663. graph.value?.dispose()
  664. if (timer) clearInterval(timer)
  665. })
  666. </script>
  667. <template>
  668. <div
  669. class="relative flex flex-col w-full overflow-hidden bg-[#0B1120] font-sans"
  670. style="
  671. height: calc(
  672. 100vh - 20px - var(--top-tool-height) - var(--tags-view-height) - var(--app-footer-height)
  673. );
  674. "
  675. >
  676. <header
  677. class="relative z-20 flex items-center justify-center h-16 shrink-0 bg-[#0B1120] border-b border-[#00E5FF]/40 shadow-[0_4px_20px_rgba(0,229,255,0.15)]"
  678. >
  679. <div
  680. class="absolute left-10 right-10 bottom-0 h-[2px] bg-gradient-to-r from-transparent via-[#00E5FF] to-transparent opacity-80"
  681. ></div>
  682. <h1
  683. class="text-2xl font-bold tracking-[0.2em] text-[#00E5FF] drop-shadow-[0_0_10px_rgba(0,229,255,0.8)]"
  684. >
  685. XX注气场站注气工艺组态图
  686. </h1>
  687. </header>
  688. <div class="relative flex-1 w-full h-full overflow-hidden">
  689. <main class="absolute inset-0 z-0" ref="containerRef"></main>
  690. <div class="absolute inset-0 z-10 pointer-events-none flex justify-between p-6">
  691. <div class="flex flex-col gap-6 w-[380px] pointer-events-auto h-full pb-2">
  692. <div
  693. class="bg-[#0A1628]/95 border border-[#00E5FF]/60 shadow-[0_0_15px_rgba(0,229,255,0.15)_inset] rounded-lg p-5 flex flex-col backdrop-blur-md transition-all shrink-0"
  694. >
  695. <h2
  696. class="text-lg font-bold text-[#00E5FF] border-b border-[#00E5FF]/30 pb-2 mb-4 drop-shadow-[0_0_5px_rgba(0,229,255,0.8)]"
  697. >场站实时总览</h2
  698. >
  699. <div class="grid grid-cols-2 gap-4">
  700. <div class="bg-[#112240] border border-[#1E3A8A] rounded p-3 flex flex-col">
  701. <span class="text-xs text-slate-300 font-medium mb-1">注气总流量 (Nm³/h)</span>
  702. <span
  703. class="text-xl font-bold font-mono text-[#00FF7F] drop-shadow-[0_0_5px_rgba(0,255,127,0.5)] transition-all"
  704. >{{ overviewData.totalFlow.toLocaleString() }}</span
  705. >
  706. </div>
  707. <div class="bg-[#112240] border border-[#1E3A8A] rounded p-3 flex flex-col">
  708. <span class="text-xs text-slate-300 font-medium mb-1">管网压力 (MPa)</span>
  709. <span
  710. class="text-xl font-bold font-mono text-[#38BDF8] drop-shadow-[0_0_5px_rgba(56,189,248,0.5)] transition-all"
  711. >{{ overviewData.pressure }}</span
  712. >
  713. </div>
  714. <div class="bg-[#112240] border border-[#1E3A8A] rounded p-3 flex flex-col">
  715. <span class="text-xs text-slate-300 font-medium mb-1">排气温度 (°C)</span>
  716. <span
  717. class="text-xl font-bold font-mono text-[#FBBF24] drop-shadow-[0_0_5px_rgba(251,191,36,0.5)] transition-all"
  718. >{{ overviewData.temperature }}</span
  719. >
  720. </div>
  721. <div class="bg-[#112240] border border-[#1E3A8A] rounded p-3 flex flex-col">
  722. <span class="text-xs text-slate-300 font-medium mb-1">系统能效 (%)</span>
  723. <span
  724. class="text-xl font-bold font-mono text-[#00E5FF] drop-shadow-[0_0_5px_rgba(0,229,255,0.5)] transition-all"
  725. >{{ overviewData.efficiency }}</span
  726. >
  727. </div>
  728. </div>
  729. </div>
  730. <div
  731. class="bg-[#0A1628]/95 border border-[#00E5FF]/60 shadow-[0_0_15px_rgba(0,229,255,0.15)_inset] rounded-lg p-5 flex flex-col flex-1 min-h-0 backdrop-blur-md"
  732. >
  733. <h2
  734. class="text-lg font-bold text-[#00E5FF] border-b border-[#00E5FF]/30 pb-2 mb-4 drop-shadow-[0_0_5px_rgba(0,229,255,0.8)] shrink-0"
  735. >全场设备状态监控</h2
  736. >
  737. <div class="flex-1 flex flex-col gap-3 overflow-y-auto pr-2 custom-scrollbar">
  738. <div
  739. v-for="dev in deviceData"
  740. :key="dev.id"
  741. class="flex items-center justify-between p-3 bg-[#112240] border border-[#1E3A8A] rounded hover:border-[#00E5FF]/60 transition-colors"
  742. >
  743. <div class="flex items-center gap-3">
  744. <div
  745. :class="[
  746. 'w-3 h-3 rounded-full shadow-[0_0_8px] transition-colors shrink-0',
  747. dev.status === 'running'
  748. ? 'bg-[#00FF7F] shadow-[#00FF7F]'
  749. : 'bg-[#EF4444] shadow-[#EF4444]'
  750. ]"
  751. ></div>
  752. <span class="text-sm font-bold text-white w-[75px] truncate" :title="dev.name">{{
  753. dev.name
  754. }}</span>
  755. </div>
  756. <div class="flex gap-3 text-sm font-mono min-w-[120px] justify-end items-center">
  757. <div class="flex gap-3 min-w-[90px] justify-end">
  758. <div
  759. v-for="(param, idx) in dev.params.slice(0, 2)"
  760. :key="idx"
  761. class="flex flex-col items-end"
  762. >
  763. <span class="text-slate-400 text-[10px]">{{ param.label }}</span>
  764. <span
  765. :class="
  766. dev.status === 'running'
  767. ? 'text-[#00E5FF] font-bold transition-all'
  768. : 'text-slate-500'
  769. "
  770. >
  771. {{ param.value }}<span class="text-[10px] ml-0.5">{{ param.unit }}</span>
  772. </span>
  773. </div>
  774. </div>
  775. <button
  776. @click="toggleDevice(dev)"
  777. class="ml-2 p-1.5 rounded flex items-center justify-center transition-all duration-300 border focus:outline-none active:scale-90"
  778. :class="
  779. dev.status === 'running'
  780. ? 'border-[#EF4444]/30 text-[#EF4444] hover:bg-[#EF4444]/20 hover:border-[#EF4444] hover:shadow-[0_0_10px_rgba(239,68,68,0.5)]'
  781. : 'border-[#00FF7F]/30 text-[#00FF7F] hover:bg-[#00FF7F]/20 hover:border-[#00FF7F] hover:shadow-[0_0_10px_rgba(0,255,127,0.5)]'
  782. "
  783. :title="dev.status === 'running' ? '停止设备' : '启动设备'"
  784. >
  785. <div
  786. :class="dev.status === 'running' ? 'i-mdi-pause' : 'i-mdi-play'"
  787. class="w-4 h-4"
  788. >
  789. </div>
  790. </button>
  791. </div>
  792. </div>
  793. </div>
  794. </div>
  795. </div>
  796. <div class="flex flex-col gap-6 w-[380px] pointer-events-auto h-full pb-2">
  797. <div
  798. class="bg-[#0A1628]/95 border border-[#00E5FF]/60 shadow-[0_0_15px_rgba(0,229,255,0.15)_inset] rounded-lg p-5 flex flex-col backdrop-blur-md shrink-0"
  799. >
  800. <h2
  801. class="text-lg font-bold text-[#00E5FF] border-b border-[#00E5FF]/30 pb-2 mb-4 drop-shadow-[0_0_5px_rgba(0,229,255,0.8)]"
  802. >注气井实时数据</h2
  803. >
  804. <div class="flex flex-col gap-4">
  805. <div
  806. class="flex justify-between items-end bg-[#112240] p-3 rounded border border-[#1E3A8A]"
  807. >
  808. <span class="text-white text-sm font-medium">井口压力</span>
  809. <span class="text-2xl font-mono text-[#00E5FF] font-bold transition-all"
  810. >{{ wellData.wellheadPressure
  811. }}<span class="text-sm text-slate-400">MPa</span></span
  812. >
  813. </div>
  814. <div
  815. class="flex justify-between items-end bg-[#112240] p-3 rounded border border-[#1E3A8A]"
  816. >
  817. <span class="text-white text-sm font-medium">日注气量</span>
  818. <span class="text-2xl font-mono text-[#00FF7F] font-bold transition-all"
  819. >{{ wellData.dailyInjection.toLocaleString()
  820. }}<span class="text-sm text-slate-400">Nm³</span></span
  821. >
  822. </div>
  823. <div
  824. class="flex justify-between items-end bg-[#112240] p-3 rounded border border-[#1E3A8A]"
  825. >
  826. <span class="text-white text-sm font-medium">累计注气</span>
  827. <span class="text-2xl font-mono text-[#FBBF24] font-bold transition-all"
  828. >{{ wellData.cumulative }} <span class="text-sm text-slate-400">万Nm³</span></span
  829. >
  830. </div>
  831. </div>
  832. </div>
  833. <div
  834. class="bg-[#0A1628]/95 border border-[#00E5FF]/60 shadow-[0_0_15px_rgba(0,229,255,0.15)_inset] rounded-lg p-5 flex flex-col backdrop-blur-md shrink-0"
  835. >
  836. <h2
  837. class="text-lg font-bold text-[#00E5FF] border-b border-[#00E5FF]/30 pb-2 mb-4 drop-shadow-[0_0_5px_rgba(0,229,255,0.8)]"
  838. >气体成分占比</h2
  839. >
  840. <div class="flex flex-col gap-4">
  841. <div v-for="gas in gasComposition" :key="gas.name" class="flex flex-col gap-2">
  842. <div class="flex justify-between text-sm">
  843. <span class="text-white font-medium">{{ gas.name }}</span>
  844. <span class="text-[#00E5FF] font-mono font-bold transition-all"
  845. >{{ gas.value }}%</span
  846. >
  847. </div>
  848. <div class="w-full h-2 bg-[#1E3A8A] rounded-full overflow-hidden">
  849. <div
  850. :class="[
  851. 'h-full rounded-full transition-all duration-500 ease-in-out',
  852. gas.color
  853. ]"
  854. :style="{ width: `${gas.value}%` }"
  855. ></div>
  856. </div>
  857. </div>
  858. </div>
  859. </div>
  860. <div
  861. class="bg-[#0A1628]/95 border border-[#00E5FF]/60 shadow-[0_0_15px_rgba(0,229,255,0.15)_inset] rounded-lg p-5 flex flex-col flex-1 min-h-0 backdrop-blur-md"
  862. >
  863. <h2
  864. class="text-lg font-bold text-[#00E5FF] border-b border-[#00E5FF]/30 pb-2 mb-4 drop-shadow-[0_0_5px_rgba(0,229,255,0.8)] shrink-0"
  865. >系统操作/告警日志</h2
  866. >
  867. <div class="flex-1 flex flex-col gap-3 overflow-y-auto pr-2 custom-scrollbar">
  868. <div
  869. v-for="(log, idx) in alarmLogs"
  870. :key="idx"
  871. class="flex flex-col p-3 bg-[#112240] rounded border-l-4"
  872. :class="log.level === 'warn' ? 'border-[#FBBF24]' : 'border-[#00E5FF]'"
  873. >
  874. <div class="flex justify-between items-center mb-2">
  875. <span class="text-xs text-slate-400 font-mono">{{ log.time }}</span>
  876. <span
  877. :class="[
  878. 'text-xs px-2 py-0.5 rounded font-bold',
  879. log.level === 'warn'
  880. ? 'bg-[#FBBF24]/20 text-[#FBBF24]'
  881. : 'bg-[#00E5FF]/20 text-[#00E5FF]'
  882. ]"
  883. >
  884. {{ log.level === 'warn' ? '警告' : '信息' }}
  885. </span>
  886. </div>
  887. <span class="text-sm text-white">{{ log.msg }}</span>
  888. </div>
  889. </div>
  890. </div>
  891. </div>
  892. </div>
  893. </div>
  894. </div>
  895. <template v-if="hoveredNodeId">
  896. <template v-for="dev in deviceData" :key="dev.id">
  897. <div
  898. v-if="dev.id === hoveredNodeId && nodeTooltip.visible"
  899. class="coord-tooltip"
  900. :style="{ left: `${nodeTooltip.x}px`, top: `${nodeTooltip.y}px`, minWidth: '200px' }"
  901. >
  902. <div
  903. style="
  904. padding-bottom: 6px;
  905. margin-bottom: 4px;
  906. font-size: 14px;
  907. font-weight: bold;
  908. color: #fff;
  909. border-bottom: 1px dashed rgb(14 165 233 / 40%);
  910. "
  911. >
  912. {{ dev.name }}
  913. </div>
  914. <div class="coord-item">
  915. <span>运行状态:</span>
  916. <span class="val" :style="{ color: dev.status === 'running' ? '#00FF7F' : '#ef4444' }">
  917. {{ dev.status === 'running' ? '运行中' : '已停机' }}
  918. </span>
  919. </div>
  920. <div class="coord-item" v-for="(param, index) in dev.params" :key="index">
  921. <span>{{ param.label }}:</span>
  922. <span class="val transition-all">{{ param.value }} {{ param.unit }}</span>
  923. </div>
  924. </div>
  925. </template>
  926. </template>
  927. <air ref="airDialogRef" />
  928. </template>
  929. <style scoped>
  930. .transition-all {
  931. transition: all 0.3s ease;
  932. }
  933. .coord-tooltip {
  934. position: fixed;
  935. z-index: 9999;
  936. display: flex;
  937. padding: 12px 16px;
  938. font-family: monospace;
  939. font-size: 13px;
  940. line-height: 1.5;
  941. color: #fff;
  942. white-space: nowrap;
  943. pointer-events: none;
  944. background: rgb(10 22 40 / 95%);
  945. border: 1px solid rgb(0 229 255 / 80%);
  946. border-radius: 6px;
  947. box-shadow:
  948. 0 4px 15px rgb(0 0 0 / 80%),
  949. 0 0 10px rgb(0 229 255 / 30%) inset;
  950. flex-direction: column;
  951. gap: 6px;
  952. }
  953. .coord-item {
  954. display: flex;
  955. justify-content: space-between;
  956. gap: 24px;
  957. }
  958. .coord-item .val {
  959. font-weight: bold;
  960. color: #00e5ff;
  961. }
  962. .custom-scrollbar::-webkit-scrollbar {
  963. width: 6px;
  964. }
  965. .custom-scrollbar::-webkit-scrollbar-track {
  966. background: rgb(17 34 64 / 80%);
  967. border-radius: 4px;
  968. }
  969. .custom-scrollbar::-webkit-scrollbar-thumb {
  970. background: rgb(0 229 255 / 60%);
  971. border-radius: 4px;
  972. }
  973. .custom-scrollbar::-webkit-scrollbar-thumb:hover {
  974. background: rgb(0 229 255 / 100%);
  975. }
  976. </style>
  977. <style>
  978. @keyframes edge-dash-flow {
  979. 0% {
  980. stroke-dashoffset: 50;
  981. }
  982. 100% {
  983. stroke-dashoffset: 0;
  984. }
  985. }
  986. </style>