<template>
  <view>
    <view class="work_contents">
      <cc-scroll-loading :meta="useModel?.metaData?.value" @load="method?.handleLoad">
        <view
          v-for="(i, index) in useModel?.listData?.value"
          :key="`items_${index}`"
          class="work_item"
          @click="method?.handleToDetail(i)"
        >
          <view>
            <view class="work_item_header">
              <view class="group_btn">
                <view class="btn_type">
                  <hs-enum-tag :value="i?.type" :Enums="HouseWorkOrdersTypeEnum" />
                </view>
                <view v-if="i?.location" class="btn_type">
                  <hs-enum-tag :value="i?.location" :Enums="HouseWorkOrdersLocationEnum" />
                </view>
                <hs-level v-if="i?.status === 'Processing'" :level="i?.level" />
              </view>

              <view :class="`btn_status status_${i?.status}`">
                <hs-enum-tag :value="i?.status" :Enums="HouseWorkOrdersStatusEnum" />
              </view>
            </view>
            <view class="full_name">
              {{ i?.asset_house?.full_name || i?.asset_project?.name }}
            </view>
            <view class="work_item_cell">
              {{ i?.content }}
            </view>
            <view class="work_item_cell">
              预计上门时间：{{ getDayTime(i?.expect_start_time) }}(2个小时内)
            </view>
          </view>
          <view class="work_item_btn_group_footer">
            工单创建时间：{{ getDayTime(i?.created_at) }}
          </view>
        </view>
      </cc-scroll-loading>
    </view>
  </view>
</template>
<script setup lang="ts">
import useModel from './model'
import method from './method'
import {
  HouseWorkOrdersLocationEnum,
  HouseWorkOrdersTypeEnum,
  HouseWorkOrdersStatusEnum
} from '@/gen/Enums'
import { getDayTime } from '@/common/libraries/day'
import { onShow } from '@dcloudio/uni-app'
const tablist = [
  { label: '处理中', value: 'Processing' },
  { label: '待支付', value: 'PendingPayment' },
  { label: '待验收', value: 'PendingAcceptance' },
  { label: '已完成', value: 'Completed' },
  { label: '已关闭', value: 'Closed' }
]
onShow(() => {
  useModel.formData.value.page = 1
  useModel.listData.value = []
  method?.getList()
})
</script>
<style lang="scss">
@import './style.scss';
</style>
