<template>
  <div class="d-page d-flex flex-column">
    <title-bar :title="pageTitle" @clickLef="onClick">
      <van-icon slot="left" name="cross" size="24" />
    </title-bar>
    <anchor-nav ref="refAnchorNav" :navList="navList">
      <!-- 年报信息 -->
      <template slot="socktRightChangeInfoList">
        <div class="content">
          <div class="customer-management-information-content">
            <!--股权变更信息-->
            <div v-if="socktRightChangeInfoList.length >0">
              <table class="customer-management-information-form">
                <tr>
                  <td style="width:5%">序号</td>
                  <td>股权变更日期</td>
                  <td>转让前股权比例</td>
                  <td>转让后股权比例</td>
                  <td>股东名称</td>
                </tr>
                <tr v-for="(item, index) in socktRightChangeInfoList" :key="index">
                  <td style="width:5%">{{ index + 1 }}</td>
                  <td>{{ item.ALT_DATE }}</td>
                  <td>{{ item.TRANS_AM_PR }}</td>
                  <td>{{ item.TRANS_AM_AFT }}</td>
                  <td>{{ item.INV }}</td>
                </tr>
              </table>
            </div>
            <div v-else>
              <table class="customer-management-information-form">
                <tr>
                  <td style="width:5%">序号</td>
                  <td>股权变更日期</td>
                  <td>转让前股权比例</td>
                  <td>转让后股权比例</td>
                  <td>股东名称</td>
                </tr>
                <tr>
                  <td colspan="5">暂无数据</td>
                </tr>
              </table>
            </div>
          </div>
        </div>
      </template>
      <!-- 网站信息 -->
      <template slot="webInfoList">
        <div class="content">
          <div class="customer-management-information-content">
            <div v-if="webInfoList.length > 0">
              <table class="customer-management-information-form">
                <tr>
                  <td style="width:5%">序号</td>
                  <td>网站(网店)类型</td>
                  <td>网站(网店)名称</td>
                  <td>网站(网店)地址</td>
                </tr>
                <tr v-for="(item, index) in webInfoList " :key="index">
                  <td style="width:5%">{{ index+1 }}</td>
                  <td>{{ item.WEB_TYPE }}</td>
                  <td>{{ item.WEBSIT_NAME }}</td>
                  <td>{{ item.DOMAIN }}</td>
                </tr>
              </table>
            </div>
            <div v-else>
              <table class="customer-management-information-form">
                <tr>
                  <td style="width:5%">序号</td>
                  <td>网站(网店)类型</td>
                  <td>网站(网店)名称</td>
                  <td>网站(网店)地址</td>
                </tr>
                <tr>
                  <td colspan="5">暂无数据</td>
                </tr>
              </table>
            </div>
          </div>
        </div>
      </template>
      <!--社会保险信息-->
      <template slot="socialInsuranceInfoList">
        <div class="content">
          <div class="customer-management-information-content">
            <div v-if="socialInsuranceInfoList.length > 0">
              <table class="customer-management-information-form">
                <tr>
                  <td style="width: 5%">序号</td>
                  <td style="width: 30%">险种</td>
                  <td style="width: 15%">参保人数</td>
                  <td style="width: 15%">缴费基础</td>
                  <td style="width: 20%">本期实际缴费金额</td>
                  <td style="width: 15%">累计欠缴金额</td>
                </tr>
                <tr v-for="(item, index) in socialInsuranceInfoList" :key="index">
                  <td>{{ index+1 }}</td>
                  <td>{{ item.shbxxxTitle }}</td>
                  <td>{{ item.Cbno }}</td>
                  <td>{{ item.Jfjs }}</td>
                  <td>{{ item.Nowmoney }}</td>
                  <td>{{ item.Total }}</td>
                </tr>
              </table>
            </div>
            <div v-else>
              <table class="customer-management-information-form">
                <tr>
                  <td style="width: 5%">序号</td>
                  <td style="width: 30%">险种</td>
                  <td style="width: 15%">参保人数</td>
                  <td style="width: 15%">缴费基础</td>
                  <td style="width: 20%">本期实际缴费金额</td>
                  <td style="width: 15%">累计欠缴金额</td>
                </tr>
                <tr>
                  <td colspan="6">暂无数据</td>
                </tr>
              </table>
            </div>
          </div>
        </div>
      </template>
    </anchor-nav>
  </div>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import TitleBar from "@/components/general/TitleBar.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";
/**
 * @Description 年报信息
 * @Author JiangTao
 * @Date 2021-11-10 下午 03:13
 */
@Component({
  name: "AnnualReport",
  components: { TitleBar },
})
export default class AnnualReport extends Vue {
  pageTitle = "年报信息"; // 页面标题
  //股权变更信息
  socktRightChangeInfoList:any[] = [];
  //网站信息
  webInfoList:any[] = [];
  //社会保险信息
  socialInsuranceInfoList:any[] = [];
  recentTime = 0; //最近一年年报信息
  navList = [
    { key: "socktRightChangeInfoList", titleText: "股权变更信息" },
    { key: "webInfoList", titleText: "网站信息" },
    { key: "socialInsuranceInfoList", titleText: "社会保险信息" }
  ];
  onClick() {

  }
  mounted() {
    this.pageTitle = this.$route.meta?.name;
    this.selectNBinfo();
  }
  /**
   * @author: zmk
   * @description: 查询年报信息
   * */
  selectNBinfo() {
    let param = {
      CUST_FULL_NAME: this.$store.getters.getCusInfo.cus_name,
      CERT_ARRAY_INFO: [
        {
          CERT_TYPE: Public.getGScode(this.$store.getters.getCusInfo.cert_type),
          CERT_NO: this.$store.getters.getCusInfo.cert_code
        }
      ],
      GS_QUERY_OPTION_ARRAY: [
        {
          GS_QUERY_OPTION_LIST: '26'
        }
      ],
      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();
      let a = '2020';
      this.pageTitle = "年报信息"+ a;
      if (res.rc === '1') {
        //获取最近一年的年报信息
        if (res.YEAR_REPORT_BASIC && res.YEAR_REPORT_BASIC.length > 0) {
          let ancheId = ""; //年报ID
          for (let i = 0; i < res.YEAR_REPORT_BASIC.length; i++) {
            if (Number(res.YEAR_REPORT_BASIC[i].ANCHE_YEAR) > this.recentTime) {
              this.recentTime = Number(res.YEAR_REPORT_BASIC[i].ANCHE_YEAR);
              this.pageTitle = "年报信息"+this.recentTime;
              ancheId = res.YEAR_REPORT_BASIC[i].ANCHEID;
            }
          }
          //根据ID获取股权变更信息
          for (let j = 0; j < res.YEAR_REPORT_ALTERSTOCK_INFO.length; j++) {
            if (ancheId == res.YEAR_REPORT_ALTERSTOCK_INFO[j].ANCHEID) {
              this.socktRightChangeInfoList.push(res.YEAR_REPORT_ALTERSTOCK_INFO[j]);
            }
          }
          //根据ID获取网站信息
          for (let k = 0; k < res.YEAR_REPORT_WEBSITEINFO_INFO.length; k++) {
            console.log("涛哥哥", ancheId);
            if (ancheId == res.YEAR_REPORT_WEBSITEINFO_INFO[k].ANCHEID) {
              this.webInfoList.push(res.YEAR_REPORT_WEBSITEINFO_INFO[k]);
            }
          }
          console.log("涛哥哥1", this.webInfoList);
          //社会保险信息
          let socialInsuranceInfo;
          for (let i = 0; i < res.YEAR_REPORT_SOCSEC_INFO.length; i++) {
            if (ancheId == res.YEAR_REPORT_SOCSEC_INFO[i].ANCHEID) {
              socialInsuranceInfo = res.YEAR_REPORT_SOCSEC_INFO[i];
              break;
            }
          }
          // 将社会保险信息组装成列表
          let obja: any = {},
            objb: any = {},
            objc: any = {},
            objd: any = {},
            obje: any = {};
          obja.Cbno = socialInsuranceInfo.SO110;
          obja.Jfjs = socialInsuranceInfo.TOTALWAGES_SO110;
          obja.Nowmoney = socialInsuranceInfo.TOTALPAYMENT_SO110;
          obja.Total = socialInsuranceInfo.UNPAIDSOCIALINS_SO110;
          obja.shbxxxTitle = '城镇职工基本养老保险';
          objb.Cbno = socialInsuranceInfo.SO210;
          objb.Jfjs = socialInsuranceInfo.TOTALWAGES_SO210;
          objb.Nowmoney = socialInsuranceInfo.TOTALPAYMENT_SO210;
          objb.Total = socialInsuranceInfo.UNPAIDSOCIALINS_SO210;
          objb.shbxxxTitle = '失业保险';
          objc.Cbno = socialInsuranceInfo.SO310;
          objc.Jfjs = socialInsuranceInfo.TOTALWAGES_SO410;
          objc.Nowmoney = socialInsuranceInfo.UNPAIDSOCIALINS_SO310;
          objc.Total = socialInsuranceInfo.TOTALPAYMENT_SO310;
          objc.shbxxxTitle = '职工基本医疗保险';
          objd.Cbno = socialInsuranceInfo.SO410;
          objd.Jfjs = socialInsuranceInfo.TOTALWAGES_SO410;
          objd.Nowmoney = socialInsuranceInfo.UNPAIDSOCIALINS_SO410;
          objd.Total = socialInsuranceInfo.TOTALPAYMENT_SO410;
          objd.shbxxxTitle = '工伤保险';
          obje.Cbno = socialInsuranceInfo.SO510;
          obje.Jfjs = socialInsuranceInfo.TOTALWAGES_SO510;
          obje.Nowmoney = socialInsuranceInfo.UNPAIDSOCIALINS_SO510;
          obje.Total = socialInsuranceInfo.TOTALPAYMENT_SO510;
          obje.shbxxxTitle = '生育保险';
          this.socialInsuranceInfoList = [obja, objb, objc, objd, obje];
        } else {
          if (res.ret_code != '4999999') {
            NativeUI.toast(res.msg);
          }
        }
      }
    });
  }
  activated() {}
}
</script>

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