diff --git a/src/components/detail/image/index.tsx b/src/components/detail/image/index.tsx new file mode 100644 index 0000000000000000000000000000000000000000..2783cb1759f396d1992d32e9efead623b36c814b --- /dev/null +++ b/src/components/detail/image/index.tsx @@ -0,0 +1,68 @@ +import React from 'react' +import { DetailField, DetailFieldConfig, IDetailField } from '../common' + +/** + * 详情项图片组件 格式定义 + * - type: 图片类型 + * - height: 图片高度 + * - width: 图片宽度 + * - preview: 点击预览 + */ +export interface ImageDetailConfig extends DetailFieldConfig { + type: 'image', + height?: string | number + width?: string | number + preview?: boolean +} + +export interface IImageDetail { + value: string + height: string | number + width: string | number + preview?: boolean +} + +export default class ImageDetail extends DetailField implements IDetailField { + renderComponent = (props: IImageDetail) => { + return + 您当前使用的UI版本没有实现Image组件。 +
+
+
+ } + + getValue = () => { + const { + value, + config: { + defaultValue + } + } = this.props + if (value === undefined || value === null || value === '') { + return defaultValue !== undefined ? defaultValue : '' + } + return value + } + + render = () => { + const { + config: { + height, + width, + preview + } + } = this.props + const props: any = { + height, + width, + preview, + value: this.getValue() + } + + return ( + + {this.renderComponent(props)} + + ) + } +} diff --git a/src/components/detail/index.tsx b/src/components/detail/index.tsx index f59083411bfa163430e87642469164213360759a..899730d1cb4e7c1ba90b701348dc1c61654f1e8f 100644 --- a/src/components/detail/index.tsx +++ b/src/components/detail/index.tsx @@ -1,6 +1,7 @@ import TextField, { TextFieldConfig } from './text' import EnumDetail, { EnumDetailConfig } from './enum' import StatementDetail, { StatementDetailConfig } from './statement' +import ImageDetail, { ImageDetailConfig } from './image' import GroupField, { GroupFieldConfig } from './group' import ImportSubformField, { ImportSubformFieldConfig } from './importSubform' @@ -12,31 +13,33 @@ import TableField, { TableFieldConfig } from './table' * 详情步骤内详情项配置文件格式定义 - 枚举 */ export type DetailFieldConfigs = - TextFieldConfig | - EnumDetailConfig | - StatementDetailConfig | - GroupFieldConfig | - ImportSubformFieldConfig | - InfoDetailConfig | - ColorDetailConfig | - TableFieldConfig + TextFieldConfig | + EnumDetailConfig | + StatementDetailConfig | + ImageDetailConfig | + GroupFieldConfig | + ImportSubformFieldConfig | + InfoDetailConfig | + ColorDetailConfig | + TableFieldConfig export type componentType = - 'text' | - 'group' | - 'detail_enum' | - 'statement' | - 'import_subform' | - 'detail_info' | - 'detail_color' | - 'table' - + 'text' | + 'group' | + 'detail_enum' | + 'statement' | + 'image' | + 'import_subform' | + 'detail_info' | + 'detail_color' | + 'table' export default { group: GroupField, text: TextField, import_subform: ImportSubformField, detail_enum: EnumDetail, + image: ImageDetail, statement: StatementDetail, detail_info: InfoDetail, detail_color: ColorDetail, diff --git a/src/index.tsx b/src/index.tsx index 04146ee53184f7031c9d80dc70534f7885ef5d74..20bdfa15924f589d0f5fd8cd1066d73de328f894 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -59,6 +59,7 @@ export { default as DetailStep } from './steps/detail' export { default as DetailGroupField } from './components/detail/group' export { default as DetailEunmField } from './components/detail/enum' export { default as DetailStatementField } from './components/detail/statement' +export { default as DetailImageField } from './components/detail/image' export { default as DetailTextField } from './components/detail/text' export { default as DetailImportSubformField } from './components/detail/importSubform' export { default as DetailInfoField } from './components/detail/detailInfo'