import React from 'react';
import { connect } from 'dva';
import { Button } from 'antd';
import EditColumnFillMapDetailShowPage from './EditColumnFillMapDetailShowPage';
import PageConfigShowBaseComponent from "../Lib/PageConfigShowBaseComponent";
import {guid} from "../../../utils/common";

class EditColumnFillMapShowPage extends PageConfigShowBaseComponent {
  constructor(props) {
    super(props);
    this.state = {
      data: {},
      paginationIndex:1,
      paginationTotalCount: 0,
      rowData:{},
      visible:false,
      visibleConfirm:false
    };
  };
  onGetTableConfig(){
    const tableConfig={
      sort: 'CREATE_TIME',
      order: 1,
      api:'PF/EditColumnFillMap/OrderPaged',
      columns: [

        {field:'SRC_NAV',label:'来源导航',isRequire:true},
        {field:'DEST_NAV',label:'目的导航',isRequire:true},
      ],
      deleteApi:'PF/EditColumnFillMap/Delete',
      editConfig:{
        data: {
          'ORG_ID': this.props.orgId,
          'EDIT_COLUMN_ID': this.props.editColumnId,
        },
        columns:[
          {controlType:1,field:'SRC_NAV',label:'来源导航',isRequire:true},
          {controlType:1,field:'DEST_NAV',label:'目的导航',isRequire:true},
        ],
        getApi:'PF/EditColumnFillMap/Get',
        saveApi:'PF/EditColumnFillMap/Update',
      },
      rule:{
        rules:[
          {field:'EDIT_COLUMN_ID',operator:1,value:this.props.editColumnId},
        ]
      },
      rowBtns:[
        {id:guid(),btnType:7,code:'edit'},
        {id:guid(),btnType:4,code:'delete'},
        {id:guid(),btnType:7,code:'detail'},
      ]
    };
    return [tableConfig];
  }

  onTableBtnParam(params){
    const {btnConfig,record}=params?params:{};
    if(btnConfig.code==='detail') {
      return {
        content: <EditColumnFillMapDetailShowPage fillMapId={record.ID} orgId={this.props.orgId}>
          <Button icon={'info'} css={'default'} size={'small'} title={'字段'}/>
        </EditColumnFillMapDetailShowPage>
      };
    }

    return super.onTableBtnParam(params);
  }
  getRowOtherBtns({record}){
    return <>
      <EditColumnFillMapDetailShowPage fillMapId={record.ID} orgId={this.props.orgId}>
        <Button icon={'info'} css={'default'}>字段</Button>
      </EditColumnFillMapDetailShowPage>
      </>
  }

}
export default  connect(({ login, app,loading,custom }) => ({ login,app, loading,custom }))(EditColumnFillMapShowPage);
