import React, { ReactNode } from "react"; import { Descriptions, Tooltip } from "antd"; import { FieldConfig } from "../../tmpl/interface"; import ViewControl from "../../controls/view-control"; import { LocaleContext } from "../../locale/LocaleProvider"; import "./index.less"; interface FieldViewGroupProps { serverKey?: string; fields: FieldConfig[]; valueMap?: object; width?: number; dataCode?: string; column?: number; audit?: { isAudit: boolean, auditMap?: object, changeFields?: string[] }; // 是否审计查看,审计查看配置 } interface FieldViewGroupState { fileList: any; } export default class FieldViewGroup extends React.PureComponent< FieldViewGroupProps, FieldViewGroupState > { constructor(props) { super(props); this.state = { fileList: [], }; } static defaultProps = { column: 2, audit: { isAudit: false } }; static contextType = LocaleContext; context: React.ContextType; initViewList = () => { const { fields, valueMap, serverKey, dataCode, audit } = this.props; const { translate } = this.context; const formItemList = []; if (fields.length > 0) { fields.forEach((item, index) => { let fieldValue = valueMap ? valueMap[item.id] : undefined; //fieldValue 没有值时不能为null 要为 undefined。antd input所限制 fieldValue = fieldValue ? fieldValue : item.defaultValue ? item.defaultValue : undefined; let label: ReactNode = translate("${" + item.title + "}"); if (audit?.isAudit && audit.changeFields?.includes(item.id)) { // 审计查看页面-上次更新内容在label标注 const tValue = audit.auditMap ? audit.auditMap[item.id] : undefined; const tTitle = label = {label}; label = (tValue || tValue === 0) ? {label} : label; } if (item.extControlType !== "hidden" && !item.hidden) { const formItem = (
); formItemList.push(formItem); } }); } return formItemList; }; render() { const { column } = this.props; return {this.initViewList()}; } }