<template>
  <div class="thumb" :class="{ empty: fileData.file_list.length === 0 }">
    <van-checkbox-group
      v-model="checked"
      :max="6"
      v-if="fileData.file_list.length"
    >
      <van-list
        v-model:loading="loading"
        :finished="finished"
         :immediate-check="false"
        finished-text="没有更多了"
        :loading-text="'加载中...'"
        @load="onLoad"
      >
        <div class="listItem" v-for="(item, index) in fileData.file_list" :key="index">
          <div class="listTop">
            <div class="checkBoxIcon">
               <img
                  @click.stop="checkboxClick(item)"
                  class="img-icon hoverP"
                  :src="checked.includes(item.path) ? activeIcon : inactiveIcon"
                />
              <!-- <van-checkbox
                :name="item.path"
                checked-color="#f68484"
              >
                <template #icon="props">
                  <img
                   @click.stop="checkboxClick(item)"
                    class="img-icon hoverP"
                    :src="props.checked ? activeIcon : inactiveIcon"
                  />
                </template>
              </van-checkbox> -->
            </div>
            <div class="topImg hoverP" @click="openFolder(item)">
              <img src="@/assets/fold_sm.png" alt="" />
            </div>
          </div>
          <div class="listCenter hoverP" @click="openFolder(item)">
            {{ ellipsis(item.name, 30) }}
          </div>
          <p class="date hoverP" @click.stop="checkboxClick(item)">
            {{ shareDateFormat(item.mtime, 0, "YYYY/MM/DD") }}
            <i class="time">{{ shareDateFormat(item.mtime, 0, "HH:mm") }}</i>
          </p>
        </div>
      </van-list>
    </van-checkbox-group>
    <div class="empty" v-else>
      <Empty></Empty>
    </div>
  </div>
</template>

<script>
import fileList from "./fileList";
export default {
  ...fileList,
};
</script>

<style lang="less" scoped>
.thumb {
  padding: 15px;
  &.empty {
    padding: 0;
  }
  .van-list {
    display: flex;
    flex-wrap: wrap;
  }
  .listItem {
    width:165px;
    height: 176px;
    padding: 10px;
    box-sizing: border-box;
    background: #ffffff;
    border-radius: 8px;
    margin-bottom: 15px;
    margin-right: 15px;
    &:nth-child(even) {
      margin-right: 0;
    }
    .listTop {
      position: relative;
      width: 145px;
      height: 90px;
      background: rgba(0, 0, 0, 0.02);
      border-radius: 8px;
      display: flex;
      justify-content: center;
      align-items: center;
      .topImg {
        width: 40px;
        height: 40px;
      }
      .checkBoxIcon {
        position: absolute;
        left: 10px;
        top: 10px;
        width: 16PX;
        height: 16PX;
        .img-icon {
          width: 16PX;
          height: 16PX;
        }
      }
    }

    .listCenter {
      height: 40px;
      font-size: 13px;
      color: #303133;
      line-height: 20px;
      overflow: hidden;
      margin: 5px 0;
    }
    .date {
      font-size: 11px;
      color: #909399;
      line-height: 16px;
    }
  }
  :deep(.van-list__loading){
    width: 100%;
  }
  :deep(.van-list__finished-text) {
    width: 100%;
  }
  .empty {
    height: calc(
      100vh - 57px - 44px - 88px
    ); //屏幕高度 - 导航栏高度 - 排序固定栏高度 - 底部
    display: flex;
    justify-content: center;
    align-items: center;
  }
}
</style>
