<template>
  <view>
    <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">
          <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 class="show_card_footer">
        <view class="work_item_cell">
          工单编号 <text>{{ useModel?.dataShow?.value?.code }}</text>
        </view>
        <view class="work_item_cell">
          期望上门时间
          <text>{{
            getTimeRangeDisplay(
              useModel?.dataShow?.value?.expect_start_time,
              useModel?.dataShow?.value?.expect_end_time
            )
          }}</text>
        </view>
        <view class="work_item_cell">
          提报时间 <text>{{ useModel?.dataShow?.value?.created_at }}</text>
        </view>
      </view>
    </view>

    <hs-footer
      :btnOtherShow="useModel?.dataShow?.value?.status === 'Completed' ? true : false"
      btnParimaryName="联系处理人"
      btnOtherName="工单评价"
      @handleParmaryClick="method?.handlePhoneCall"
      @handleOtherClick="method?.handleEvaluate"
    />

    <hs-popup-evaluate
      :show="useModel?.showEvaluate?.value"
      mode="bottom"
      :closeable="true"
      :round="20"
      @onSubmit="method?.handlepopupClose"
      @onClose="useModel.showEvaluate.value = false"
    />
  </view>
</template>
<script setup lang="ts">
import { onLoad } from '@dcloudio/uni-app'
import method from './method'
import useModel from './model'
import {
  HouseWorkOrdersTypeEnum,
  HouseWorkOrdersStatusEnum,
  HouseWorkOrdersLocationEnum
} from '@/gen/Enums'
import { getTimeRangeDisplay } from '@/common/libraries/day'
import { ref } from 'vue'
onLoad(e => {
  method.getShow(e?.id)
})
</script>
<style lang="scss">
@import './style.scss';
</style>
