page.tsx 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394
  1. "use client"
  2. import React, {useEffect, useMemo, useState} from "react"
  3. import type {MenuProps, TableColumnsType} from "antd"
  4. import {
  5. Badge,
  6. Button,
  7. Card,
  8. Col,
  9. ConfigProvider,
  10. DatePicker,
  11. Descriptions,
  12. Divider,
  13. Drawer,
  14. Empty,
  15. Layout,
  16. Menu,
  17. Progress,
  18. Row,
  19. Segmented,
  20. Select,
  21. Space,
  22. Statistic,
  23. Switch,
  24. Table,
  25. Tabs,
  26. Tag,
  27. Timeline,
  28. Tooltip as AntdTooltip,
  29. } from "antd"
  30. import {
  31. Activity,
  32. AlertTriangle,
  33. BellRing,
  34. ClipboardList,
  35. Database,
  36. Droplets,
  37. Factory,
  38. Flame,
  39. Gauge,
  40. Layers3,
  41. LineChartIcon,
  42. MapIcon,
  43. Moon,
  44. Settings2,
  45. ShieldCheck,
  46. Sun,
  47. Table2,
  48. TrendingUp,
  49. Users,
  50. Waves
  51. } from 'lucide-react'
  52. import EChart from "@/components/echarts"
  53. import dayjs from "dayjs"
  54. import "dayjs/locale/zh-cn"
  55. import zhCN from "antd/es/locale/zh_CN"
  56. dayjs.locale("zh-cn")
  57. const { Header, Sider, Content } = Layout
  58. const { RangePicker } = DatePicker
  59. // Helpers
  60. const primary = "#10b981" // teal, avoid blue
  61. const danger = "#ef4444"
  62. const warn = "#f59e0b"
  63. const ok = "#22c55e"
  64. const muted = "#6b7280"
  65. type Facility = {
  66. id: string
  67. industry: "燃气" | "供水" | "排水"
  68. type: string
  69. count: number
  70. age: number
  71. region: string
  72. }
  73. type Device = {
  74. id: string
  75. type: string
  76. status: "在线" | "离线"
  77. industry: Facility["industry"]
  78. risk: "高" | "中" | "低"
  79. lat: number
  80. lng: number
  81. }
  82. type Alert = {
  83. id: string
  84. level: "I级" | "II级" | "III级" | "IV级"
  85. industry: Facility["industry"]
  86. type: string
  87. time: string
  88. status: "待处置" | "处置中" | "已闭环"
  89. location: string
  90. desc: string
  91. }
  92. function useMockData() {
  93. const [facilities] = useState<Facility[]>(() => {
  94. const regions = ["中心城区", "东区", "西区", "南区", "北区"]
  95. const types = {
  96. 燃气: ["高压管道", "调压站", "门站", "阀门井"],
  97. 供水: ["原水管", "净水厂", "二次供水", "监测点"],
  98. 排水: ["主干管", "泵站", "检查井", "溢流口"],
  99. } as const
  100. let i = 0
  101. return (["燃气", "供水", "排水"] as Facility["industry"][]).flatMap((ind) =>
  102. types[ind].map((t) => ({
  103. id: `f-${i++}`,
  104. industry: ind,
  105. type: t,
  106. count: Math.floor(Math.random() * 900 + 100),
  107. age: Math.floor(Math.random() * 30 + 1),
  108. region: regions[Math.floor(Math.random() * regions.length)],
  109. }))
  110. )
  111. })
  112. const [devices, setDevices] = useState<Device[]>(() => {
  113. const types = ["压力", "流量", "液位", "阀位", "水质", "气体浓度"]
  114. let i = 0
  115. return Array.from({ length: 250 }).map(() => ({
  116. id: `d-${i++}`,
  117. type: types[Math.floor(Math.random() * types.length)],
  118. status: Math.random() > 0.12 ? "在线" : "离线",
  119. industry: (["燃气", "供水", "排水"] as const)[Math.floor(Math.random() * 3)],
  120. risk: Math.random() > 0.8 ? "高" : Math.random() > 0.5 ? "中" : "低",
  121. lat: Math.random(),
  122. lng: Math.random(),
  123. }))
  124. })
  125. // Simulate device status fluctuation
  126. useEffect(() => {
  127. const t = setInterval(() => {
  128. setDevices((prev) =>
  129. prev.map((d) =>
  130. Math.random() > 0.97 ? { ...d, status: d.status === "在线" ? "离线" : "在线" } : d
  131. )
  132. )
  133. }, 4000)
  134. return () => clearInterval(t)
  135. }, [])
  136. const [alerts, setAlerts] = useState<Alert[]>(() => {
  137. const levels: Alert["level"][] = ["I级", "II级", "III级", "IV级"]
  138. const types = ["泄漏", "压力异常", "流量突变", "停电", "液位过低", "浊度异常"]
  139. let i = 0
  140. return Array.from({ length: 30 }).map(() => ({
  141. id: `a-${i++}`,
  142. level: levels[Math.floor(Math.random() * levels.length)],
  143. industry: (["燃气", "供水", "排水"] as const)[Math.floor(Math.random() * 3)],
  144. type: types[Math.floor(Math.random() * types.length)],
  145. time: dayjs().subtract(Math.floor(Math.random() * 200), "minute").format("YYYY-MM-DD HH:mm"),
  146. status: Math.random() > 0.6 ? "已闭环" : Math.random() > 0.3 ? "处置中" : "待处置",
  147. location: ["中心城区", "东区", "西区", "南区", "北区"][Math.floor(Math.random() * 5)],
  148. desc: "自动监测发现异常,已推送至管理单位核实。",
  149. }))
  150. })
  151. // Simulate new alerts
  152. useEffect(() => {
  153. const t = setInterval(() => {
  154. setAlerts((prev) => {
  155. const n: Alert = {
  156. id: `a-${prev.length + 1}`,
  157. level: Math.random() > 0.85 ? "I级" : Math.random() > 0.6 ? "II级" : Math.random() > 0.3 ? "III级" : "IV级",
  158. industry: (["燃气", "供水", "排水"] as const)[Math.floor(Math.random() * 3)],
  159. type: ["泄漏", "压力异常", "流量突变", "停电", "液位过低", "浊度异常"][Math.floor(Math.random() * 6)],
  160. time: dayjs().format("YYYY-MM-DD HH:mm"),
  161. status: "待处置",
  162. location: ["中心城区", "东区", "西区", "南区", "北区"][Math.floor(Math.random() * 5)],
  163. desc: "前端设备上报新预警,请尽快核查。",
  164. }
  165. return [n, ...prev].slice(0, 60)
  166. })
  167. }, 20000)
  168. return () => clearInterval(t)
  169. }, [])
  170. return { facilities, devices, alerts }
  171. }
  172. function LevelTag({ level }: { level: Alert["level"] }) {
  173. const map = {
  174. "I级": { color: danger },
  175. "II级": { color: warn },
  176. "III级": { color: "#f97316" },
  177. "IV级": { color: ok },
  178. } as const
  179. return <Tag color={map[level].color}>{level}</Tag>
  180. }
  181. function StatusBadge({ s }: { s: Alert["status"] }) {
  182. const status = {
  183. 待处置: "error",
  184. 处置中: "processing",
  185. 已闭环: "success",
  186. } as const
  187. // @ts-expect-error antd types for Badge status
  188. return <Badge status={status[s]} text={s} />
  189. }
  190. export default function Page() {
  191. const [collapsed, setCollapsed] = useState(false)
  192. const { facilities, devices, alerts } = useMockData()
  193. const [selectedMenu, setSelectedMenu] = useState("overview")
  194. const [drawerOpen, setDrawerOpen] = useState(false)
  195. const [selectedAlert, setSelectedAlert] = useState<Alert | null>(null)
  196. const [isDark, setIsDark] = useState(false) // 默认白色主题
  197. const [assetTab, setAssetTab] = useState("archive")
  198. const [monitorTab, setMonitorTab] = useState("summary")
  199. const [alertTab, setAlertTab] = useState("current")
  200. const totals = useMemo(() => {
  201. const sum = { 燃气: 0, 供水: 0, 排水: 0 } as Record<Facility["industry"], number>
  202. facilities.forEach((f) => (sum[f.industry] += f.count))
  203. return sum
  204. }, [facilities])
  205. const onlineRate = useMemo(() => {
  206. const total = devices.length
  207. const online = devices.filter((d) => d.status === "在线").length
  208. return Math.round((online / Math.max(total, 1)) * 100)
  209. }, [devices])
  210. const riskDist = useMemo(() => {
  211. const dist = { 高: 0, 中: 0, 低: 0 } as Record<Device["risk"], number>
  212. devices.forEach((d) => (dist[d.risk] += 1))
  213. return dist
  214. }, [devices])
  215. // Menu
  216. const menuItems: MenuProps["items"] = [
  217. { key: "overview", icon: <Layers3 size={18} />, label: "总体概览" },
  218. { key: "asset", icon: <Database size={18} />, label: "基础设施管理" },
  219. { key: "monitor", icon: <Activity size={18} />, label: "运行监测管理" },
  220. { key: "alert", icon: <BellRing size={18} />, label: "预警处置管理" },
  221. { type: "divider" as const },
  222. { key: "devices", icon: <Gauge size={18} />, label: "设备管理" },
  223. { key: "reports", icon: <ClipboardList size={18} />, label: "数据报表" },
  224. { key: "incidents", icon: <Users size={18} />, label: "事件中心" },
  225. { key: "bigscreen", icon: <LineChartIcon size={18} />, label: "数据大屏(示意)" },
  226. { type: "divider" as const },
  227. { key: "settings", icon: <Settings2 size={18} />, label: "设置" },
  228. ]
  229. // Charts Options
  230. const infraPieOption = useMemo(
  231. () => ({
  232. title: { text: "设施类型占比", left: "center", textStyle: { fontSize: 14 } },
  233. tooltip: { trigger: "item" },
  234. legend: { bottom: 0 },
  235. color: [primary, "#f59e0b", "#6366f1", "#ef4444", "#14b8a6", "#a855f7"],
  236. series: [
  237. {
  238. type: "pie",
  239. radius: ["35%", "60%"],
  240. avoidLabelOverlap: false,
  241. itemStyle: { borderRadius: 6, borderColor: "#fff", borderWidth: 2 },
  242. data: ["燃气", "供水", "排水"].map((ind) => ({
  243. name: ind,
  244. value: facilities
  245. .filter((f) => f.industry === ind)
  246. .reduce((acc, f) => acc + f.count, 0),
  247. })),
  248. },
  249. ],
  250. }),
  251. [facilities]
  252. )
  253. const deviceBarOption = useMemo(() => {
  254. const types = Array.from(new Set(devices.map((d) => d.type)))
  255. const byType = types.map((t) => devices.filter((d) => d.type === t).length)
  256. return {
  257. title: { text: "监测设备类型规模", left: "center", textStyle: { fontSize: 14 } },
  258. tooltip: { trigger: "axis" },
  259. xAxis: { type: "category", data: types, axisLabel: { rotate: 20 } },
  260. yAxis: { type: "value" },
  261. grid: { left: 40, right: 10, bottom: 50, top: 40 },
  262. color: [primary],
  263. series: [{ type: "bar", data: byType, barWidth: "50%", itemStyle: { borderRadius: [4, 4, 0, 0] } }],
  264. } as const
  265. }, [devices])
  266. const alertTrendOption = useMemo(() => {
  267. const days = 14
  268. const labels = Array.from({ length: days }).map((_, i) => dayjs().subtract(days - i - 1, "day").format("MM-DD"))
  269. const series = (["燃气", "供水", "排水"] as const).map((ind, idx) => ({
  270. name: ind,
  271. type: "line",
  272. smooth: true,
  273. data: labels.map(() => Math.floor(Math.random() * (idx === 0 ? 12 : idx === 1 ? 9 : 7)) + (idx === 0 ? 3 : 1)),
  274. }))
  275. return {
  276. title: { text: "预警趋势(近14天)", left: "center", textStyle: { fontSize: 14 } },
  277. tooltip: { trigger: "axis" },
  278. legend: { bottom: 0 },
  279. grid: { left: 40, right: 10, bottom: 40, top: 40 },
  280. xAxis: { type: "category", data: labels },
  281. yAxis: { type: "value" },
  282. color: [primary, "#f59e0b", "#a855f7"],
  283. series,
  284. } as const
  285. }, [])
  286. const onlineGaugeOption = useMemo(
  287. () => ({
  288. title: { text: "设备在线率", left: "center", top: 10, textStyle: { fontSize: 14 } },
  289. series: [
  290. {
  291. type: "gauge",
  292. startAngle: 200,
  293. endAngle: -20,
  294. radius: "90%",
  295. pointer: { show: false },
  296. progress: { show: true, width: 16, itemStyle: { color: onlineRate > 95 ? ok : onlineRate > 85 ? "#84cc16" : warn } },
  297. axisLine: { lineStyle: { width: 16 } },
  298. axisTick: { show: false },
  299. splitLine: { show: false },
  300. axisLabel: { show: false },
  301. detail: { valueAnimation: true, formatter: "{value}%", fontSize: 22, offsetCenter: [0, "10%"] },
  302. data: [{ value: onlineRate }],
  303. },
  304. ],
  305. }),
  306. [onlineRate]
  307. )
  308. const riskBarOption = useMemo(
  309. () => ({
  310. title: { text: "风险等级分布", left: "center", textStyle: { fontSize: 14 } },
  311. tooltip: { trigger: "axis" },
  312. grid: { left: 40, right: 10, top: 40, bottom: 20 },
  313. xAxis: { type: "category", data: ["高", "中", "低"] },
  314. yAxis: { type: "value" },
  315. color: [danger, warn, ok],
  316. series: [{ type: "bar", data: [riskDist["高"], riskDist["中"], riskDist["低"]], barWidth: "50%" }],
  317. }),
  318. [riskDist]
  319. )
  320. const efficiencyPieOption = useMemo(() => {
  321. const closed = alerts.filter((a) => a.status === "已闭环").length
  322. const correct = Math.floor(closed * (0.85 + Math.random() * 0.1)) // 假定人工复核正确率
  323. const wrong = Math.max(closed - correct, 0)
  324. return {
  325. title: { text: "预警正确性(闭环内)", left: "center", textStyle: { fontSize: 14 } },
  326. tooltip: { trigger: "item", formatter: "{b}: {c} ({d}%)" },
  327. legend: { bottom: 0 },
  328. color: [ok, danger],
  329. series: [
  330. {
  331. type: "pie",
  332. radius: ["35%", "60%"],
  333. data: [
  334. { name: "正确预警", value: correct },
  335. { name: "误报", value: wrong },
  336. ],
  337. },
  338. ],
  339. } as const
  340. }, [alerts])
  341. const radarCapacityOption = useMemo(
  342. () => ({
  343. title: { text: "应急保障能力雷达", left: "center", textStyle: { fontSize: 14 } },
  344. tooltip: {},
  345. radar: {
  346. indicator: [
  347. { name: "抢修速度", max: 100 },
  348. { name: "物资充足", max: 100 },
  349. { name: "跨部门联动", max: 100 },
  350. { name: "覆盖广度", max: 100 },
  351. { name: "应急演练", max: 100 },
  352. ],
  353. },
  354. color: [primary],
  355. series: [
  356. {
  357. type: "radar",
  358. data: [{ value: [78, 85, 72, 88, 76], name: "当前" }],
  359. areaStyle: { color: primary + "33" },
  360. },
  361. ],
  362. }),
  363. []
  364. )
  365. // Tables
  366. const facilityColumns: TableColumnsType<Facility> = [
  367. { title: "行业", dataIndex: "industry", key: "industry", width: 90 },
  368. { title: "类型", dataIndex: "type", key: "type" },
  369. { title: "数量", dataIndex: "count", key: "count", width: 100 },
  370. { title: "平均年限", dataIndex: "age", key: "age", width: 120, render: (v) => `${v} 年` },
  371. { title: "分布区域", dataIndex: "region", key: "region", width: 120 },
  372. ]
  373. const alertColumns: TableColumnsType<Alert> = [
  374. { title: "等级", dataIndex: "level", key: "level", width: 90, render: (v) => <LevelTag level={v} /> },
  375. { title: "行业", dataIndex: "industry", key: "industry", width: 90 },
  376. { title: "类型", dataIndex: "type", key: "type", width: 140 },
  377. { title: "时间", dataIndex: "time", key: "time", width: 160 },
  378. { title: "状态", dataIndex: "status", key: "status", width: 120, render: (s) => <StatusBadge s={s} /> },
  379. { title: "位置", dataIndex: "location", key: "location", width: 120 },
  380. {
  381. title: "操作",
  382. key: "action",
  383. render: (_, record) => (
  384. <Space size="small">
  385. <a
  386. onClick={() => {
  387. setSelectedAlert(record)
  388. setDrawerOpen(true)
  389. }}
  390. >
  391. 查看
  392. </a>
  393. <a>派单</a>
  394. <a>联动</a>
  395. </Space>
  396. ),
  397. width: 160,
  398. fixed: "right",
  399. },
  400. ]
  401. const deviceColumns: TableColumnsType<Device> = [
  402. { title: "行业", dataIndex: "industry", key: "industry", width: 90 },
  403. { title: "类型", dataIndex: "type", key: "type", width: 100 },
  404. {
  405. title: "状态",
  406. dataIndex: "status",
  407. key: "status",
  408. width: 100,
  409. render: (s) => <Badge status={s === "在线" ? "success" : "default"} text={s} />,
  410. filters: [
  411. { text: "在线", value: "在线" },
  412. { text: "离线", value: "离线" },
  413. ],
  414. onFilter: (v, r) => r.status === v,
  415. },
  416. {
  417. title: "风险",
  418. dataIndex: "risk",
  419. key: "risk",
  420. width: 100,
  421. render: (r) => <Tag color={r === "高" ? danger : r === "中" ? warn : ok}>{r}</Tag>,
  422. filters: [
  423. { text: "高", value: "高" },
  424. { text: "中", value: "中" },
  425. { text: "低", value: "低" },
  426. ],
  427. onFilter: (v, r) => r.risk === v,
  428. },
  429. { title: "编号", dataIndex: "id", key: "id" },
  430. ]
  431. const alertLevelColor = (lvl: Alert["level"]) =>
  432. lvl === "I级" ? danger : lvl === "II级" ? warn : lvl === "III级" ? "#f97316" : ok
  433. // Derived numbers
  434. const stats = [
  435. {
  436. title: "燃气总规模",
  437. value: totals["燃气"],
  438. icon: <Flame className="text-white" size={18} />,
  439. bg: "bg-emerald-500",
  440. },
  441. {
  442. title: "供水总规模",
  443. value: totals["供水"],
  444. icon: <Droplets className="text-white" size={18} />,
  445. bg: "bg-teal-500",
  446. },
  447. {
  448. title: "排水总规模",
  449. value: totals["排水"],
  450. icon: <Waves className="text-white" size={18} />,
  451. bg: "bg-cyan-500",
  452. },
  453. {
  454. title: "在线设备",
  455. value: devices.filter((d) => d.status === "在线").length,
  456. icon: <Gauge className="text-white" size={18} />,
  457. bg: "bg-lime-500",
  458. },
  459. ]
  460. // Map markers for device distribution
  461. const markers = devices.slice(0, 120).map((d) => ({
  462. id: d.id,
  463. top: `${Math.floor(d.lat * 85) + 5}%`,
  464. left: `${Math.floor(d.lng * 90) + 5}%`,
  465. color: d.risk === "高" ? danger : d.risk === "中" ? warn : ok,
  466. title: `${d.industry}/${d.type}(${d.status})`,
  467. }))
  468. const themeTokens = useMemo(
  469. () => ({
  470. token: {
  471. colorPrimary: primary,
  472. colorInfo: primary,
  473. borderRadius: 8,
  474. fontSize: 13,
  475. },
  476. components: {
  477. Layout: {
  478. headerBg: isDark ? "#0f172a" : "#ffffff",
  479. siderBg: isDark ? "#0b1220" : "#ffffff",
  480. bodyBg: isDark ? "#0b1220" : "#f6f7f9",
  481. },
  482. Menu: {
  483. itemSelectedBg: isDark ? "#0ea5a8" : "#d1fae5",
  484. itemSelectedColor: isDark ? "#fff" : "#0f172a",
  485. itemActiveBg: "#0ea5a822",
  486. },
  487. },
  488. }),
  489. [isDark]
  490. )
  491. return (
  492. <ConfigProvider locale={zhCN} theme={themeTokens}>
  493. <Layout style={{ minHeight: "100vh" }}>
  494. <Sider collapsible collapsed={collapsed} onCollapse={setCollapsed} width={240} theme={isDark ? "dark" : "light"}>
  495. <div className="flex items-center gap-2 px-4 py-3">
  496. <ShieldCheck className="text-emerald-400" size={22} />
  497. {!collapsed && (
  498. <div className={isDark ? "text-emerald-100 font-medium" : "text-emerald-700 font-medium"}>
  499. 城市生命线驾驶舱
  500. </div>
  501. )}
  502. </div>
  503. <Menu
  504. theme={isDark ? "dark" : "light"}
  505. mode="inline"
  506. selectedKeys={[selectedMenu]}
  507. onClick={(e) => setSelectedMenu(e.key)}
  508. items={menuItems}
  509. />
  510. </Sider>
  511. <Layout>
  512. <Header className="flex items-center justify-between px-4">
  513. <div className={`flex items-center gap-3 ${isDark ? "text-white" : "text-slate-800"}`}>
  514. <Factory size={18} />
  515. <span className="font-medium">综合运行态势</span>
  516. <span className={`text-xs hidden md:inline ${isDark ? "text-slate-300" : "text-slate-500"}`}>
  517. 更新时间 {dayjs().format("YYYY-MM-DD HH:mm:ss")}
  518. </span>
  519. </div>
  520. <div className="flex items-center gap-3">
  521. <Select
  522. size="small"
  523. defaultValue="全市"
  524. options={[
  525. { value: "全市", label: "全市" },
  526. { value: "中心城区", label: "中心城区" },
  527. { value: "东区", label: "东区" },
  528. { value: "西区", label: "西区" },
  529. { value: "南区", label: "南区" },
  530. { value: "北区", label: "北区" },
  531. ]}
  532. style={{ width: 120 }}
  533. />
  534. <RangePicker size="small" />
  535. <Button size="small" onClick={() => setIsDark((v) => !v)} icon={isDark ? <Sun size={14} /> : <Moon size={14} />}>
  536. {isDark ? "暗色" : "白色"}
  537. </Button>
  538. </div>
  539. </Header>
  540. <Content className="p-4 md:p-6">
  541. {selectedMenu === "overview" && (
  542. <section className="space-y-4">
  543. <Row gutter={[16, 16]}>
  544. {stats.map((s) => (
  545. <Col xs={24} sm={12} md={12} lg={6} key={s.title}>
  546. <Card>
  547. <div className="flex items-center gap-3">
  548. <div className={`w-9 h-9 rounded-md flex items-center justify-center ${s.bg}`}>{s.icon}</div>
  549. <div className="flex-1">
  550. <div className="text-xs text-slate-500">{s.title}</div>
  551. <div className="text-xl font-semibold">{s.value.toLocaleString()}</div>
  552. </div>
  553. <AntdTooltip title="环比增长">
  554. <TrendingUp className="text-emerald-500" size={18} />
  555. </AntdTooltip>
  556. </div>
  557. </Card>
  558. </Col>
  559. ))}
  560. </Row>
  561. <Row gutter={[16, 16]}>
  562. <Col xs={24} md={12} lg={8}>
  563. <Card>
  564. <EChart option={infraPieOption} />
  565. </Card>
  566. </Col>
  567. <Col xs={24} md={12} lg={8}>
  568. <Card>
  569. <EChart option={deviceBarOption} />
  570. </Card>
  571. </Col>
  572. <Col xs={24} md={24} lg={8}>
  573. <Card>
  574. <EChart option={onlineGaugeOption} />
  575. </Card>
  576. </Col>
  577. </Row>
  578. <Row gutter={[16, 16]}>
  579. <Col xs={24} md={12}>
  580. <Card>
  581. <EChart option={alertTrendOption} />
  582. </Card>
  583. </Col>
  584. <Col xs={24} md={12}>
  585. <Card>
  586. <EChart option={riskBarOption} />
  587. </Card>
  588. </Col>
  589. </Row>
  590. <Card title="监测分布(示意)" extra={<span className="text-xs text-slate-500">标注颜色代表风险等级</span>}>
  591. <div className="relative w-full h-[380px] rounded-md overflow-hidden bg-slate-100">
  592. <img
  593. src="/images/city-map.png"
  594. alt="城市简化地图"
  595. className="absolute inset-0 w-full h-full object-cover opacity-90"
  596. />
  597. {markers.map((m) => (
  598. <AntdTooltip key={m.id} title={m.title}>
  599. <div
  600. className="absolute w-2.5 h-2.5 rounded-full ring-2 ring-white/70"
  601. style={{ top: m.top, left: m.left, backgroundColor: m.color }}
  602. />
  603. </AntdTooltip>
  604. ))}
  605. <div className="absolute right-3 top-3 bg-white/90 backdrop-blur rounded-md p-2 text-xs shadow">
  606. <div className="font-medium mb-1 flex items-center gap-1">
  607. <MapIcon size={14} /> 覆盖与风险
  608. </div>
  609. <div className="flex items-center gap-3">
  610. <div className="flex items-center gap-1">
  611. <span className="inline-block w-2.5 h-2.5 rounded-full" style={{ background: danger }} /> 高
  612. </div>
  613. <div className="flex items-center gap-1">
  614. <span className="inline-block w-2.5 h-2.5 rounded-full" style={{ background: warn }} /> 中
  615. </div>
  616. <div className="flex items-center gap-1">
  617. <span className="inline-block w-2.5 h-2.5 rounded-full" style={{ background: ok }} /> 低
  618. </div>
  619. </div>
  620. </div>
  621. </div>
  622. </Card>
  623. </section>
  624. )}
  625. {selectedMenu === "asset" && (
  626. <section className="space-y-4">
  627. <Tabs
  628. activeKey={assetTab}
  629. onChange={setAssetTab}
  630. items={[
  631. { key: "archive", label: "基础档案" },
  632. { key: "run", label: "运行信息" },
  633. { key: "mgmt", label: "管理信息" },
  634. { key: "emergency", label: "应急保障" },
  635. ]}
  636. />
  637. {assetTab === "archive" && (
  638. <>
  639. <Row gutter={[16, 16]}>
  640. <Col xs={24} lg={14}>
  641. <Card title="设施基础档案">
  642. <Table
  643. size="small"
  644. rowKey="id"
  645. columns={facilityColumns}
  646. dataSource={facilities}
  647. pagination={{ pageSize: 8 }}
  648. scroll={{ x: 700 }}
  649. />
  650. </Card>
  651. </Col>
  652. <Col xs={24} lg={10}>
  653. <Card title="行业重点指标">
  654. <div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
  655. <div>
  656. <div className="text-xs text-slate-500 mb-1">平均设施年限</div>
  657. <Statistic value={Math.round(facilities.reduce((a, b) => a + b.age, 0) / facilities.length)} suffix="年" />
  658. <Progress percent={Math.min(100, Math.round((facilities.filter((f) => f.age >= 20).length / facilities.length) * 100))} size="small" />
  659. <div className="text-xs text-slate-500 mt-1">20年以上占比</div>
  660. </div>
  661. <div>
  662. <div className="text-xs text-slate-500 mb-1">重点设施数量</div>
  663. <Statistic value={facilities.filter((f) => f.type.includes("主") || f.type.includes("厂")).reduce((a, b) => a + b.count, 0)} />
  664. <div className="text-xs text-slate-500 mt-1">主干/厂站等关键设施总量</div>
  665. </div>
  666. </div>
  667. </Card>
  668. <Card className="mt-4" title="分布热点(示意)">
  669. <EChart
  670. option={{
  671. title: { text: "区域设施数量", left: "center", textStyle: { fontSize: 14 } },
  672. xAxis: { type: "category", data: ["中心城区", "东区", "西区", "南区", "北区"] },
  673. yAxis: { type: "value" },
  674. grid: { left: 40, right: 10, bottom: 20, top: 40 },
  675. color: [primary],
  676. series: [
  677. {
  678. type: "bar",
  679. data: ["中心城区", "东区", "西区", "南区", "北区"].map(
  680. (r) => facilities.filter((f) => f.region === r).reduce((a, b) => a + b.count, 0)
  681. ),
  682. barWidth: "50%",
  683. },
  684. ],
  685. }}
  686. />
  687. </Card>
  688. </Col>
  689. </Row>
  690. </>
  691. )}
  692. {assetTab === "run" && (
  693. <>
  694. <Row gutter={[16, 16]}>
  695. <Col xs={24} md={12}>
  696. <Card title="日常供应能力(示意)">
  697. <EChart
  698. option={{
  699. tooltip: { trigger: "axis" },
  700. legend: { bottom: 0 },
  701. grid: { left: 40, right: 10, top: 20, bottom: 40 },
  702. xAxis: { type: "category", data: Array.from({ length: 24 }).map((_, i) => `${i}:00`) },
  703. yAxis: { type: "value" },
  704. color: [primary, "#f59e0b"],
  705. series: [
  706. { name: "供水(万m³/h)", type: "line", smooth: true, data: Array.from({ length: 24 }).map(() => 50 + Math.random() * 20) },
  707. { name: "燃气(万m³/h)", type: "line", smooth: true, data: Array.from({ length: 24 }).map(() => 30 + Math.random() * 15) },
  708. ],
  709. }}
  710. />
  711. </Card>
  712. </Col>
  713. <Col xs={24} md={12}>
  714. <Card title="承载能力(示意)">
  715. <EChart
  716. option={{
  717. tooltip: { trigger: "axis" },
  718. grid: { left: 40, right: 10, top: 20, bottom: 40 },
  719. xAxis: { type: "category", data: ["中心", "东", "西", "南", "北"] },
  720. yAxis: { type: "value" },
  721. color: [primary],
  722. series: [{ type: "bar", data: [92, 86, 74, 80, 77] }],
  723. }}
  724. />
  725. </Card>
  726. </Col>
  727. </Row>
  728. </>
  729. )}
  730. {assetTab === "mgmt" && (
  731. <>
  732. <Row gutter={[16, 16]}>
  733. <Col xs={24} md={12}>
  734. <Card title="管理单位信息">
  735. <Descriptions size="small" column={1} bordered>
  736. <Descriptions.Item label="燃气管理单位">市燃气集团、区属燃气公司等(共 6 家)</Descriptions.Item>
  737. <Descriptions.Item label="供水管理单位">市自来水公司、二供物业等(共 9 家)</Descriptions.Item>
  738. <Descriptions.Item label="排水管理单位">城排中心、各区运营公司(共 7 家)</Descriptions.Item>
  739. <Descriptions.Item label="产权分布">市属 60%,区属 30%,社会 10%</Descriptions.Item>
  740. </Descriptions>
  741. <Divider className="my-3" />
  742. <Timeline
  743. items={[
  744. { color: "green", children: "制度更新:设施巡检标准(本月)" },
  745. { color: "blue", children: "完成年度普查 80%" },
  746. { color: "orange", children: "外包维保单位进场(上周)" },
  747. ]}
  748. />
  749. </Card>
  750. </Col>
  751. <Col xs={24} md={12}>
  752. <Card title="产权分布">
  753. <EChart
  754. option={{
  755. tooltip: { trigger: "item" },
  756. legend: { bottom: 0 },
  757. color: [primary, "#34d399", "#a7f3d0"],
  758. series: [
  759. { type: "pie", radius: ["35%", "60%"], data: [{ value: 60, name: "市属" }, { value: 30, name: "区属" }, { value: 10, name: "社会" }] },
  760. ],
  761. }}
  762. />
  763. </Card>
  764. </Col>
  765. </Row>
  766. </>
  767. )}
  768. {assetTab === "emergency" && (
  769. <>
  770. <Row gutter={[16, 16]}>
  771. <Col xs={24} md={12}>
  772. <Card title="应急资源配置">
  773. <div className="grid grid-cols-2 gap-4">
  774. <Card size="small">
  775. <div className="text-xs text-slate-500">物资仓库</div>
  776. <div className="text-xl font-semibold mt-1">12 处</div>
  777. <Progress percent={78} status="active" size="small" />
  778. <div className="text-xs text-slate-500 mt-1">库存充足度</div>
  779. </Card>
  780. <Card size="small">
  781. <div className="text-xs text-slate-500">抢修队伍</div>
  782. <div className="text-xl font-semibold mt-1">26 支</div>
  783. <Progress percent={86} status="active" size="small" />
  784. <div className="text-xs text-slate-500 mt-1">到岗率</div>
  785. </Card>
  786. <Card size="small">
  787. <div className="text-xs text-slate-500">重点防护目标</div>
  788. <div className="text-xl font-semibold mt-1">143 处</div>
  789. <Progress percent={92} status="active" size="small" />
  790. <div className="text-xs text-slate-500 mt-1">纳入台账比例</div>
  791. </Card>
  792. <Card size="small">
  793. <div className="text-xs text-slate-500">联动单位</div>
  794. <div className="text-xl font-semibold mt-1">19 家</div>
  795. <Progress percent={74} status="active" size="small" />
  796. <div className="text-xs text-slate-500 mt-1">联动成熟度</div>
  797. </Card>
  798. </div>
  799. </Card>
  800. </Col>
  801. <Col xs={24} md={12}>
  802. <Card>
  803. <EChart option={radarCapacityOption} />
  804. </Card>
  805. </Col>
  806. </Row>
  807. </>
  808. )}
  809. </section>
  810. )}
  811. {selectedMenu === "monitor" && (
  812. <section className="space-y-4">
  813. <Tabs
  814. activeKey={monitorTab}
  815. onChange={setMonitorTab}
  816. items={[
  817. { key: "summary", label: "监测概览" },
  818. { key: "distribution", label: "监测分布" },
  819. { key: "running", label: "运行概况" },
  820. ]}
  821. />
  822. {monitorTab === "summary" && (
  823. <>
  824. <Row gutter={[16, 16]}>
  825. <Col xs={24} md={12} lg={8}>
  826. <Card>
  827. <EChart option={onlineGaugeOption} />
  828. </Card>
  829. </Col>
  830. <Col xs={24} md={12} lg={8}>
  831. <Card>
  832. <EChart option={deviceBarOption} />
  833. </Card>
  834. </Col>
  835. <Col xs={24} md={24} lg={8}>
  836. <Card>
  837. <EChart option={riskBarOption} />
  838. </Card>
  839. </Col>
  840. </Row>
  841. </>
  842. )}
  843. {monitorTab === "distribution" && (
  844. <>
  845. <Card title="监测分布(按行业与风险)">
  846. <Row gutter={[16, 16]}>
  847. {(["燃气", "供水", "排水"] as const).map((ind) => (
  848. <Col xs={24} md={8} key={ind}>
  849. <Card size="small" title={ind}>
  850. <div className="flex items-center gap-4">
  851. <div className="flex-1">
  852. <div className="text-xs text-slate-500">设备在线</div>
  853. <div className="text-lg font-semibold">
  854. {devices.filter((d) => d.industry === ind && d.status === "在线").length}
  855. </div>
  856. <div className="text-xs text-slate-500">总量 {devices.filter((d) => d.industry === ind).length}</div>
  857. </div>
  858. <div className="flex-1">
  859. <div className="text-xs text-slate-500">高风险</div>
  860. <div className="text-lg font-semibold">
  861. {devices.filter((d) => d.industry === ind && d.risk === "高").length}
  862. </div>
  863. <Progress
  864. percent={Math.round(
  865. (devices.filter((d) => d.industry === ind && d.risk === "高").length /
  866. Math.max(devices.filter((d) => d.industry === ind).length, 1)) *
  867. 100
  868. )}
  869. size="small"
  870. />
  871. </div>
  872. </div>
  873. </Card>
  874. </Col>
  875. ))}
  876. </Row>
  877. </Card>
  878. <Card title="一张图(示意)">
  879. <div className="relative w-full h-[380px] rounded-md overflow-hidden bg-slate-100">
  880. <img
  881. src="/images/city-map.png"
  882. alt="城市简化地图"
  883. className="absolute inset-0 w-full h-full object-cover opacity-90"
  884. />
  885. {markers.map((m) => (
  886. <AntdTooltip key={m.id} title={m.title}>
  887. <div
  888. className="absolute w-2.5 h-2.5 rounded-full ring-2 ring-white/70"
  889. style={{ top: m.top, left: m.left, backgroundColor: m.color }}
  890. />
  891. </AntdTooltip>
  892. ))}
  893. </div>
  894. </Card>
  895. </>
  896. )}
  897. {monitorTab === "running" && (
  898. <>
  899. <Card title="运行概况(报警覆盖)">
  900. <EChart
  901. option={{
  902. tooltip: { trigger: "axis" },
  903. legend: { bottom: 0 },
  904. grid: { left: 40, right: 10, top: 20, bottom: 40 },
  905. xAxis: { type: "category", data: Array.from({ length: 12 }).map((_, i) => dayjs().subtract(11 - i, "month").format("YYYY-MM")) },
  906. yAxis: { type: "value" },
  907. color: [primary, "#f59e0b", "#a855f7"],
  908. series: (["燃气", "供水", "排水"] as const).map((ind, idx) => ({
  909. name: ind,
  910. type: "bar",
  911. stack: "sum",
  912. emphasis: { focus: "series" },
  913. data: Array.from({ length: 12 }).map(() => Math.floor(Math.random() * (idx === 0 ? 50 : idx === 1 ? 40 : 30))),
  914. })),
  915. }}
  916. />
  917. </Card>
  918. <Row gutter={[16, 16]} className="mt-1">
  919. <Col xs={24} md={12}>
  920. <Card>
  921. <EChart option={alertTrendOption} />
  922. </Card>
  923. </Col>
  924. <Col xs={24} md={12}>
  925. <Card>
  926. <EChart option={deviceBarOption} />
  927. </Card>
  928. </Col>
  929. </Row>
  930. </>
  931. )}
  932. </section>
  933. )}
  934. {selectedMenu === "alert" && (
  935. <section className="space-y-4">
  936. <Tabs
  937. activeKey={alertTab}
  938. onChange={setAlertTab}
  939. items={[
  940. { key: "current", label: "当前预警" },
  941. { key: "history", label: "历史分析" },
  942. { key: "efficiency", label: "预警效率" },
  943. { key: "analysis", label: "预警分析" },
  944. ]}
  945. />
  946. {alertTab === "current" && (
  947. <>
  948. <Row gutter={[16, 16]}>
  949. <Col xs={24} lg={16}>
  950. <Card title="总体预警处置情况">
  951. <Table
  952. size="small"
  953. rowKey="id"
  954. columns={alertColumns}
  955. dataSource={alerts}
  956. pagination={{ pageSize: 8 }}
  957. onRow={(record) => ({
  958. onClick: () => {
  959. setSelectedAlert(record)
  960. setDrawerOpen(true)
  961. },
  962. })}
  963. scroll={{ x: 900 }}
  964. />
  965. </Card>
  966. </Col>
  967. <Col xs={24} lg={8}>
  968. <Card title="处置效率">
  969. <div className="grid grid-cols-2 gap-4">
  970. <div>
  971. <div className="text-xs text-slate-500">平均处置时效</div>
  972. <div className="text-xl font-semibold mt-1">{(45 + Math.random() * 30).toFixed(0)} 分钟</div>
  973. <Progress percent={78} status="active" size="small" />
  974. <div className="text-xs text-slate-500 mt-1">较上月 +6%</div>
  975. </div>
  976. <div>
  977. <div className="text-xs text-slate-500">闭环率</div>
  978. <div className="text-xl font-semibold mt-1">
  979. {Math.round((alerts.filter((a) => a.status === "已闭环").length / Math.max(alerts.length, 1)) * 100)}%
  980. </div>
  981. <Progress percent={86} status="active" size="small" />
  982. <div className="text-xs text-slate-500 mt-1">较上周 +2%</div>
  983. </div>
  984. </div>
  985. </Card>
  986. <Card className="mt-4">
  987. <EChart option={efficiencyPieOption} />
  988. </Card>
  989. </Col>
  990. </Row>
  991. <Drawer
  992. title={
  993. <div className="flex items-center gap-2">
  994. <AlertTriangle size={18} color={selectedAlert ? alertLevelColor(selectedAlert.level) : primary} />
  995. <span>预警详情</span>
  996. </div>
  997. }
  998. placement="right"
  999. width={520}
  1000. open={drawerOpen}
  1001. onClose={() => setDrawerOpen(false)}
  1002. >
  1003. {selectedAlert ? (
  1004. <div className="space-y-4">
  1005. <Descriptions size="small" column={1} bordered>
  1006. <Descriptions.Item label="预警编号">{selectedAlert.id}</Descriptions.Item>
  1007. <Descriptions.Item label="等级">
  1008. <LevelTag level={selectedAlert.level} />
  1009. </Descriptions.Item>
  1010. <Descriptions.Item label="行业">{selectedAlert.industry}</Descriptions.Item>
  1011. <Descriptions.Item label="类型">{selectedAlert.type}</Descriptions.Item>
  1012. <Descriptions.Item label="时间">{selectedAlert.time}</Descriptions.Item>
  1013. <Descriptions.Item label="位置">{selectedAlert.location}</Descriptions.Item>
  1014. <Descriptions.Item label="状态">
  1015. <StatusBadge s={selectedAlert.status} />
  1016. </Descriptions.Item>
  1017. <Descriptions.Item label="描述">{selectedAlert.desc}</Descriptions.Item>
  1018. </Descriptions>
  1019. <Card size="small" title="事件时序">
  1020. <EChart
  1021. option={{
  1022. grid: { left: 30, right: 10, top: 20, bottom: 20 },
  1023. xAxis: { type: "category", data: ["发现", "确认", "处置", "复盘"] },
  1024. yAxis: { type: "value" },
  1025. color: [primary],
  1026. series: [{ type: "line", smooth: true, data: [0, 12, 38, 60] }],
  1027. }}
  1028. />
  1029. </Card>
  1030. <Card size="small" title="一张图联动(示意)">
  1031. <div className="relative w-full h-[200px] rounded-md overflow-hidden">
  1032. <img src="/images/city-map.png" alt="地图联动示意图" className="absolute inset-0 w-full h-full object-cover opacity-90" />
  1033. <div className="absolute inset-0">
  1034. <div
  1035. className="absolute w-3 h-3 rounded-full ring-2 ring-white animate-pulse"
  1036. style={{ top: "42%", left: "56%", background: alertLevelColor(selectedAlert.level) }}
  1037. title="预警位置"
  1038. />
  1039. </div>
  1040. </div>
  1041. </Card>
  1042. <Space>
  1043. <a className="text-emerald-600">查看工单</a>
  1044. <a className="text-emerald-600">下达指令</a>
  1045. <a className="text-emerald-600">通知联动</a>
  1046. </Space>
  1047. </div>
  1048. ) : (
  1049. <div className="text-slate-500 text-sm">请选择左侧预警查看详情。</div>
  1050. )}
  1051. </Drawer>
  1052. </>
  1053. )}
  1054. {alertTab === "history" && (
  1055. <>
  1056. <Row gutter={[16, 16]}>
  1057. <Col xs={24} md={12}>
  1058. <Card title="各行业预警数量(近6月)">
  1059. <EChart
  1060. option={{
  1061. tooltip: { trigger: "axis" },
  1062. legend: { bottom: 0 },
  1063. grid: { left: 40, right: 10, top: 20, bottom: 40 },
  1064. xAxis: { type: "category", data: Array.from({ length: 6 }).map((_, i) => dayjs().subtract(5 - i, "month").format("YYYY-MM")) },
  1065. yAxis: { type: "value" },
  1066. color: [primary, "#f59e0b", "#a855f7"],
  1067. series: (["燃气", "供水", "排水"] as const).map((ind, idx) => ({
  1068. name: ind,
  1069. type: "line",
  1070. smooth: true,
  1071. data: Array.from({ length: 6 }).map(() => Math.floor(Math.random() * (idx === 0 ? 60 : idx === 1 ? 45 : 35)) + 5),
  1072. })),
  1073. }}
  1074. />
  1075. </Card>
  1076. </Col>
  1077. <Col xs={24} md={12}>
  1078. <Card title="已闭环预警(示意)">
  1079. <Table
  1080. size="small"
  1081. rowKey="id"
  1082. columns={[
  1083. { title: "编号", dataIndex: "id" },
  1084. { title: "类型", dataIndex: "type" },
  1085. { title: "行业", dataIndex: "industry", width: 90 },
  1086. { title: "完成时间", dataIndex: "time", width: 160 },
  1087. ]}
  1088. dataSource={alerts.filter((a) => a.status === "已闭环")}
  1089. pagination={{ pageSize: 6 }}
  1090. />
  1091. </Card>
  1092. </Col>
  1093. </Row>
  1094. </>
  1095. )}
  1096. {alertTab === "efficiency" && (
  1097. <>
  1098. <Row gutter={[16, 16]}>
  1099. <Col xs={24} md={12}>
  1100. <Card title="整体效率">
  1101. <div className="grid grid-cols-2 gap-4">
  1102. <div>
  1103. <div className="text-xs text-slate-500">平均处置时效</div>
  1104. <div className="text-xl font-semibold mt-1">{(42 + Math.random() * 25).toFixed(0)} 分钟</div>
  1105. <Progress percent={82} status="active" size="small" />
  1106. <div className="text-xs text-slate-500 mt-1">较上月 +4%</div>
  1107. </div>
  1108. <div>
  1109. <div className="text-xs text-slate-500">正确预警率</div>
  1110. <div className="text-xl font-semibold mt-1">{(88 + Math.random() * 4).toFixed(1)}%</div>
  1111. <Progress percent={89} status="active" size="small" />
  1112. <div className="text-xs text-slate-500 mt-1">核实误报下降</div>
  1113. </div>
  1114. </div>
  1115. </Card>
  1116. </Col>
  1117. <Col xs={24} md={12}>
  1118. <Card>
  1119. <EChart option={efficiencyPieOption} />
  1120. </Card>
  1121. </Col>
  1122. </Row>
  1123. </>
  1124. )}
  1125. {alertTab === "analysis" && (
  1126. <>
  1127. <Row gutter={[16, 16]}>
  1128. <Col xs={24}>
  1129. <Card title="预警类型与成因分布">
  1130. <EChart
  1131. option={{
  1132. tooltip: { trigger: "axis" },
  1133. legend: { bottom: 0 },
  1134. grid: { left: 40, right: 10, top: 20, bottom: 40 },
  1135. xAxis: {
  1136. type: "category",
  1137. data: ["泄漏", "压力异常", "流量突变", "停电", "液位过低", "浊度异常"],
  1138. axisLabel: { rotate: 20 },
  1139. },
  1140. yAxis: { type: "value" },
  1141. color: [primary, "#f59e0b"],
  1142. series: [
  1143. { name: "设备原因", type: "bar", data: [30, 22, 18, 12, 9, 7] },
  1144. { name: "外部原因", type: "bar", data: [18, 15, 14, 28, 11, 10] },
  1145. ],
  1146. }}
  1147. />
  1148. </Card>
  1149. </Col>
  1150. </Row>
  1151. </>
  1152. )}
  1153. </section>
  1154. )}
  1155. {selectedMenu === "devices" && (
  1156. <section className="space-y-4">
  1157. <Row justify="space-between" align="middle">
  1158. <Col>
  1159. <div className="text-base font-medium">设备管理</div>
  1160. </Col>
  1161. <Col>
  1162. <Space>
  1163. <Segmented
  1164. options={["全部", "在线", "离线"]}
  1165. onChange={() => {}}
  1166. aria-label="设备状态筛选"
  1167. />
  1168. <Button size="small" icon={<Table2 size={14} />}>
  1169. 批量导出
  1170. </Button>
  1171. </Space>
  1172. </Col>
  1173. </Row>
  1174. <Card>
  1175. <Table
  1176. size="small"
  1177. rowKey="id"
  1178. columns={deviceColumns}
  1179. dataSource={devices}
  1180. pagination={{ pageSize: 10 }}
  1181. scroll={{ x: 700 }}
  1182. />
  1183. </Card>
  1184. </section>
  1185. )}
  1186. {selectedMenu === "reports" && (
  1187. <section className="space-y-4">
  1188. <Row gutter={[16, 16]}>
  1189. <Col xs={24} md={12}>
  1190. <Card title="月度运行报告(示意)" extra={<Button size="small">导出 PDF</Button>}>
  1191. <EChart
  1192. option={{
  1193. tooltip: { trigger: "axis" },
  1194. grid: { left: 40, right: 10, top: 20, bottom: 30 },
  1195. xAxis: { type: "category", data: ["一", "二", "三", "四", "五", "六"] },
  1196. yAxis: { type: "value" },
  1197. color: [primary],
  1198. series: [{ type: "line", smooth: true, data: [120, 132, 101, 134, 90, 230] }],
  1199. }}
  1200. />
  1201. </Card>
  1202. </Col>
  1203. <Col xs={24} md={12}>
  1204. <Card title="安全事件统计(示意)" extra={<Button size="small">导出 Excel</Button>}>
  1205. <EChart
  1206. option={{
  1207. tooltip: { trigger: "axis" },
  1208. grid: { left: 40, right: 10, top: 20, bottom: 30 },
  1209. xAxis: { type: "category", data: ["燃气", "供水", "排水"] },
  1210. yAxis: { type: "value" },
  1211. color: [primary, "#f59e0b", "#a855f7"],
  1212. series: [{ type: "bar", data: [32, 21, 17], barWidth: "50%" }],
  1213. }}
  1214. />
  1215. </Card>
  1216. </Col>
  1217. </Row>
  1218. </section>
  1219. )}
  1220. {selectedMenu === "incidents" && (
  1221. <section className="space-y-4">
  1222. <Row gutter={[16, 16]}>
  1223. <Col xs={24} md={16}>
  1224. <Card title="事件列表(示意)" extra={<Button size="small">新建事件</Button>}>
  1225. <Empty description="暂无数据(示意)" />
  1226. </Card>
  1227. </Col>
  1228. <Col xs={24} md={8}>
  1229. <Card title="事件趋势(示意)">
  1230. <EChart
  1231. option={{
  1232. tooltip: { trigger: "axis" },
  1233. grid: { left: 40, right: 10, top: 20, bottom: 30 },
  1234. xAxis: { type: "category", data: Array.from({ length: 12 }).map((_, i) => `${i + 1}月`) },
  1235. yAxis: { type: "value" },
  1236. color: [primary],
  1237. series: [{ type: "line", smooth: true, data: Array.from({ length: 12 }).map(() => Math.floor(Math.random() * 20) + 5) }],
  1238. }}
  1239. />
  1240. </Card>
  1241. </Col>
  1242. </Row>
  1243. </section>
  1244. )}
  1245. {selectedMenu === "bigscreen" && (
  1246. <section className="space-y-4">
  1247. <Card title="数据大屏(示意)">
  1248. <Row gutter={[16, 16]}>
  1249. {[
  1250. { title: "设备总数", val: devices.length },
  1251. { title: "在线率", val: `${onlineRate}%` },
  1252. { title: "本月预警", val: (alerts.length + Math.floor(Math.random() * 30)).toString() },
  1253. { title: "闭环率", val: `${Math.round((alerts.filter((a) => a.status === "已闭环").length / Math.max(alerts.length, 1)) * 100)}%` },
  1254. ].map((s) => (
  1255. <Col xs={12} md={6} key={s.title}>
  1256. <Card size="small">
  1257. <div className="text-xs text-slate-500">{s.title}</div>
  1258. <div className="text-2xl font-semibold mt-1">{s.val}</div>
  1259. </Card>
  1260. </Col>
  1261. ))}
  1262. </Row>
  1263. <Row gutter={[16, 16]} className="mt-1">
  1264. <Col xs={24} md={12}>
  1265. <Card>
  1266. <EChart option={deviceBarOption} />
  1267. </Card>
  1268. </Col>
  1269. <Col xs={24} md={12}>
  1270. <Card>
  1271. <EChart option={riskBarOption} />
  1272. </Card>
  1273. </Col>
  1274. </Row>
  1275. </Card>
  1276. </section>
  1277. )}
  1278. {selectedMenu === "settings" && (
  1279. <section className="space-y-4">
  1280. <Card title="预警设置">
  1281. <Row gutter={[16, 16]}>
  1282. <Col xs={24} md={12}>
  1283. <Card size="small" title="阈值设置">
  1284. <div className="grid grid-cols-2 gap-4">
  1285. <div>
  1286. <div className="text-xs text-slate-500 mb-1">压力异常阈值</div>
  1287. <Select defaultValue="P≤0.3MPa" options={[{ value: "P≤0.3MPa", label: "P≤0.3MPa" }, { value: "P≤0.2MPa", label: "P≤0.2MPa" }]} />
  1288. </div>
  1289. <div>
  1290. <div className="text-xs text-slate-500 mb-1">流量突变阈值</div>
  1291. <Select defaultValue="ΔQ≥20%" options={[{ value: "ΔQ≥20%", label: "ΔQ≥20%" }, { value: "ΔQ≥30%", label: "ΔQ≥30%" }]} />
  1292. </div>
  1293. <div>
  1294. <div className="text-xs text-slate-500 mb-1">水质指标(浊度)</div>
  1295. <Select defaultValue="≥5 NTU" options={[{ value: "≥5 NTU", label: "≥5 NTU" }, { value: "≥3 NTU", label: "≥3 NTU" }]} />
  1296. </div>
  1297. <div>
  1298. <div className="text-xs text-slate-500 mb-1">液位过低</div>
  1299. <Select defaultValue="≤20%" options={[{ value: "≤20%", label: "≤20%" }, { value: "≤15%", label: "≤15%" }]} />
  1300. </div>
  1301. </div>
  1302. </Card>
  1303. </Col>
  1304. <Col xs={24} md={12}>
  1305. <Card size="small" title="通知策略">
  1306. <div className="grid grid-cols-2 gap-4">
  1307. <div className="flex items-center justify-between">
  1308. <span>高等级预警短信</span>
  1309. <Switch defaultChecked />
  1310. </div>
  1311. <div className="flex items-center justify-between">
  1312. <span>邮件抄送管理层</span>
  1313. <Switch />
  1314. </div>
  1315. <div className="flex items-center justify-between">
  1316. <span>自动派单</span>
  1317. <Switch />
  1318. </div>
  1319. <div className="flex items-center justify-between">
  1320. <span>与值守大屏联动</span>
  1321. <Switch defaultChecked />
  1322. </div>
  1323. </div>
  1324. </Card>
  1325. </Col>
  1326. </Row>
  1327. </Card>
  1328. </section>
  1329. )}
  1330. </Content>
  1331. </Layout>
  1332. </Layout>
  1333. </ConfigProvider>
  1334. )
  1335. }