<template>
  <view class="content">
    <u-tabs
        lineWidth="336rpx"
        :list="tabsList"
        itemStyle="height:80rpx;padding-bottom:10rpx;background-color: #fff;"
        @click="tabsClick"
    ></u-tabs>
    <view class="search card">
      <u--input
          prefixIcon="search"
          placeholder="请输入关键字"
          border="surround"
          v-model="KEYWORDS"
          clearable
          shape="circle"
      ></u--input>
      <view class="bth-mini ml-10">
        <u-button type="success" text="确定" @click="resetList"></u-button>
      </view>

    </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.LIST_NAME }}</text>
          </view>
          <view class="flex-between mt-10 subtitle">
            <text>人员：{{ item.CREATOR }}</text>
          </view>
          <view class="flex-between mt-10 subtitle">
            <text>检查周期：{{ item.DATESTART }}-{{ item.DATEEND }}</text>
          </view>
          <view class="flex-between mt-10 subtitle" v-show="TYPE === 1">
            <text>检查人：{{ item.CHECK_USERS }}</text>
            <text>检查时间：{{ item.CHECK_TIME }}</text>
          </view>
          <view class="flex-between mt-10 subtitle" v-show="TYPE === 2">
            <text>清单类型：{{ item.TYPENAME }}</text>
            <text>清单周期：{{ item.PERIODNAME }}</text>
          </view>
          <view class="flex-end mt-10 see_btn" v-show="TYPE === 1">
            <u-button type="primary" text="查看" size="mini"
                      @click="fnNavigatorDetail(item.CHECKRECORD_ID,item.CORPINFO_ID)"></u-button>
          </view>
        </view>
      </u-list-item>
    </u-list>
    <empty v-else></empty>
  </view>
</template>

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

export default {
  data() {
    return {
      KEYWORDS: '',
      LISTMANAGER_ID: '',
      CORPINFO_ID: '',
      TYPE: 1,
      pageSize: 10,
      currentPage: 1,
      totalPage: 0,
      list: [],
      tabsList: [{name: '已检查记录', id: 1}, {name: '超期未检查记录', id: 2}]
    }
  },
  onLoad(event) {
    this.CORPINFO_ID = event.CORPINFO_ID;
    this.LISTMANAGER_ID = event.LISTMANAGER_ID;
    this.resetList()
  },
  methods: {
    async getData() {
      let resData = await getInspectionReportListManageRecordsList({
        KEYWORDS: this.KEYWORDS,
        CORPINFO_ID: this.CORPINFO_ID,
        SELECT_CORPINFO_ID: this.CORPINFO_ID,
        LISTMANAGER_ID: this.LISTMANAGER_ID,
        TYPE: this.TYPE,
        showCount: this.pageSize,
        currentPage: this.currentPage,
      });
      this.list = [...this.list, ...resData.varList];
      this.totalPage = resData.page.totalPage;
    },
    resetList() {
      this.pageSize = 10
      this.currentPage = 1
      this.list = []
      this.getData()
    },
    fnNavigatorDetail(CHECKRECORD_ID,CORPINFO_ID) {
      uni.$u.route({
        url: '/pages/branch-self-report/index/inspection-records-detail',
        params: {
          CHECKRECORD_ID,CORPINFO_ID
        }
      })
    },
    scrolltolower() {
      this.currentPage++;
      if (this.totalPage >= this.currentPage) this.getData();
    },
    tabsClick(e) {
      this.TYPE = e.id
      this.resetList()
    }
  }
}
</script>

<style scoped lang="scss">
.search{
  display: flex;
  .ml-10{
    margin-left: 10rpx;
  }
  .bth-mini{
    width: 100rpx;
  }

}
.see_btn{
  width: 100rpx;
  float: right;
}

</style>
