/***
 * 
 * 第一个 
 * 
***/

import React, { Component, Fragment } from 'react'
import {
	Page, Validator, Notification, FormItem, BottomBtn,
	InputItem, Input, Bind, SelectItem, Button, Label, DatePickerItem, Section, ConfirmButton, Steps
} from '@/components/Common-Library'
import Api from '@/service/api'
import CodeTableFactory from '@/components/CodeTable'
import "./index.less"
import { inject, observer } from 'mobx-react'
import { action, observable } from 'mobx'
import { Row, Col, Popconfirm, Modal ,Spin} from 'antd';
import { PtyPicker } from '@/components/Business-Library'
import { Link, withRouter } from 'react-router-dom'
import Ptspta1 from '@/views/Public/Ptspta1'
import Business from '@/views/Public/Business'

const { Pre, Next, StepWrapper } = Steps
const CodeTable = CodeTableFactory.getInstance()
const confirm = Modal.confirm
  
@withRouter
@inject('UserContext')
@inject('i18n')
@observer
export default class OvwpScreen extends Page {
	@observable
	formBlur = false

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

	async componentWillMount(){
		this.onDocprbrol();
	}

	onDocprbrol= ()=>{
		this.formBlur=true  //已触发表单提交处理
		Validator.validate(this.model,this.model.descriptor,async(errors,values)=>{
						if(errors)
								return 
						const rtnmsg = await Api.post('bmtrgf/docprbrol',{data:this.model})
						if(rtnmsg.retcod == SUCCESS)
						{
								// Notification.success({message:'docprfrol接口数据提交成功!'})
								
								this.model.docprbrol = rtnmsg.data.docprbrol;
						}
						else
						{
							Notification.error({message:'服务端请求失败!'})
						}
						//余下逻辑处理
		})
	}

	//交易内实现
	renderPage() {
		const bind = this.bind
		const { i18n } = this.props
		const { bchlevelLst } = this.props.extra
		//const {next,pre} = this.props.steps
		if(this.props.flag==true){
			return <Spin style={{width:"100%", justifyContent:"center"}} spinning={this.props.flag} />
		}
		return (
			<div style={{ position: 'relative' }}>
         <Business  wrappedComponentRef={ref => (this.com = ref)} page={this} steps={this.props.steps} extra={this.props.extra}  model={this.model} />
				{/* 第一行 */}
				<Row>
          <Col span={12}>
						<Row className="row">
              <Col span={5} offset={2}>
								<Label itext="业务编号" trn="bmtrfc" />	
              </Col>
              <Col span={14}>
                <InputItem InputProps={bind("ownref1")}  maxLength={20}  desp="业务编号" path="/dedgrp/rec/ownref"  disabled={true} />
              </Col>
            </Row>
          </Col>
          <Col span={12}>
						<Row className="row">
              <Col span={5} offset={2}>
								<Label itext="信用证编号" trn="bmtrfc" />	
              </Col>
              <Col span={14}>
                <InputItem InputProps={bind("lcref")}  maxLength={35}  desp="信用证编号" path="/dedgrp/rec/lcref"  disabled={true} />
              </Col>
            </Row>
          </Col>
        </Row>

				{/**第二行 */}
				<Row>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label itext="信用证金额" trn="bmtrfc" />	
							</Col>
							<Col span={6}>
                <SelectItem InputProps={bind("max1_cur")} code={CodeTable.curtxt}  desp="Currency" path="/dedgrp/cbs/max/cur"  disabled={true}/>
							</Col>
							<Col span={7} offset={1}>
								<InputItem   InputProps={ {...bind("max1_amt"), type:"amount", cur:this.model.max1_cur} } disabled={true} />
							</Col>
						</Row>
					</Col>
					<Col span={12}>
						<Row className="row">
              <Col span={5} offset={2}>
								<Label itext="受益人" trn="bmtrfc" />	
              </Col>
              <Col span={14}>
                <InputItem InputProps={bind("pts15_namcn")}  maxLength={100}  desp="客户中文名称" path="/dedgrp/ben/pts/namcn"  disabled={true} />
              </Col>
						</Row>
					</Col>
				</Row>

				{/**第三行 */}
				<Row>
					<Col span={12}>
						<Row className="row">
              <Col span={5} offset={2}>
								<Label itext="信用证余额" trn="bmtrfc" />	
							</Col>
							<Col span={6}>
							  <SelectItem InputProps={bind("opn1_cur")} code={CodeTable.curtxt}  desp="Currency" path="/dedgrp/cbs/opn1/cur"  disabled={true}/>
							</Col>
							<Col span={7} offset={1}>
								<InputItem   InputProps={ {...bind("opn1_amt"), type:"amount", cur:this.model.opn1_cur} } disabled={true} />
							</Col>
						</Row>
					</Col>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label itext="申请人" trn="bmtrfc" />
							</Col>
							<Col span={14}>
                <InputItem InputProps={bind("pts14_namcn")}  maxLength={100}  desp="客户中文名称" path="/dedgrp/apl/pts/namcn"  disabled={true} />
							</Col>
						</Row>
					</Col>
				</Row>

				{/**第四行 */}
				<Row>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label itext="开立日期" trn="bmtrfc" />
							</Col>
							<Col span={14}>
                <DatePickerItem InputProps={bind("opndat")}  desp="开立日期" path="/dedgrp/rec/opndat"  disabled={true} />
							</Col>
						</Row>
					</Col>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label itext="开证行" trn="bmtrfc" />	
							</Col>
							<Col span={14}>
                <InputItem InputProps={bind("pts16_namcn")}  maxLength={100}  desp="客户中文名称" path="/dedgrp/iss/pts/namcn"  disabled={true} />
							</Col>
						</Row>
					</Col>
				</Row>

				{/**第五行 */}
				<Row>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label itext="信用证兑付方式" trn="bmtrfc" />
							</Col>
							<Col span={14}>
                <SelectItem InputProps={bind("avbby")} code={CodeTable.avbby}  desp="信用证对付方式" path="/dedgrp/rec/avbby"  disabled={true}/>
							</Col>
						</Row>
					</Col>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label itext="有效地点" trn="bmtrfc" />
							</Col>
							<Col span={14}>
                <InputItem InputProps={bind("expplc")}  maxLength={100}  desp="有效地点" path="/dedgrp/rec/expplc"  disabled={true} />
							</Col>
						</Row>
					</Col>
				</Row>

				{/**第六行 */}
				<Row>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label itext="有效日期" trn="bmtrfc" />
							</Col>
							<Col span={14}>
                <DatePickerItem InputProps={bind("expdat")}  desp="有效日期" path="/dedgrp/rec/expdat"  disabled={true} />
							</Col>
						</Row>
					</Col>
					<Col span={12}>
            <Row className="row">
              <Col span={5} offset={2}>
								<Label itext="概要说明" trn="bmtrfc" />
							</Col>
							<Col span={14}>
                <InputItem InputProps={bind("nam")}  maxLength={40}  desp="Externally Displayed Name to Identify the Contract" path="/bmdgrp/rec/nam"  disabled={true} />
							</Col>
						</Row>
					</Col>
				</Row>

				{/**第七行 */}
				<Row>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label itext="寄单索款编号" trn="bmtrfc" />
							</Col>
							<Col span={14}>
                <InputItem InputProps={bind("ownref")}  maxLength={16}  desp="Own Reference BE Number" path="/bmdgrp/rec/ownref"  disabled={true} />
							</Col>
						</Row>
          </Col>
          <Col span={12}>
            <Row className="row">
              <Col span={5} offset={2}>
                <Label itext="交单人类型" trn="bmtrfc" />
              </Col>
              <Col span={14}>
                <SelectItem InputProps={bind("docprbrol")} code={CodeTable.jiaodan}   desp="Presented by" path="/bmdgrp/rec/docprbrol"/>
              </Col>
            </Row>
					</Col>
				</Row>

				{/**第八行 */}
				<Row>
					<Col span={12}>
						<Col span={24}>
							<Row className="row">
								<Col span={5} offset={2}>
									<Label itext="单据类型" trn="bmtrfc" />
								</Col>
								<Col span={14}>
									<SelectItem InputProps={bind("doctypcod")} code={CodeTable.doc}  desp="Document Type" path="/bmdgrp/rec/doctypcod"/>
								</Col>
							</Row>
						</Col>
						<Col span={24}>
							<Row className="row">
								<Col span={5} offset={2}>
									<Label itext="单据金额" trn="bmtrfc" />
								</Col>
								<Col span={6}>
									<SelectItem InputProps={bind("max_cur")} code={CodeTable.curtxt}  desp="Currency" path="/bmdgrp/cbs/max/cur"/>
								</Col>
								<Col span={7} offset={1}>
									<InputItem   InputProps={ {...bind("max_amt"), type:"amount", cur:this.model.max_cur} } />
								</Col>
							</Row>
						</Col>
						<Col span={24}>
							<Row className="row">
								<Col span={5} offset={2}>
									<Label itext="收单日期" trn="bmtrfc" />
								</Col>
								<Col span={14}>
									<DatePickerItem InputProps={bind("rcvdat")}  desp="Date of Receipt of Documents" path="/bmdgrp/rec/rcvdat" />
								</Col>
							</Row>
						</Col>
          </Col>
					<Col span={12}>
            <Row className="row">
							{/* 交单人 */}
              <Ptspta1 model={this.model} argArr={{ desc: "交单人", prefix: 'pts12', url: 'bmtrfc/prbp_ptysel', flg: 'C', datakey: '\\bmtp\\prbp\\ptslst' }}  />	
            </Row>
					</Col>
				</Row>

        {/**第九行 */}
        <Row>
          <Col span={12}>
						<Col span={24}>
							<Row className="row">
								<Col span={5} offset={2}>
									<Label itext="寄单日期" trn="bmtrfc" />
								</Col>
								<Col span={14}>
									<DatePickerItem InputProps={bind("predat")}  desp="Order Date" path="/bmdgrp/rec/predat" />
								</Col>
							</Row>
						</Col>
						<Col span={24}>
							<Row className="row">
								<Col span={5} offset={2}>
									<Label itext="到期日期" trn="bmtrfc" />
								</Col>
								<Col span={14}>
									<DatePickerItem InputProps={bind("matdat")}  desp="Maturity Date" path="/bmdgrp/rec/matdat" />
								</Col>
							</Row>
						</Col>
						<Col span={24}>
							<Row className="row">
								<Col span={5} offset={2}>
									<Label itext="装运日期" trn="bmtrfc" />
								</Col>
								<Col span={14}>
									<DatePickerItem InputProps={bind("shpdat")}  desp="Date of Shipment" path="/bmdgrp/rec/shpdat" />
								</Col>
							</Row>
						</Col>
          </Col>
          <Col span={12}>
            <Row className="row">
              <Ptspta1 model={this.model} argArr={{ desc: "交单行", prefix: 'pts9', url: 'bmtrfc/frep_ptysel', flg: 'B', datakey: '\\bmtp\\frep\\ptslst' }}  />
            </Row>
          </Col>
        </Row>

				{/* 底部按钮 */}
        <BottomBtn _this={this} />
			</div >
		)
	}
}
