//第二个


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

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

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

	//单据表格
	docgrdm_docgrdHeader=[
		{
			title:<Label itext="一次" />, 
			dataIndex:"cmail1",
			key:"cmail1",
			width:80,
			render:(val,record,index)=><Input value={val}
				onChange={(val2)=>{
					// console.log(record);
					// console.log(val2)
					record.cmail1=val2;
					//解决刷新问题
					this.model.docgrdm_docgrd=[...this.model.docgrdm_docgrd]
					console.log(this.model.docgrdm_docgrd);
				}}
			/>
		},
		{
			title:<Label itext="二次" />, 
			dataIndex:"cmail2",
			key:"cmail2",
			width:80,
			render:(val,record,index)=><Input value={val}
				onChange={(val2)=>{
					record.cmail2=val2;
					//解决刷新问题
					this.model.docgrdm_docgrd=[...this.model.docgrdm_docgrd]
				}}
			/>
		},
		{
			title:<Label itext="单据" />, 
			dataIndex:"docnam",
			key:"docnam",
			width:200,
			render:(val,record,index)=><Select className="bmtrgf_btn" 
				size="small"
				value={val||[]}
				mode="tags"
				allowClear={true}
				onSelect={(val2)=>{
					record.docnam=val2
					this.model.docgrdm_docgrd=[...this.model.docgrdm_docgrd]
				}}
				onChange={(val3)=>{
					if(val3.length==0){
						record.docnam=null
						this.model.docgrdm_docgrd=[...this.model.docgrdm_docgrd]
					}
				}}
			>
				<Select.Option value="产地证">产地证</Select.Option>
				<Select.Option value="分析证">分析证</Select.Option>
				<Select.Option value="海运提单(副本)">海运提单(副本)</Select.Option>
				<Select.Option value="海运提单(正本)">海运提单(正本)</Select.Option>
				<Select.Option value="汇票">汇票</Select.Option>
				<Select.Option value="检验证">检验证</Select.Option>
				<Select.Option value="空运单">空运单</Select.Option>
				<Select.Option value="商业发票">商业发票</Select.Option>
			</Select>
		},
	]

	//新增行按钮
	onAddData=()=>{
		let newData={
			dsp: null, 
			cmail2: null, 
			tcddoc: null, 
			cmail1: null, 
			docnam: null
		}
		this.model.docgrdm_docgrd.push(newData);
		//解决刷新问题
		this.model.docgrdm_docgrd=[...this.model.docgrdm_docgrd];
	}


	//交易内实现
	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}>
						<Col span={24}>
							<Row className="row">
								<Col span={5} offset={2}>
									<Label itext="索偿金额" trn="bmtrfc" />
								</Col>
								<Col span={6}>
									<SelectItem InputProps={bind("totcur")} code={CodeTable.curtxt}  desp="Currency" path="/bmdgrp/rec/totcur"/>
								</Col>
								<Col span={7} offset={1}>
									<InputItem   InputProps={ {...bind("totamt"), type:"amount", cur:this.model.totcur} } />
								</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("totcur")} code={CodeTable.curtxt} disabled={true} />
								</Col>
								<Col span={7} offset={1}>
									<InputItem   InputProps={ {...bind("prbfee"), type:"amount", cur:this.model.totcur} } />
								</Col>
							</Row> 
						</Col>
						<Col span={24}>
							<Row className="row">
								<Col span={24}>
									<Ptspta1 model={this.model} argArr={{ desc: "收单行", prefix: 'pts11', url: 'bmtrfc/othp_ptysel', flg: 'B', datakey: '\\bmtp\\othp\\ptslst' }}  />
								</Col>
							</Row> 
						</Col>
            <Col span={24}>
              <Row className="row">
                <Col span={5} offset={2}>
                  <Label itext="远期付款指示" trn="bmtrgf" />
                </Col>
                <Col span={14}>
                  <InputItem InputProps={bind("payinf")}  maxLength={60} />
                </Col>
              </Row>
            </Col>
            <Col span={24}>
              <Row className="row">
                <Col span={5} offset={2}>
                  <Label itext="远期付款期限" trn="bmtrgf" />
                </Col>
                <Col span={14}>
                  <InputItem InputProps={bind("tenmaxday")} />
                </Col>
              </Row>
            </Col>
					</Col>
					<Col span={12}>
            <Col span={24}>
              <Row className="row">
                <Col span={5} offset={2}>
                  <Label itext="单据明细" trn="bmtrgf" />
                </Col>
              </Row>
            </Col>
            <Col span={24}>
              <Row className="row"> 
                <Col span={19}  offset={2}>
                  <TextAreaItem InputProps={bind("prsdoc")} rows={5} style={{ resize: "none" }} />
                </Col>
              </Row>
            </Col>
            <Col span={24}>
							<Row className="row">
								<Col span={5} offset={2}>
									<Label itext="发票信息" trn="bmtrfc" />
								</Col>
							</Row>
						</Col>
						<Col span={24}>
							<Row className="row">
								<Col span={19} offset={2}>
									<TextAreaItem InputProps={bind("invdtl")} rows={5} style={{ resize: "none" }}/>
								</Col>
							</Row>
						</Col>
					</Col>
				</Row>

        <Row>
          <Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label itext="修改内容" trn="bmtrfc" />
							</Col>
						</Row>
						<Row className="row">
							<Col span={19} offset={2}>
								<TextAreaItem InputProps={bind("remark")} rows={5} style={{ resize: "none" }} />
							</Col>
						</Row>
					</Col>
        </Row>

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