page.tsx 59 KB

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