<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>

    <anchor-nav
      v-if="projectInfo.length + relationInfo.length != 0"
      ref="anchorNav"
      :navList="navList"
    >
      <template>
        <div slot="projectInfo">
          <!-- 项目信息 -->
          <div v-for="(item, index) in projectInfo" :key="index">
            <table-double-view
              :data="item"
              :keyValue="projectInfoKeys"
            ></table-double-view>
          </div>
        </div>
        <div slot="relationInfo">
          <!-- 申请关联信息 -->
          <div v-for="(item, index) in relationInfo" :key="index">
            <table-double-view
              :data="item"
              :keyValue="relationInfoKeys"
            ></table-double-view>
          </div>
        </div>
      </template>
    </anchor-nav>
    <div v-else align="center">
      <img
        src="@/assets/images/nodata.png"
        style="width: 40%; margin-top: 137px"
      />
    </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 TableDoubleView from "@/public/TableDoubleView.vue";
import TableSingleView from "@/public/TableSingleView.vue";
/**
 * @Description 项目信息
 * @Author JiangTao
 * @Date 2021-11-10 下午 03:17
 */
@Component({
  name: "ProjectInfo",
  components: { TitleBar },
})
export default class ProjectInfo extends Vue {
  title = "项目信息"; // 页面标题
  navList = [
    { key: "projectInfo", titleText: "项目信息" },
    { key: "relationInfo", titleText: "申请关联查询" },
  ];
  projectInfo: any[] = [];
  relationInfo: any[] = [];
  projectInfoKeys = {
    cus_name: "客户名称",
    prj_name: "项目名称",
    prj_no: "项目编号",
    b_b_type_cnName: "登记状态",
    prj_type_cnName: "项目类型",
  };
  relationInfoKeys = {
    cus_name: "客户名称",
    prj_no: "项目编号",
    prj_name: "项目名称",
    prj_type: "项目类型",
    serno: "申请业务流水号",
    prd_name: "产品名称",
  };

  onClick() {
    this.$router.go(-1);
  }
  activated() {
    this.getProjectArray();
  }
  getProjectArray() {
    var parm = {
      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,
      tc: nettyApi.TRADE_CODE.selectKHXQ,
    };
    NativeUI.showWaiting("正在查询...");
    return IF.transferDataInter(nettyApi.commonRq, parm).then((res: any) => {
      NativeUI.closeWaiting();
      if (res.rc === "1") {
        for (let obj of res.basicBuildIColl) {
          obj.cus_name = this.$store.getters.getCusInfo.cus_name;
        }
        this.projectInfo = res.basicBuildIColl;
        // if (this.itemData2 != '') {
        //   this.flagProject = false;
        // }
        // this.itemData = this.itemData2;
        this.relationInfo = res.basicAppBuildIColl;
        // if (this.itemData3 != '') {
        //   this.flagApply = false;
        // }
      } else {
        NativeUI.toast(res.msg);
      }
    });
  }
}
</script>

<style scoped>
::v-deep .van-index-bar__sidebar {
  top: 130px !important;
  right: 5px !important;
  transform: unset;
}
.no-data-class {
  width: 40%;
}
</style>
