<template>
    <div id="category">
      <!--头部-->
      <!-- <Header/> -->
      <div class="header-title">
        <span class="header-title-return" @click="returnClick"><van-icon name="arrow-left" /></span>
        <span class="header-title-name-bold">经营异常</span>
      </div>
  
      <div style="font-size: 13px;margin-top: 10px;margin-left: 5px;">共<span style="color: #DB2C2C;">{{ total }}</span>条经营异常</div>
      <div class="manage-body">
<!--        <div class="fw-bold mg-lt-16">列入经营异常名录<van-tag class="mg-lt-5 pd-5 fs-13" color="#FDEAEB" text-color="#DB2C2C" size="large">列入</van-tag></div>-->
<!--        <van-cell-group>-->
<!--            <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">做出决定机关(单位)：特种设备使用登记证</div>-->
<!--            <div class="fs-14 mg-lt-16 mg-bt-5 mg-tp-8">列入日期：2024-03-24</div>-->
<!--        </van-cell-group>-->
        <div v-for="(item, index) in operateList" :key="index">
        <div class="fw-bold mg-lt-16 mg-tp-15">列入经营异常名录<van-tag style="padding: 2px 5px 2px 5px" class="mg-rt-5 fs-13 ft-right" color="#FDEAEB" text-color="#DB2C2C" size="large">列入</van-tag></div>
        <van-cell-group>
            <div class="fs-14 mg-lt-16 mg-bt-5 mg-tp-8">列入原因：{{ item.addReason }}</div>
            <div class="fs-14 mg-lt-16 mg-bt-5 mg-tp-8">做出决定机关(单位)：{{ item.decisionOffice }}</div>
            <div class="fs-14 mg-lt-16 mg-bt-5 mg-tp-8" style="padding-bottom: 20px">列入日期：{{ item.addDate }}</div>
        </van-cell-group>
        </div>
      </div>
    </div>

  </template>

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

  import {postQueryOperateexception} from "@/service/api/customerDashboard";


  export default {
    name: "AbnormalOperation",

    data() {
      return {
        operateList: [],
        total: '',
        currentPage: 1,
        loading: false,
        isEndLoading: false,
      }
    },
    components: {
      VanButton: Button,
      VanRow: Row,
      VanCol: Col,
      VanIcon: Icon,
      VanField: Field,
      VanTag: Tag,
    },
    created() {
      this.postOperateexception();
    },
    mounted() {
      window.addEventListener('scroll', this.scrollBottom);
    },
    destroyed() {
      window.removeEventListener('scroll', this.scrollBottom)
    },
    methods: {
      // 获取经营异常
      async postOperateexception(){
        let result = await postQueryOperateexception({companyId: sessionStorage.getItem('companyId'), pageNum: this.currentPage, pageSize: 10});
        // this.operateList = result.records;
        this.total = result.total;
        if (this.loading) {
          this.operateList = this.operateList.concat(result.records);
        } else {
          this.operateList = result.records;
        }
        if (this.operateList.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.postOperateexception();
        }
      },

    },
  }
  </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: 10px 10px 10px 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