<template>
  <view class="release_items_page">
    <cc-scroll-loading :meta="useModel?.metaData?.value" @load="method?.loadMore">
      <view v-for="(i, index) in useModel?.listData?.value" :key="`items_${index}`" class="items">
        <view class="cell_items">
          <view class="label"> 状态 </view>
          <view :class="`value status status_${i.status}`">
            {{ GoodsReleasesStatusEnum[i.status as keyof typeof GoodsReleasesStatusEnum]?.text }}
          </view>
        </view>
        <view class="cell_items">
          <view class="label"> 房屋信息 </view>
          <view class="value"> {{ i?.asset_house?.full_name || '-' }} </view>
        </view>
        <view class="cell_items">
          <view class="label"> 放行日期 </view>
          <view class="value"> {{ i?.passed_time || '-' }} </view>
        </view>
        <view class="cell_items">
          <view class="label"> 申请原因 </view>
          <view class="value">
            {{
              GoodsReleasesPassedTypeEnum[
                i?.passed_type as keyof typeof GoodsReleasesPassedTypeEnum
              ]?.text || '-'
            }}
          </view>
        </view>
        <view class="footer_items" v-if="i?.status === 'Approved'">
          <hs-button label="出示放行码" type="ghost" @click="method?.showPassedDoc(i)" />
        </view>
      </view>
    </cc-scroll-loading>
    <hs-footer btnParimaryName="新增申请" url="/ME/release_items/add/index" />
  </view>
</template>
<script setup lang="ts">
import { onLoad, onShow, onUnload } from '@dcloudio/uni-app'
import method from './method'
import useModel from './model'
import { GoodsReleasesStatusEnum, GoodsReleasesPassedTypeEnum } from '@/gen/Enums'
onLoad(() => {
  method?.getList()
})
onShow(() => {
  if (useModel?.loadingStatus?.value) {
    useModel.listData.value = []
    useModel.formData.value = { page: 1 }
    method?.getList()
  }
})

onUnload(() => {
  useModel.loadingStatus.value = false
  useModel.listData.value = []
  useModel.formData.value = { page: 1 }
})
</script>
<style lang="scss">
@import './style.scss';
</style>
