import React from 'react'; import { DictService, StringUtil } from 'matrix-ui-service'; import { Tag } from 'antd'; import { EntityColumnProps } from '../layout'; export interface DictViewProps { dictService: DictService; dictType: string; dictCode: string; multipleMode?: boolean; } export class DictView extends React.Component { render() { const { dictService, dictType, dictCode, multipleMode } = this.props; if (StringUtil.isBlank(dictCode)) return null; if (!multipleMode) return dictService.getName(dictType, dictCode); const codes = dictCode.split(','); return (
{codes.map((code) => ( {dictService.getName(dictType, code)} ))}
); } static build = (dictService: DictService) => (props: Omit) => ( ); static dictColumn(dictService: DictService, title: string, dataIndex: string, typeId: string): EntityColumnProps { return { title, dataIndex, render: dictService.getName.bind(null, typeId) }; } static multiDictColumn( dictService: DictService, title: string, dataIndex: string, typeId: string, ): EntityColumnProps { return { title, dataIndex, render: (text) => , renderText: (text) => { if (!text) return null; const codes = text.split(','); return codes.map((code) => dictService.getName(typeId, code)).join(','); }, }; } }