page.tsx 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376
  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 'leaflet/dist/leaflet.css'
  56. import L from 'leaflet'
  57. import GisMap from "@/components/gisMap";
  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. <GisMap height={'50'}/>
  601. </Card>
  602. </section>
  603. )}
  604. {selectedMenu === "asset" && (
  605. <section className="space-y-4">
  606. <Tabs
  607. activeKey={assetTab}
  608. onChange={setAssetTab}
  609. items={[
  610. { key: "archive", label: "基础档案" },
  611. { key: "run", label: "运行信息" },
  612. { key: "mgmt", label: "管理信息" },
  613. { key: "emergency", label: "应急保障" },
  614. ]}
  615. />
  616. {assetTab === "archive" && (
  617. <>
  618. <Row gutter={[16, 16]}>
  619. <Col xs={24} lg={14}>
  620. <Card title="设施基础档案">
  621. <Table
  622. size="small"
  623. rowKey="id"
  624. columns={facilityColumns}
  625. dataSource={facilities}
  626. pagination={{ pageSize: 8 }}
  627. scroll={{ x: 700 }}
  628. />
  629. </Card>
  630. </Col>
  631. <Col xs={24} lg={10}>
  632. <Card title="行业重点指标">
  633. <div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
  634. <div>
  635. <div className="text-xs text-slate-500 mb-1">平均设施年限</div>
  636. <Statistic value={Math.round(facilities.reduce((a, b) => a + b.age, 0) / facilities.length)} suffix="年" />
  637. <Progress percent={Math.min(100, Math.round((facilities.filter((f) => f.age >= 20).length / facilities.length) * 100))} size="small" />
  638. <div className="text-xs text-slate-500 mt-1">20年以上占比</div>
  639. </div>
  640. <div>
  641. <div className="text-xs text-slate-500 mb-1">重点设施数量</div>
  642. <Statistic value={facilities.filter((f) => f.type.includes("主") || f.type.includes("厂")).reduce((a, b) => a + b.count, 0)} />
  643. <div className="text-xs text-slate-500 mt-1">主干/厂站等关键设施总量</div>
  644. </div>
  645. </div>
  646. </Card>
  647. <Card className="mt-4" title="分布热点(示意)">
  648. <EChart
  649. option={{
  650. title: { text: "区域设施数量", left: "center", textStyle: { fontSize: 14 } },
  651. xAxis: { type: "category", data: ["中心城区", "东区", "西区", "南区", "北区"] },
  652. yAxis: { type: "value" },
  653. grid: { left: 40, right: 10, bottom: 20, top: 40 },
  654. color: [primary],
  655. series: [
  656. {
  657. type: "bar",
  658. data: ["中心城区", "东区", "西区", "南区", "北区"].map(
  659. (r) => facilities.filter((f) => f.region === r).reduce((a, b) => a + b.count, 0)
  660. ),
  661. barWidth: "50%",
  662. },
  663. ],
  664. }}
  665. />
  666. </Card>
  667. </Col>
  668. </Row>
  669. </>
  670. )}
  671. {assetTab === "run" && (
  672. <>
  673. <Row gutter={[16, 16]}>
  674. <Col xs={24} md={12}>
  675. <Card title="日常供应能力(示意)">
  676. <EChart
  677. option={{
  678. tooltip: { trigger: "axis" },
  679. legend: { bottom: 0 },
  680. grid: { left: 40, right: 10, top: 20, bottom: 40 },
  681. xAxis: { type: "category", data: Array.from({ length: 24 }).map((_, i) => `${i}:00`) },
  682. yAxis: { type: "value" },
  683. color: [primary, "#f59e0b"],
  684. series: [
  685. { name: "供水(万m³/h)", type: "line", smooth: true, data: Array.from({ length: 24 }).map(() => 50 + Math.random() * 20) },
  686. { name: "燃气(万m³/h)", type: "line", smooth: true, data: Array.from({ length: 24 }).map(() => 30 + Math.random() * 15) },
  687. ],
  688. }}
  689. />
  690. </Card>
  691. </Col>
  692. <Col xs={24} md={12}>
  693. <Card title="承载能力(示意)">
  694. <EChart
  695. option={{
  696. tooltip: { trigger: "axis" },
  697. grid: { left: 40, right: 10, top: 20, bottom: 40 },
  698. xAxis: { type: "category", data: ["中心", "东", "西", "南", "北"] },
  699. yAxis: { type: "value" },
  700. color: [primary],
  701. series: [{ type: "bar", data: [92, 86, 74, 80, 77] }],
  702. }}
  703. />
  704. </Card>
  705. </Col>
  706. </Row>
  707. </>
  708. )}
  709. {assetTab === "mgmt" && (
  710. <>
  711. <Row gutter={[16, 16]}>
  712. <Col xs={24} md={12}>
  713. <Card title="管理单位信息">
  714. <Descriptions size="small" column={1} bordered>
  715. <Descriptions.Item label="燃气管理单位">市燃气集团、区属燃气公司等(共 6 家)</Descriptions.Item>
  716. <Descriptions.Item label="供水管理单位">市自来水公司、二供物业等(共 9 家)</Descriptions.Item>
  717. <Descriptions.Item label="排水管理单位">城排中心、各区运营公司(共 7 家)</Descriptions.Item>
  718. <Descriptions.Item label="产权分布">市属 60%,区属 30%,社会 10%</Descriptions.Item>
  719. </Descriptions>
  720. <Divider className="my-3" />
  721. <Timeline
  722. items={[
  723. { color: "green", children: "制度更新:设施巡检标准(本月)" },
  724. { color: "blue", children: "完成年度普查 80%" },
  725. { color: "orange", children: "外包维保单位进场(上周)" },
  726. ]}
  727. />
  728. </Card>
  729. </Col>
  730. <Col xs={24} md={12}>
  731. <Card title="产权分布">
  732. <EChart
  733. option={{
  734. tooltip: { trigger: "item" },
  735. legend: { bottom: 0 },
  736. color: [primary, "#34d399", "#a7f3d0"],
  737. series: [
  738. { type: "pie", radius: ["35%", "60%"], data: [{ value: 60, name: "市属" }, { value: 30, name: "区属" }, { value: 10, name: "社会" }] },
  739. ],
  740. }}
  741. />
  742. </Card>
  743. </Col>
  744. </Row>
  745. </>
  746. )}
  747. {assetTab === "emergency" && (
  748. <>
  749. <Row gutter={[16, 16]}>
  750. <Col xs={24} md={12}>
  751. <Card title="应急资源配置">
  752. <div className="grid grid-cols-2 gap-4">
  753. <Card size="small">
  754. <div className="text-xs text-slate-500">物资仓库</div>
  755. <div className="text-xl font-semibold mt-1">12 处</div>
  756. <Progress percent={78} status="active" size="small" />
  757. <div className="text-xs text-slate-500 mt-1">库存充足度</div>
  758. </Card>
  759. <Card size="small">
  760. <div className="text-xs text-slate-500">抢修队伍</div>
  761. <div className="text-xl font-semibold mt-1">26 支</div>
  762. <Progress percent={86} status="active" size="small" />
  763. <div className="text-xs text-slate-500 mt-1">到岗率</div>
  764. </Card>
  765. <Card size="small">
  766. <div className="text-xs text-slate-500">重点防护目标</div>
  767. <div className="text-xl font-semibold mt-1">143 处</div>
  768. <Progress percent={92} status="active" size="small" />
  769. <div className="text-xs text-slate-500 mt-1">纳入台账比例</div>
  770. </Card>
  771. <Card size="small">
  772. <div className="text-xs text-slate-500">联动单位</div>
  773. <div className="text-xl font-semibold mt-1">19 家</div>
  774. <Progress percent={74} status="active" size="small" />
  775. <div className="text-xs text-slate-500 mt-1">联动成熟度</div>
  776. </Card>
  777. </div>
  778. </Card>
  779. </Col>
  780. <Col xs={24} md={12}>
  781. <Card>
  782. <EChart option={radarCapacityOption} />
  783. </Card>
  784. </Col>
  785. </Row>
  786. </>
  787. )}
  788. </section>
  789. )}
  790. {selectedMenu === "monitor" && (
  791. <section className="space-y-4">
  792. <Tabs
  793. activeKey={monitorTab}
  794. onChange={setMonitorTab}
  795. items={[
  796. { key: "summary", label: "监测概览" },
  797. { key: "distribution", label: "监测分布" },
  798. { key: "running", label: "运行概况" },
  799. ]}
  800. />
  801. {monitorTab === "summary" && (
  802. <>
  803. <Row gutter={[16, 16]}>
  804. <Col xs={24} md={12} lg={8}>
  805. <Card>
  806. <EChart option={onlineGaugeOption} />
  807. </Card>
  808. </Col>
  809. <Col xs={24} md={12} lg={8}>
  810. <Card>
  811. <EChart option={deviceBarOption} />
  812. </Card>
  813. </Col>
  814. <Col xs={24} md={24} lg={8}>
  815. <Card>
  816. <EChart option={riskBarOption} />
  817. </Card>
  818. </Col>
  819. </Row>
  820. </>
  821. )}
  822. {monitorTab === "distribution" && (
  823. <>
  824. <Card title="监测分布(按行业与风险)">
  825. <Row gutter={[16, 16]}>
  826. {(["燃气", "供水", "排水"] as const).map((ind) => (
  827. <Col xs={24} md={8} key={ind}>
  828. <Card size="small" title={ind}>
  829. <div className="flex items-center gap-4">
  830. <div className="flex-1">
  831. <div className="text-xs text-slate-500">设备在线</div>
  832. <div className="text-lg font-semibold">
  833. {devices.filter((d) => d.industry === ind && d.status === "在线").length}
  834. </div>
  835. <div className="text-xs text-slate-500">总量 {devices.filter((d) => d.industry === ind).length}</div>
  836. </div>
  837. <div className="flex-1">
  838. <div className="text-xs text-slate-500">高风险</div>
  839. <div className="text-lg font-semibold">
  840. {devices.filter((d) => d.industry === ind && d.risk === "高").length}
  841. </div>
  842. <Progress
  843. percent={Math.round(
  844. (devices.filter((d) => d.industry === ind && d.risk === "高").length /
  845. Math.max(devices.filter((d) => d.industry === ind).length, 1)) *
  846. 100
  847. )}
  848. size="small"
  849. />
  850. </div>
  851. </div>
  852. </Card>
  853. </Col>
  854. ))}
  855. </Row>
  856. </Card>
  857. <Card title="(示意)">
  858. <div className="relative w-full h-[380px] rounded-md overflow-hidden bg-slate-100">
  859. <img
  860. src="/images/city-map.png"
  861. alt="城市简化地图"
  862. className="absolute inset-0 w-full h-full object-cover opacity-90"
  863. />
  864. {markers.map((m) => (
  865. <AntdTooltip key={m.id} title={m.title}>
  866. <div
  867. className="absolute w-2.5 h-2.5 rounded-full ring-2 ring-white/70"
  868. style={{ top: m.top, left: m.left, backgroundColor: m.color }}
  869. />
  870. </AntdTooltip>
  871. ))}
  872. </div>
  873. </Card>
  874. </>
  875. )}
  876. {monitorTab === "running" && (
  877. <>
  878. <Card title="运行概况(报警覆盖)">
  879. <EChart
  880. option={{
  881. tooltip: { trigger: "axis" },
  882. legend: { bottom: 0 },
  883. grid: { left: 40, right: 10, top: 20, bottom: 40 },
  884. xAxis: { type: "category", data: Array.from({ length: 12 }).map((_, i) => dayjs().subtract(11 - i, "month").format("YYYY-MM")) },
  885. yAxis: { type: "value" },
  886. color: [primary, "#f59e0b", "#a855f7"],
  887. series: (["燃气", "供水", "排水"] as const).map((ind, idx) => ({
  888. name: ind,
  889. type: "bar",
  890. stack: "sum",
  891. emphasis: { focus: "series" },
  892. data: Array.from({ length: 12 }).map(() => Math.floor(Math.random() * (idx === 0 ? 50 : idx === 1 ? 40 : 30))),
  893. })),
  894. }}
  895. />
  896. </Card>
  897. <Row gutter={[16, 16]} className="mt-1">
  898. <Col xs={24} md={12}>
  899. <Card>
  900. <EChart option={alertTrendOption} />
  901. </Card>
  902. </Col>
  903. <Col xs={24} md={12}>
  904. <Card>
  905. <EChart option={deviceBarOption} />
  906. </Card>
  907. </Col>
  908. </Row>
  909. </>
  910. )}
  911. </section>
  912. )}
  913. {selectedMenu === "alert" && (
  914. <section className="space-y-4">
  915. <Tabs
  916. activeKey={alertTab}
  917. onChange={setAlertTab}
  918. items={[
  919. { key: "current", label: "当前预警" },
  920. { key: "history", label: "历史分析" },
  921. { key: "efficiency", label: "预警效率" },
  922. { key: "analysis", label: "预警分析" },
  923. ]}
  924. />
  925. {alertTab === "current" && (
  926. <>
  927. <Row gutter={[16, 16]}>
  928. <Col xs={24} lg={16}>
  929. <Card title="总体预警处置情况">
  930. <Table
  931. size="small"
  932. rowKey="id"
  933. columns={alertColumns}
  934. dataSource={alerts}
  935. pagination={{ pageSize: 8 }}
  936. onRow={(record) => ({
  937. onClick: () => {
  938. setSelectedAlert(record)
  939. setDrawerOpen(true)
  940. },
  941. })}
  942. scroll={{ x: 900 }}
  943. />
  944. </Card>
  945. </Col>
  946. <Col xs={24} lg={8}>
  947. <Card title="处置效率">
  948. <div className="grid grid-cols-2 gap-4">
  949. <div>
  950. <div className="text-xs text-slate-500">平均处置时效</div>
  951. <div className="text-xl font-semibold mt-1">{(45 + Math.random() * 30).toFixed(0)} 分钟</div>
  952. <Progress percent={78} status="active" size="small" />
  953. <div className="text-xs text-slate-500 mt-1">较上月 +6%</div>
  954. </div>
  955. <div>
  956. <div className="text-xs text-slate-500">闭环率</div>
  957. <div className="text-xl font-semibold mt-1">
  958. {Math.round((alerts.filter((a) => a.status === "已闭环").length / Math.max(alerts.length, 1)) * 100)}%
  959. </div>
  960. <Progress percent={86} status="active" size="small" />
  961. <div className="text-xs text-slate-500 mt-1">较上周 +2%</div>
  962. </div>
  963. </div>
  964. </Card>
  965. <Card className="mt-4">
  966. <EChart option={efficiencyPieOption} />
  967. </Card>
  968. </Col>
  969. </Row>
  970. <Drawer
  971. title={
  972. <div className="flex items-center gap-2">
  973. <AlertTriangle size={18} color={selectedAlert ? alertLevelColor(selectedAlert.level) : primary} />
  974. <span>预警详情</span>
  975. </div>
  976. }
  977. placement="right"
  978. width={520}
  979. open={drawerOpen}
  980. onClose={() => setDrawerOpen(false)}
  981. >
  982. {selectedAlert ? (
  983. <div className="space-y-4">
  984. <Descriptions size="small" column={1} bordered>
  985. <Descriptions.Item label="预警编号">{selectedAlert.id}</Descriptions.Item>
  986. <Descriptions.Item label="等级">
  987. <LevelTag level={selectedAlert.level} />
  988. </Descriptions.Item>
  989. <Descriptions.Item label="行业">{selectedAlert.industry}</Descriptions.Item>
  990. <Descriptions.Item label="类型">{selectedAlert.type}</Descriptions.Item>
  991. <Descriptions.Item label="时间">{selectedAlert.time}</Descriptions.Item>
  992. <Descriptions.Item label="位置">{selectedAlert.location}</Descriptions.Item>
  993. <Descriptions.Item label="状态">
  994. <StatusBadge s={selectedAlert.status} />
  995. </Descriptions.Item>
  996. <Descriptions.Item label="描述">{selectedAlert.desc}</Descriptions.Item>
  997. </Descriptions>
  998. <Card size="small" title="事件时序">
  999. <EChart
  1000. option={{
  1001. grid: { left: 30, right: 10, top: 20, bottom: 20 },
  1002. xAxis: { type: "category", data: ["发现", "确认", "处置", "复盘"] },
  1003. yAxis: { type: "value" },
  1004. color: [primary],
  1005. series: [{ type: "line", smooth: true, data: [0, 12, 38, 60] }],
  1006. }}
  1007. />
  1008. </Card>
  1009. <Card size="small" title="一张图联动(示意)">
  1010. <div className="relative w-full h-[200px] rounded-md overflow-hidden">
  1011. <img src="/images/city-map.png" alt="地图联动示意图" className="absolute inset-0 w-full h-full object-cover opacity-90" />
  1012. <div className="absolute inset-0">
  1013. <div
  1014. className="absolute w-3 h-3 rounded-full ring-2 ring-white animate-pulse"
  1015. style={{ top: "42%", left: "56%", background: alertLevelColor(selectedAlert.level) }}
  1016. title="预警位置"
  1017. />
  1018. </div>
  1019. </div>
  1020. </Card>
  1021. <Space>
  1022. <a className="text-emerald-600">查看工单</a>
  1023. <a className="text-emerald-600">下达指令</a>
  1024. <a className="text-emerald-600">通知联动</a>
  1025. </Space>
  1026. </div>
  1027. ) : (
  1028. <div className="text-slate-500 text-sm">请选择左侧预警查看详情。</div>
  1029. )}
  1030. </Drawer>
  1031. </>
  1032. )}
  1033. {alertTab === "history" && (
  1034. <>
  1035. <Row gutter={[16, 16]}>
  1036. <Col xs={24} md={12}>
  1037. <Card title="各行业预警数量(近6月)">
  1038. <EChart
  1039. option={{
  1040. tooltip: { trigger: "axis" },
  1041. legend: { bottom: 0 },
  1042. grid: { left: 40, right: 10, top: 20, bottom: 40 },
  1043. xAxis: { type: "category", data: Array.from({ length: 6 }).map((_, i) => dayjs().subtract(5 - i, "month").format("YYYY-MM")) },
  1044. yAxis: { type: "value" },
  1045. color: [primary, "#f59e0b", "#a855f7"],
  1046. series: (["燃气", "供水", "排水"] as const).map((ind, idx) => ({
  1047. name: ind,
  1048. type: "line",
  1049. smooth: true,
  1050. data: Array.from({ length: 6 }).map(() => Math.floor(Math.random() * (idx === 0 ? 60 : idx === 1 ? 45 : 35)) + 5),
  1051. })),
  1052. }}
  1053. />
  1054. </Card>
  1055. </Col>
  1056. <Col xs={24} md={12}>
  1057. <Card title="已闭环预警(示意)">
  1058. <Table
  1059. size="small"
  1060. rowKey="id"
  1061. columns={[
  1062. { title: "编号", dataIndex: "id" },
  1063. { title: "类型", dataIndex: "type" },
  1064. { title: "行业", dataIndex: "industry", width: 90 },
  1065. { title: "完成时间", dataIndex: "time", width: 160 },
  1066. ]}
  1067. dataSource={alerts.filter((a) => a.status === "已闭环")}
  1068. pagination={{ pageSize: 6 }}
  1069. />
  1070. </Card>
  1071. </Col>
  1072. </Row>
  1073. </>
  1074. )}
  1075. {alertTab === "efficiency" && (
  1076. <>
  1077. <Row gutter={[16, 16]}>
  1078. <Col xs={24} md={12}>
  1079. <Card title="整体效率">
  1080. <div className="grid grid-cols-2 gap-4">
  1081. <div>
  1082. <div className="text-xs text-slate-500">平均处置时效</div>
  1083. <div className="text-xl font-semibold mt-1">{(42 + Math.random() * 25).toFixed(0)} 分钟</div>
  1084. <Progress percent={82} status="active" size="small" />
  1085. <div className="text-xs text-slate-500 mt-1">较上月 +4%</div>
  1086. </div>
  1087. <div>
  1088. <div className="text-xs text-slate-500">正确预警率</div>
  1089. <div className="text-xl font-semibold mt-1">{(88 + Math.random() * 4).toFixed(1)}%</div>
  1090. <Progress percent={89} status="active" size="small" />
  1091. <div className="text-xs text-slate-500 mt-1">核实误报下降</div>
  1092. </div>
  1093. </div>
  1094. </Card>
  1095. </Col>
  1096. <Col xs={24} md={12}>
  1097. <Card>
  1098. <EChart option={efficiencyPieOption} />
  1099. </Card>
  1100. </Col>
  1101. </Row>
  1102. </>
  1103. )}
  1104. {alertTab === "analysis" && (
  1105. <>
  1106. <Row gutter={[16, 16]}>
  1107. <Col xs={24}>
  1108. <Card title="预警类型与成因分布">
  1109. <EChart
  1110. option={{
  1111. tooltip: { trigger: "axis" },
  1112. legend: { bottom: 0 },
  1113. grid: { left: 40, right: 10, top: 20, bottom: 40 },
  1114. xAxis: {
  1115. type: "category",
  1116. data: ["泄漏", "压力异常", "流量突变", "停电", "液位过低", "浊度异常"],
  1117. axisLabel: { rotate: 20 },
  1118. },
  1119. yAxis: { type: "value" },
  1120. color: [primary, "#f59e0b"],
  1121. series: [
  1122. { name: "设备原因", type: "bar", data: [30, 22, 18, 12, 9, 7] },
  1123. { name: "外部原因", type: "bar", data: [18, 15, 14, 28, 11, 10] },
  1124. ],
  1125. }}
  1126. />
  1127. </Card>
  1128. </Col>
  1129. </Row>
  1130. </>
  1131. )}
  1132. </section>
  1133. )}
  1134. {selectedMenu === "devices" && (
  1135. <section className="space-y-4">
  1136. <Row justify="space-between" align="middle">
  1137. <Col>
  1138. <div className="text-base font-medium">设备管理</div>
  1139. </Col>
  1140. <Col>
  1141. <Space>
  1142. <Segmented
  1143. options={["全部", "在线", "离线"]}
  1144. onChange={() => {}}
  1145. aria-label="设备状态筛选"
  1146. />
  1147. <Button size="small" icon={<Table2 size={14} />}>
  1148. 批量导出
  1149. </Button>
  1150. </Space>
  1151. </Col>
  1152. </Row>
  1153. <Card>
  1154. <Table
  1155. size="small"
  1156. rowKey="id"
  1157. columns={deviceColumns}
  1158. dataSource={devices}
  1159. pagination={{ pageSize: 10 }}
  1160. scroll={{ x: 700 }}
  1161. />
  1162. </Card>
  1163. </section>
  1164. )}
  1165. {selectedMenu === "reports" && (
  1166. <section className="space-y-4">
  1167. <Row gutter={[16, 16]}>
  1168. <Col xs={24} md={12}>
  1169. <Card title="月度运行报告(示意)" extra={<Button size="small">导出 PDF</Button>}>
  1170. <EChart
  1171. option={{
  1172. tooltip: { trigger: "axis" },
  1173. grid: { left: 40, right: 10, top: 20, bottom: 30 },
  1174. xAxis: { type: "category", data: ["一", "二", "三", "四", "五", "六"] },
  1175. yAxis: { type: "value" },
  1176. color: [primary],
  1177. series: [{ type: "line", smooth: true, data: [120, 132, 101, 134, 90, 230] }],
  1178. }}
  1179. />
  1180. </Card>
  1181. </Col>
  1182. <Col xs={24} md={12}>
  1183. <Card title="安全事件统计(示意)" extra={<Button size="small">导出 Excel</Button>}>
  1184. <EChart
  1185. option={{
  1186. tooltip: { trigger: "axis" },
  1187. grid: { left: 40, right: 10, top: 20, bottom: 30 },
  1188. xAxis: { type: "category", data: ["燃气", "供水", "排水"] },
  1189. yAxis: { type: "value" },
  1190. color: [primary, "#f59e0b", "#a855f7"],
  1191. series: [{ type: "bar", data: [32, 21, 17], barWidth: "50%" }],
  1192. }}
  1193. />
  1194. </Card>
  1195. </Col>
  1196. </Row>
  1197. </section>
  1198. )}
  1199. {selectedMenu === "incidents" && (
  1200. <section className="space-y-4">
  1201. <Row gutter={[16, 16]}>
  1202. <Col xs={24} md={16}>
  1203. <Card title="事件列表(示意)" extra={<Button size="small">新建事件</Button>}>
  1204. <Empty description="暂无数据(示意)" />
  1205. </Card>
  1206. </Col>
  1207. <Col xs={24} md={8}>
  1208. <Card title="事件趋势(示意)">
  1209. <EChart
  1210. option={{
  1211. tooltip: { trigger: "axis" },
  1212. grid: { left: 40, right: 10, top: 20, bottom: 30 },
  1213. xAxis: { type: "category", data: Array.from({ length: 12 }).map((_, i) => `${i + 1}月`) },
  1214. yAxis: { type: "value" },
  1215. color: [primary],
  1216. series: [{ type: "line", smooth: true, data: Array.from({ length: 12 }).map(() => Math.floor(Math.random() * 20) + 5) }],
  1217. }}
  1218. />
  1219. </Card>
  1220. </Col>
  1221. </Row>
  1222. </section>
  1223. )}
  1224. {selectedMenu === "bigscreen" && (
  1225. <section className="space-y-4">
  1226. <Card title="数据大屏(示意)">
  1227. <Row gutter={[16, 16]}>
  1228. {[
  1229. { title: "设备总数", val: devices.length },
  1230. { title: "在线率", val: `${onlineRate}%` },
  1231. { title: "本月预警", val: (alerts.length + Math.floor(Math.random() * 30)).toString() },
  1232. { title: "闭环率", val: `${Math.round((alerts.filter((a) => a.status === "已闭环").length / Math.max(alerts.length, 1)) * 100)}%` },
  1233. ].map((s) => (
  1234. <Col xs={12} md={6} key={s.title}>
  1235. <Card size="small">
  1236. <div className="text-xs text-slate-500">{s.title}</div>
  1237. <div className="text-2xl font-semibold mt-1">{s.val}</div>
  1238. </Card>
  1239. </Col>
  1240. ))}
  1241. </Row>
  1242. <Row gutter={[16, 16]} className="mt-1">
  1243. <Col xs={24} md={12}>
  1244. <Card>
  1245. <EChart option={deviceBarOption} />
  1246. </Card>
  1247. </Col>
  1248. <Col xs={24} md={12}>
  1249. <Card>
  1250. <EChart option={riskBarOption} />
  1251. </Card>
  1252. </Col>
  1253. </Row>
  1254. </Card>
  1255. </section>
  1256. )}
  1257. {selectedMenu === "settings" && (
  1258. <section className="space-y-4">
  1259. <Card title="预警设置">
  1260. <Row gutter={[16, 16]}>
  1261. <Col xs={24} md={12}>
  1262. <Card size="small" title="阈值设置">
  1263. <div className="grid grid-cols-2 gap-4">
  1264. <div>
  1265. <div className="text-xs text-slate-500 mb-1">压力异常阈值</div>
  1266. <Select defaultValue="P≤0.3MPa" options={[{ value: "P≤0.3MPa", label: "P≤0.3MPa" }, { value: "P≤0.2MPa", label: "P≤0.2MPa" }]} />
  1267. </div>
  1268. <div>
  1269. <div className="text-xs text-slate-500 mb-1">流量突变阈值</div>
  1270. <Select defaultValue="ΔQ≥20%" options={[{ value: "ΔQ≥20%", label: "ΔQ≥20%" }, { value: "ΔQ≥30%", label: "ΔQ≥30%" }]} />
  1271. </div>
  1272. <div>
  1273. <div className="text-xs text-slate-500 mb-1">水质指标(浊度)</div>
  1274. <Select defaultValue="≥5 NTU" options={[{ value: "≥5 NTU", label: "≥5 NTU" }, { value: "≥3 NTU", label: "≥3 NTU" }]} />
  1275. </div>
  1276. <div>
  1277. <div className="text-xs text-slate-500 mb-1">液位过低</div>
  1278. <Select defaultValue="≤20%" options={[{ value: "≤20%", label: "≤20%" }, { value: "≤15%", label: "≤15%" }]} />
  1279. </div>
  1280. </div>
  1281. </Card>
  1282. </Col>
  1283. <Col xs={24} md={12}>
  1284. <Card size="small" title="通知策略">
  1285. <div className="grid grid-cols-2 gap-4">
  1286. <div className="flex items-center justify-between">
  1287. <span>高等级预警短信</span>
  1288. <Switch defaultChecked />
  1289. </div>
  1290. <div className="flex items-center justify-between">
  1291. <span>邮件抄送管理层</span>
  1292. <Switch />
  1293. </div>
  1294. <div className="flex items-center justify-between">
  1295. <span>自动派单</span>
  1296. <Switch />
  1297. </div>
  1298. <div className="flex items-center justify-between">
  1299. <span>与值守大屏联动</span>
  1300. <Switch defaultChecked />
  1301. </div>
  1302. </div>
  1303. </Card>
  1304. </Col>
  1305. </Row>
  1306. </Card>
  1307. </section>
  1308. )}
  1309. </Content>
  1310. </Layout>
  1311. </Layout>
  1312. </ConfigProvider>
  1313. )
  1314. }