<template>
    <div id="category">
      <!--头部-->
      <!-- <Header/> -->
      <div class="header-title">
        <span class="header-title-return-back" @click="returnClick"><van-icon name="arrow-left" /></span>
        <span class="header-title-name-bold">税收违法</span>
      </div>
<!--      <div style="width: 100%;height: 90px;background-color: #fff;"><div style="width: 90%;height: 90%;margin-left: 5%;text-align: center;line-height: 80px;background-color: #FBE9E9;font-weight: bold;">罚款总金额：<span style="color: #DB2C2C;">40.00</span>万元</div></div>-->

      <div style="font-size: 13px;margin-top: 10px;margin-left: 5px;">共<span style="color: #DB2C2C;">{{ total }}</span>条税收违法</div>
      <div class="manage-body" v-if="taxIllegalList.length !== 0">
        <div  v-for="(item, index) in taxIllegalList" :key="index">
          <div class="fw-bold mg-lt-16">税收违法</div>
          <van-cell-group>
            <div class="fs-14 mg-lt-16 mg-bt-5 mg-tp-8">案件性质：{{ item.caseNature }}</div>
            <div class="fs-14 mg-lt-16 mg-bt-5 mg-tp-8">违法事实：{{ item.illegalContent }}</div>
            <!--            <div class="fs-14 mg-lt-16 mg-bt-5 mg-tp-8">处罚金额(元)：特种设备使用登记证</div>-->
            <div class="fs-14 mg-lt-16 mg-bt-5 mg-tp-8">所属税务机关：{{ item.taxGov }}</div>
            <div style="padding-bottom: 10px" class="fs-14 mg-lt-16 mg-bt-5 mg-tp-8">发布日期：{{ item.illegalTime }}</div>
          </van-cell-group>
        </div>
      </div>
    </div>

  </template>

  <script>
  import { Button, Col, Row, Icon, Field } from 'vant';

  // 3. 引入接口
  import {postQueryTaxIllegal} from "@/service/api/customerDashboard";


  export default {
    name: "TaxViolations",

    data() {
      return {
        taxIllegalList: [],
        total: '',
        currentPage: 1,
        loading: false,
        isEndLoading: false,
      }
    },
    components: {
      VanButton: Button,
      VanRow: Row,
      VanCol: Col,
      VanIcon: Icon,
      VanField: Field,
    },
    created() {
      this.postTaxIllegal();
    },
    mounted() {
      window.addEventListener('scroll', this.scrollBottom);
    },
    destroyed() {
      window.removeEventListener('scroll', this.scrollBottom)
    },
    methods: {
      // 获取税收违法
      async postTaxIllegal(){
        let result = await postQueryTaxIllegal({companyId: sessionStorage.getItem('companyId'), pageNum: this.currentPage, pageSize: 10});
        // this.taxIllegalList = result.records;
        this.total = result.total;
        if (this.loading) {
          this.taxIllegalList = this.taxIllegalList.concat(result.records);
        } else {
          this.taxIllegalList = result.records;
        }
        if (this.taxIllegalList.length < result.total) {
          this.isEndLoading = false;
        } else {
          this.isEndLoading = true;
        }
        this.loading = false;
      },
      returnClick() {
        this.$router.go(-1)
      },

      scrollBottom() {
        let scrollTop = document.documentElement.scrollTop || document.body.scrollTop  //页面滚动的高度
        let clientHeight = document.documentElement.clientHeight  //可视区域高度
        let scrollHeight = document.documentElement.scrollHeight  //可滚动内容的高度
        let bottomOfWindow = scrollTop + clientHeight + 1000 >= scrollHeight    //是否滚动到底部
        //loading 和 this.tableData.length和this.total是自己的判断条件
        if (scrollTop !== 0 && bottomOfWindow && !this.loading && this.total > 10) {
          this.loading = true;
          this.currentPage += 1;
          this.postTaxIllegal();
        }
      },

    },
  }
  </script>
  
  <style lang="less" scoped>
  
  .header-title {
    height: 46px;
    width: 100%;
    background-color: #fff;
    text-align: center;
  }
  .header-title-name {
    font-weight: bold;
    line-height: 46px;
    align-items: center;
    justify-content: center;
    display: inline-flex;
  }
  .header-title-return {
    position: absolute;
    top: 13px;
    left: 20px;
    font-size: 15px;
  }
  .manage-body {
    margin-top: 10px;
    background-color: #fff;
    padding: 20px 10px 0px 10px;
  }
  /deep/ .van-nav-bar__text {
    color: gray !important;
    font-weight: bold;
  }
  .icon-mg {
    margin-left: 3px;
  }
  /deep/ .van-cell__value {
    bottom: 5px;
  }
  </style>../../service/api/index