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

class FormRelationShowPage extends PageConfigShowBaseComponent {
  constructor (props) {
    super(props)
    this.state = {
      data: {},
      paginationIndex: 1,
      paginationTotalCount: 0,
      rowData: {},
      visible: false,
    }
  };

  onGetTableConfig () {
    const tableConfig = {
      sort: 'CODE',
      order: 0,
      api: 'PF/FormRelation/OrderPaged',
      columns: [
        { field: 'CODE', label: '表单编码', isRequire: true },
        { field: 'REMARK', label: '备注' },
      ],
      deleteApi: 'PF/FormRelation/Delete',
      editConfig: {
        data: {
          'ORG_ID': this.props.orgId,
          'PAGE_FORM_ID': this.props.formId
        },
        columns: [
          { controlType: 1, field: 'CODE', label: '表单编码', isRequire: true },
          { controlType: 1, field: 'REMARK', label: '备注' },
        ],
        getApi: 'PF/FormRelation/Get',
        saveApi: 'PF/FormRelation/Update',
      },
      rule: {
        rules: [
          { field: 'PAGE_FORM_ID', operator: 1, value: this.props.formId },
        ]
      },
      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 }))(FormRelationShowPage)
