<template>
  <div class="eibs-tab">
    <!-- left -->
    <c-col :span="11">
      <c-col :span="24">
        <el-form-item
          label="Discrepancies"
          prop="bedgrp.blk.docdis"
          style="width: 100%"
        >
          <c-fullbox>
            <c-input
              type="textarea"
              v-model="model.bedgrp.blk.docdis"
              maxlength="50"
              show-word-limit
              placeholder="Please input Discrepancies"
              :disabled="!docdisflg"
            ></c-input>
            <template slot="footer">
              <c-button
                style="margin-left: 10px; padding: 0 10px"
                size="small"
                type="primary"
                :disabled="!docdisflg"
              >
                ...
              </c-button>
            </template>
          </c-fullbox>
        </el-form-item>
      </c-col>

      <c-col :span="24">
        <el-form-item
          label="Internal Discrepancies"
          prop="bedgrp.blk.intdis"
          style="width: 100%"
        >
          <c-fullbox>
            <c-input
              type="textarea"
              v-model="model.bedgrp.blk.intdis"
              maxlength="65"
              show-word-limit
              placeholder="Please input Internal Discrepancies"
            ></c-input>
            <template slot="footer">
              <c-button
                style="margin-left: 10px; padding: 0 10px"
                size="small"
                type="primary"
              >
                ...
              </c-button>
            </template>
          </c-fullbox>
        </el-form-item>
      </c-col>

      <c-col :span="24">
        <el-form-item
          label="Comments and Conclusions"
          prop="bedgrp.blk.comcon"
          style="width: 100%"
        >
          <c-fullbox>
            <c-input
              type="textarea"
              v-model="model.bedgrp.blk.comcon"
              maxlength="65"
              show-word-limit
              placeholder="Please input Comments and Conclusions"
            ></c-input>
            <template slot="footer">
              <c-button
                style="margin-left: 10px; padding: 0 10px"
                size="small"
                type="primary"
              >
                ...
              </c-button>
            </template>
          </c-fullbox>
        </el-form-item>
      </c-col>

      <c-col :span="24">
        <el-form-item
          label="Settlement Instructions for this Document Set"
          prop="bedgrp.blk.setinsbe"
          style="width: 100%"
        >
          <c-fullbox>
            <c-input
              type="textarea"
              v-model="model.bedgrp.blk.setinsbe"
              maxlength="65"
              show-word-limit
              placeholder="Please input Settlement Instructions for this Document Set"
            ></c-input>
            <template slot="footer">
              <c-button
                style="margin-left: 10px; padding: 0 10px"
                size="small"
                type="primary"
              >
                ...
              </c-button>
            </template>
          </c-fullbox>
        </el-form-item>
      </c-col>
    </c-col>

    <!-- right -->
    <c-col :span="11" :offset="1">
      <c-col :span="24">
        <el-form-item label="Further Handling" prop="betp.folwupopt">
          <c-fullbox>
            <c-select
              v-model="model.betp.folwupopt"
              style="width: 100%"
              placeholder="Please select Further Handling"
              disabled
            >
              <el-option
                v-for="item in codes.folwupopt"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </c-select>
            <template slot="footer">
              <c-checkbox v-model="docdisflg" style="margin-left: 10px"
                >Discrepancies modified</c-checkbox
              >
            </template>
          </c-fullbox>
        </el-form-item>
      </c-col>
      <c-col :span="24">
        <el-form-item label="Payer" prop="bedgrp.rec.payrol">
          <c-select
            v-model="model.bedgrp.rec.payrol"
            style="width: 100%"
            placeholder="Please select Payer"
          >
            <el-option
              v-for="item in codes.payrol"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </c-select>
        </el-form-item>
      </c-col>
      <c-col :span="24">
        <c-ptap
          :model="model"
          :argadr="{
            title: '',
            grp: 'bedgrp',
            rol: 'oth',
          }"
          :noRef="false"
          :disabled="true"
          :isAdrblk="true"
          @onSeainf="onSeainf"
          @onAplpDet="onBenpDet"
        >
        </c-ptap>
      </c-col>
    </c-col>

    <!-- next part -->
    <c-col :span="24" style="height: 24px; margin-top: -10px">
      <el-form-item :label="model.betp.docgrdm.docdsclab" class="messageLabel">
        <c-button style="float: right" @click="addTableValue" type="primary"
          >新增单据</c-button
        >
      </el-form-item>
    </c-col>
    <c-col :span="24" style="height: 0px">
      <el-divider></el-divider>
    </c-col>
    <c-col :span="24" style="margin-bottom: 30px">
      <c-table
        height="200px"
        style="text-align: center"
        :list="this.model.betp.docgrdm.docgrd || []"
        :paginationShow="false"
        :border="true"
      >
        <el-table-column label="1st" width="auto">
          <template slot-scope="scope">
            <c-input v-model="scope.row.cmail1"></c-input>
          </template>
        </el-table-column>
        <el-table-column label="2nd" width="auto">
          <template slot-scope="scope">
            <c-input v-model="scope.row.cmail2"></c-input>
          </template>
        </el-table-column>

        <el-table-column label="Document" prop="docnam" width="auto">
          <template slot-scope="scope">
            <!-- {{scope.row.docnam}} -->
            <c-select
              style="width: 100%"
              placeholder="请选择"
              v-model="scope.row.docnam"
            >
              <el-option
                v-for="item in codeTable"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </c-select>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="170px" fixed="right">
          <template slot-scope="scope">
            <c-button @click="deleteTable(scope.$index)" type="primary"
              >删除</c-button
            >
          </template>
        </el-table-column>
      </c-table>
    </c-col>
    <!-- S0000201 : 不符点

    <c-col :span="12">
      <c-checkbox v-model="model.bedgrp.blk.docdisflg">{{
        $t("betp.CF000208")
      }}</c-checkbox>
    </c-col>

    <c-col :span="12">
      <c-form-item label="Discrepancies" prop="bedgrp.blk.docdis">
        <c-input
          type="textarea"
          v-model="model.bedgrp.blk.docdis"
          maxlength="50"
          show-word-limit
          :placeholder="$t('other.please_enter') + 'Discrepancies'"
        ></c-input>
      </c-form-item>
    </c-col>

    <c-col :span="12">
      <c-button
        size="small"
        type="primary"
        icon="el-icon-search"
        @click="onDocdisButtxmsel"
      >
        {{ $t("betp.CF000198") }}
      </c-button>
    </c-col>
    SF000209 : 寄单状态

    <c-col :span="12">
      <el-form-item label="Processing Options" prop="betp.folwupopt">
        <c-select
          v-model="model.betp.folwupopt"
          style="width: 100%"
          :placeholder="$t('other.please_enter') + 'Processing Options'"
        >
        </c-select>
      </el-form-item>
    </c-col>
    S0000202 : 单据内部不符点

    <c-col :span="12">
      <c-form-item label="Internal Discrepancies" prop="bedgrp.blk.intdis">
        <c-input
          type="textarea"
          v-model="model.bedgrp.blk.intdis"
          maxlength="65"
          show-word-limit
          :placeholder="$t('other.please_enter') + 'Internal Discrepancies'"
        ></c-input>
      </c-form-item>
    </c-col>
    SF000210 : 付款人

    <c-col :span="12">
      <el-form-item label="Payer" prop="bedgrp.rec.payrol">
        <c-select
          v-model="model.bedgrp.rec.payrol"
          style="width: 100%"
          :placeholder="$t('other.please_enter') + 'Payer'"
        >
        </c-select>
      </el-form-item>
    </c-col>

    <c-col :span="12">
      <c-button
        size="small"
        type="primary"
        icon="el-icon-search"
        @click="onIntdisButtxmsel"
      >
        {{ $t("betp.CF000196") }}
      </c-button>
    </c-col>
    SF000211 : 参考号

    <c-col :span="12">
      <c-form-item :label="$t('betp.SF000211')" prop="bedgrp.oth.pts.ref">
        <c-input
          v-model="model.bedgrp.oth.pts.ref"
          maxlength="16"
          :placeholder="$t('other.please_enter') + $t('betp.SF000211')"
        ></c-input>
      </c-form-item>
    </c-col>
    S0000203 : 注释和结论

    <c-col :span="12">
      <c-form-item
        label="Drag  Drop Sender"
        prop="betp.othp.ptsget.sdamod.dadsnd"
      >
        <c-input
          v-model="model.betp.othp.ptsget.sdamod.dadsnd"
          :placeholder="$t('other.please_enter') + 'Drag  Drop Sender'"
        ></c-input>
      </c-form-item>
    </c-col>

    <c-col :span="12">
      <c-form-item label="External Key of Address" prop="bedgrp.oth.pts.extkey">
        <c-input
          v-model="model.bedgrp.oth.pts.extkey"
          maxlength="16"
          :placeholder="$t('other.please_enter') + 'External Key of Address'"
        ></c-input>
      </c-form-item>
    </c-col>

    <c-col :span="12">
      <c-form-item label="" prop="betp.othp.ptsget.sdamod.seainf">
        <c-input
          v-model="model.betp.othp.ptsget.sdamod.seainf"
          :placeholder="$t('other.please_enter') + ''"
        ></c-input>
      </c-form-item>
    </c-col>

    <c-col :span="12">
      <c-button size="small" type="primary" @click="onOthpDet">
        {{ $t("ptsp.CF000081") }}
      </c-button>
    </c-col>

    <c-col :span="12">
      <c-form-item label="Comments and Conclusions" prop="bedgrp.blk.comcon">
        <c-input
          type="textarea"
          v-model="model.bedgrp.blk.comcon"
          maxlength="65"
          show-word-limit
          :placeholder="$t('other.please_enter') + 'Comments and Conclusions'"
        ></c-input>
      </c-form-item>
    </c-col>

    <c-col :span="12">
      <c-button
        size="small"
        type="primary"
        icon="el-icon-search"
        @click="onComconButtxmsel"
      >
        {{ $t("betp.CF000197") }}
      </c-button>
    </c-col>

    <c-col :span="12">
      <c-form-item label="名称" prop="bedgrp.oth.namelc">
        <c-input
          type="textarea"
          v-model="model.bedgrp.oth.namelc"
          maxlength="35"
          show-word-limit
          :placeholder="$t('other.please_enter') + '名称'"
        ></c-input>
      </c-form-item>
    </c-col>

    <c-col :span="12">
      <c-form-item label="Address Block" prop="bedgrp.oth.pts.adrblk">
        <c-input
          type="textarea"
          v-model="model.bedgrp.oth.pts.adrblk"
          maxlength="35"
          show-word-limit
          :placeholder="$t('other.please_enter') + 'Address Block'"
        ></c-input>
      </c-form-item>
    </c-col>

    <c-col :span="12">
      <c-form-item label="Chinese address" prop="bedgrp.oth.dbfadrblkcn">
        <c-input
          type="textarea"
          v-model="model.bedgrp.oth.dbfadrblkcn"
          maxlength="35"
          show-word-limit
          :placeholder="$t('other.please_enter') + 'Chinese address'"
        ></c-input>
      </c-form-item>
    </c-col>

    <c-col :span="12">
      <c-form-item label="地址" prop="bedgrp.oth.adrelc">
        <c-input
          type="textarea"
          v-model="model.bedgrp.oth.adrelc"
          maxlength="35"
          show-word-limit
          :placeholder="$t('other.please_enter') + '地址'"
        ></c-input>
      </c-form-item>
    </c-col>
    S0000200 : 结算指示

    <c-col :span="12">
      <c-button
        size="small"
        type="primary"
        icon="el-icon-search"
        @click="onSetinstxmButtxmsel"
      >
        {{ $t("betp.CF000215") }}
      </c-button>
    </c-col>

    <c-col :span="12">
      <c-form-item
        label="Settlement Instructions transaction field"
        prop="bedgrp.blk.setinsbe"
      >
        <c-input
          type="textarea"
          v-model="model.bedgrp.blk.setinsbe"
          maxlength="65"
          show-word-limit
          :placeholder="
            $t('other.please_enter') +
            'Settlement Instructions transaction field'
          "
        ></c-input>
      </c-form-item>
    </c-col>

    <c-col :span="12">
      <span
        v-text="model.betp.docgrdm.docdsclab"
        data-path=".betp.docgrdm.docdsclab"
      >
      </span>
    </c-col> -->
  </div>
</template>
<script>
import Api from "~/service/Api";
import commonProcess from "~/mixin/commonProcess";
import CodeTable from "~/config/CodeTable";
import Event from "~/model/Letdrv/Event";
import Ptap from "~/views/Public/Ptap";
import Utils from "~/utils";

export default {
  components: { "c-ptap": Ptap },
  inject: ["root"],
  props: ["model", "codes"],
  mixins: [commonProcess],
  data() {
    return {
      TableValue: [
        {
          id: 0,
          cmail1: "",
          cmail2: "",
          docnam: "",
          description: "",
          docnam: "",
          serialNum: "",
          tableName: "",
          tcddoc: "",
        },
      ],
      newValue: {
        id: 0,
        cmail1: "",
        cmail2: "",
        docnam: "",
        docnam: "",
        description: "",
        docnam: "",
        serialNum: "",
        tableName: "",
        tcddoc: "",
      },
      codeTable: [
        { label: "Airway Bills", value: "1" },
        { label: "Beneficiary's Declaration", value: "2" },
        { label: "Bill of Lading Copies", value: "3" },
        { label: "Bill of Lading Originals", value: "4" },
        { label: "Certificate", value: "5" },
        { label: "Certificate of Analysis", value: "6" },
        { label: "Certificate of Origin", value: "7" },
        { label: "Certificate of Quality", value: "8" },
        { label: "Certificate of Quantity", value: "9" },
        { label: "Commercial Invoice", value: "10" },
        { label: "Courier Receipt ", value: "11" },
        { label: "Draft", value: "12" },
        { label: "Export Licence", value: "13" },
        { label: "Fax Report", value: "14" },
        { label: "Inspection Cert", value: "15" },
        { label: "Insurance Policy", value: "16" },
        { label: "Packing List", value: "17" },
        { label: "Shipment Advice", value: "18" },
        { label: "Weight List", value: "19" },
      ],
    };
  },
  computed: {
    docdisflg: {
      get() {
        return this.model.bedgrp.blk.docdisflg != "";
      },
      set(val) {
        this.model.bedgrp.blk.docdisflg = val ? "X" : "";
      },
    },
  },
  methods: {
    ...Event,
    addTableValue(index) {
      var newTableValue = Object.assign({},this.newValue);
      const serial = Utils.generateUUID();
      newTableValue.serialNum = serial;
      this.model.betp.docgrdm.docgrd.splice(index-1,0,newTableValue);
    },
    deleteTable(index) {
      this.model.betp.docgrdm.docgrd.splice(index,1);
    },
  },
  created: function () {},
};
</script>
<style>
.messageLabel >>> .el-form-item__label {
  text-align: left;
  font-weight: bold;
  font-size: 12px;
}
</style>
