<template>
  <view class="">
    <view @tap.stop="toDetailFn(v.id)" class="list" v-for="(v, i) in dataList" :key="i">
      <text class="font">{{ v.updateTime }}</text>
      <view class="list_content">
        <view class="font_style">
          <view class="font_style_left"> 文件标题： </view>
          <view class="font_style_right">
            {{ v.title }}
          </view>
        </view>
        <view class="font_style">
          <view class="font_style_left"> 创建时间： </view>
          <view class="font_style_right">
            {{ v.createTime }}
          </view>
        </view>
        <view class="font_style">
          <view class="font_style_left"> 备注： </view>
          <view class="font_style_right">
            {{ v.remark }}
          </view>
        </view>
      </view>
    </view>
    <Loading :loadStatus="loadStatus" :dataList="dataList" />
  </view>
</template>

<script>
import { mapState } from 'vuex'
import { getUserInfo } from '@/common/utils/util'
export default {
  data() {
    return {
      pageNum: 1,
      pageSize: 20,
      remark: '',
      status: true,
      title: '',
      dataList: [],
      loadStatus: 0
    }
  },
  async onPullDownRefresh() {
    this.pageNum = 1
    await this.getData()
    uni.stopPullDownRefresh()
  },
  async onReachBottom() {
    this.pageNum++
    await this.getData()
  },
  computed: {
    ...mapState(['userInfo', 'isLogin', 'userId'])
  },
  mounted() {
    this.getData()
  },
  methods: {
    //跳转页面
    toDetailFn(id) {
      this.$navToPage({
        url: `/packageMine/pages/coreLssuedFile/detail?id=${id}`
      })
    },
    //获取数据
    async getData() {
      this.loadStatus = 1
      this.$api
        .get('/worker/comlist/list', {
          pageNum: this.pageNum,
          pageSize: this.pageSize,
          remark: this.remark,
          status: this.status,
          title: this.title,
          workerNumber: (await getUserInfo())?.workerNumber
        })
        .then(res => {
          if (this.pageNum == 1) {
            this.dataList = res.data.records
          } else if (this.pageNum > 1) {
            this.dataList.push(...res.data.records)
            if (res.data.records.length == 0) {
              this.pageNum--
            }
          }
          this.loadStatus = 2
          return res.data.records
        })
    }
  }
}
</script>

<style scoped lang="scss">
.page {
  padding: 0 34rpx;
}
.list {
  margin: 0 32rpx;
  font-size: 28rpx;

  .list_content {
    background-color: #fff;
    padding: 20rpx;
    border-radius: 20rpx;
  }
}

.font_style {
  display: flex;
  color: #101010;
  line-height: 45rpx;

  .font_style_right {
    flex: 1;
  }

  .font_style_left {
    width: 145rpx;
  }

  .status {
    color: #00be8d;
  }
}

.font {
  display: block;
  color: #909090;
  padding: 20rpx 0;
}
</style>
