<template>
  <div class="eibs-tab">
    <c-col :span="24">
      <c-col :span="24" style="text-align: right">
        <el-button
          type="primary"
          icon="el-icon-search"
          size="small"
          @click="onSearch()"
          >查询
        </el-button>
      </c-col>
    </c-col>
    <c-col :span="24">
      <el-form-item label="" label-width="0" prop="ECIFList">
        <c-table :columnsConfig="columns" :list="ECIFList">
        </c-table>
      </el-form-item>
    </c-col>
  </div>
</template>

<script>
import Api from "~/service/Api"
export default {
  name: "ECIF",
  inject: ["root"],
  props: ["model"],
  data() {
    return {
      ECIFList: [],
      operate: "",
      operateIdx: 0,
      columns: [
        { label: '客户号', prop: 'orgno', width: 'auto' },
        { label: '客户类别', prop: 'orgclasscd', width: 'auto' },	
        { label: '客户名称', prop: 'orglegalname', width: 'auto' },
        { label: '英文名称', prop: 'ennam', width: 'auto' },
        { label: '所属国家地区代码', prop: 'regcountry', width: 'auto' },
        { label: '组织机构代码', prop: 'nationalorgcode', width: 'auto' },
        { label: '组织机构代码有效日期', prop: 'nationalorgeffectdt', width: 'auto' },
        { label: '营业执照号', prop: 'buslicenceno', width: 'auto' },
        { label: '外汇许可证号', prop: 'foreignlicenceno', width: 'auto' },
        { label: '企业外管代码', prop: 'enterexternalno', width: 'auto' },
        { label: '进出口经营权许可证书', prop: 'foreigntradelicence', width: 'auto' },
        { label: '是否自贸区客户', prop: 'freetradecustflag', width: 'auto' },
        { label: '是否正式客户', prop: 'orglifecyclecd', width: 'auto' },
        { label: '所属地区代码', prop: 'regareacode', width: 'auto' },
        { label: '角色的ECIF客户号', prop: 'ecifno', width: 'auto' },
        { label: '是否为光大股东客户', prop: 'isstockholder', width: 'auto' },
        { label: '是否为光大集团关联单位', prop: 'isrelated', width: 'auto' },
        { label: '客户状态', prop: 'orgstate', width: 'auto' },
        { label: '是否为NRA账户', prop: 'isnra', width: 'auto' },
        { label: 'SWIFT编号', prop: 'swiftno', width: 'auto' },
        { label: '统一社会信用代码', prop: 'unifiedsocialcreditcode', width: 'auto' },
        { label: '金融机构类型', prop: 'finorgtype', width: 'auto' },
      ],

      //客户类别
      orgclasscd: [
          { label: "对公", value: "1" },
          { label: "同业", value: "2" },
      ],

      //‘是/否’标志
      //是否自贸区客户,是否正式客户,是否为光大股东客户,是否为光大集团关联单位,是否为NRA账户
      transIf:  [
          { label: "否", value: "0" },
          { label: "是", value: "1" },
          { label: "", value: "空"},
      ],
      //客户状态
      orgstate: [
          { label: "有效", value: "0" },
          { label: "无效", value: "1" },
          { label: "睡眠", value: "2" },
      ],
    };
  },
  created() {
      
  },
  methods: {
    init() {
      this.onSearch()
      // const ptyinr = this.$route.query.inr;

      // Api.post(`/manager/pty/getPtyListInfoByEcif0904`, {"ptyinr": ptyinr}).then((res)=> {
      //   if (res.respCode == "AAAAAA") {
      //     this.$set(this, "ECIFList", res.data.res)
      //   } else {
      //     this.$notify.error(res.errorMsg)
      //   }
      // });
    },
    onSearch() {
      const ptyinr = this.$route.query.inr;
      Api.post(`/manager/pty/getPtyListInfoByEcif0904`, {"ptyinr": ptyinr}).then((res)=> {
        if (res.respCode == "AAAAAA") {
          if (res.data.cod == "Y"){
            this.ECIFList = res.data.res
            this.$notify.success({
            	title: '成功:',
              message: res.data.msg,
              dangerouslyUseHTMLString: true 
            });
            const list = res.data.res
            Object.keys(list).forEach((item) => {
              let obj = list[item]
              
              //orgclasscd映射
              let codTb = this.orgclasscd.filter((i) => {
                return i.value == obj.orgclasscd
              })
              if(codTb.length > 0){
                obj.orgclasscd = codTb[0].label
              }

              //freetradecustflag映射
              codTb = this.transIf.filter((i) => {
                return i.value == obj.freetradecustflag
              })
              if(codTb.length > 0){
                obj.freetradecustflag = codTb[0].label
              }

              //orglifecyclecd
              codTb = this.transIf.filter((i) => {
                return i.value == obj.orglifecyclecd
              })
              if(codTb.length > 0){
                obj.orglifecyclecd = codTb[0].label
              }
              
              //isrelated
              codTb = this.transIf.filter((i) => {
                return i.value == obj.isrelated
              })
              if(codTb.length > 0){
                obj.isrelated = codTb[0].label
              }

              //isnra
              codTb = this.transIf.filter((i) => {
                return i.value == obj.isnra
              })
              if(codTb.length > 0){
                obj.isnra = codTb[0].label
              }

              //orgstate
              codTb = this.orgstate.filter((i) => {
                return i.value == obj.orgstate
              })
              if(codTb.length > 0){
                obj.orgstate = codTb[0].label
              }

              //isstockholder
              codTb = this.transIf.filter((i) => {
                return i.value == obj.isstockholder
              })
              if(codTb.length > 0){
                obj.isstockholder = codTb[0].label
              }

              // enterexternalno映射
              codTb = this.transIf.filter((i) => {
                return i.value == obj.enterexternalno
              })
              if(codTb.length > 0){
                obj.enterexternalno = codTb[0].label
              }
            })
          }else{
            this.ECIFList = null
            this.$notify.error({
            	title: '提示:',
              message: res.data.msg,
              dangerouslyUseHTMLString: true 
            });
          }
          
        }
      })
    },
    cancel() {
      this.handleClose();
    },
    handleClose(done) {
      this.adrDialog = false;
      if (done && typeof done === "function") {
        done();
      }
    },
  },
};
</script>

<style>
.paginationLable {
  display:none;
}
</style>