<template>
  <div class="eibs-tab">
    <!-- left -->
    <c-col :span="11">
      <c-col :span="24">
        <c-col :span="20">
          <el-form-item
            label="出口信用证编号"
            prop="ledgrp.rec.ownref"
            style="width: 100%"
          >
            <c-input
              v-model="model.ledgrp.rec.ownref"
              maxlength="16"
              placeholder="请输入出口信用证编号"
              style="width: 95%"
              disabled
            ></c-input>
          </el-form-item>
        </c-col>
       
        <c-col :span="1">
          
          <c-button
            style="margin: 0 10px 0 0; padding: 0 12px"
            size="small"
            type="primary"
            @click="onSeainf"
          >
            <i class="el-icon-info" style="font-size:15px"></i>
          </c-button>
          <!-- </el-form-item> -->
        </c-col>
        <c-col :span="2" :offset="1" style="text-align: right">
          
          <c-button
            style="margin: 0 0"
            size="small"
            type="primary"
            :disabled="!this.flag && model.ledgrp.rec.ownref == ''? false:true"
            @click="onDetpButgetref"
          >
            获取
          </c-button>
          
        </c-col>
        
      </c-col>

      <c-col :span="24">
        <c-col :span="20">
          <el-form-item
            label="出口单据编号"
            prop="bedgrp.rec.ownref"
            style="width: 100%"
          >
            <c-input
              v-model="model.bedgrp.rec.ownref"
              maxlength="16"
              placeholder="请输入出口单据编号"
              style="width: 95%"
              disabled
            ></c-input>
          </el-form-item>
        </c-col>
       
        <c-col :span="1">
          
          <c-button
            style="margin: 0 10px 0 0; padding: 0 12px"
            size="small"
            type="primary"
            @click="onSeainf"
          >
            <i class="el-icon-info" style="font-size:15px"></i>
          </c-button>
         
        </c-col>
        <c-col :span="2" :offset="1" style="text-align: right">
          
          <c-button
            style="margin: 0 0"
            size="small"
            type="primary"
            :disabled="!this.flag && model.bedgrp.rec.ownref == ''? false:true"
            @click="onDetpButgetref"
          >
            获取
          </c-button>
          
        </c-col>
       
      </c-col>
      <c-col :span="24">
        <el-form-item label="单据金额" prop="bedgrp.cbs.max.cur">
          <c-fullbox>
            <c-input
              v-model="model.bedgrp.cbs.max.cur"
              maxlength="3"
              style="width: 50%"
              placeholder="请输入单据金额"
              disabled
            ></c-input>
            <c-input
              v-model="model.bedgrp.cbs.max.amt"
              style="width: 50%"
              placeholder="请输入金额"
              disabled
            ></c-input>
            <template slot="footer">
              <c-checkbox
                v-model="model.betp.adaflg"
                style="margin-left: 10px"
                disabled
                >附加金额</c-checkbox
              >
            </template>
          </c-fullbox>
        </el-form-item>
      </c-col>
      <c-col :span="24">
        <c-col :span="12">
          <el-form-item label="单据余额" prop="bedgrp.cbs.opn1.cur">
            <c-input
              v-model="model.bedgrp.cbs.opn1.cur"
              maxlength="3"
              placeholder="请输入"
              disabled
            ></c-input>
          </el-form-item>
        </c-col>
        <c-col :span="12">
          <el-form-item label="" label-width="5px" prop="bedgrp.cbs.max.amt">
            <c-input
              v-model="model.bedgrp.cbs.max.amt"
              placeholder="请输入金额"
              disabled
            ></c-input>
          </el-form-item>
        </c-col>
      </c-col>
      <c-col :span="24">
        <el-form-item label="单据类型" prop="bedgrp.rec.doctypcod">
          <c-select
            v-model="model.bedgrp.rec.doctypcod"
            style="width: 100%"
            placeholder="请输入单据类型"
            disabled
          >
            <el-option
              v-for="item in codes.doctypcod1"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </c-select>
        </el-form-item>
      </c-col>
      <c-col :span="24">
        <el-form-item label="到期日" prop="bedgrp.rec.matdat">
          <c-date-picker
            type="date"
            v-model="model.bedgrp.rec.matdat"
            style="width: 100%"
            placeholder="请选择到期日"
            disabled
          ></c-date-picker>
        </el-form-item>
      </c-col>
      <c-col :span="24">
        <c-col :span="12">
          <el-form-item label="收到日期" prop="bedgrp.rec.rcvdat">
            <c-date-picker
              type="date"
              v-model="model.bedgrp.rec.rcvdat"
              style="width: 100%"
              placeholder="请选择收到日期"
              disabled
            ></c-date-picker>
          </el-form-item>
        </c-col>
        <c-col :span="12">
          <el-form-item label="交单日期" prop="bedgrp.rec.predat">
            <c-date-picker
              type="date"
              v-model="model.bedgrp.rec.predat"
              style="width: 100%"
              placeholder="请选择交单日期"
              disabled
            ></c-date-picker>
          </el-form-item>
        </c-col>
      </c-col>
      <c-col :span="24">
        <el-form-item label="单据状态" prop="bedgrp.rec.docsta">
          <c-select
            v-model="model.bedgrp.rec.docsta"
            style="width: 100%"
            placeholder="请选择单据状态"
            disabled
          >
            <el-option
              v-for="item in codes.docsta"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </c-select>
        </el-form-item>
      </c-col>
    </c-col>

    <!-- right -->
    <c-col :span="11" :offset="1">
      <c-col :span="24">
        <c-col :span="12">
          <el-form-item label="信用证余额" prop="ledgrp.cbs.opn1.cur">
            <c-input
              v-model="model.ledgrp.cbs.opn1.cur"
              maxlength="3"
              placeholder="请输入信用证余额"
              disabled
            ></c-input>
          </el-form-item>
        </c-col>
        <c-col :span="12">
          <el-form-item label="" label-width="5px" prop="ledgrp.cbs.opn1.amt">
            <c-input
              v-model="model.ledgrp.cbs.opn1.amt"
              placeholder="请输入金额"
              disabled
            ></c-input>
          </el-form-item>
        </c-col>
      </c-col>

      <c-col :span="24">
        <el-form-item label="单据简略信息" prop="bedgrp.rec.nam">
          <c-input
            v-model="model.bedgrp.rec.nam"
            maxlength="40"
            placeholder="请输入Name"
            disabled
          ></c-input>
        </el-form-item>
      </c-col>

      <c-col :span="24">
        <c-ptsmsg
          :model="model"
          :argadr="{
            title: '交单人',
            grp: 'bedgrp',
            rol: 'prb',
          }"
          :disabled="true"
          :enRef="false"
          :enNam="false"
        ></c-ptsmsg>
      </c-col>
      <c-col :span="24">
        <c-ptsmsg
          :model="model"
          :argadr="{
            title: '开证行',
            grp: 'bedgrp',
            rol: 'iss',
          }"
          :disabled="true"
          :enRef="false"
          :enNam="false"
        ></c-ptsmsg>
      </c-col>
      <c-col :span="24">
        <c-ptsmsg
          :model="model"
          :argadr="{
            title: '申请人',
            grp: 'bedgrp',
            rol: 'apl',
          }"
          :disabled="true"
          :enRef="false"
          :enNam="false"
        ></c-ptsmsg>
      </c-col>
    </c-col>
    <!-- <c-col :span="24">
      <el-form-item style="margin-left: 0px">
        <el-divider />
      </el-form-item>
    </c-col> -->

    <!-- next part -->
    <c-col :span="24" style="margin-bottom: 35px">
      <c-istream-table
        ref="table"
        :list="model.liaall.tenstm.rows || []"
        :columns="stmData.columns"
        :showSelection="true"
        v-on:multipleSelect="multipleSelect"
        prop="liaall.tenstm"
      >
      </c-istream-table>
    </c-col>
    <!-- left -->
    <c-col :span="11">
      <c-col :span="24">
        <c-col :span="12">
          <el-form-item label="单据部分金额" prop="bedgrp.cbs.opn2.cur">
            <c-input
              v-model="model.bedgrp.cbs.opn2.cur"
              maxlength="3"
              placeholder="请输入单据部分金额"
              disabled
            ></c-input>
          </el-form-item>
        </c-col>
        <c-col :span="12">
          <el-form-item label="" label-width="5px" prop="aamset.utlamt">
            <c-input
              v-model="model.aamset.utlamt"
              placeholder="请输入单据部分金额"
              disabled
              @change="eventFunction(
                    'aamset.utlamt'
                  )"
            ></c-input>
          </el-form-item>
        </c-col>
      </c-col>

      <c-col :span="24">
        <c-col :span="12">
          <el-form-item label="附加金额" prop="bedgrp.cbs.opn2.cur">
            <c-input
              v-model="model.bedgrp.cbs.opn2.cur"
              maxlength="3"
              placeholder="请输入附加金额"
              disabled
            ></c-input>
          </el-form-item>
        </c-col>
        <c-col :span="12">
          <el-form-item label="" label-width="5px" prop="aamset.utlamt2">
            <c-input
              v-model="model.aamset.utlamt2"
              placeholder="请输入附加金额"
              disabled
              @change="eventFunction(
                    'aamset.utlamt2'
                  )"
            ></c-input>
          </el-form-item>
        </c-col>
      </c-col>
      <c-col :span="24">
        <el-form-item label="" prop="rmbclm.clmrmbflg">
          <c-checkbox v-model="clmrmbflg"
            >Claim Reimbursement(e.g via MT 742)</c-checkbox
          >
        </el-form-item>
      </c-col>
    </c-col>

    <!-- right -->
    <c-col :span="11" :offset="1">
      <c-col :span="24">
        <c-form-item label="扣除佣金" prop="bedgrp.rec.lescom">
          <c-input
            v-model="model.bedgrp.rec.lescom"
            placeholder="请输入内容"
          ></c-input>
        </c-form-item>
      </c-col>

      <c-col :span="24">
        <c-form-item label="描述内容(77A)" prop="trnmod.trndoc.nar754">
          <c-input
            type="textarea"
            v-model="model.trnmod.trndoc.nar754"
            maxlength="35"
            show-word-limit
            placeholder="请输入77A场内容"
          ></c-input>
        </c-form-item>
      </c-col>
    </c-col>

    <!-- bottom -->
    <c-col :span="24">
      <el-form-item
        label="给开证行/可用银行的付款指示"
        prop="payinstxt"
        style="width: 100%"
      >
        <c-fullbox>
          <c-input
            type="textarea"
            v-model="model.payinstxt"
            maxlength="300"
            show-word-limit
            placeholder="请输入付款指示"
          ></c-input>
          <template slot="footer">
            <c-button
              style="margin-left: 10px; padding: 0 10px"
              size="small"
              type="primary"
              @click="showGridPromptDialog('payins.buttxmsel',null,null,{TXT:'payinstxt'},{TXT:false},'doxpDialog')"
            >
              ...
            </c-button>
          </template>
        </c-fullbox>
      </el-form-item>
    </c-col>

   
  </div>
</template>
<script>
import Api from "~/service/Api";
import commonProcess from "~/mixin/commonProcess";
import CodeTable from "~/config/CodeTable";
import Event from "~/model/Betrcl/Event";
import Ptsmsg from "~/views/Public/Ptsmsg";

export default {
  components: { "c-ptsmsg": Ptsmsg },
  inject: ["root"],
  props: ["model", "codes"],
  mixins: [commonProcess],
  data() {
    return {
      stmData: {
        columns: [
          '1 1 "类型" 250',
          '2 2 "Dbt" 250',
          '3 3 "Cdt" 250',
          '4 4 "币种" 250',
          '5 5 "金额" 250 2 8 1 4',
          // '6 6 "Mat.Dat." 250 4 7 1',
          {
            index: 6,
            position: 6,
            width: 250,
            render: (item, scope) => {
              return scope.row[item.prop] === "null"
                ? ""
                : scope.row[item.prop];
            },
            label: "Mat.Dat.",
          },
        ],
        data: [],
      },
    };
  },
  computed: {
    clmrmbflg: {
      get() {
        return this.model.rmbclm.clmrmbflg === "X";
      },
      set(val) {
        this.model.rmbclm.clmrmbflg = val ? "X" : "";
      },
    },
    flag() {
      return this.model.mtabut.coninf.usr.extkey == "";
    },
  },
  mounted() {
    this.$nextTick(() => {});
  },
  methods: {
    ...Event,
    async multipleSelect(selection) {
      if (selection.length > 1) {
        this.$notify({
          title: "错误",
          message: "您不能选择多个期限",
          type: "error",
        });
      } else {
        let chkIds;
        if (selection.length === 0) {
          chkIds = []
          // this.model.liaall.tensetstm.rows = []
          // this.model.liaall.tenstm.rows = []
        } else {
          chkIds = [selection[0] + 1]
        }
        //
        console.log(this.model.liaall.tensetstm);
        let params = { chkDst: "liaall.tenstm", chkIds };
        const rtnmsg = await this.executeRule("liaall.tenstm", params);
        if (rtnmsg.respCode == SUCCESS) {
          this.updateModel(rtnmsg.data);
        } else {
          this.$notify.error({ title: "错误", message: "服务请求失败!" });
        }
      }
      // console.log(selection);
      // if (selection) {
      //   let selIds = selection.map((x) => x + 1);
      //   let params = { selDst: "liaall.tenstm", selIds };
      //   const rtnmsg = await this.executeRule("liaall.tenstm", params);
      //   if (rtnmsg.respCode == SUCCESS) {
      //     this.updateModel(rtnmsg.data);
      //   } else {
      //     this.$notify.error({ title: "错误", message: "服务请求失败!" });
      //   }
      // }
    },
  },
  created: function () {},
};
</script>
<style>
.messageLabel >>> .el-form-item__label {
  text-align: left;
  font-weight: bold;
  font-size: 12px;
}
</style>