<template>
  <div class="d-flex flex-column">
    <div>
      <button @click="onclick" class="verify-view-details">综合收益率试算</button>
    </div>
    <img v-if="no_data_record" src="../../../../assets/images/nodata.png" class="no-data-class"/>
    <table v-else class="customer-management-information-form">
      <tr>
        <td>试算时间</td>
        <td>试算状态</td>
      </tr>
      <tr>
        <td>{{ item.input_date }}</td>
        <td><span v-if="item.cal_type === '0'">试算中</span><span v-if="item.cal_type === '1'">试算完成</span></td>
      </tr>
    </table>
  </div>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import { NativeUI } from "@/public/ts/NativeUI";
import nettyApi from "@/constants/api/ms-netty/netty.api";
/**
 * @Description 综合收益率
 * @Author JiangTao
 * @Date 2021-11-10 下午 04:20
 */
@Component({
  name: "CustomerContributionSituationTable",
})
export default class CustomerContributionSituationTable extends Vue {
  itemData: any[] = [];
  no_data_record = true;


  mounted() {
    this.selectSSJL();
  }

  selectSSJL(pageNo = 1) {
    let param = {
      cust_no: this.$store.getters.getCusInfo.cus_id,
      tc: nettyApi.TRADE_CODE.selectSSJL
    };
    NativeUI.showWaiting('正在查询...');
    this.$IF.transferDataInter(nettyApi.commonRq, param).then((res:any) => {
      NativeUI.closeWaiting();
      if (res.rc === '1') {
        if (res.cusZhsyBaseInfoIColl && res.cusZhsyBaseInfoIColl.length !== 0) {
          let time = '';
          for (let i = 0; i < res.cusZhsyBaseInfoIColl.length - 1; i++) {
            for (let j = 0; j < res.cusZhsyBaseInfoIColl.length - i - 1; j++) {
              if (res.cusZhsyBaseInfoIColl[j].input_date < res.cusZhsyBaseInfoIColl[j + 1].input_date) {
                time = res.cusZhsyBaseInfoIColl[j];
                res.cusZhsyBaseInfoIColl[j] = res.cusZhsyBaseInfoIColl[j + 1];
                res.cusZhsyBaseInfoIColl[j + 1] = time;
              }
            }
          }
          this.itemData = res.cusZhsyBaseInfoIColl;
          this.no_data_record = false;
        }
      } else {
        NativeUI.toast(res.msg);
      }
    });
  }

  /**
   * @description:  跳转试算页面
   * @author LiShenghui
   * @date 2022/2/21 11:38
   */
  onclick() {
    this.$router.push({
      path: "TrialEntry",
    });
  }
}
</script>

<style scoped>
.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: "苹方 粗体", "苹方 中等", "苹方";
}
.no-data-class {
  width: 10%;
  margin: auto;
  display: flex;
}
</style>
