<template>
  <div class="d-page d-flex flex-column">
    <title-bar :title="title" @clickLef="onClick">
      <van-icon slot="left" name="cross" size="30" />
    </title-bar>
    <anchor-nav ref="anchorNav" :navList="navList">
      <template slot="baseInfo">
        <div class="flow-y-dhc">
          <button class="verify-view-details" @click="baseInfoHistoryClick">基本信息变动历史</button>
          <table-double-view :data="dataBasic" :keyValue="keyValueDouble"></table-double-view>
          <table-single-view :data="dataBasic" :keyValue="keyValueSingle"></table-single-view>
        </div>
      </template>
    </anchor-nav>
  </div>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import BasicInformation from "@/components/customer-information/business-information/overview/BasicInformation.vue";
import TableDoubleView from "@/public/TableDoubleView.vue";
import TableSingleView from "@/public/TableSingleView.vue";
import Public from "@/public/ts/Public";
import nettyApi from "@/constants/api/ms-netty/netty.api";
import { NativeUI } from "@/public/ts/NativeUI";
import IF from "@/public/factory/InterFaceFactory";
import { toMillion } from "@/public/ts/money.util";
import { getText } from "@/stores";
import { forTime } from "@/public/ts/date.util";

/**
 * @Description 基本信息
 * @Author JiangTao
 * @Date 2021-11-10 下午 03:12
 */
@Component({
  name: "Overview",
  components: { BasicInformation, TableDoubleView, TableSingleView }
})
export default class Overview extends Vue {
  title = "基本信息"; // 页面标题

  indexList = ["基本信息"];
  navList = [{ key: "baseInfo", titleText: "基本信息" }];
  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 = {};

  baseInfoHistoryClick() {
    this.$router.push({
      path: "InfoChangeHistory"
    });
  }

  /**
   * @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);
        }
      }
    });
  }

  onClick() {
    console.log(111111);
  }

  mounted() {
    this.getCompanyInfo();
  }
}
</script>

<style scoped>
span {
  color: #999999;
  font-size: 16px;
}

.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: "苹方 粗体", "苹方 中等", "苹方";
}
/*右侧导航栏*/
::v-deep .van-index-bar__sidebar {
  top: 130px !important;
  right: 5px !important;
  transform: unset;
}
</style>