<template>
  <div class="d-page d-flex flex-column">
    <title-bar :title="title" @clickLeft="onClick">
      <van-icon slot="left" name="cross" size="24" />
    </title-bar>
    <div class="information-container h-scroller flex-1-dhc">
      <van-index-bar highlight-color="#F79400" :index-list="indexList">
        <div style="padding-bottom: 50px">
          <van-index-anchor index="股东与股东大会">
            <sub-title>股东与股东大会</sub-title>
          </van-index-anchor>
          <div class="v-list d-page d-scroll-container" v-for="(data_item, index) in itemData_GD_data" :key="index + 'a'">
            <div class="divCls1">
              <div class="divCls2"></div>
              <div class="divCls3">
                <span class="spanCls1">{{ data_item.title }}</span>
              </div>
            </div>
            <div class="labelMainCls">
              {{ data_item.data }}
            </div>
          </div>
          <van-index-anchor index="董监高">
            <sub-title>董监高</sub-title>
          </van-index-anchor>
          <div class="v-list d-page d-scroll-container" v-for="(data_item, index) in itemData_DJ_data" :key="index + 'b'">
            <div class="divCls1">
              <div class="divCls2"></div>
              <div class="divCls3">
                <span class="spanCls1">{{ data_item.title }}</span>
              </div>
            </div>
            <div class="labelMainCls">
              {{ data_item.data }}
            </div>
          </div>
          <van-index-anchor index="公司合并、分离、解散和清算">
            <sub-title>公司合并、分离、解散和清算</sub-title>
          </van-index-anchor>
          <div class="v-list d-page d-scroll-container" v-for="(data_item, index) in itemData_GS_data" :key="index + 'c'">
            <div class="divCls1">
              <div class="divCls2"></div>
              <div class="divCls3">
                <span class="spanCls1">{{ data_item.title }}</span>
              </div>
            </div>
            <div class="labelMainCls">
              {{ data_item.data }}
            </div>
          </div>
          <van-index-anchor index="财务会计制度利润分配和内部审计">
            <sub-title>财务会计制度利润分配和内部审计</sub-title>
          </van-index-anchor>
          <div class="v-list d-page d-scroll-container" v-for="(data_item, index) in itemData_CW_data" :key="index + 'd'">
            <div class="divCls1">
              <div class="divCls2"></div>
              <div class="divCls3">
                <span class="spanCls1">{{ data_item.title }}</span>
              </div>
            </div>
            <div class="labelMainCls">
              {{ data_item.data }}
            </div>
          </div>
        </div>
      </van-index-bar>
    </div>
  </div>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import TitleBar from "@/components/general/TitleBar.vue";
import nettyApi from "@/constants/api/ms-netty/netty.api.ts";
import IF from "@/public/factory/InterFaceFactory";
import { NativeUI } from "@/public/ts/NativeUI";
import Public from '@/public/ts/Public';
import { getText } from '@/stores';
/**
 * @Description 公司章程
 * @Author JiangTao
 * @Date 2022-01-04 下午 03:37
 */
@Component({
  name: "CompanyPolicy",
  components: { TitleBar },
})
export default class CompanyPolicy extends Vue {
  title = "公司章程"; // 页面标题
  indexList = ["股东与股东大会", "董监高", "公司合并、分离、解散和清算", "财务会计制度利润分配和内部审计"];
  cus_id = "";
  cus_name = "";
  cert_type = "";
  cert_code = "";
  itemData_GD: any = [];
  itemData_GD_data: any = [];
  itemData_DJ: any = [];
  itemData_DJ_data: any = [];
  itemData_GS: any = [];
  itemData_GS_data: any = [];
  itemData_CW: any = [];
  itemData_CW_data: any = [];

  onClick() {
    this.$router.go(-1);
  }
  mounted() {
    this.itemData_GD = [];
    this.itemData_GD_data = [];
    this.itemData_DJ = [];
    this.itemData_DJ_data = [];
    this.itemData_GS = [];
    this.itemData_GS_data = [];
    this.itemData_CW = [];
    this.itemData_CW_data = [];
    this.getZCinfo();
  }
  getZCinfo() {
    var param = {
      tc: nettyApi.TRADE_CODE.selectKHXQ,
      cus_id: this.$store.getters.getCusInfo.cus_id,
      cus_name: this.$store.getters.getCusInfo.cus_name,
      cert_type: this.$store.getters.getCusInfo.cert_type,
      cert_code: this.$store.getters.getCusInfo.cert_code
    };
    NativeUI.showWaiting('正在查询...');
    return IF.transferDataInter(nettyApi.commonRq, param).then((res: any) => {
      NativeUI.closeWaiting();
      if (res.rc == '1') {
        this.cus_id = res.cus_id;
        this.cus_name = res.cus_name;
        this.cert_type = res.cert_type;
        this.cert_code = res.cert_code;
        if (res.constitution1 && res.constitution1 != '') {
          this.itemData_GD.push((JSON.parse(res.constitution1.substring(1, res.constitution1.length - 1)) as never));
          if ((this.itemData_GD[0] as any).sh_hold_1 && (this.itemData_GD[0] as any).sh_hold_1 != '') {
            this.itemData_GD_data.push(({
              title: getText('sh_hold_1', 'share_holder'),
              data: (this.itemData_GD[0] as any).sh_hold_1,
            } as never));
          }
          if ((this.itemData_GD[0] as any).sh_hold_2 && (this.itemData_GD[0] as any).sh_hold_2 != '') {
            this.itemData_GD_data.push(({
              title: getText('sh_hold_2', 'share_holder'),
              data: (this.itemData_GD[0] as any).sh_hold_2,
            } as never));
          }
          if ((this.itemData_GD[0] as any).sh_hold_3 && (this.itemData_GD[0] as any).sh_hold_3 != '') {
            this.itemData_GD_data.push(({
              title: getText('sh_hold_3', 'share_holder'),
              data: (this.itemData_GD[0] as any).sh_hold_3,
            } as never));
          }
          if ((this.itemData_GD[0] as any).sh_hold_4 && (this.itemData_GD[0] as any).sh_hold_4 != '') {
            this.itemData_GD_data.push(({
              title: getText('sh_hold_4', 'share_holder'),
              data: (this.itemData_GD[0] as any).sh_hold_4,
            } as never));
          }
        }
        if (res.constitution2 && res.constitution2 != '') {
          this.itemData_DJ.push((JSON.parse(res.constitution2.substring(1, res.constitution2.length - 1)) as never));
          if ((this.itemData_DJ[0] as any).director_1 && (this.itemData_DJ[0] as any).director_1 != '') {
            this.itemData_DJ_data.push(({
              title: getText('director_1', 'director'),
              data: (this.itemData_DJ[0] as any).director_1,
            } as never));
          }
          if ((this.itemData_DJ[0] as any).director_2 && (this.itemData_DJ[0] as any).director_2 != '') {
            this.itemData_DJ_data.push(({
              title: getText('director_2', 'director'),
              data: (this.itemData_DJ[0] as any).director_2,
            } as never));
          }
          if ((this.itemData_DJ[0] as any).director_3 && (this.itemData_DJ[0] as any).director_3 != '') {
            this.itemData_DJ_data.push(({
              title: getText('director_3', 'director'),
              data: (this.itemData_DJ[0] as any).director_3,
            } as never));
          }
          if ((this.itemData_DJ[0] as any).director_4 && (this.itemData_DJ[0] as any).director_4 != '') {
            this.itemData_DJ_data.push(({
              title: getText('director_4', 'director'),
              data: (this.itemData_DJ[0] as any).director_4,
            } as never));
          }
          if ((this.itemData_DJ[0] as any).director_5 && (this.itemData_DJ[0] as any).director_5 != '') {
            this.itemData_DJ_data.push(({
              title: getText('director_5', 'director'),
              data: (this.itemData_DJ[0] as any).director_5,
            } as never));
          }
        }
        if (res.constitution3 && res.constitution3 != '') {
          this.itemData_GS.push((JSON.parse(res.constitution3.substring(1, res.constitution3.length - 1)) as never));
          if ((this.itemData_GS[0] as any).company_1 && (this.itemData_GS[0] as any).company_1 != '') {
            this.itemData_GS_data.push(({
              title: getText('company_1', 'company'),
              data: (this.itemData_GS[0] as any).company_1,
            } as never));
          }
        }
        if (res.constitution4 && res.constitution4 != '') {
          this.itemData_CW.push((JSON.parse(res.constitution4.substring(1, res.constitution4.length - 1)) as never));
          if ((this.itemData_CW[0] as any).finance_1 && (this.itemData_CW[0] as any).finance_1 != '') {
            this.itemData_CW_data.push(({
              title: getText('finance_1', 'finance'),
              data: (this.itemData_CW[0] as any).finance_1,
            } as never));
          }
        }
      } else {
        NativeUI.toast(res.msg);
      }
    });
  }
}
</script>

<style scoped>
.spanCls1 {
  font-size: 16px;
  font-weight: bold;
  line-height: 30px;
}
.labelMainCls {
  font-size: 16px;
  padding-left: 30px;
  line-height: 25px;
}
.divCls1 {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding-left: 15px;
}
.divCls2 {
  width: 10px;
  height: 10px;
  border-radius: 5px;
  background-color: #000;
  margin-right: 5px;
}
</style>
