/***
 * 
 * 明细  
 * 
***/

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, autorun } from 'mobx'
import { Row, Col, Popconfirm, Modal ,Spin} from 'antd';
import { PtyPicker } from '@/components/Business-Library'
import { Link, withRouter } from 'react-router-dom'
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)
	}

	//交易描述赋值
	componentDidMount() {
		super.componentDidMount()
		this.autoDispose = autorun(() => {
			//最大金额变动=修改后最大金额-原最大金额
      this.model.detamep_maxamt=(this.model.max_amt-this.model.max1_amt).toString()
      
      //计算修改金额
      this.model.detamep_engamt=(this.model.nom1_amt-this.model.nom11_amt).toString()
      console.log(this.model.detamep_engamt)

      //非拒绝修改时，清空修改理由
      if(!(this.model.rejameflg=="RJCT")){
        this.model.rejamersn=""
      }
    })
	}

	componentWillUnmount() {
		this.autoDispose && this.autoDispose()
	}

	//交易内实现
	renderPage() {
		const bind = this.bind
		const { i18n } = this.props
    const { bchlevelLst } = this.props.extra
    const rejameflgCode = [
      { label: `拒绝修改`, value: `RJCT` },
      { label: `同意修改`, value: `ACPT` },
    ]
		//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 i18nId={"CPTP_LT000022"} />
							</Col>
							<Col span={14}>
								<InputItem InputProps={bind("ownref")}  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="概要描述"  />	
							</Col>
							<Col span={14}>
								<InputItem InputProps={bind("nam")}  maxLength={40}  desp="概要描述" path="/dedgrp/rec/nam"  disabled={true} />
							</Col>
						</Row>
					</Col>
				</Row>
				
				<Row>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label itext="最后修改日期" trn="detame" />
							</Col>
							<Col span={14}>
								<DatePickerItem InputProps={bind("amedat")}  desp="最后修改日期" path="/dedgrp/rec/amedat"  disabled={true} />
							</Col>
						</Row>
					</Col>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label itext="修改次数" trn="detame" />
							</Col>
							<Col span={14}>
								<InputItem InputProps={bind("amenbr")}   desp="修改次数" path="/dedgrp/rec/amenbr"  disabled={true} />
							</Col>
						</Row>
					</Col>
				</Row>

				<Row>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label itext="原溢短装" trn="detame" />	
							</Col>
							<Col span={6}>
								<InputItem InputProps={bind("nomtop1")}   desp="上浮" path="/olddedgrp/rec/nomtop"  disabled={true} />
							</Col>
							<Col span={1} offset={1}>
								<Label itext="/" trn="detame" />	
							</Col>
							<Col span={6}>
								<InputItem InputProps={bind("nomton1")}   desp="下浮" path="/olddedgrp/rec/nomton"  disabled={true} />
							</Col>
						</Row>
					</Col>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label itext="新溢短装" trn="detame" />
							</Col>
							<Col span={6}>
								<InputItem InputProps={bind("nomtop")} disabled={true} />
							</Col>
							<Col span={1} offset={1}>
								<Label itext="/" trn="detame" />	
							</Col>
							<Col span={6}>
								<InputItem InputProps={bind("nomton")} disabled={true} />
							</Col>
						</Row>
					</Col>
				</Row>

				<Row>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label itext="原开证金额" trn="detame" />
							</Col>
							<Col span={6}>
								<SelectItem InputProps={bind("nom11_cur")} code={CodeTable.curtxt}  desp="Currency" path="/olddedgrp/cbs/nom1/cur"  disabled={true}/>
							</Col>
							<Col span={7} offset={1}>
								<InputItem   InputProps={ {...bind("nom11_amt"), type:"amount", cur:this.model.nom11_cur} } disabled={true} />
							</Col>
						</Row>
					</Col>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label itext="原最大金额" trn="detame" />	
							</Col>
							<Col span={6}>
								<SelectItem InputProps={bind("max1_cur")} code={CodeTable.curtxt}  desp="Currency" path="/olddedgrp/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>
				</Row>

				<Row>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label itext="修改金额" trn="detame" />	
							</Col>
							<Col span={6}>
								<SelectItem InputProps={bind("detamep_engcur")} code={CodeTable.curtxt}   desp="Engagement Currency" path="/detamep/engcur"  disabled={true}/>
							</Col>
							<Col span={7} offset={1}>
								<InputItem   InputProps={ {...bind("detamep_engamt"), type:"amount", cur:this.model.detamep_engcur} } disabled={true}/>
							</Col>
						</Row>
					</Col>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label itext="最大金额变动" trn="detame" />
							</Col>
							<Col span={6}>
								<SelectItem InputProps={bind("detamep_maxcur")} code={CodeTable.curtxt}   desp="Currency of Maximum Amount" path="/detamep/maxcur"  disabled={true}/>
							</Col>
							<Col span={7} offset={1}>
								<InputItem   InputProps={ {...bind("detamep_maxamt"), type:"amount", cur:this.model.detamep_maxcur} } disabled={true} />
							</Col>
						</Row>
					</Col>
				</Row>

				<Row>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label itext="修改后金额" trn="detame" />
							</Col>
							<Col span={6}>
								<SelectItem InputProps={bind("nom1_cur")} code={CodeTable.curtxt}  desp="Currency" path="/dedgrp/cbs/nom1/cur"  disabled={true}/>
							</Col>
							<Col span={7} offset={1}>
								<InputItem   InputProps={ {...bind("nom1_amt"), type:"amount", cur:this.model.nom1_cur} } disabled={true}/>
							</Col>
						</Row>
					</Col>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label itext="修改后最大金额" trn="detame" />	
							</Col>
							<Col span={6}>
								<SelectItem InputProps={bind("max_cur")} code={CodeTable.curtxt}  desp="Currency" path="/dedgrp/cbs/max/cur"  disabled={true}/>
							</Col>
							<Col span={7} offset={1}>
								<InputItem   InputProps={ {...bind("max_amt"), type:"amount", cur:this.model.max_cur} } disabled={true} />
							</Col>
						</Row>
					</Col>
				</Row>

				<Row>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label itext="原有效日期" trn="detame" />
							</Col>
							<Col span={14}>
								<DatePickerItem InputProps={bind("expdat1")}  desp="有效日期" path="/olddedgrp/rec/expdat"  disabled={true} />
							</Col>
						</Row>
					</Col>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label itext="新有效日期" trn="detame" />
							</Col>
							<Col span={14}>
								<DatePickerItem InputProps={bind("expdat")}  desp="有效日期" path="/dedgrp/rec/expdat" />
							</Col>
						</Row>
					</Col>
				</Row>

				<Row>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label itext="原最迟货物装运日期" trn="detame" />
							</Col>
							<Col span={14}>
								<DatePickerItem InputProps={bind("shpdat1")}  desp="最迟货物装运/服务提供日期 " path="/olddedgrp/rec/shpdat"  disabled={true} />
							</Col>
						</Row>
					</Col>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label itext="新最迟货物装运日期 " trn="detame" />	
							</Col>
							<Col span={14}>
								<DatePickerItem InputProps={bind("shpdat")}  desp="最迟货物装运/服务提供日期 " path="/dedgrp/rec/shpdat" />
							</Col>
						</Row>
					</Col>
				</Row>

				<Row>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label itext="原有效地点" trn="detame" />
							</Col>
							<Col span={14}>
								<InputItem InputProps={bind("expplc1")}  maxLength={100}  desp="有效地点" path="/olddedgrp/rec/expplc"  disabled={true} />
							</Col>
						</Row>
					</Col>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label itext="新有效地点" trn="detame" />
							</Col>
							<Col span={14}>
								<InputItem InputProps={bind("expplc")}  maxLength={100}  desp="有效地点" path="/dedgrp/rec/expplc" />
							</Col>
						</Row>
					</Col>
				</Row>

        <Row>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
                <Label itext="拒绝修改标识" trn="detame" />
							</Col>
							<Col span={14}>
                <SelectItem InputProps={bind("rejameflg")} code={rejameflgCode} />
							</Col>
						</Row>
					</Col>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
                <Label itext="拒绝修改理由" trn="detame" />
							</Col>
							<Col span={14}>
								<InputItem InputProps={bind("rejamersn")}  maxLength={60} disabled={!(this.model.rejameflg == "RJCT")} />
							</Col>
						</Row>
					</Col>
				</Row>

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