2021-12-23 18:23:21 +05:00
|
|
|
import { memo, Fragment } from 'react'
|
2021-11-17 14:08:13 +05:00
|
|
|
import { Empty, Form } from 'antd'
|
2021-12-23 18:23:21 +05:00
|
|
|
|
2022-01-24 17:32:45 +05:00
|
|
|
import { Grid, GridItem } from '@components/Grid'
|
2021-12-23 18:23:21 +05:00
|
|
|
|
2022-01-24 17:32:45 +05:00
|
|
|
import '@styles/index.css'
|
|
|
|
import '@styles/measure.css'
|
2021-10-06 13:57:04 +05:00
|
|
|
|
2021-11-17 14:08:13 +05:00
|
|
|
const colsCount = 3
|
2021-10-06 13:57:04 +05:00
|
|
|
|
2021-12-23 18:23:21 +05:00
|
|
|
export const View = memo(({ columns, item }) => !item || !columns?.length ? (
|
|
|
|
<Empty key={'empty'} image={Empty.PRESENTED_IMAGE_SIMPLE} />
|
|
|
|
) : (
|
|
|
|
<Grid>
|
|
|
|
{columns.map((column, i) => (
|
|
|
|
<Fragment key={i}>
|
|
|
|
<GridItem
|
|
|
|
key={column.dataIndex}
|
|
|
|
row={Math.floor(i / colsCount) + 1}
|
|
|
|
col={(i % colsCount) * 2 + 1}
|
|
|
|
className={'measure-column-header'}
|
|
|
|
>
|
|
|
|
{column.title}
|
|
|
|
</GridItem>
|
2021-11-17 14:08:13 +05:00
|
|
|
|
2021-12-23 18:23:21 +05:00
|
|
|
<GridItem
|
|
|
|
key={column.title}
|
|
|
|
row={Math.floor(i / colsCount) + 1}
|
|
|
|
col={(i % colsCount) * 2 + 2}
|
|
|
|
className={'measure-column-value'}
|
|
|
|
style={{ padding: 0 }}
|
|
|
|
>
|
|
|
|
{column.render ? (
|
|
|
|
<Form.Item
|
|
|
|
key={column.dataIndex}
|
|
|
|
name={column.dataIndex}
|
2021-12-27 15:18:20 +05:00
|
|
|
style={{ margin: 0 }}
|
2021-12-23 18:23:21 +05:00
|
|
|
>
|
|
|
|
{column.render(item[column.dataIndex])}
|
|
|
|
</Form.Item>
|
|
|
|
) : (
|
|
|
|
<p key={column.title} className={'m-5px'}>
|
|
|
|
{item[column.dataIndex]}
|
|
|
|
</p>
|
|
|
|
)}
|
|
|
|
</GridItem>
|
|
|
|
</Fragment>
|
|
|
|
))}
|
|
|
|
</Grid>
|
|
|
|
))
|