pipeline-data-management.tsx 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. "use client"
  2. import {useState} from "react"
  3. import {Button, Card, Col, Form, Input, Modal, Popconfirm, Row, Select, Space, Table, Tag} from "antd"
  4. import {DeleteOutlined, EditOutlined, PlusOutlined} from "@ant-design/icons"
  5. import globalMessage from "@/app/_modules/globalMessage";
  6. const { Option } = Select
  7. // 模拟管网数据
  8. const mockPipelineData = [
  9. {
  10. id: "P001",
  11. name: "解放路主干线",
  12. type: "主干管",
  13. material: "钢管",
  14. diameter: "DN400",
  15. pressure: "0.4MPa",
  16. length: 1200,
  17. installDate: "2020-03-15",
  18. status: "正常",
  19. location: "解放路段",
  20. },
  21. {
  22. id: "P002",
  23. name: "人民路支线",
  24. type: "支管",
  25. material: "PE管",
  26. diameter: "DN200",
  27. pressure: "0.2MPa",
  28. length: 800,
  29. installDate: "2021-06-20",
  30. status: "维护中",
  31. location: "人民路段",
  32. },
  33. {
  34. id: "P003",
  35. name: "建设路次高压管",
  36. type: "次高压管",
  37. material: "钢管",
  38. diameter: "DN600",
  39. pressure: "0.8MPa",
  40. length: 2000,
  41. installDate: "2019-11-10",
  42. status: "正常",
  43. location: "建设路段",
  44. },
  45. ]
  46. const mockNodeData = [
  47. {
  48. id: "N001",
  49. name: "解放路调压站",
  50. type: "调压站",
  51. inletPressure: "0.4MPa",
  52. outletPressure: "0.2MPa",
  53. capacity: "5000m³/h",
  54. status: "运行",
  55. location: "解放路与建设路交叉口",
  56. },
  57. {
  58. id: "N002",
  59. name: "人民路阀门井",
  60. type: "阀门井",
  61. inletPressure: "0.2MPa",
  62. outletPressure: "0.2MPa",
  63. capacity: "-",
  64. status: "正常",
  65. location: "人民路中段",
  66. },
  67. ]
  68. const mockWellData = [
  69. {
  70. id: "W001",
  71. name: "解放路窨井001",
  72. type: "检查井",
  73. depth: "2.5m",
  74. material: "混凝土",
  75. coverType: "铸铁井盖",
  76. status: "正常",
  77. location: "解放路北段",
  78. lastInspection: "2024-01-15",
  79. },
  80. {
  81. id: "W002",
  82. name: "人民路窨井002",
  83. type: "阀门井",
  84. depth: "3.0m",
  85. material: "砖砌",
  86. coverType: "复合井盖",
  87. status: "需维护",
  88. location: "人民路南段",
  89. lastInspection: "2024-01-10",
  90. },
  91. ]
  92. export default function PipelineDataManagement() {
  93. const [activeTab, setActiveTab] = useState("pipeline")
  94. const [isModalVisible, setIsModalVisible] = useState(false)
  95. const [editingRecord, setEditingRecord] = useState(null)
  96. const [form] = Form.useForm()
  97. const handleAdd = () => {
  98. setEditingRecord(null)
  99. form.resetFields()
  100. setIsModalVisible(true)
  101. }
  102. const handleEdit = (record: any) => {
  103. setEditingRecord(record)
  104. form.setFieldsValue(record)
  105. setIsModalVisible(true)
  106. }
  107. const handleDelete = (id: string) => {
  108. globalMessage.success("删除成功")
  109. }
  110. const handleModalOk = () => {
  111. form.validateFields().then((values) => {
  112. if (editingRecord) {
  113. globalMessage.success("更新成功")
  114. } else {
  115. globalMessage.success("添加成功")
  116. }
  117. setIsModalVisible(false)
  118. form.resetFields()
  119. })
  120. }
  121. const pipelineColumns = [
  122. { title: "管线编号", dataIndex: "id", key: "id" },
  123. { title: "管线名称", dataIndex: "name", key: "name" },
  124. { title: "管线类型", dataIndex: "type", key: "type" },
  125. { title: "管材", dataIndex: "material", key: "material" },
  126. { title: "管径", dataIndex: "diameter", key: "diameter" },
  127. { title: "压力等级", dataIndex: "pressure", key: "pressure" },
  128. { title: "长度(m)", dataIndex: "length", key: "length" },
  129. { title: "安装日期", dataIndex: "installDate", key: "installDate" },
  130. {
  131. title: "状态",
  132. dataIndex: "status",
  133. key: "status",
  134. render: (status: string) => (
  135. <Tag color={status === "正常" ? "green" : status === "维护中" ? "orange" : "red"}>{status}</Tag>
  136. ),
  137. },
  138. {
  139. title: "操作",
  140. key: "action",
  141. render: (_, record) => (
  142. <Space>
  143. <Button type="link" icon={<EditOutlined />} onClick={() => handleEdit(record)}>
  144. 编辑
  145. </Button>
  146. <Popconfirm title="确定删除吗?" onConfirm={() => handleDelete(record.id)}>
  147. <Button type="link" danger icon={<DeleteOutlined />}>
  148. 删除
  149. </Button>
  150. </Popconfirm>
  151. </Space>
  152. ),
  153. },
  154. ]
  155. const nodeColumns = [
  156. { title: "节点编号", dataIndex: "id", key: "id" },
  157. { title: "节点名称", dataIndex: "name", key: "name" },
  158. { title: "节点类型", dataIndex: "type", key: "type" },
  159. { title: "进口压力", dataIndex: "inletPressure", key: "inletPressure" },
  160. { title: "出口压力", dataIndex: "outletPressure", key: "outletPressure" },
  161. { title: "处理能力", dataIndex: "capacity", key: "capacity" },
  162. {
  163. title: "状态",
  164. dataIndex: "status",
  165. key: "status",
  166. render: (status: string) => (
  167. <Tag color={status === "运行" ? "green" : status === "正常" ? "blue" : "red"}>{status}</Tag>
  168. ),
  169. },
  170. {
  171. title: "操作",
  172. key: "action",
  173. render: (_, record) => (
  174. <Space>
  175. <Button type="link" icon={<EditOutlined />} onClick={() => handleEdit(record)}>
  176. 编辑
  177. </Button>
  178. <Popconfirm title="确定删除吗?" onConfirm={() => handleDelete(record.id)}>
  179. <Button type="link" danger icon={<DeleteOutlined />}>
  180. 删除
  181. </Button>
  182. </Popconfirm>
  183. </Space>
  184. ),
  185. },
  186. ]
  187. const wellColumns = [
  188. { title: "窨井编号", dataIndex: "id", key: "id" },
  189. { title: "窨井名称", dataIndex: "name", key: "name" },
  190. { title: "窨井类型", dataIndex: "type", key: "type" },
  191. { title: "深度", dataIndex: "depth", key: "depth" },
  192. { title: "材质", dataIndex: "material", key: "material" },
  193. { title: "井盖类型", dataIndex: "coverType", key: "coverType" },
  194. { title: "最后检查", dataIndex: "lastInspection", key: "lastInspection" },
  195. {
  196. title: "状态",
  197. dataIndex: "status",
  198. key: "status",
  199. render: (status: string) => <Tag color={status === "正常" ? "green" : "orange"}>{status}</Tag>,
  200. },
  201. {
  202. title: "操作",
  203. key: "action",
  204. render: (_, record) => (
  205. <Space>
  206. <Button type="link" icon={<EditOutlined />} onClick={() => handleEdit(record)}>
  207. 编辑
  208. </Button>
  209. <Popconfirm title="确定删除吗?" onConfirm={() => handleDelete(record.id)}>
  210. <Button type="link" danger icon={<DeleteOutlined />}>
  211. 删除
  212. </Button>
  213. </Popconfirm>
  214. </Space>
  215. ),
  216. },
  217. ]
  218. const renderTabContent = () => {
  219. switch (activeTab) {
  220. case "pipeline":
  221. return (
  222. <Table columns={pipelineColumns} dataSource={mockPipelineData} rowKey="id" pagination={{ pageSize: 10 }} />
  223. )
  224. case "node":
  225. return <Table columns={nodeColumns} dataSource={mockNodeData} rowKey="id" pagination={{ pageSize: 10 }} />
  226. case "well":
  227. return <Table columns={wellColumns} dataSource={mockWellData} rowKey="id" pagination={{ pageSize: 10 }} />
  228. default:
  229. return null
  230. }
  231. }
  232. const renderModalForm = () => {
  233. if (activeTab === "pipeline") {
  234. return (
  235. <>
  236. <Form.Item name="name" label="管线名称" rules={[{ required: true }]}>
  237. <Input />
  238. </Form.Item>
  239. <Form.Item name="type" label="管线类型" rules={[{ required: true }]}>
  240. <Select>
  241. <Option value="主干管">主干管</Option>
  242. <Option value="支管">支管</Option>
  243. <Option value="次高压管">次高压管</Option>
  244. </Select>
  245. </Form.Item>
  246. <Form.Item name="material" label="管材" rules={[{ required: true }]}>
  247. <Select>
  248. <Option value="钢管">钢管</Option>
  249. <Option value="PE管">PE管</Option>
  250. <Option value="铸铁管">铸铁管</Option>
  251. </Select>
  252. </Form.Item>
  253. <Form.Item name="diameter" label="管径" rules={[{ required: true }]}>
  254. <Input />
  255. </Form.Item>
  256. <Form.Item name="pressure" label="压力等级" rules={[{ required: true }]}>
  257. <Input />
  258. </Form.Item>
  259. <Form.Item name="length" label="长度(m)" rules={[{ required: true }]}>
  260. <Input type="number" />
  261. </Form.Item>
  262. <Form.Item name="location" label="位置" rules={[{ required: true }]}>
  263. <Input />
  264. </Form.Item>
  265. </>
  266. )
  267. }
  268. return null
  269. }
  270. return (
  271. <div className="p-6">
  272. <Card title="燃气管网基础数据管理">
  273. <Row gutter={16} className="mb-4">
  274. <Col>
  275. <Button type={activeTab === "pipeline" ? "primary" : "default"} onClick={() => setActiveTab("pipeline")}>
  276. 管线数据
  277. </Button>
  278. </Col>
  279. <Col>
  280. <Button type={activeTab === "node" ? "primary" : "default"} onClick={() => setActiveTab("node")}>
  281. 管点数据
  282. </Button>
  283. </Col>
  284. <Col>
  285. <Button type={activeTab === "well" ? "primary" : "default"} onClick={() => setActiveTab("well")}>
  286. 窨井数据
  287. </Button>
  288. </Col>
  289. </Row>
  290. <div className="mb-4">
  291. <Space>
  292. <Button type="primary" icon={<PlusOutlined />} onClick={handleAdd}>
  293. 新增
  294. </Button>
  295. <Input.Search placeholder="搜索..." style={{ width: 300 }} onSearch={(value) => console.log(value)} />
  296. </Space>
  297. </div>
  298. {renderTabContent()}
  299. <Modal
  300. title={editingRecord ? "编辑数据" : "新增数据"}
  301. open={isModalVisible}
  302. onOk={handleModalOk}
  303. onCancel={() => setIsModalVisible(false)}
  304. width={600}
  305. >
  306. <Form form={form} layout="vertical">
  307. {renderModalForm()}
  308. </Form>
  309. </Modal>
  310. </Card>
  311. </div>
  312. )
  313. }