<template>
  <div>
    <button @click="onclick" class="verify-view-details">基本信息变动历史</button>

    <table-double-view :keyValue="keyValueDouble" :data="dataBasic"></table-double-view>
    <table-single-view :keyValue="keyValueSingle" :data="dataBasic"></table-single-view>
  </div>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import TableSingleView from '@/public/TableSingleView.vue';
import TableDoubleView from '@/public/TableDoubleView.vue';
import { NativeUI } from "@/public/ts/NativeUI";
import nettyApi from "@/constants/api/ms-netty/netty.api.ts";
import IF from "@/public/factory/InterFaceFactory";
import Public from '@/public/ts/Public';
import { getText } from '@/stores';
import { toMillion } from '@/public/ts/money.util';
import { forTime } from '@/public/ts/date.util';
/**
 * @Description 基本信息
 * @Author JiangTao
 * @Date 2021-11-10 下午 04:08
 */
@Component({
  name: "BasicInformation",
  components: { TableDoubleView, TableSingleView },
})
export default class BasicInformation extends Vue {
  keyValueDouble = {
    cus_id: '客户号',
    ENT_NAME_OLD: '曾用名',
    REPR_NAME: '法定代表人',
    PT_STATE: '经营状态',
    limittime: '经营期限',
    REG_CAP: '注册资本(万元)',
    REC_CAP: '实收资本(万元)',
    ECO_TYPE: '企业类型',
    IDNO: '统一社会信用代码',
    EST_DATE: '成立日期',
    IND_CODE: '国民经济行业',
    INST_CODE: '组织机构代码',
    REC_AUTH_CODE: '登记机关',
    APPV_DATE: '核准日期',
    TOTAL_EMPL: '员工人数'
  }
  keyValueSingle = {
    DOMICILE: '注册地址',
    OP_LOCAL: '经营场所',
    BUSI_SCOPE: '经营范围',
  }
  dataBasic = {}
  onclick() {
    this.$router.push({
      path: "InfoChangeHistory",
    });
  }
  activated() {
    this.getCompanyInfo();
  }
  /**
   * @Description 基本信息查询
   * @Author JiangTao
   * @Date 2022-01-07 下午 03:15
   */
  getCompanyInfo() {
    var param = {
      CUST_FULL_NAME: this.$store.getters.getCusInfo.cus_name,
      CERT_ARRAY_INFO: [
        {
          CERT_TYPE: Public.getGScode(this.$store.getters.getCusInfo.cert_type), //'200',
          CERT_NO: this.$store.getters.getCusInfo.cert_code //'77454934-7'
        }
      ],
      GS_QUERY_OPTION_ARRAY: [
        {
          GS_QUERY_OPTION_LIST: '1'
        },
        {
          GS_QUERY_OPTION_LIST: '2'
        },
        {
          GS_QUERY_OPTION_LIST: '3'
        }
      ],
      ProdId: Public.getProdId(),
      SvrCode: Public.getSvrCode(nettyApi.TRADE_CODE.selectGSXXCX),
      ClientNo: this.$store.getters.getCusInfo.cus_id,
      tc: nettyApi.TRADE_CODE.selectGSXXCX
    };
    NativeUI.showWaiting('正在查询...');
    IF.transferDataInter(nettyApi.commonRq, param).then((res: any) => {
      NativeUI.closeWaiting();
      if (res.rc == '1') {
        res.cus_id = this.$store.getters.getCusInfo.cus_id;
        res.REG_CAP = toMillion(res.REG_CAP);
        res.REC_CAP = toMillion(res.REC_CAP);
        res.ECO_TYPE = getText(res.ECO_TYPE, 'ECOTYPE');
        res.PT_STATE = getText(res.PT_STATE, 'ENTSTATUS');
        res.REG_CAP_CUR = getText(res.REG_CAP_CUR, 'CURRENCY');
        res.EST_DATE = forTime(res.EST_DATE);
        Public.getTreeValue('GMJJHY', res.IND_CODE, function(result: any) {
          res.IND_CODE = result;
        });

        if (res.OP_FRO !== '' && res.OP_FRO !== undefined && res.OP_TO !== '' && res.OP_TO !== undefined) {
          if (res.OP_FRO.length === 8) {
            res.OP_FRO =
              res.OP_FRO.substring(0, 4) + '-' + res.OP_FRO.substring(4, 6) + '-' + res.OP_FRO.substring(6, 8);
          }
          if (res.OP_TO.length === 8) {
            res.OP_TO = res.OP_TO.substring(0, 4) + '-' + res.OP_TO.substring(4, 6) + '-' + res.OP_TO.substring(6, 8);
          }
          res.limittime = '自 ' + res.OP_FRO + ' 至 ' + res.OP_TO;
        }
        this.dataBasic = res;
      } else {
        if (res.ret_code != '4999999') {
          NativeUI.toast(res.msg);
        }
      }
    });
  }
}
</script>

<style scoped>
table {
  width: 98%;
  margin: 0 auto;
}
td {
  font-size: 16px;
  color: #666666;
  padding: 1% 0;
  font-family: "苹方";
}
tr > td:nth-child(1) {
  width: 17%;
  text-align: right;
}
tr > td:nth-child(3) {
  width: 28%;
  text-align: right;
}
tr > td:nth-child(2),
tr > td:nth-child(4) {
  width: 30%;
}
.verify-view-details {
  float: right;
  margin-bottom: 10px;
  color: #fd5065;
  font-size: 12px;
  border: 1px solid #fd5065;
  border-radius: 4px;
  background-color: white;
  padding: 0.5% 0.8%;
  font-family: "苹方 粗体", "苹方 中等", "苹方";
}
</style>
