<template>
  <view>
    <view class="collection_record_header">
      <hs-tabs
        :list="tablist"
        :current="useModel?.tabCurrent?.value"
        @onChange="method?.changeTab"
      />
    </view>
    <view class="collection_record_body">
      <cc-scroll-loading :meta="useModel?.meta?.value" @load="method?.load">
        <view
          v-for="(i, index) in useModel?.dataList?.value"
          :key="`items_${index}`"
          :class="`collection_record_item items_${i?.status}`"
          @click="method?.goDetail(i)"
        >
          <view>
            <view class="item_head_info">
              {{ i?.task_name }}
              <view v-if="i?.status === 'Processing'" class="status_refresh">
                <uni-icons type="refreshempty" size="14" color="#0082fa"></uni-icons> 刷新状态
              </view>
            </view>
            <view class="item_others_info">
              <view class="item_others_info_item">
                <uni-icons type="person" size="15" color="#C4C4C4"></uni-icons>
                <text> {{ i?.company_employee?.name }} </text>
              </view>
              <view class="item_others_info_item">
                <up-icon name="clock" size="15" color="#C4C4C4" />
                <text> {{ i?.created_at }} </text>
              </view>
            </view>
          </view>
          <view :class="`status status_${i?.status}`">
            <hs-enum-tag :value="i?.status" :Enums="HouseCollectionTasksStatusEnum" />
            <uni-icons
              type="right"
              size="15"
              :color="i?.status === 'Processing' ? '#0082fa' : '#67C23A'"
            ></uni-icons>
          </view>
        </view>
      </cc-scroll-loading>
    </view>
  </view>
</template>

<script setup lang="ts">
import { onLoad } from '@dcloudio/uni-app'
import useModel from './model'
import method from './method'
import { HouseCollectionTasksStatusEnum } from '@/gen/Enums'
import { getCurrentInstance } from 'vue'
const tablist = [
  { label: '全部', value: '' },
  { label: '已完成', value: 'Completed' },
  { label: '进行中', value: 'Processing' }
]
onLoad(async () => {
  await getCurrentInstance()?.appContext.config.globalProperties.$onLaunched
  useModel.dataList.value = []
  method?.getList()
})
</script>

<style lang="scss">
@import './style.scss';
</style>
