<template>
  <view class="work_page">
    <view class="show_card">
      <view class="card_header_type_status">
        <view class="work_item_header_left">
          <view class="btn_type">
            <hs-enum-tag
              :value="useModel?.dataShow?.value?.type"
              :Enums="HouseWorkOrdersTypeEnum"
            />
          </view>
          <view class="btn_type">
            <hs-enum-tag
              :value="useModel?.dataShow?.value?.location"
              :Enums="HouseWorkOrdersLocationEnum"
            />
          </view>
        </view>
        <view :class="`btn_status btn_status_${useModel?.dataShow?.value?.status}`">
          <hs-enum-tag
            :value="useModel?.dataShow?.value?.status"
            :Enums="HouseWorkOrdersStatusEnum"
          />
        </view>
      </view>
      <view class="card_header_huse_info">
        <text> {{ useModel?.dataShow?.value?.asset_house?.full_name }} </text>
        <text> {{ useModel?.dataShow?.value?.title }} </text>
      </view>
      <view class="card_header_content_info">
        {{ useModel?.dataShow?.value?.content }}
      </view>
      <view class="card_header_imgs">
        <view
          v-for="(k, idx) in useModel?.dataShow?.value?.attachments"
          :key="`img_${idx}`"
          class="item"
        >
          <image :src="k?.url" mode="aspectFill" />
        </view>
      </view>
    </view>
    <view class="show_card">
      <view class="work_item_cell">
        工单编号 <text>{{ useModel?.dataShow?.value?.code }}</text>
      </view>
      <view class="work_item_cell">
        房屋信息 <text>{{ useModel?.dataShow?.value?.asset_house?.full_name }}</text>
      </view>
      <view class="work_item_cell">
        报修人 <text>{{ useModel?.dataShow?.value?.reporter_name }}</text>
      </view>
      <view class="work_item_cell">
        联系电话 <text>{{ useModel?.dataShow?.value?.reporter_phone }}</text>
      </view>
      <view class="work_item_cell">
        提报时间 <text>{{ useModel?.dataShow?.value?.created_at }}</text>
      </view>
    </view>

    <hs-footer btnOtherShow btnParimaryName="联系维修管家" btnOtherName="关闭工单" />
  </view>
</template>
<script setup lang="ts">
import { onLoad, onShow, onUnload } from '@dcloudio/uni-app'
import method from './method'
import useModel from './model'
import { HouseWorkOrdersTypeEnum, HouseWorkOrdersStatusEnum } from '@/gen/Enums'
onLoad(e => {
  method.getShow(e?.id)
  method?.getHouseWorkLogs(e?.id)
})

onShow(() => {
  if (useModel?.dataShow?.value?.id) {
    method?.getShow(useModel?.dataShow?.value?.id)
    method?.getHouseWorkLogs(useModel?.dataShow?.value?.id)
  }
})
onUnload(() => {
  useModel.dataShow.value = undefined
})
</script>
<style lang="scss">
@import './style.scss';
</style>
