<template>
  <view class="add_worker_container">
    <view class="form_card">
      <view class="form_card_title"> <text></text> 申请人信息 </view>
      <hs-cell title="姓名" required borderTop>
        <hs-input v-model:valueModel="useModel.formData.value.worker_name" textAlign="right" />
      </hs-cell>
      <hs-cell title="手机号" required borderTop>
        <hs-input
          v-model:valueModel="useModel.formData.value.worker_phone"
          maxLength="11"
          textAlign="right"
        />
      </hs-cell>
    </view>
    <view class="form_card">
      <hs-radio-cell-picker
        title="证件类型"
        required
        isLink
        :Enums="HouseOccupantsCardTypeEnum"
        v-model:valueModel="useModel.formData.value.card_type"
      />
      <hs-cell title="证件号" required borderTop>
        <hs-input
          v-model:valueModel="useModel.formData.value.id_card"
          maxLength="18"
          textAlign="right"
        />
      </hs-cell>
      <hs-upload-id-card
        required
        borderTop
        v-model:valueFrontModel="useModel.formData.value.card_front"
        v-model:valueBackModel="useModel.formData.value.card_back"
      />
      <hs-upload
        title="工人照片"
        :count="1"
        :size="4"
        required
        borderTop
        v-model:valueModel="useModel.formData.value.worker_photo"
      />
    </view>
    <view class="form_card">
      <hs-date-picker
        title="开始通行时间"
        v-model:valueModel="useModel.formData.value.valid_from"
        required
        isLink
      />
      <hs-date-picker
        title="结束通行时间"
        v-model:valueModel="useModel.formData.value.valid_to"
        required
        borderTop
        isLink
      />
    </view>

    <hs-footer btnParimaryName="确定" @handleParmaryClick="method.handleSubmit" />
  </view>
</template>

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

onShow(() => {
  method.init()
})

onLoad((e: any) => {
  useModel.formData.value.renovation_applies_id = e?.id
  useModel.formData.value.type = e?.type
})
</script>

<style lang="scss">
@import './style.scss';
</style>
