<template>
	<div class="eibs-tab">
		<!-- ==================左边================ -->
		<c-col :span="12" style="padding-right: 20px;">
			<c-col :span="24">
				<c-ptap :model="model" :disabled="true" :disabledRef="true" :disabledExtkey="true" :noRef="true" :isAdrblk="false" :haveAdrLabel="true" :isAdrVisible="false" :argadr="{title: $t('getopn.受益人'), grp: 'gidgrp', rol: 'ben'}" ptytyp="C" bchinr='00000047'>
				</c-ptap>
			</c-col>

      <c-col :span="24">
				<div  class="custom-box-wrap">
					<div style="width: 280px;">
						<el-form-item :label="$t('getopn.保函币种和金额')" prop="gidgrp.cbs.max.cur">
							<c-select v-model="model.gidgrp.cbs.max.cur" disabled dbCode="curtxt" style="width: 100%" placeholder="请选择保函币种">
							</c-select>
						</el-form-item>
					</div>

					<div style="width: calc(100% - 280px);">
						<el-form-item label-width="5px" prop="gidgrp.cbs.max.amt">
							<c-input-currency disabled :currency="model.gidgrp.cbs.max.cur" v-model="model.gidgrp.cbs.max.amt" placeholder="请输入保函金额" style="width: 100%"></c-input-currency>
						</el-form-item>
					</div>
				</div>
			</c-col>

      <c-col :span="24"  class="custom-box-wrap">
					<div class="box-1">
						<div style="width: 280px;">
							<el-form-item :label="$t('gitopn.保函余额')" prop="gidgrp.cbs.opn1.cur">
								<c-select disabled v-model="model.gidgrp.cbs.opn1.cur" style="width: 100%" placeholder="请选择保函余额币种" dbCode="curtxt" sort="SRT">
								</c-select>
							</el-form-item>
						</div>
						<div style="width: calc(100% - 280px);">
							<el-form-item label-width="5px" prop="gidgrp.cbs.opn1.amt">
								<c-input-currency disabled v-model="model.gidgrp.cbs.opn1.amt" :currency="model.gidgrp.cbs.opn1.cur" style="width:100%" placeholder="请输入">
								</c-input-currency>
							</el-form-item>
						</div>
					</div>
          <div class="box-2">
						<c-checkbox v-model="model.gitp.aamp.addamtflg" true-label="X" false-label=""  class="checkbox-left">
							Add. Amount
						</c-checkbox>
					</div>
				</c-col>

        <c-col :span="24" v-if="model.gitp.aamp.addamtflg == 'X'">
					<div class="custom-box-wrap">
						<div style="width: 280px;">
							<el-form-item label="Add. Amount" prop="gidgrp.cbs.max2.cur">
								<c-select disabled v-model="model.gidgrp.cbs.max2.cur" placeholder="请选择币种" dbCode="curtxt" sort="SRT">
								</c-select>
							</el-form-item>
						</div>
						<div style="width: calc(100% - 280px);">
							<el-form-item label-width="5px" prop="gidgrp.cbs.max2.amt">
								<c-input-currency disabled :currency="model.gidgrp.cbs.max2.amt" v-model="model.gidgrp.cbs.max2.amt" style="width:100%" placeholder="请输入附加金额" ></c-input-currency>
							</el-form-item>
						</div>
					</div>
				</c-col>


			<c-col :span="24" class="custom-box-wrap">
				<div style="width: calc(100% - 120px);">
					<el-form-item :label="$t('getopn.接收目的')" prop="gidgrp.rec.purposin">
						<c-select disabled v-model="model.gidgrp.rec.purposin" style="width: 100%" placeholder="请选择接收目的" dbCode="PURPOI" :filterKey="['ISSU']">
						</c-select>
					</el-form-item>
				</div>
				<div style="width: 100px;margin-left: 20px;display: flex;align-items: flex-start;">
					<c-checkbox v-model="model.gitp.inc760" disabled true-label="X" false-label="" >
						Incoming Lose
					</c-checkbox>
				</div>
			</c-col>

			<c-col :span="24">
				<el-form-item :label="$t('getopn.支出目的')" prop="gidgrp.rec.purpos">
					<c-select  v-model="model.gidgrp.rec.purpos" disabled style="width: 100%" dbCode="purpos" :filterKey="['ADVI']" placeholder="请选择支出目的">
					</c-select>
				</el-form-item>
			</c-col>
			<c-col :span="24">
				<el-form-item :label="$t('getopn.保函种类')" prop="gidgrp.rec.gartyp">
					<c-select v-model="model.gidgrp.rec.gartyp" disabled stygartyple="width: 100%" dbCode="TYPGAR" :filterKey="['A','B','C','D','G','J','W','Y','Z','3']" placeholder="请选择保函种类">
					</c-select>
				</el-form-item>
			</c-col>

			<c-col :span="24">
				<c-col :span="24">
					<el-form-item :label="$t('getopn.保函形式')" prop="gidgrp.rec.legfrm">
						<c-select v-model="model.gidgrp.rec.legfrm" disabled dbCode="Legfrm" :filterKey="['DGAR','STBY','DEPU']" style="width: 100%" placeholder="请选择保函形式">
						</c-select>
					</el-form-item>
				</c-col>
			</c-col>

			<c-col :span="24">
				<el-form-item :label="$t('getopn.需求指示')" prop="gidgrp.rec.demand">
					<c-select v-model="model.gidgrp.rec.demand" disabled dbCode="demand" style="width: 100%" placeholder="请选择需求指示">
					</c-select>
				</el-form-item>
			</c-col>
			<c-col :span="24">
				<div class="custom-box-wrap">
					<div style="width: 280px;">
						<el-form-item :label="$t('getopn.适用规则')" prop="gidgrp.blk.apprul">
							<c-select  v-model="model.gidgrp.blk.apprul" disabled style="width: 100%" :filterKey="deltoFilterKey" isShowKeyAndLabel dbCode="apprul" placeholder="请选择适用规则">
							</c-select>
						</el-form-item>
					</div>
					<div style="width: calc(100% - 280px);">
						<el-form-item label-width="5px" prop="gidgrp.blk.apprultxt">
							<c-input disabled v-model="model.gidgrp.blk.apprultxt" maxlength="35" placeholder="请输入适用规则"></c-input>
						</el-form-item>
					</div>
				</div>
			</c-col>
		</c-col>
		<!-- ============右边================= -->
		<c-col :span="12" style="padding-left: 20px;">
			<c-col :span="24">
				<el-form-item :label="$t('getopn.保函编号')" prop="gidgrp.rec.ownref">
					<c-fullbox>
						<c-input disabled v-model="model.gidgrp.rec.ownref" maxlength="16" placeholder="请输入保函编号"></c-input>
						<template slot="footer">
							<c-button style="margin: 0 0" disabled size="small" type="primary" @click="queryOwnref">
								获取
							</c-button>
						</template>
					</c-fullbox>
				</el-form-item>
			</c-col>
			<c-col :span="24">
				<el-form-item :label="$t('getopn.责任人')" prop="gidgrp.rec.ownusr">
					<c-input disabled v-model="model.gidgrp.rec.ownusr" maxlength="8" placeholder="请输入责任人"></c-input>
				</el-form-item>
			</c-col>

			<c-col :span="24">
				<el-form-item :label="$t('getopn.客户委托我行日期')" prop="gidgrp.rec.orddat">
					<c-date-picker type="date" disabled v-model="model.gidgrp.rec.orddat" style="width: 100%" placeholder="请选择客户委托我行日期">
					</c-date-picker>
				</el-form-item>
			</c-col>

			<c-col :span="24">
				<el-form-item :label="$t('getopn.生效日期')" prop="gidgrp.rec.opndat">
					<c-date-picker type="date" disabled v-model="model.gidgrp.rec.opndat" style="width: 100%" placeholder="请选择生效日期">
					</c-date-picker>
				</el-form-item>
			</c-col>

			<c-col :span="24">
				<el-form-item :label="$t('getopn.到期类型')" prop="gidgrp.rec.exptyp">
					<c-select disabled v-model="model.gidgrp.rec.exptyp" dbCode="exptyp" isShowKeyAndLabel style="width: 100%" placeholder="请选择到期类型">
						<!-- @change="$event => executeNotify(null, true)" -->
					</c-select>
				</el-form-item>
			</c-col>
			<c-col :span="24" class="custom-box-wrap">
				<div style="width: calc(100% - 135px);">
					<el-form-item :label="$t('getopn.到期日期')" prop="gidgrp.rec.expdat">
						<c-date-picker disabled type="date" v-model="model.gidgrp.rec.expdat" style="width: 100%" placeholder="请选择到期日期" :picker-options="startDatePicker"></c-date-picker>
					</el-form-item>
				</div>
				<div style="width: 115px;margin-left: 20px;display: flex;align-items: flex-start;">
					<c-checkbox disabled v-model="model.gidgrp.rec.expflg" true-label="X" false-label="">Unlimited Validity</c-checkbox>
					<!-- :disabled="model.gidgrp.rec.expdat != '' || model.gidgrp.rec.expflg == 'X'" -->
				</div>
			</c-col>

			<c-col :span="24">
				<div class="custom-box-wrap">
					<div style="width: calc(100% - 135px);">
						<el-form-item :label="$t('getopn.到期条件')" prop="gidgrp.blk.exptxt">
							<c-input type="textarea" rows="6" disabled v-model="model.gidgrp.blk.exptxt" maxlength="780" show-word-limit placeholder="请输入到期条件"></c-input>
						</el-form-item>
					</div>
					<div style="width: 115px;margin-left: 10px;display: flex;align-items: flex-start;">
						<c-checkbox v-model="model.gitp.exptxtmodflg" disabled style="margin: 0 0 0 10px;float:left">Modify Text</c-checkbox>
					</div>
				</div>
			</c-col>

			<c-col :span="24">
				<el-form-item :label="$t('getopn.合同号')" prop="gidgrp.rec.orcref">
					<c-input v-model="model.gidgrp.rec.orcref" disabled maxlength="35" placeholder="请输入合同号"></c-input>
				</el-form-item>
			</c-col>

			<c-col :span="24">
				<div class="custom-box-wrap">
					<div style="width: 280px;">
						<el-form-item :label="$t('getopn.适用法律')" prop="gidgrp.rec.jurlaws20">
							<c-select v-model="model.gidgrp.rec.jurlaws20" disabled dbCode="ctytxt"  :isShowKey="true" style="width: 100%" placeholder="请选择适用法律">
							</c-select>
						</el-form-item>
					</div>
					<div style="width: calc(100% - 280px);">
						<el-form-item label-width="5px" prop="gidgrp.rec.jurlaw">
							<c-select disabled v-model="model.gidgrp.rec.jurlaw" dbCode="ctytxt" maxlength="35" style="width: 100%" placeholder="请输入仲裁法律"></c-select>
						</el-form-item>
					</div>
				</div>
			</c-col>

			<c-col :span="24">
				<div class="custom-box-wrap">
					<div style="width: calc(100% - 135px);">
						<el-form-item :label="$t('getopn.合同标的')" prop="gidgrp.blk.covgodsrv">
							<c-input disabled  rows="7" type="textarea" v-model="model.gidgrp.blk.covgodsrv" maxlength="350" show-word-limit placeholder="请输入合同标的"></c-input>
						</el-form-item>
					</div>
					<div style="width: 115px;margin-left: 10px;display: flex;align-items: flex-start;">
						<c-checkbox v-model="model.gitp.covgodsrvmodflg" style="margin: 0 0 0 10px;float:left">Modify Text</c-checkbox>
					</div>
				</div>
			</c-col>
		</c-col>
	</div>
</template>
<script>
import CodeTable from "~/config/CodeTable";
import event from "../../event";
import Api from "~/service/Api";
import Default from "../../model/default";

export default {
  components: {},
  inject: ["root"],
  props: ["model", "codes"],
  mixins: [event, Default],
  data() {
    return {
      startDatePicker: this.beginDate(),
    };
  },
  computed: {
    deltoFilterKey() {
      let filterKey = [""];
      if (this.model.gidgrp.rec.legfrm == 'DGAR') {
        filterKey = ["URDG","NONE","OTHR","UCPR"];
      }
      else if (this.model.gidgrp.rec.legfrm == 'STBY') {
        filterKey = ["ISPR","NONE","OTHR","UCPR"];
      }
      else{
        filterKey = ["URDG","ISPR","NONE","OTHR","UCPR"];
      }
      return filterKey;
    }
  },
  watch: {},
  mounted() {
    // this.queryOrgList();
    this.onExpflg();
    this.onExptyp();
  },
  created: function() {},
  methods: {
    
    onExpflg() {
      if (this.model.gidgrp.rec.expdat=="") {
        this.model.gidgrp.rec.expflg = "X"
      } else {
        this.model.gidgrp.rec.expflg = "";
      }
    },
    
    onExptyp() {
      let modifyList = this.model.gidgrp.rec.modifySet
      if ((!this.model.gidgrp.rec.exptyp) && (!modifyList || (!!modifyList && !modifyList.includes('gidgrp.rec.exptyp')))) {
        if (this.model.gidgrp.rec.expflg != '') {
          this.model.gidgrp.rec.exptyp = 'OPEN'
        } else if (this.model.gidgrp.rec.expdat != '') {
          this.model.gidgrp.rec.exptyp = 'FIXD'
        }
      }
      if (this.model.gidgrp.rec.exptyp == '' || this.model.gidgrp.rec.exptyp == 'OPEN') {
        this.model.gidgrp.rec.expdat = ''
      }
      if (this.model.gidgrp.rec.exptyp != 'COND') {
        this.model.gitp.exptxtmodflg = ''
      }
      this.onExpflg()
    },
    beginDate() {
      const self = this;
      return {
        disabledDate(time) {
          if (self.model.gidgrp.rec.opndat) {
            return (
              new Date(self.model.gidgrp.rec.opndat).getTime() - 8.64e7 >
              time.getTime()
            );
          } else {
            return time.getTime() < Date.now() - 8.64e7; //如果没有后面的-8.64e7就是不可以选择今天的
          }
        }
      };
    }
  }
};
</script>
<style lang="less" scoped>
.custom-box-wrap {
  width: 100%;
  display: flex;
  justify-content: flex-start;
  .box-1 {
    width: calc(100% - 120px);
    display: flex;
    align-items: center;
    justify-content: flex-start;
  }
  .box-2 {
    width: 100px;
    margin-left: 20px;
    display: flex;
    align-items: flex-start;
  }
}
</style>