<template>
  <view class="collection_record_show">
    <view class="show_card">
      <hs-cell title="催缴类型" borderTop :value="useModel?.showData?.value?.task_name" />
      <hs-cell title="状态" borderTop>
        <view :class="`status_tag_${useModel?.showData?.value?.status}`">
          <hs-enum-tag
            :value="useModel?.showData?.value?.status"
            :Enums="HouseCollectionTasksStatusEnum"
          />
        </view>
      </hs-cell>
      <hs-cell
        title="发起人"
        borderTop
        :value="useModel?.showData?.value?.company_employee?.name"
      />
      <hs-cell title="通知方式" borderTop>
        {{ method?.getShowChannel(useModel?.showData?.value?.channel) }}
      </hs-cell>
      <hs-cell title="创建时间" borderTop :value="useModel?.showData?.value?.created_at" />
    </view>

    <view class="show_card card_table">
      <view class="head_title"> 催缴房屋 </view>
      <view class="record_table">
        <view class="table_thead">
          <view class="td"> 房屋名称 </view>
          <view
            v-for="(i, index) in useModel?.showData?.value?.channel"
            :key="`h_td_${index}`"
            class="td"
          >
            <hs-enum-tag :value="i" :Enums="HouseCollectionTasksChannelEnum" />
          </view>
        </view>
        <view class="table_tbody">
          <view
            v-for="(i, index) in useModel?.showDataTable?.value"
            :key="`tr_${index}`"
            class="table_tr"
          >
            <view class="td"> {{ i?.full_name }} </view>
            <template v-for="(k, idx) in i?.notify_info" :key="`td_${idx}`">
              <view class="td">
                <uni-icons
                  v-if="k?.status === 'Notified'"
                  type="checkbox"
                  color="#67C23A"
                  size="20"
                ></uni-icons>
                <uni-icons
                  v-else-if="k?.status === 'Failed'"
                  type="close"
                  color="#F89898"
                  size="20"
                ></uni-icons>
                <uni-icons v-else type="spinner-cycle" color="#999" size="20"></uni-icons>
              </view>
            </template>
          </view>
        </view>
      </view>
    </view>

    <hs-refresh @onClick="method.getShow(useModel?.showData?.value?.id)" />
  </view>
</template>

<script setup lang="ts">
import { onLoad } from '@dcloudio/uni-app'
import useModel from './model'
import method from './method'
import { HouseCollectionTasksStatusEnum, HouseCollectionTasksChannelEnum } from '@/gen/Enums'

onLoad(e => {
  method?.getShow(e?.id)
})
</script>
<style lang="scss">
@import './style.scss';
</style>
