/* eslint-disable array-callback-return,no-undef */
import React, { Component } from 'react';
import { Form } from '@ant-design/compatible';
// import '@ant-design/compatible/assets/index.css';
import { Layout, Tabs, Spin } from 'antd-v4';
import styles from '@/index.less';
import * as commonFunc from '@/components/Common/commonFunc';
import CommonBase from '@/components/Common/CommonBase';
import CommonImportDataComponet from '@/components/Common/CommonImportDataEvent';
import StaticEditTable from '@/components/Common/CommonTable';/* 可编辑表格 */
import CommonView from '@/components/Common/CommonViewNew';
import * as commonBusiness from '@/components/Common/commonBusiness';/* 单据业务功能 */

/* 通用方法 */
const { Content } = Layout;
const { TabPane } = Tabs;

class ImportDataInfo extends Component {
  constructor(props) {
    super(props);
    this.state = {
    };
    this.form = {}; /*   表单对象   */
  }
  render() {
    const { pageLoading } = this.props;
    return (
      <div>
        <Spin spinning={pageLoading}>
          <div>
            <ImportDataComponet
              {...this.props}
              {...this.state}
            />
          </div>
        </Spin>
      </div>
    );
  }
}
const ImportDataComponet = Form.create({
  mapPropsToFields(props) {
    const { masterData } = props;
    const obj = commonFunc.mapPropsToFields(masterData, Form);
    return obj;
  },
})((props) => {
  const {
    form, onReturnForm, app,
  } = props;
  /*   回带表单   */
  onReturnForm(form);
  const nocanbeInsertProps = {
    ...commonBusiness.getTableTypes('nocanbeInsert', props),
    tableProps: { rowKey: 'rowIndex', rowSelection: null },
    enabled: false,
  };
  const tabVerifyResult = commonFunc.showMessage(app.commonConst, 'tabVerifyResult');/* 校验结果 */
  /*
  const canbeInsertProps = {
    ...commonBusiness.getTableTypes('canbeInsert', props),
    tableProps: { rowKey: 'rowIndex', rowSelection: null },
    enabled: false,
  };

  <TabPane tab="正确数据" key={7}>
      <StaticEditTable {...canbeInsertProps} />
  </TabPane>

*/
  return (
    <Form>
      <Layout>
        <Layout className={styles.clayout}>
          <Content className="importDataInfo">
            <CommonView {...commonBusiness.getWriteTypes('master', props)} />
            <div id="importDataInfo">
              <div id="insertData" >
                <Tabs className={styles.slaveTabs} style={{ margin: '0px!important' }} tabBarStyle={{ margin: '0 10px' }}>
                  <TabPane tab={tabVerifyResult} key={6}>
                    <StaticEditTable {...nocanbeInsertProps} />
                  </TabPane>
                </Tabs>
              </div>
            </div>
          </Content>
        </Layout>
      </Layout>
    </Form>
  );
});

export default CommonBase(CommonImportDataComponet(ImportDataInfo));

