<template>
  <hs-popup-buttom-custom
    :show="props?.show"
    title="提交验收"
    @close="handleClose"
    mode="bottom"
    :closeable="true"
    :round="20"
    :safeAreaInsetBottom="false"
  >
    <view class="popup_content">
      <hs-reservation-picker
        title="期望上门时间"
        required
        v-model:valueDefault="popupFormData"
        v-model:valueExpectStartTime="popupFormData.expect_start_time"
        v-model:valueExpectEndTime="popupFormData.expect_end_time"
      />
      <view class="popup_footer">
        <hs-button label="提交" size="md" @click="handleSubmit" />
      </view>
    </view>
  </hs-popup-buttom-custom>
</template>
<script setup lang="ts">
import { onHide } from '@dcloudio/uni-app'
import { ref, watch } from 'vue'
import { showToastBack, showToast } from '@/common/libraries/naviHelper'
const props = defineProps(['show', 'items'])
const emit = defineEmits(['click', 'handleSubmit', 'handleClose'])
const popupFormData = ref<any>({})

watch(
  () => props?.show,
  newVal => {
    popupFormData.value = {}
  }
)
const handleSubmit = () => {
  if (!popupFormData.value?.expect_start_time) {
    return showToast('请选择期望上门时间！')
  }
  emit('handleSubmit', { ...props?.items, ...popupFormData.value })
}
const handleClose = () => {
  emit('handleClose')
}

onHide(() => {
  handleClose()
})
</script>
<style lang="scss" scoped>
.popup_content {
  padding: 30rpx;
  .popup_footer {
    padding: 30rpx 0 100rpx 0;
  }
}
</style>
