isNewTable.jsx 4.1 KB
/**
 * 测试新表格
 */
import React, { Component } from 'react'
import TableCom from '../tableCompon/index';
export default class isNewTable extends Component {
    render() {
        const {
            items,
            checkAllHidden,
            isBorder,
            borderStyle,
            fatherCode,
            index,
            datas,
            isEdit,
            currentFormKey,
            init,
            get,
            obj,
            mapData,
            form,
            sqlData,
            defaultValues,
            width
        } = this.props
        return (
            <>
                {
                    items.map((row,i)=>{
                        const allhidden = checkAllHidden(row)
                        console.log(row,items)
                        return <div key={i}>
                            {
                                row.map((cell,j)=>{ // 每行渲染
                                    let styles={}
                                    if(cell.content&&cell.content.styles){
                                        try{
                                            styles= JSON.parse(cell.content.styles)
                                        }catch (e) {
                                            console.log(`第${i}行第${j}列样式配置有误,${e}`)
                                        }
                                    }
                                    console.log(cell)
                                    return !allhidden && cell.hidden ? 
                                            "" 
                                            :<div // 组件渲染
                                                style = {{
                                                    display:'inline-block',
                                                    width:i==0?
                                                    ((cell.content!=null&&cell.content.cwidth!=null?cell.content.cwidth:width) * (cell.col ? cell.col : 1))      
                                                    :width * (cell.col ? cell.col : 1),
                                                    overflow:'auto',
                                                    textAlign: cell.content&&cell.content.calign?cell.content.calign:"left",
                                                    ...isBorder?borderStyle:{},
                                                    minWidth:100,
                                                    minHeight:32
                                                }}
                                                key ={j}
                                                >
                                                    <TableCom 
                                                        i={i}  
                                                        j={j} 
                                                        fatherCode={fatherCode} 
                                                        index={index} 
                                                        datas={datas} 
                                                        uuid={cell.uuid} 
                                                        isEdit={isEdit} 
                                                        formKey={currentFormKey} 
                                                        init={init} 
                                                        get={get} 
                                                        json={cell.content} 
                                                        obj={ obj}
                                                        mapData={mapData} 
                                                        form={form} 
                                                        sqlData={sqlData} 
                                                        defaultValues={defaultValues}
                                                        />
                                            </div>
                                            })
                            }
                        </div>
                    })
                }
            </>
        )
    }
}