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

class TableParamShowPage extends PageConfigShowBaseComponent {
  constructor(props) {
    super(props);
    this.state = {
      data: {},
      paginationIndex:1,
      paginationTotalCount: 0,
      rowData:{},
      visible:false,
      visibleConfirm:false
    };
  };
  componentDidMount() {
    super.componentDidMount();
  };
  onGetTableConfig(){
    const tableConfig={
      sort: 'ID',
      order: 0,
      api:'PF/TableParams/OrderPaged',
      columns: [
        {field:'FIELD_NAME',label:'字段',isRequire:true},
        {field:'OPERATION',label:'条件操作符',data:{enumName:'PFOperateEnum'}},
        {field:'VALUE',label:'值'},
        {label: '自定义字段', field: 'IS_CUSTOM', isBool: true},
        {field: 'IS_SYS_PARAM', label: '是否系统参数', isBool: true},
      ],
      deleteApi:'PF/TableParams/Delete',
      editConfig:{
        data: {
          ORG_ID: this.props.orgId,
          PAGE_TABLE_ID: this.props.pageTableId,
          OPERATION: 1,
        },
        columns:[
          {controlType:1,field:'FIELD_NAME',label:'字段',isRequire:true},
          {controlType:3,field:'OPERATION',label:'条件操作符',data:{enumName:'PFOperateEnum'}},
          {controlType:1,field:'VALUE',label:'值'},
          {controlType:4,field:'IS_CUSTOM',label:'是否自定义字段',},
          {controlType:4,field:'IS_SYS_PARAM',label:'系统参数',},
        ],
        getApi:'PF/TableParams/Get',
        saveApi:'PF/TableParams/Update',
        promptInfo:'说明：值可以通过@user取到当前用户的信息，例子：用户ID设置为@user.ID 注意@user大小写;部门@department;班组@team',
      },
      rule:{
        rules:[
          {field:'PAGE_TABLE_ID',operator:1,value:this.props.pageTableId}
        ]
      },
      rowBtns:[
        {id:guid(),btnType:7,code:'edit'},
        {id:guid(),btnType:4,code:'delete'},
      ]
    };
    return [tableConfig];
  }

}


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