asb_cloud_front/src/pages/Measure/View.jsx

51 lines
1.3 KiB
React
Raw Normal View History

import { memo, Fragment } from 'react'
import { Empty, Form } from 'antd'
import { Grid, GridItem } from '../../components/Grid'
2021-10-06 13:57:04 +05:00
import '../../styles/index.css'
import '../../styles/measure.css'
2021-10-06 13:57:04 +05:00
const colsCount = 3
2021-10-06 13:57:04 +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>
<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}
style={{ padding: 0 }}
>
{column.render(item[column.dataIndex])}
</Form.Item>
) : (
<p key={column.title} className={'m-5px'}>
{item[column.dataIndex]}
</p>
)}
</GridItem>
</Fragment>
))}
</Grid>
))