import React, { useEffect, useState } from 'react'; import { Modal, Table, Spin } from 'antd'; import { getSupplierChangeDetail } from '../services'; interface Qualification { type: string; name: string; level: string; number: string; org: string; issueDate: string; validDate: string; file?: string; } interface InfoItem { label: string; value: string; } interface DetailData { baseInfo: InfoItem[]; changeInfo: InfoItem[]; qualifications: Qualification[]; } interface DetailViewProps { visible: boolean; onClose: () => void; detailId?: string | number; } const DetailView: React.FC = ({ visible, onClose, detailId }) => { const [loading, setLoading] = useState(false); const [detailData, setDetailData] = useState(null); useEffect(() => { if (visible && detailId) { setLoading(true); getSupplierChangeDetail(detailId) .then(res => { if (res.code === 200) { setDetailData(res.data); } }) .finally(() => setLoading(false)); } if (!visible) setDetailData(null); }, [visible, detailId]); const columns = [ { title: '资质证书类型', dataIndex: 'type', width: 120 }, { title: '资质名称', dataIndex: 'name', width: 120 }, { title: '资质类别和等级', dataIndex: 'level', width: 120 }, { title: '资质证书编号', dataIndex: 'number', width: 120 }, { title: '发证机构', dataIndex: 'org', width: 120 }, { title: '发证日期', dataIndex: 'issueDate', width: 120 }, { title: '资质有效期至', dataIndex: 'validDate', width: 120 }, { title: '附件', dataIndex: 'file', width: 120, render: (file: string) => file ? ( 附件 更多 ) : ( '-' ), }, ]; // 把info数组两两合并成一行显示 function renderInfoTable(infoArr: InfoItem[]) { const rows = []; for (let i = 0; i < infoArr.length; i += 2) { const left = infoArr[i]; const right = infoArr[i + 1] || { label: '', value: '' }; rows.push( {left.label} {left.value} {right.label} {right.value} ); } return ( {rows}
); } return ( {detailData && (
{/* 基本信息 */} {renderInfoTable(detailData.baseInfo)} {/* 变更内容 */}
变更内容:
{renderInfoTable(detailData.changeInfo)} {/* 新增资质 */}
新增资质1
)} ); }; const tdStyleTitle: React.CSSProperties = { background: '#fafafa', fontWeight: 700, width: 130, padding: 8, border: '1px solid #f0f0f0', }; const tdStyle: React.CSSProperties = { background: '#fff', padding: 8, border: '1px solid #f0f0f0', }; export default DetailView;