"use client" import {useState} from "react" import {Button, Card, Col, DatePicker, Form, Input, Modal, Popconfirm, Row, Select, Space, Table, Tag,} from "antd" import {DeleteOutlined, EditOutlined, EyeOutlined, PlusOutlined} from "@ant-design/icons" import dayjs from "dayjs" import globalMessage from "@/app/_modules/globalMessage"; const { Option } = Select const { TextArea } = Input // 模拟隐患数据 const mockHazardData = [ { id: "H001", title: "解放路段管线压力异常", type: "压力异常", level: "高", location: "解放路与建设路交叉口", description: "管线压力超出正常范围,存在安全隐患", reportDate: "2024-01-15", reportPerson: "张三", status: "处理中", assignedTo: "李四", expectedDate: "2024-02-15", actualDate: null, treatmentPlan: "更换老化管段,加强压力监测", progress: 60, }, { id: "H002", name: "人民路窨井盖损坏", type: "设施损坏", level: "中", location: "人民路中段", description: "窨井盖出现裂纹,影响安全", reportDate: "2024-01-20", reportPerson: "王五", status: "已完成", assignedTo: "赵六", expectedDate: "2024-01-25", actualDate: "2024-01-24", treatmentPlan: "更换新井盖", progress: 100, }, { id: "H003", name: "建设路段泄漏检测", type: "泄漏隐患", level: "高", location: "建设路北段", description: "检测到微量燃气泄漏", reportDate: "2024-01-25", reportPerson: "孙七", status: "待处理", assignedTo: null, expectedDate: "2024-02-10", actualDate: null, treatmentPlan: "待制定", progress: 0, }, ] export default function HazardArchive() { const [isModalVisible, setIsModalVisible] = useState(false) const [isDetailModalVisible, setIsDetailModalVisible] = useState(false) const [editingRecord, setEditingRecord] = useState(null) const [viewingRecord, setViewingRecord] = useState(null) const [form] = Form.useForm() const handleAdd = () => { setEditingRecord(null) form.resetFields() setIsModalVisible(true) } const handleEdit = (record: any) => { setEditingRecord(record) form.setFieldsValue({ ...record, reportDate: record.reportDate ? dayjs(record.reportDate) : null, expectedDate: record.expectedDate ? dayjs(record.expectedDate) : null, actualDate: record.actualDate ? dayjs(record.actualDate) : null, }) setIsModalVisible(true) } const handleView = (record: any) => { setViewingRecord(record) setIsDetailModalVisible(true) } const handleDelete = (id: string) => { globalMessage.success("删除成功") } const handleModalOk = () => { form.validateFields().then((values) => { if (editingRecord) { globalMessage.success("更新成功") } else { globalMessage.success("添加成功") } setIsModalVisible(false) form.resetFields() }) } const columns = [ { title: "隐患编号", dataIndex: "id", key: "id", width: 100 }, { title: "隐患标题", dataIndex: "title", key: "title", width: 200 }, { title: "隐患类型", dataIndex: "type", key: "type", width: 120 }, { title: "风险等级", dataIndex: "level", key: "level", width: 100, render: (level: string) => { const colorMap = { 高: "red", 中: "orange", 低: "green" } return {level} }, }, { title: "位置", dataIndex: "location", key: "location", width: 150 }, { title: "上报日期", dataIndex: "reportDate", key: "reportDate", width: 120 }, { title: "上报人", dataIndex: "reportPerson", key: "reportPerson", width: 100 }, { title: "处理状态", dataIndex: "status", key: "status", width: 100, render: (status: string) => { const colorMap = { 待处理: "default", 处理中: "processing", 已完成: "success", 已关闭: "error", } return {status} }, }, { title: "负责人", dataIndex: "assignedTo", key: "assignedTo", width: 100 }, { title: "进度", dataIndex: "progress", key: "progress", width: 80, render: (progress: number) => `${progress}%`, }, { title: "操作", key: "action", width: 200, fixed: "right", render: (_, record) => ( handleDelete(record.id)}> ), }, ] return (
156
隐患总数
23
待处理
45
处理中
88
已完成
{/* 编辑/新增模态框 */} setIsModalVisible(false)} width={800} >