import React, { useEffect, useState } from 'react'; import { Modal, Table, Spin, Descriptions } from 'antd'; import { supplierChangeApplyById } from '../services'; interface InfoItem { fieldAnnotation?: string; newValue?: string; oldValue?: string; title?: string; changeDesc?: string; supplierName?: string; approveStatusText?: string; coscoSupplierChangeHistoryList?: []; } interface DetailData { fieldAnnotation?: string; newValue?: string; oldValue?: string; title?: string; changeDesc?: string; supplierName?: string; approveStatusText?: string; coscoSupplierChangeHistoryList: InfoItem[]; } interface DetailViewProps { visible: boolean; onClose: () => void; detailId?: string; } const DetailView: React.FC = ({ visible, onClose, detailId }) => { const [loading, setLoading] = useState(false); const [detailData, setDetailData] = useState(null); useEffect(() => { if (visible && detailId) { setLoading(true); supplierChangeApplyById(detailId) .then(res => { if (res.code === 200) { setDetailData(res.data); } }) .finally(() => setLoading(false)); } if (!visible) setDetailData(null); }, [visible, detailId]); // 把info数组两两合并成一行显示 function renderInfoTable(infoArr: InfoItem[]) { const rows = []; for (let i = 0; i < infoArr.length; i++) { rows.push( <> {infoArr[i].oldValue} {infoArr[i].newValue} ); } return ( {rows} ); } return ( {detailData && (
{/* 基本信息 */} {detailData?.title} {detailData?.changeDesc} {/* {detailData?.coscoSupplierChangeHistoryList && ( {detailData?.changeDesc} ) } */} {/* 变更内容 */}
变更内容:
{renderInfoTable(detailData.coscoSupplierChangeHistoryList)}
)}
); }; 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;