/**
 * 测试新表格
 */
import React, { Component } from 'react';
import { Card, WhiteSpace } from 'antd-mobile';
import { Row, Col } from 'antd';
import TableCom from '../tableCompon/index';

export default class isNewTable extends Component {
	render() {
		const {
			isRowCol,
			items,
			checkAllHidden,
			isBorder,
			borderStyle,
			fatherCode,
			userId,
			index,
			datas,
			isEdit,
			currentFormKey,
			init,
			get,
			obj,
			mapData,
			form,
			sqlData,
			defaultValues,
			width,
			routerState,
			messageData,
			formCode,
			formId,
			fatherObj,
			style,
			isPreview,
			modalInit,
			concealModel,
			taskAssignee,
			currentFormTitle,
			getCellValue,
			hfInstance,
			trees,
			getCurrentFormTitle,
		} = this.props;
		if (!isEdit) {
			// 展示栏 暂不做处理
			return (
				<>
					{items.map((item, i) => {
						const allhidden = checkAllHidden(items);
						return (
							<div
								key={i}
								style={{
									marginTop: 0,
									background: '#ffffff',

									width: '100%',
									flexWrap: 'wrap',
									...style,
								}}>
								{item.map((ary, j) => {
									let styles = {};
									if (ary.content && ary.content.styles) {
										try {
											styles = JSON.parse(ary.content.styles);
										} catch (e) {
											console.log(`第${i}行第${j}列样式配置有误,${e}`);
										}
									}
									return !allhidden && ary.hidden ? (
										''
									) : (
										<div
											style={{
												...styles,
												textAlign: 'left',
												borderBottom: '1px solid white',
												display:
													ary.content &&
													(ary.content.comName === 'InputHidden' || ary.content.isMobileHidden) &&
													'none',
											}}>
											<TableCom
												taskAssignee={taskAssignee} // 提交人
												trees={trees}
												userId={userId}
												modalInit={modalInit}
												formCode={formCode}
												formId={formId}
												isPreview={isPreview}
												i={i}
												j={j}
												taskId={this.props.taskId}
												setRealTimeValues={this.props.setRealTimeValues}
												index={index}
												getCurrentFormTitle={getCurrentFormTitle}
												fatherCode={fatherCode}
												datas={datas}
												isEdit={isEdit}
												fatherObj={this.props.fatherObj}
												formKey={currentFormKey}
												currentFormTitle={currentFormTitle}
												hfInstance={hfInstance}
												getCellValue={getCellValue}
												initExcel={this.props.initExcel}
												init={init}
												get={get}
												key={j}
												sqlData={sqlData}
												obj={obj || {}}
												form={this.props.form}
												mapData={mapData}
												json={ary.content}
												uuid={ary.uuid}
												routerState={routerState} // 兼容表单设计器路由传参
												defaultValues={defaultValues || {}}
												messageData={messageData} // 场景设计器共享变量参数
												concealModel={concealModel} // 场景设计器路由跳转参数
											/>
										</div>
									);
								})}
							</div>
						);
					})}
				</>
			);
		}

		return items.map((item, i) => {
			const allhidden = checkAllHidden(items);
			return (
				<Row
					style={{
						...style,
					}}>
					{item.map((ary, j) => {
						let styles = {};
						if (ary.content && ary.content.styles) {
							try {
								styles = JSON.parse(ary.content.styles);
							} catch (e) {
								console.log(`第${i}行第${j}列样式配置有误,${e}`);
							}
						}
						if (ary.content?.comName === 'Label') {
							return (
								<Col
									style={{
										display:
											ary.content &&
											(ary.content.comName === 'InputHidden' || ary.content.isMobileHidden) &&
											'none',
										...styles,
									}}
									span={ary.content?.labelSpan || 24}>
									{!allhidden && ary.hidden ? (
										''
									) : (
										<>
											<TableCom
												trees={trees}
												formCode={formCode}
												taskAssignee={taskAssignee}
												formId={formId}
												modalInit={modalInit}
												i={i}
												j={j}
												taskId={this.props.taskId}
												isPreview={isPreview}
												index={index}
												fatherCode={fatherCode}
												datas={datas}
												isEdit={isEdit}
												setRealTimeValues={this.props.setRealTimeValues}
												getCurrentFormTitle={getCurrentFormTitle}
												importExcel={this.props.importExcel}
												fatherObj={this.props.fatherObj}
												formKey={currentFormKey}
												currentFormTitle={currentFormTitle}
												hfInstance={hfInstance}
												getCellValue={getCellValue}
												init={init}
												get={get}
												key={j}
												sqlData={sqlData}
												obj={obj || {}}
												form={this.props.form}
												mapData={mapData}
												json={ary.content}
												uuid={ary.uuid}
												routerState={routerState} // 兼容表单设计器路由传参
												defaultValues={defaultValues || {}}
												messageData={messageData} // 场景设计器共享变量参数
											/>
										</>
									)}
								</Col>
							);
						}
						return (
							<Col
								span={24}
								style={{
									display:
										ary.content &&
										(ary.content.comName === 'InputHidden' || ary.content.isMobileHidden) &&
										'none',
									...styles,
								}}>
								{!allhidden && ary.hidden ? (
									''
								) : (
									<>
										<TableCom
											trees={trees}
											formCode={formCode}
											taskAssignee={taskAssignee}
											formId={formId}
											taskId={this.props.taskId}
											isPreview={isPreview}
											i={i}
											j={j}
											index={index}
											fatherCode={fatherCode}
											datas={datas}
											modalInit={modalInit}
											isEdit={isEdit}
											getCurrentFormTitle={getCurrentFormTitle}
											fatherObj={this.props.fatherObj}
											formKey={currentFormKey}
											importExcel={this.props.importExcel}
											currentFormTitle={currentFormTitle}
											hfInstance={hfInstance}
											getCellValue={getCellValue}
											init={init}
											get={get}
											key={j}
											setRealTimeValues={this.props.setRealTimeValues}
											sqlData={sqlData}
											obj={obj || {}}
											form={this.props.form}
											mapData={mapData}
											json={ary.content}
											uuid={ary.uuid}
											routerState={routerState} // 兼容表单设计器路由传参
											defaultValues={defaultValues || {}}
											messageData={messageData} // 场景设计器共享变量参数
										/>
									</>
								)}
							</Col>
						);
					})}
				</Row>
			);
		});
	}
}
