2021-11-17 14:08:13 +05:00
|
|
|
import React 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'
|
|
|
|
|
2021-11-17 14:08:13 +05:00
|
|
|
const colsCount = 3
|
2021-10-06 13:57:04 +05:00
|
|
|
|
2021-11-17 14:08:13 +05:00
|
|
|
const headerCellStyle = {
|
|
|
|
border:'1px solid lightgrey'
|
2021-10-06 13:57:04 +05:00
|
|
|
}
|
2021-09-03 09:26:43 +05:00
|
|
|
|
2021-11-17 14:08:13 +05:00
|
|
|
const valueCellStyle = {
|
|
|
|
border:'1px solid lightgrey',
|
|
|
|
justifyContent:'right',
|
|
|
|
marginRight:'16px',
|
|
|
|
fontWeight:'bold',
|
|
|
|
textAlign:'right',
|
|
|
|
padding: 0
|
|
|
|
}
|
|
|
|
|
|
|
|
export const View = React.memo(({columns, item}) => {
|
2021-09-03 09:26:43 +05:00
|
|
|
if (!item || !columns?.length)
|
2021-10-07 15:05:59 +05:00
|
|
|
return <Empty key='empty' image={Empty.PRESENTED_IMAGE_SIMPLE}/>
|
2021-09-03 09:26:43 +05:00
|
|
|
|
2021-11-17 14:08:13 +05:00
|
|
|
return (
|
2021-10-04 18:06:42 +05:00
|
|
|
<Grid>
|
2021-11-17 14:08:13 +05:00
|
|
|
{columns.map((column, i) => (
|
|
|
|
<>
|
|
|
|
<GridItem
|
|
|
|
key={column.dataIndex}
|
|
|
|
row={Math.floor(i / colsCount) + 1}
|
|
|
|
col={(i % colsCount) * 2 + 1}
|
|
|
|
style={headerCellStyle}
|
|
|
|
>
|
|
|
|
{column.title}
|
|
|
|
</GridItem>
|
|
|
|
|
|
|
|
<GridItem
|
|
|
|
key={column.title}
|
|
|
|
row={Math.floor(i / colsCount) + 1}
|
|
|
|
col={(i % colsCount) * 2 + 2}
|
|
|
|
style={valueCellStyle}
|
|
|
|
>
|
|
|
|
{column.render ? (
|
|
|
|
<Form.Item
|
|
|
|
key={column.dataIndex}
|
|
|
|
name={column.dataIndex}
|
|
|
|
style={{ margin: 0 }}
|
|
|
|
//rules={column.formItemRules}
|
|
|
|
>
|
|
|
|
{column.render(item[column.dataIndex])}
|
|
|
|
</Form.Item>
|
|
|
|
) : (
|
|
|
|
<p key={column.title} className='m-5px'>{item[column.dataIndex]}</p>
|
|
|
|
)}
|
|
|
|
</GridItem>
|
|
|
|
</>
|
|
|
|
))}
|
2021-10-04 18:06:42 +05:00
|
|
|
</Grid>
|
2021-11-17 14:08:13 +05:00
|
|
|
)
|
|
|
|
})
|