<template>
  <div class="eibs-tab">
    <c-list-search :formCount='3' @form-reset="handleReset('paramsForm')" @form-search="handleSearch">
      <template v-slot="searchSlot">
        <el-form class="m-table-search-form" ref="paramsForm" label-position="right" label-width="110px" size="small">
          <el-row>
            <c-col :span="24">
              <c-col :span="8">
                <el-form-item label="客户号" prop="signinfo.extkey" style="width: 100%">
                  <c-input v-model="model.signinfo.extkey" placeholder="请输入客户号" style="width: 100%">
                  </c-input>
                </el-form-item>
              </c-col>
              <c-col :span="8">
                <el-form-item label="账号" prop="signinfo.act" style="width: 100%">
                  <c-input v-model="model.signinfo.act"  placeholder="请输入账号"></c-input>
                </el-form-item>
              </c-col>
              <c-col :span="8">
                <el-form-item label="起止日期" style="width: 100%">
                  <c-col :span="11">
                    <c-date-picker placeholder="请选择起始时间" style="width: 100%" type="date" v-model="model.signinfo.inidatfro">
                    </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 placeholder="请选择截止时间" style="width: 100%" type="date" v-model="model.signinfo.inidattil">
                    </c-date-picker>
                  </c-col>
                </el-form-item>
              </c-col>
            </c-col>
            <c-col :span="24">
              <c-col :span="8">
                <el-form-item label="汇款类型" prop="signinfo.paytyp" style="width: 100%">
                  <c-select v-model="model.signinfo.paytyp" placeholder="请输入汇款类型" dbCode="PAYTYP" sort="SRT">
                  </c-select>
                </el-form-item>
              </c-col>
              <c-col :span="8" v-if="model.signinfo.paytyp != ''">
                <el-form-item label="签约场景" prop="signinfo.scenecode">
                  <c-select v-model="model.signinfo.scenecode" dbCode="SITRTP" sort="SRT" :filterKey="model.signinfo.paytyp=='I'?['CPTECI','CPTHYI']:['CPTECO','CPTHYF']" :isShowKeyAndLabel="false" style="width: 100%" placeholder="请输入签约场景"></c-select>
                </el-form-item>
              </c-col>
              <c-col :span="8" v-if="model.signinfo.paytyp == ''">
                <el-form-item label="签约场景" prop="signinfo.scenecode">
                  <c-select v-model="model.signinfo.scenecode" dbCode="SITRTP" sort="SRT" :isShowKeyAndLabel="false" style="width: 100%" placeholder="请输入签约场景"></c-select>
                </el-form-item>
              </c-col>
            </c-col>
          </el-row>
        </el-form>
      </template>
    </c-list-search>

    <c-col :span="24" style="margin-top: 0px">
      <c-button @click="sigAdd" class="medium_bcs" size="medium" style="margin-left: 0" type="primary">新增签约
      </c-button>
      <c-button @click="handleDelete" class="medium_bcs" size="medium" style="margin-left: 20px" type="primary">批量删除
      </c-button>
    </c-col>
    <div style="height: 70%">
      <c-col :span="24">
        <el-tabs v-model="activeTab" class="y-tabs">
          <el-table height="calc(100vh - 480px)" :data="stmData.data" :columns="stmData.columns" :showButtonFlg="true" :highlight-current-row="true" @selection-change="handleSelectionChange">
            <el-table-column :selectable="selectableFn" type="selection" min-width="55px">
            </el-table-column>
            <!-- <el-table-column v-for="(item, key) in stmData.columns" :key="key" :label="item.label" :prop="item.prop" :min-width="item.width">
            </el-table-column> -->
            <el-table-column prop="extkeyStr" label="客户号" min-width="100px" :formatter="formatExtkey">
            </el-table-column>
            <el-table-column prop="nam" label="客户名称" min-width="200px">
            </el-table-column>
            <el-table-column prop="cur" label="签约币种" min-width="100px">
            </el-table-column>
            <el-table-column prop="act" label="签约账号" min-width="100px">
            </el-table-column>
            <el-table-column prop="actpro" label="账号性质" min-width="100px">
              <template slot-scope="scope">
                <span> {{getCodelabel(scope.row.actpro,"actpro") }}
                </span>
              </template>
            </el-table-column>
            <el-table-column prop="paytypStr" label="汇款类型" min-width="100px" :formatter="formatPaytyp">
            </el-table-column>
            <el-table-column prop="paytypStr" label="签约场景" min-width="100px" :formatter="formatBustyp">
            </el-table-column>
            <el-table-column prop="creatim" label="签约时间" min-width="100px">
            </el-table-column>
            <!-- 自定义组件里加了最右边的一列”操作“ -->
            <el-table-column fixed="right" prop="op" label="操作" min-width="100px">
              <template slot-scope="scope">
                <!-- <c-button style="margin-right: 7px" size="small" type="primary" @click="handleEdit(scope.row)">编辑
                </c-button> -->
                <c-button :disabled="isFHbch&&scope.row.scenecode != 'CPTHYI'" style="margin-left: 0px" size="small" type="primary" @click="handleDeleteOne(scope.row)" slot="reference">删除
                </c-button>
              </template>
            </el-table-column>
          </el-table>
          <div class="pagination-box">
            <el-pagination style="margin-right: 30px;" @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="pagination.pageIndex" :page-sizes="[10, 20, 50, 100, 500]" :page-size="pagination.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="pagination.total">
            </el-pagination>
          </div>
        </el-tabs>
      </c-col>
    </div>
    <!-- 报文 -->
    <message-view ref="msgView"></message-view>
  </div>
</template>
<script>
import commonFunctions from "~/mixin/commonFunctions";
import event from "../event";
import moment from "moment";
import Api from "~/service/Api";
import MessageView from "~/components/business/docpan/views/MessageView";

export default {
  inject: ["root"],
  props: ["model", "codes"],
  mixins: [commonFunctions,event],
  components: {
    MessageView
  },
  data() {
    return {
      curinr: "",
      ownref: "",
      activeTab: "cd",
      handleModel: {},
      trnUrl: "",
      inifrm: "",
      bchShow: false,
      stadialog: false,
      initdialog: false,
      bchList: [],
      stmData: {
        columns: [
          // {
          //   label: "签约渠道",
          //   prop: "channel",
          //   width: "180px"
          // },
          // {
          //   label: "汇款类型",
          //   prop: "paytyp",
          //   width: "50px"
          // },
          // {
          //   label: "客户",
          //   prop: "extkey",
          //   width: "150px"
          // },
          // {
          //   label: "客户名称",
          //   prop: "nam",
          //   width: "150px"
          // },
          // {
          //   label: "汇款币种",
          //   prop: "cur",
          //   width: "120px"
          // },
          // {
          //   label: "我行客户账号",
          //   prop: "act",
          //   width: "200px"
          // },
          // {
          //   label: "客户分类",
          //   prop: "a",
          //   width: "150px"
          // },
          // {
          //   label: "是否跨境人民币业务重点监管名单",
          //   prop: "b",
          //   width: "150px"
          // },
          // {
          //   label: "收款人居民标志",
          //   prop: "mantyp",
          //   width: "120px"
          // },
          // {
          //   label: "企业分类认定",
          //   prop: "d",
          //   width: "120px"
          // },
          // {
          //   label: "签约场景",
          //   prop: "scenecode",
          //   width: "150px"
          // }
          // {
          //   label: "款项性质",
          //   prop: "trntyp",
          //   width: "150px"
          // },
          // {
          //   label: "交易类型",
          //   prop: "bopcod",
          //   width: "150px"
          // },
          // {
          //   label: "账户性质",
          //   prop: "h",
          //   width: "120px"
          // },
          // {
          //   label: "交易对手是否必输",
          //   prop: "hascountpty",
          //   width: "180px"
          // }
        ],
        data: []
      },
      pagination: {
        pageIndex: 1,
        pageSize: 10,
        total: 0
      },
      handlerDataList: [],
      currentHandleRow: {},
      multipleSelection: [],
      multipleSelectionObj: [],
      multipleStatusSelection: [],
      multipleSelectionRow: {},
      codeMap: {
        I: "汇入汇款",
        O: "汇出汇款",
        T: "Transit Payment"
      },
      mantypCodeMap: {
        0: "境内客户",
        1: "NRA客户",
        2: "FTN客户",
        3: "EFN客户",
        4: "其他"
      },
      trntypCodeMap: {
        "01": "货物贸易",
        "02": "服务贸易",
        "03": "收益与经常转移",
        "04": "境外直接投资",
        "05": "境内直接投资",
        "06": "跨境担保",
        "07": "企业境外放款",
        "08": "外债",
        "09": "境外贷款",
        "10": "国际贸易融资",
        "11": "其他"
      },
      dbCodes:{
        actpro:[],
      },
      isFHbch: false,
    };
  },
  created() {
    let bchLev = JSON.parse(window.sessionStorage.currentOrg).level;
    if (bchLev != "0") {
      this.isFHbch = true;
    }
    this.model.signinfo.inidatfro = moment(new Date()).subtract(7, "days").format("YYYY-MM-DD");
    this.model.signinfo.inidattil = moment(new Date()).format("yyyy-MM-DD");
    this.handleSearch();
  },
  methods: {},
  computed: {},
  watch: {
    "$store.state.busRefresh.aulsigRefresh"(newVal) {
      if (newVal) {
        this.handleSearch();
        this.$store.commit("updateAulsigRefresh", false);
      }
    }
  },
  mounted() {
    this.getdbCode("ACTPRO","CN","actpro");
  }
};
</script>
<style scoped lang="less">
.pagination-box {
  width: 100%;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 10px;
  background: #fff;
  margin-top: 5px;
}
.btn-group-wrap {
  max-height: 200px;
  width: 100%;
  overflow-y: auto;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  flex-wrap: wrap;
}
.btn-item {
  margin-bottom: 10px;
  margin-right: 10px;
}
.medium_bcs {
  border-radius: 5px;
}
.m-table-search-form {
  /deep/ .el-form-item {
    margin-bottom: 0;
  }
}
::v-deep #business_container {
  .eContainer {
    .c-page-container-div {
      /deep/ .el-form {
        height: calc(100% - 20px);
      }
    }
  }
}
</style>