import React from 'react';
import { connect } from 'dva';
import { Button, Row, Col, Form, Popconfirm,message} from 'antd';
import {   initFilter, } from "../../../utils/common";
import TableListComponent from "../../../baseComponents/TableListComponent";
import TableComponent from '../../../baseComponents/TableComponent';

class EntityFieldTableComponent extends TableComponent{
  constructor(props) {
    super(props);
    this.state = {
      data: {},
    };
  }; 
  // onLoadData(){
    
  //   const data=this.props.data;
  //   if(data.parentRecord&&data.parentRecord.FieldEntityName){
  //     console.log(data);
  //    // loadParam.Keyword=data.parentRecord.FieldEntityName?data.parentRecord.FieldEntityName:data.parentRecord.EntityName;
  //   }
  //   else{
  //     super.onLoadData();
  //   }
  // }

  onLoadTableDataParam(params){
    super.onLoadTableDataParam(params);
    const {tableCode,loadParam,tableConfig}=params?params:{};
    const data=this.props.data;
    if(data.parentRecord){
      console.log(data);
      loadParam.Keyword=data.parentRecord.FieldEntityName?data.parentRecord.FieldEntityName:data.parentRecord.EntityName;
    }
  }
}



class EntityFieldListPage extends TableListComponent {
  constructor(props) {
    super(props);
    this.state = {
      data: {},
    };
  }; 
  
  onRenderTable({formCode}){
    return <EntityFieldTableComponent
    {...this.props}
    formCode={formCode}
    onRegLoadDataFunc={this.handleLoadData.bind(this)}
    onLoadParam={this.handleLoadParam}
    onLoadAllData={this.handleLoadAllData} 
    isQuery={false}
/>
  } 
}
 
export default connect(({ login, loading,custom }) => ({ login, loading,custom }))(Form.create()(EntityFieldListPage));
