<template>
  <div class="app-container">
    <van-nav-bar
      title="项目公告"
      left-arrow
      fixed
      placeholder
      @click-left="onClickLeft"
    />
    <van-tabs animated type="card" color="#007b76" style="margin-top: 10px;">
      <van-tab>
        <template #title><van-icon name="newspaper-o" size="18" style="top: 4px"/>成交公告</template>
        <van-list
          v-model="loading"
          :finished="finished"
          finished-text="没有更多了"
          style="margin-top: 10px;"
          @load="getList"
        >
          <van-cell v-for="(item,index) in noticeList" icon="play" :key="index" :title="item.projectName" :to="{name:'noticeDetail', query: {id:item.id}}">
            <template #label>
              项目编号：{{item.projectCode}} <p style="float: right;">{{item.contractDate}}</p>
            </template>
          </van-cell>
        </van-list>
      </van-tab>
      <van-tab>
        <template #title><van-icon name="records" size="18" style="top: 4px"/>鉴证公告</template>
        <van-list
          v-model="attestationLoading"
          :finished="attestationFinished"
          finished-text="没有更多了"
          style="margin-top: 10px;"
          @load="getAttestationList"
        >
          <van-cell v-for="(item,index) in attestationList" :key="index" icon="play" :title="item.projectName" :to="{name:'attestationDetail', query: {id:item.id}}">
            <template #label>
              鉴证书编号：[{{item.jzsNumOne}}{{item.jzsNumTwo}}] <p style="float: right;">{{item.jzsSignDate}}</p>
            </template>
          </van-cell>
        </van-list>
      </van-tab>
      <van-tab>
        <template #title><van-icon name="description" size="18" style="top: 4px"/>招标公告</template>
        <van-list
          v-model="inviteTendersLoading"
          :finished="inviteTendersFinished"
          finished-text="没有更多了"
          style="margin-top: 10px;"
          @load="getinviteTendersList"
        >
          <van-cell v-for="(item,index) in inviteTendersList" :key="index" icon="play" :title="item.projectName" :to="{name:'inviteTendersDetail', query: {id:item.id}}">
            <template #label>
              招标方：{{item.tenderName}} <p style="float: right;">{{item.logintime}}</p>
            </template>
          </van-cell>
        </van-list>
      </van-tab>
      <van-tab>
        <template #title><van-icon name="completed" size="18" style="top: 4px"/>中标公告</template>
        <van-list
          v-model="winTheBiddingLoading"
          :finished="winTheBiddingFinished"
          finished-text="没有更多了"
          style="margin-top: 10px;"
          @load="getwinTheBiddingList"
        >
          <van-cell v-for="(item,index) in winTheBiddingList" :key="index" icon="play" :title="item.projectName" :to="{name:'winTheBiddingDetail', query: {id:item.id}}">
            <template #label>
              招标方：{{item.tenderName}} <p style="float: right;">{{item.dealTime}}</p>
            </template>
          </van-cell>
        </van-list>
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import { noticeList , Attestation , tenderList , winList } from "@/api/notice/index";
export default {
  name: "notice",
  data() {
    return {
      //是否显示加载
      loading: false,
      //是否滚动到底部
      finished: false,
      //是否显示加载
      attestationLoading: false,
      //是否滚动到底部
      attestationFinished: false,
      //是否显示加载
      inviteTendersLoading: false,
      //是否滚动到底部
      inviteTendersFinished: false,
      //是否显示加载
      winTheBiddingLoading: false,
      //是否滚动到底部
      winTheBiddingFinished: false,
      //成交公告集合
      noticeList:[],
      //招标公告集合
      inviteTendersList:[],
      //中标公告集合
      winTheBiddingList:[],
      //鉴证公告集合
      attestationList:[],
      //成交公告查询参数
      queryParams: {
        deptId:100,
        pageNum:1,
        pageSize:10
      },
      //招标公告查询参数
      inviteTendersQueryParams: {
        deptId:100,
        pageNum:1,
        pageSize:10
      },
      //招标公告查询参数
      winTheBiddingQueryParams: {
        deptId:100,
        pageNum:1,
        pageSize:10
      },
      //鉴证公告查询参数
      attestationQueryParams: {
        deptId:100,
        pageNum:1,
        pageSize:10
      },
    };
  },
  created() {

  },
  methods: {
    //成交公告集合
    getList(){
      this.loading = true;
      noticeList(this.queryParams).then(response => {
        this.noticeList = response.rows;
        if(this.noticeList.length >= response.total){
          this.finished = true;
          return;
        }
        this.queryParams.pageNum += 1 ;
        this.loading = false;
      });
    },
    //鉴证公告集合
    getAttestationList(){
      this.attestationLoading = true;
      Attestation(this.attestationQueryParams).then(response => {
        this.attestationList = response.rows;
        console.log(response.rows)
        if(this.attestationList.length >= response.total){
          this.attestationFinished = true;
          return;
        }
        this.queryParams.pageNum += 1 ;
        this.attestationLoading = false;
      });
    },
    //招标公告集合
    getinviteTendersList(){
      this.inviteTendersLoading = true;
      tenderList(this.inviteTendersQueryParams).then(response => {
        this.inviteTendersList = response.rows;
        if(this.inviteTendersList.length >= response.total){
          this.inviteTendersFinished = true;
          return;
        }
        this.inviteTendersQueryParams.pageNum += 1 ;
        this.inviteTendersLoading = false;
      });
    },
    //招标公告集合
    getwinTheBiddingList(){
      this.winTheBiddingLoading = true;
      winList(this.winTheBiddingQueryParams).then(response => {
        this.winTheBiddingList = response.rows;
        if(this.winTheBiddingList.length >= response.total){
          this.winTheBiddingFinished = true;
          return;
        }
        this.winTheBiddingQueryParams.pageNum += 1 ;
        this.winTheBiddingLoading = false;
      });
    },
  },
};
</script>

<style scoped lang="scss">
.app-container {
}
  .titleClass{

  }
</style>
