import React, { useState, useEffect } from "react"; import { Form, Table, Button, Tag, Modal, Row, Col, Card, Statistic, Descriptions, Steps, Tooltip, } from "antd"; import { AntdTableFuncControl } from "@cqsjjb/jjb-common-decorator/antd"; import PageLayout from "@cqsjjb/jjb-react-admin-component/PageLayout"; import SearchForm from "@cqsjjb/jjb-react-admin-component/SearchForm"; import ControlWrapper from "@cqsjjb/jjb-react-admin-component/ControlWrapper"; import { NS_SAFETY_EVAL_BUSINESS } from "~/enumerate/namespace"; import { PROGRESS_STATUS_MAP, NODE_LABELS, EVAL_TYPE_MAP, } from "~/enumerate/constant"; import { Connect } from "@cqsjjb/jjb-dva-runtime"; import { tools } from "@cqsjjb/jjb-common-lib"; import "./index.less"; const { router } = tools; const ProjectProgress = (props) => { const [searchForm] = Form.useForm(); const [dataSource, setDataSource] = useState([]); const [total, setTotal] = useState(0); const [statData, setStatData] = useState({}); const [detailModalVisible, setDetailModalVisible] = useState(false); const [currentRecord, setCurrentRecord] = useState(null); const { evalProjectProgressPageLoading } = props.safetyEvalBusiness; const getStat = async () => { const res = await props.evalProjectProgressStat(); if (res?.success !== false) { setStatData(res?.data || {}); } }; const getData = async () => { const params = { ...router.query, current: router.query.current || 1, size: router.query.size || 10, }; const res = await props.evalProjectProgressPage(params); if (res?.success !== false) { setDataSource(res?.data || []); setTotal(res?.total || 0); } }; useEffect(() => { searchForm.setFieldsValue(router.query); getStat(); getData(); }, []); const handleSearch = (values) => { router.query = { ...router.query, ...values, current: 1, size: 10 }; getData(); }; const handleReset = (values) => { searchForm.resetFields(); router.query = { ...values, current: 1, size: 10 }; getData(); }; const handlePageChange = (pagination) => { router.query = { ...router.query, current: pagination.current, size: pagination.pageSize, }; getData(); }; const handleView = (record) => { setCurrentRecord(record); setDetailModalVisible(true); }; const renderProgressDots = (nodes) => { if (!nodes || nodes.length === 0) return 暂无进度; const total = nodes.length; const done = nodes.filter((n) => n.state === 1).length; return (
{nodes.map((node, idx) => { const dotClass = node.state === 1 ? "pp-progress-dot-done" : "pp-progress-dot-wait"; const name = NODE_LABELS[node.type] || node.type; return ( ); })}
{done}/{total} · {Math.round((done / total) * 100)}%
); }; const columns = [ { title: "项目编号", dataIndex: "projectNo", width: 100 }, { title: "客户/项目", width: 180, render: (_, record) => (
{record.projectName}
{record.customerName}
), }, { title: "评价类别", dataIndex: "evalTypeCode", width: 110, render: (_, record) => { return EVAL_TYPE_MAP[record.evalTypeCode]; }, }, { title: "负责人", dataIndex: "projectLeaderName", width: 100, ellipsis: true, }, { title: "项目进度", width: 240, render: (_, record) => renderProgressDots(record.projectNode), }, { title: "项目结束日期", dataIndex: "planEndDate", width: 120 }, { title: "项目状态", dataIndex: "progressStatusCode", width: 130, render: (code, record) => { const cfg = PROGRESS_STATUS_MAP[code]; const daysText = record.remainingDays >= 0 ? `剩余${record.remainingDays}天` : `超期${Math.abs(record.remainingDays)}天`; return (
{cfg ? ( {cfg.text}-{daysText} ) : ( {code} )}
); }, }, // { // title: "操作", // width: 80, // fixed: "right", // render: (_, record) => ( // // ), // }, ]; return ( 当前机构名下评价项目 } /> 距项目结束日期超过3天 } /> 项目结束前3天自动提醒 } /> 已超过项目结束日期 } /> , , ]} onFinish={handleSearch} onReset={handleReset} /> `共 ${total} 条`, }} onChange={handlePageChange} /> setDetailModalVisible(false)} footer={null} width={680} destroyOnHide={true} > {currentRecord && ( <> {currentRecord.projectNo} {currentRecord.projectName} {currentRecord.customerName} {currentRecord.customerContactName} {currentRecord.evalTypeName} {currentRecord.projectLeaderName} {currentRecord.planEndDate} {currentRecord.remainingDays >= 0 ? `${currentRecord.remainingDays}天` : `已超期${Math.abs(currentRecord.remainingDays)}天`} {currentRecord.progressStatusName}
项目节点进度
({ title: node.nodeName, status: node.statusCode === 3 ? "finish" : node.statusCode === 2 ? "process" : node.statusCode === 4 ? "error" : "wait", description: node.statusName, })) || [] } /> )}
); }; export default Connect( [NS_SAFETY_EVAL_BUSINESS], true, )(AntdTableFuncControl(ProjectProgress));