<template>
  <view class="content">
    <u-tabs
        lineWidth="336upx"
        :list="tabsList"
        itemStyle="height:80upx;padding-bottom:10upx;background-color: #fff;"
        @click="tabsClick"
    ></u-tabs>
    <u-list @scrolltolower="scrolltolower" v-if="list.length > 0">
      <u-list-item v-for="(item, index) in list" :key="index">
        <view>
          <view class="flex-between main-title">
            <text>{{ item.OUTSOURCED_NAME }}</text>
          </view>
          <view class="flex-between mt-10 subtitle">
            <text>视频名称：{{ item.VIDEONAME }}</text>
          </view>
          <view class="flex-between mt-10 subtitle">
            <text>报警类型：{{item.TYPE }}</text>
          </view>
          <view class="flex-between mt-10 subtitle">
            <text>报警时间：{{item.CREATTIME}}</text>
          </view>
          <view class="flex-between mt-10 subtitle">
            <text>处置状态：{{ item.STATUS === "0" ? "待处理" : "已处理" }}</text>
            <u-button  v-if="item.STATUS === '1' " type="primary" text="查看" size="mini" class="bth-mini" @click="fnNavigatorDetail(item.AIWARNING_ID,item.OUTSOURCED_ID,'view')"></u-button>
            <u-button v-if="item.STATUS === '0' " type="primary" text="处置" size="mini" class="bth-mini ml-10" @click="fnNavigatorDetail(item.AIWARNING_ID,item.OUTSOURCED_ID,'edit')"></u-button>
          </view>
        </view>
      </u-list-item>
    </u-list>
    <empty v-else></empty>
  </view>
</template>

<script>
import {getKeyProjectsAIWarningList} from "../../../api";

export default {
  data() {
    return {
      tabsList: [
        {name: '待处置', id: '1'},
        {name: '已处置', id: '2'}
      ],
      tabsType: '1',
      pageSize: 10,
      currentPage: 1,
      totalPage: 0,
      list: [],
    }
  },
  onShow() {
    this.resetList()
  },
  methods:{
    async getData(){
      let resData = await getKeyProjectsAIWarningList({
        showCount: this.pageSize,
        currentPage: this.currentPage,
        STATUS: this.tabsType
      });
      this.list = [...this.list,...resData.varList];
      this.totalPage = resData.page.totalPage;
    },
    resetList() {
      this.pageSize= 10
      this.currentPage= 1
      this.list = []
      this.getData()
    },
    fnNavigatorDetail(AIWARNING_ID,OUTSOURCED_ID,type){
      uni.$u.route({
        url: '/pages/key-project-management/AI-warning/detail',
        params: {
          AIWARNING_ID:AIWARNING_ID,
          OUTSOURCED_ID:OUTSOURCED_ID,
          type:type
        }
      })
    },
    scrolltolower() {
      this.currentPage++;
      if(this.totalPage >= this.currentPage) this.getData();
    },
    tabsClick(e) {
      this.tabsType = e.id
      this.resetList()
    },
  }
}
</script>

<style scoped>

</style>
