import React,{Component,Fragment} from 'react'
import {Page,Validator,Notification,FormItem,
    InputItem,Input,Bind,SelectItem,Button,Label,Table,Section,DatePickerItem} from '@/components/Common-Library'
import {Divider,Card} from 'antd'
import Api from '@/service/api'
import mDbibch from '../model'
import CodeTableFactory from '@/components/CodeTable'
import "./index.less"
import { inject, observer } from 'mobx-react'
import { action, observable } from 'mobx'
import {Col,Row} from 'antd'
import {Link} from 'react-router-dom'
import Moment from 'moment'
import Ptspta1 from '@/views/Public/Ptspta1'
const CodeTable = CodeTableFactory.getInstance()




@inject('UserContext')
@inject('i18n')
@observer
export default class DbibchScreen extends Page
{
    @observable
    formBlur=false

    @observable
    extra = { inifrm: 'dbibch', sptinr: '', upbchkey:[], accbch:[]}

    constructor(props)
    {
        super(props)
        this.model = new mDbibch()
        this.bind = Bind.bind(this)
    }

    componentWillUnmount()
    {
      this.model.stopMonitor&&this.model.stopMonitor()//关闭校验
    }

	async componentWillMount() {
		if(this.props.location.query){
			let selinr = this.props.location.query.inr
			const rtnmsg = await Api.post('dbibch/init', { params: {selinr} })
			if (rtnmsg.retcod == SUCCESS) {
				//Notification.success({ message: '数据提交成功!' })
        Object.assign(this.model,rtnmsg.data)
        this.extra.upbchkey = rtnmsg.codetable.upbchkey;
        this.extra.accbch = rtnmsg.codetable.accbch;
			}
			else {
				Notification.error({ message: '服务端请求失败!' })
			}	
		}	
    
    //快照模式下，不必开启校验，否则，静默校验，和记录变动
    !this.loadDisplay() && this.model.openMonitor() //开启校验
	}


    //按钮事件
     onRtn = ()=>{
		this.props.history.goBack();
	}

    //交易内实现
    renderPage(){
    	const bind = this.bind
        const {i18n} = this.props
        const CodeTable = CodeTableFactory.getInstance()
     
        return (
        	<Card title="机构维护" size="small" className="transTitle">
        	<div style={{position:'relative'}}>
          <Row>
            <Col span={12}>
              <Row className="row">
                <Col span={5} offset={2}>
                  <Label i18nId={"BCHP_LT000003"} />
                </Col>
                <Col span={14}>
                  <InputItem InputProps={bind("branch")} maxLength={8} desp="机构编码" path="/bchgrp/rec/branch" disabled={true} />
                </Col>
              </Row>
            </Col>
            <Col span={12}>
              <Row className="row">
                <Col span={5} offset={2}>
                  <Label i18nId={"BCHP_LT000004"} />
                </Col>
                <Col span={14}>
                  <InputItem InputProps={bind("namcn")} maxLength={40} desp="中文名称" path="/bchgrp/rec/namcn" disabled={true} />
                </Col>
              </Row>
            </Col>
          </Row>

          <Row>
            <Col span={12}>
              <Row className="row">
                <Col span={5} offset={2}>
                  <Label i18nId={"BCHP_LT000008"} />
                </Col>
                <Col span={14}>
                  <SelectItem InputProps={bind("lev")} code={CodeTable.bchlev} desp="机构级别" path="/bchgrp/rec/lev" disabled={true} />
                </Col>
              </Row>
            </Col>
            <Col span={12}>
              <Row className="row">
                <Col span={5} offset={2}>
                  <Label i18nId={"BCHP_LT000006"} />
                </Col>
                <Col span={14}>
                  <InputItem  InputProps={bind("adrcn")} desp="中文地址" path="/bchgrp/rec/adrcn" disabled={true} />
                </Col>
              </Row>
            </Col>
          </Row>

          <Row>
            <Col span={12}>
              <Row className="row">
                <Col span={5} offset={2}>
                  <Label i18nId={"BCHP_LT000010"} />
                </Col>
                <Col span={14}>
                  <InputItem InputProps={bind("upbranch")} maxLength={8} desp="上级机构编码" path="/bchgrp/rec/upbranch" disabled={true} />
                </Col>
              </Row>
            </Col>
            <Col span={12}>
              <Row className="row">
                <Col span={5} offset={2}>
                  <Label i18nId={"BCHP_LT000005"} />
                </Col>
                <Col span={14}>
                  <InputItem InputProps={bind("decnum")} maxLength={12} desp="金融机构标识码" path="/bchgrp/rec/decnum" disabled={true} />
                </Col>
              </Row>
            </Col>
          </Row>

          <Row>
            <Col span={12}>
              <Row className="row">
                <Col span={5} offset={2}>
                  <Label i18nId={"BCHP_LT000009"} />
                </Col>
                <Col span={14}>
                  <SelectItem InputProps={bind("accbch")} code={this.extra.accbch} desp="记账机构" disabled={true} />
                </Col>
              </Row>
            </Col>
            <Col span={12}>
              <Row className="row">
                <Col span={5} offset={2}>
                  <Label i18nId={"BCHP_LT000014"} />
                </Col>
                <Col span={14}>
                  <InputItem InputProps={bind("rmbrpt")} maxLength={12} desp="人行支付行号" path="/bchgrp/rec/rmbrpt" disabled={true} />
                </Col>
              </Row>
            </Col>
          </Row>

          <Row>
            <Col span={12}>
              <Row className="row">
                <Col span={5} offset={2}>
                  <Label i18nId={"BCHP_LT000015"} />
                </Col>
                <Col span={14}>
                  <SelectItem InputProps={bind("sta")} code={CodeTable.bchsta} desp="机构状态" path="/bchgrp/rec/sta" disabled={true} />
                </Col>
              </Row>
            </Col>
            <Col span={12}>
              <Row className="row">
                <Col span={5} offset={2}>
                  <Label value="机构类型" />
                </Col>
                <Col span={14}>
                  <SelectItem InputProps={bind("corflg")} code={CodeTable.corflg} desp="机构类型" path="/bchgrp/rec/corflg" disabled={true} />
                </Col>
              </Row>
            </Col>
          </Row>

          <Row>
            <Col span={12}>
              <Row className="row">
                <Col span={5} offset={2}>
                  <Label i18nId="业务上交单证中心" />
                </Col>
                <Col span={14}>
                  <SelectItem InputProps={bind("upbchkey")} code={this.extra.upbchkey} desp="业务上交单证中心" path="/bchgrp/rec/upbchkey" disabled={true} />
                </Col>
              </Row>
            </Col>
            <Col span={12}>
              <Ptspta1  model={this.model} argArr={{ desc: "关联客户信息", prefix: 'pts', url: 'dbibch/ptsp_ptysel',flg: 'B', datakey: '\\bchp\\ptsp\\ptslst'}} isDisabled={true} />
            </Col>
          </Row>

				<Row gutter={16}>
					<Col offset={11}>
						<Button type="primary" onClick={this.onRtn}>
   						<Label i18nId="MTABUT_BT000020" />      
            </Button>
					</Col>
				</Row>
			</div>
		</Card>
		)
	}
}
