<template>
  <div v-if="list.length>0">
    <group title="开票历史">
      <cell :title="i.invoiceBigType | invoiceBigTypeFilter" @click.native="toInvoiceDetail(i)"
            :inline-desc="$utils.getLocalTime(i.invoiceDate)"
            v-for="(i, index) in list">
        <div>
          <p>{{i.invoiceState | invoiceStateFilter}}</p>
          <p>¥ {{(i.invoiceTotalFee/100).toFixed(2)}}</p>
        </div>
      </cell>
    </group>
  </div>

  <div class="noDada" v-else>
    <img src="../../../assets/images/parkInvoice/parkInvoiceNo.png" width="180px" height="140px">
    <p>暂无开票历史记录</p>
  </div>
</template>


<script>
import {
  queryCustInvoiceHistoryList
} from "@/api/invoice/invoice.js";
export default {
  name: "invoiceRecord",
  data() {
    return {
      list: []
    };
  },
  mounted() {
    this.queryCustInvoiceHistoryList();
  },
  methods: {
    queryCustInvoiceHistoryList: function() {
      let jsondata = this.$utils.commonParams();
      jsondata.sign = this.$utils.signObject(jsondata);
      console.log("传参  " + JSON.stringify(jsondata));
      queryCustInvoiceHistoryList(jsondata).then(response => {
        console.log(response);
        this.list = response.data;
      });
    },
    toInvoiceDetail: function(i) {
      sessionStorage.setItem('recordData',JSON.stringify(i.custInvoiceHisDetailDTOList))
      this.$router.push({
        path:'invoiceDetail',
        query:{
          custEmail:i.custEmail,
          len:i.custInvoiceHisDetailDTOList.length,
          invoiceId:i.invoiceId,
          invoiceUrl:i.invoiceUrl
        }
      })
    }
  },
  filters: {
    invoiceBigTypeFilter(val) {
      switch (val) {
        case 100:
          return "停车";
          break;
        case 200:
          return "充值";
          break;
        case 300:
          return "会员卡";
          break;
        default:
          break;
      }
    },
    invoiceStateFilter(val) {
      if (val == 2) {
        return "已发送电子邮箱";
      } else if (val == 3 || val == 4) {
        return "已开票";
      } else {
        return "待开票";
      }
    }
  }
};
</script>

<style scoped lang="scss">
  .noDada {
    text-align: center;
    img {
      margin: 20px auto;
    }
  }

</style>
