<template>
  <view class="content">
    <view class="search card">
      <u--input
          prefixIcon="search"
          placeholder="请输入公司名称"
          border="surround"
          v-model="KEYWORDS"
          clearable
          shape="circle"
      ></u--input>
      <u-button class="bth-mini ml-10" type="success" text="确定" @click="resetList"></u-button>
    </view>
    <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.CORP_NAME }}</text>
          </view>
          <view class="flex-between  mt-10 subtitle">
            <text>
              隐患考评组类型：
              <template v-if="item.TYPE===1">安全类</template>
              <template v-if="item.TYPE===2">环保类</template>
            </text>
          </view>
          <view class="flex-between  mt-10 subtitle">
            <text>安全环保奖惩监管端：
              <template>
                {{ item.checked_count3 }} / {{ item.count3 }}
              </template>
            </text>
          </view>
          <view class="flex-between  mt-10 subtitle">
            <text>安全环保奖惩企业端：
              <template>
                {{ item.checked_count4 }} / {{ item.count4 }}
              </template>
            </text>
          </view>
          <view class="flex-between  mt-10 subtitle">
            <text>隐患排查：
              <template>
                {{ item.checked_count2 }} / {{ item.count2 }}
              </template>
            </text>
          </view>
          <view class="flex-between  mt-10 subtitle">
            <text>隐患快报：
              <template>
                {{ item.checked_count1 }} / {{ item.count1 }}
              </template>
            </text>
          </view>
          <view class="flex-between  mt-10 subtitle">
            <text>消防检查：
              <template>
                {{ item.checked_count5 }} / {{ item.count5 }}
              </template>
            </text>
          </view>
          <view class="flex-between  mt-10 subtitle">
            <text>考评组成员：{{ item.CHECK_USER }}</text>
          </view>
          <view class="flex-end mt-10">
            <u-button type="default" text="考评" size="mini" class="bth-mini btn-bg" @click="fnNavigatorDetail(item.CORPINFO_ID, item.EVALUATIONCONFIG_ID, item.TYPE)"></u-button>
          </view>
        </view>
      </u-list-item>
    </u-list>
    <empty v-else></empty>
  </view>
</template>
<script>
import {getHiddenDangerReview} from "../../../api";
export default {
  data() {
    return {
      KEYWORDS: '',
      pageSize: 10,
      currentPage: 1,
      totalPage: 0,
      list: [],
    }
  },
  onLoad() {
    this.resetList()
  },
  computed: {
    userInfo() {
      return this.$store.getters.getUserInfo
    }
  },
  methods:{
    async getData(){
      let resData = await getHiddenDangerReview({
        KEYWORDS: this.KEYWORDS,
        showCount: this.pageSize,
        currentPage: this.currentPage,
        USER_ID: this.userInfo.USER_ID,
      });
      this.list = [...this.list,...resData.varList];
      this.totalPage = resData.page.totalPage;
    },
    resetList() {
      this.pageSize= 10
      this.currentPage= 1
      this.list = []
      this.getData()
    },
    fnNavigatorDetail(CORPINFO_ID, EVALUATIONCONFIG_ID, TYPE){
      uni.$u.route({
        url: '/pages/hidden-danger-review/evaluation/list',
        params: {
          CORPINFO_ID,
          EVALUATIONCONFIG_ID,
          TYPE,
        }
      })
    },
    scrolltolower() {
      this.currentPage++;
      if(this.totalPage >= this.currentPage) this.getData();
    },
  }
}
</script>
<style scoped lang="scss">
  .btn-bg {
    background-color: #007aff;
    color: white;
  }
</style>
