<template>
  <div class="eibs-tab">
    <c-list-search @form-reset="handleReset" @form-search="handleSearch">
      <template v-slot="searchSlot">
        <el-form
          class="m-table-search-form"
          ref="paramsForm"
          :inline="true"
          label-position="right"
          label-width="110px"
          size="small"
        >
          <el-row>
            <c-col :span="24">
              <c-col :span="8">
                <el-form-item
                  label="Own Reference"
                  prop="infcon.seaownref"
                  style="width: 100%"
                >
                  <c-input
                    v-model="model.infcon.seaownref"
                    maxlength="16"
                    placeholder="请输入Own Reference"
                  ></c-input>
                </el-form-item>
              </c-col>

              <c-col :span="8">
                <el-form-item
                  label="Opening"
                  prop="infcon.opndatfrom"
                  style="width: 100%"
                >
                  <c-col :span="11">
                    <c-date-picker
                      type="date"
                      value-format="yyyy-MM-dd"
                      v-model="model.infcon.opndatfrom"
                      style="width: 100%"
                      placeholder="请选择"
                    ></c-date-picker>
                  </c-col>
                  <c-col :span="2" style="text-align: center">
                    <label style="display: inline-block; width: 100%">-</label>
                  </c-col>
                  <c-col :span="11">
                    <c-date-picker
                      type="date"
                      value-format="yyyy-MM-dd"
                      v-model="model.infcon.opndatto"
                      style="width: 100%"
                      placeholder="请选择"
                    ></c-date-picker>
                  </c-col>
                </el-form-item>
              </c-col>

              <c-col :span="8">
                <el-form-item
                  label="Name"
                  prop="infcon.nam"
                  style="width: 100%"
                >
                  <c-input
                    v-model="model.infcon.nam"
                    maxlength="40"
                    placeholder="请输入Name"
                  ></c-input>
                </el-form-item>
              </c-col>
            </c-col>
          </el-row>

          <el-row v-show="searchSlot.searchToggle">
            <c-col :span="24">
              <c-col :span="8">
                <el-form-item
                  label="Release Status"
                  prop="infcon.relflg"
                  style="width: 100%"
                >
                  <c-select
                    v-model="model.infcon.relflg"
                    style="width: 100%"
                    placeholder="请选择Release Status"
                  >
                  </c-select>
                </el-form-item>
              </c-col>

              <c-col :span="8">
                <el-form-item
                  label="Select Single Party"
                  prop="infcon.pty.extkey"
                  style="width: 100%"
                >
                  <c-input
                    v-model="model.infcon.pty.extkey"
                    maxlength="24"
                    placeholder="请输入Select Single Party"
                  ></c-input>
                </el-form-item>
              </c-col>

              <c-col :span="8">
                <el-form-item
                  label="Party Name"
                  prop="infcon.pty.nam"
                  style="width: 100%"
                >
                  <c-input
                    v-model="model.infcon.pty.nam"
                    maxlength="40"
                    placeholder="请输入External Visible Name"
                  ></c-input>
                </el-form-item>
              </c-col>
            </c-col>

            <c-col :span="24">
              <c-col :span="8">
                <el-form-item
                  label="Party Name/BIC"
                  prop="infcon.seapty"
                  style="width: 100%"
                >
                  <c-input
                    v-model="model.infcon.seapty"
                    maxlength="24"
                    placeholder="请输入Party Name/BIC"
                  ></c-input>
                </el-form-item>
              </c-col>

              <c-col :span="8">
                <el-form-item
                  label="Role"
                  prop="infcon.searol"
                  style="width: 100%"
                >
                  <c-select
                    v-model="model.infcon.searol"
                    style="width: 100%"
                    placeholder="请选择Role"
                  >
                  </c-select>
                </el-form-item>
              </c-col>

              <c-col :span="8">
                <el-form-item
                  label="Party Reference"
                  prop="infcon.searef"
                  style="width: 100%"
                >
                  <c-input
                    v-model="model.infcon.searef"
                    maxlength="16"
                    placeholder="请输入Party Reference"
                  ></c-input>
                </el-form-item>
              </c-col>
            </c-col>

            <c-col :span="24">
              <c-col :span="8">
                <el-form-item
                  label="Resp.User"
                  prop="infcon.usr.extkey"
                  style="width: 100%"
                >
                  <c-input
                    v-model="model.infcon.usr.extkey"
                    maxlength="8"
                    placeholder="请输入User ID"
                  ></c-input>
                </el-form-item>
              </c-col>

              <c-col :span="8">
                <el-form-item
                  label="Status"
                  prop="infcon.seasta"
                  style="width: 100%"
                >
                  <c-select
                    v-model="model.infcon.seasta"
                    style="width: 100%"
                    placeholder="请选择Status"
                  >
                    <el-option
                      v-for="item in codes.seasta"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    >
                    </el-option>
                  </c-select>
                </el-form-item>
              </c-col>
              <c-col :span="8">
                <el-form-item
                  label="Currency"
                  prop="infcon.seacur"
                  style="width: 100%"
                >
                  <c-select
                    v-model="model.infcon.seacur"
                    style="width: 100%"
                    placeholder="请选择Currency"
                  >
                    <el-option
                      v-for="item in codes.curtxt"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    >
                    </el-option>
                  </c-select>
                </el-form-item>
              </c-col>
            </c-col>

            <c-col :span="24">
              <c-col :span="8">
                <el-form-item
                  label="Type of Advance"
                  prop="seafintyp"
                  style="width: 100%"
                >
                  <c-select
                    v-model="model.seafintyp"
                    style="width: 100%"
                    placeholder="请选择Type of Advance"
                  >
                    <el-option
                      v-for="item in codes.boppayattr"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    >
                    </el-option>
                  </c-select>
                </el-form-item>
              </c-col>

              <c-col :span="8">
                <el-form-item
                  label="融资状态"
                  prop="infcon.cxmflg"
                  style="width: 100%"
                >
                  <c-select
                    v-model="model.infcon.cxmflg"
                    style="width: 100%"
                    placeholder="请选择是否显示查询码"
                  >
                    <el-option
                      v-for="item in codes.ovdflg"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    >
                    </el-option>
                  </c-select>
                </el-form-item>
              </c-col>

              <c-col :span="8">
                <el-form-item
                  label="福费廷转卖类型"
                  prop="infcon.cxmflg"
                  style="width: 100%"
                >
                  <c-select
                    v-model="model.infcon.cxmflg"
                    style="width: 100%"
                    placeholder="请选择是否显示查询码"
                  >
                  </c-select>
                </el-form-item>
              </c-col>
            </c-col>

            <c-col :span="24">
              <c-col :span="8">
                <el-form-item
                  label="Forfaiting Type"
                  prop="infcon.cxmflg"
                  style="width: 100%"
                >
                  <c-select
                    v-model="model.infcon.cxmflg"
                    style="width: 100%"
                    placeholder="请选择是否显示查询码"
                  >
                    <el-option
                      v-for="item in codes.ffttyp"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    >
                    </el-option>
                  </c-select>
                </el-form-item>
              </c-col>
              <c-col :span="8">
                <el-form-item
                  label="Amount"
                  prop="infcon.seaamtfr"
                  style="width: 100%"
                >
                  <c-col :span="11">
                    <c-input-currency
                      v-model="model.infcon.seaamtfr"
                      placeholder="请输入Amount"
                    ></c-input-currency>
                  </c-col>
                  <c-col :span="2" style="text-align: center">
                    <label style="display: inline-block; width: 100%">-</label>
                  </c-col>
                  <c-col :span="11">
                    <c-input-currency
                      v-model="model.infcon.seaamtto"
                      placeholder="请输入Amount"
                    ></c-input-currency>
                  </c-col>
                </el-form-item>
              </c-col>
            </c-col>
          </el-row>
        </el-form> </template
    ></c-list-search>

    <c-col :span="24" style="margin-top: 10px">
      <c-button
        class="medium_bcs"
        size="medium"
        style="margin-left: 0px"
        type="primary"
        @click="toBptopn"
        >出口融资放款</c-button
      >
    </c-col>

    <!-- <el-row> -->
    <c-col :span="24">
      <c-istream-table :list="stmData.data" :columns="stmData.columns">
        <el-table-column fixed="right" prop="op" label="操作" width="140px">
          <template slot="header">
            <c-col :span="11" style="text-align: left"><span>操作</span></c-col>
            <c-col :span="12" style="text-align: right"
              ><c-button icon="el-icon-s-tools"></c-button
            ></c-col>
          </template>
          <template slot-scope="scope">
            <el-popover
              placement="top-start"
              title="历史信息"
              width="800"
              trigger="click"
              :ref="'popover_' + scope.row.IDX"
            >
              <div
                style="
                  text-align: right;
                  margin-top: -30px;
                  margin-right: 5px;
                  font-size: 16px;
                "
              >
                <span
                  class="el-icon-close"
                  @click="closeTrn('popover_' + scope.row.IDX)"
                />
              </div>
              <c-istream-table :list="trnData.data" :columns="trnData.columns">
                <el-table-column prop="op" label="操作" width="0">
                  <template slot-scope="scope">
                    <c-button
                      style="margin-left: 0"
                      size="small"
                      @click="display(scope.row['INR'])"
                    >
                      详情
                    </c-button>
                  </template>
                </el-table-column>
              </c-istream-table>
              <c-button
                style="margin-left: 0"
                size="small"
                @click="getTrnInfo(scope.$index, scope.row)"
                slot="reference"
              >
                详情
              </c-button>
              <!-- <c-button
                  style="margin-left: 0"
                  size="small"
                 
                >
                  关闭
                </c-button> -->
            </el-popover>

            <!-- <c-button
                style="margin-left: 0"
                size="small"
                @click="getTrnInfo(scope.$index,scope.row)"
              >
                详情
              </c-button> -->
            <c-button
              style="margin-left: 0"
              size="small"
              type="primary"
              @click="getButtons(scope.row['Reference'])"
            >
              处理
            </c-button>

            <!-- <c-button
                style="margin-left: 0"
                size="small"
                type="primary"
                @click="getDitSelInfo(scope.$index, scope.row)"
              >
                info
              </c-button> -->
          </template>
        </el-table-column>
      </c-istream-table>
    </c-col>

        <m-busbtn ref="childs" :ownref="ownref" @onChoose="onChoose"
          >11</m-busbtn
        >
  </div>
</template>
<script>
import Utils from "~/utils/index";
import Api from "~/service/Api";
import commonProcess from "~/mixin/commonProcess";
import CodeTable from "~/config/CodeTable";
import Event from "~/model/Infbpd/Event";
import BusNavbar from "~/views/Business/Infbpd/BusNavbar";

export default {
  inject: ["root"],
  props: ["model", "codes"],
  mixins: [commonProcess],
  components: { "m-busbtn": BusNavbar },
  data() {
    return {
      ownref: "",
      dialogTableVisible: false,
      searchToggle: true,
      stmData: {
        columns: [
          '0 1 "INR" 150',
          '1 2 "OWNREF" 150',
          '2 3 "NAM" 150',
          '3 4 "FIANAM" 150',
          '4 5 "PNTNAM" 150',
          '5 6 "FIAREF" 150',
          '6 7 "PNTREF" 150',
          '7 8 "CREDAT" 150',
          {
            index: 8,
            position: 9,
            width: 100,
            pattern: "date",
            label: "OPNDAT",
          },
          {
            index: 9,
            position: 10,
            width: 100,
            pattern: "date",
            label: "CLSDAT",
          },
          '10 11 "MATDAT" 150',
          '11 12 "INTUNT" 150',
          '12 13 "OWNUSR" 150',
          '13 14 "VER" 150',
          '14 15 "PNTINR" 150',
          '15 16 "FPDINR" 150',
          '16 17 "PNTTYP" 150',
          '17 18 "INTRAT" 150',
          '18 19 "INTDAY" 150',
          '19 20 "LIAEXTID" 150',
          '20 21 "FINTYP" 150',
          '21 22 "PCTFIN" 150',
          '22 23 "INTIRT" 150',
          '23 24 "JZLLGZ" 150',
          '24 25 "ETYEXTKEY" 150',
          '25 26 "PUNINTRAT" 150',
          '26 27 "TOLRAT" 150',
          '27 28 "MARRAT" 150',
          '28 29 "GRARAT" 150',
          '29 30 "BRANCHINR" 150',
          '30 31 "BCHKEYINR" 150',
          '31 32 "RSKRAT" 150',
          '32 33 "RSKTYP" 150',
          '33 34 "FINACT" 170 ',
          '34 35 "FORTYP" 150',
          '35 36 "LCTYP" 150',
          '36 37 "FINCOD" 150',
          '37 38 "FINBLK" 150',
          '38 39 "ITFBLK" 150',
          '39 40 "OVDDAT" 150',
          '40 41 "OVDFLG" 150',
          '41 42 "FEETYP" 150',
          '42 43 "FEEAMT" 150',
          '43 44 "ACTYLD" 150',
          '44 45 "GUAFLG" 150',
          '45 46 "DINJDM" 150',
          '46 47 "F0102" 150',
          '47 48 "F0103" 150',
          '48 49 "F0104" 150',
          '49 50 "F0105" 150',
          '50 51 "TRNTYP" 150',
          '51 52 "OPPACC" 150',
          '52 53 "FLOWFLAG" 150',
          '53 54 "RECACCOUNT" 150',
          '54 55 "RECNAME" 150',
          '55 56 "RECCOUNTRYCODE" 150',
          '56 57 "RECDISTRICTCODE" 150',
          '57 58 "SHUILV" 150',
          '58 59 "CONRAT" 150',
          '59 60 "INVTYP" 150',
          '60 61 "FFTTYP" 150',
          '61 62 "BMHSWF" 170 ',
          '62 63 "BMHENM" 170 ',
          {
            index: 63,
            position: 64,
            width: 100,
            pattern: "date",
            label: "MCDATE",
          },
          {
            index: 64,
            position: 65,
            width: 100,
            pattern: "date",
            label: "BMHRZD",
          },
          '65 66 "BMHAMT" 150',
          '66 67 "BMHRAT" 150',
          '67 68 "YWACCT" 150',
          '68 69 "LPRTYP" 150',
          '69 70 "BENNAM" 150',
          '70 71 "LOANNO" 150',
          '71 72 "BENIDCODE" 150',
          '72 73 "MYCONTNO" 150',
        ],
        data: [],
      },
      trnData: {
        columns: [
          '1 1 "编号" 200',
          '2 2 "交易名称" 130',
          // '3 3 "日期" 200',
          { index: 3, position: 3, width: 110, pattern: "date", label: "日期" },
          // '4 4 "状态" 50',
          {
            index: 4,
            position: 4,
            width: 100,
            pattern: "code",
            label: "状态",
            code: this.codes.relstaEN,
          },
          '5 5 "币种" 80',
          '6 6 "金额" 100',
        ],
        data: [],
      },
    };
  },
  methods: {
    ...Event,
    async getButtons(ownref){
        this.ownref = ownref
        this.$refs.childs.initdialog = true
        console.log("ownref:" +ownref);
      },
        async  onChoose(code){
            //跳转交易
          this.$router.history.push("/business/" + code) 
          this.$refs.childs.initdialog = false                    
        } ,
        async  getDitSelInfo(code){
            //跳转交易
          this.$router.history.push("/business/" + code) 
          this.$refs.childs.initdialog = false                    
        },
    async getTrnInfo(idx, row) {
      this.model.infcon.objinr = row["INR"];
      this.model.bpdgrp.rec.inr = row["INR"];
      this.model.infcon.chksubcon = "X";

      this.dialogTableVisible = true;
      let rtnmsg = await this.executeDefault("infcon.chksubcon");

      if ((rtnmsg.respCode = SUCCESS)) {
        this.trnData.data = rtnmsg.data.infcon_trnstm.rows;
      }
    },
    closeTrn(refId) {
      this.$refs[refId].doClose();
    },
    toBptopn() {
      this.$router.history.push("/business/bptopn");
    },
  },
  created: function () {},
};
</script>
<style>
</style>
