<template>
  <view class="workorder_add_page">
    <!-- <view class="card_form">
      <hs-cell title="工单类型" required>
        <hs-radio
          :Enums="HouseWorkOrdersTypeEnumList"
          v-model:valueModel="useModel.formData.value.type"
        />
      </hs-cell>
    </view> -->
    <view class="card_form">
      <!-- <hs-cell title="报事位置" required v-if="useModel.formData.value.type !== 'Complaint'">
        <hs-radio
          :Enums="HouseWorkOrdersLocationEnum"
          v-model:valueModel="useModel.formData.value.location"
        />
      </hs-cell> -->
      <hs-cell title="选择项目" required borderTop v-if="useModel.formData.value.location !== 'MyHome'" :isLink="true"
        :value="useModel?.formData?.value?.project_name" isPlaceholder="请选择项目"
        url="/pages/public/select_project/index?source=work_add" />



      <template v-if="useModel.formData.value.location === 'MyHome'">
        <!-- <hs-cell title="房屋信息" required borderTop :isLink="true" :value="useModel?.formData?.value?.full_name"
          isPlaceholder="请选择房屋" url="/pages/public/asset_houses/index?type=work_add" /> -->

        <hs-popup-project-houer title="选择房屋" @change="method?.handleSelectProject"
          :defaultValueName="useModel?.formData?.value?.full_name" />


        <hs-cell title="客户姓名" required borderTop>
          <hs-input v-model:valueModel="useModel.formData.value.reporter_name" textAlign="right" />
        </hs-cell>
        <hs-cell title="客户电话" required borderTop>
          <hs-input v-model:valueModel="useModel.formData.value.reporter_phone" maxLength="11" textAlign="right" />
        </hs-cell>
        <hs-cell title="备用联系电话" borderTop>
          <hs-input v-model:valueModel="useModel.formData.value.contact_phone" maxLength="11" textAlign="right" />
        </hs-cell>
      </template>
      <hs-cell-textarea borderTop required title="问题描述" placeholder="请详细描述问题情况，包括具体位置现象等"
        v-model:valueModel="useModel.formData.value.content" />
      <hs-upload borderTop title="上传图片" :count="6" v-model:valueModel="useModel.formData.value.attachments" />
    </view>

    <!-- <view class="card_form">
      <hs-reservation-picker title="期望上门时间" required v-if="useModel.formData.value.location === 'MyHome'"
        v-model:valueExpectStartTime="useModel.formData.value.expect_start_time"
        v-model:valueExpectEndTime="useModel.formData.value.expect_end_time" />
      <hs-cell title="工单处理方" required :borderTop="useModel.formData.value.location === 'MyHome'">
        <hs-radio v-model:valueModel="useModel.formData.value.is_self" :Enums="IsSelfEnum" />
      </hs-cell>
      <view class="text_gray"> *自己处理选后者（进任务列表），处理不了选前者（后台派专人）。 </view>
    </view> -->
    <hs-footer btnParimaryName="提交" @handleParmaryClick="method?.handleSubmit" />
  </view>
</template>

<script setup lang="ts">
import {
  HouseWorkOrdersLocationEnum,
  HouseWorkOrdersTypeEnum
} from '@/gen/Enums'
import { onLoad, onShow, onUnload } from '@dcloudio/uni-app'
import { ref } from 'vue'
import method from './method'
import useModel from './model'
const HouseWorkOrdersTypeEnumList = ref({})
const IsSelfEnum = {
  Processing1: { text: '需后台分派', value: '0' },
  Processing2: { text: '指派自己', value: '1' }
}
onLoad(e => {
  useModel.formData.value.type = e?.type || ''
  useModel.formData.value.location = e?.location || ''
  console.log(e, '2222')
})

onShow(() => {
  let Enums = JSON.parse(JSON.stringify(HouseWorkOrdersTypeEnum))
  delete Enums?.Complaint
  HouseWorkOrdersTypeEnumList.value = Enums
  HouseWorkOrdersLocationEnum.MyHome.text = '房屋'
  method?.init()
})

onUnload(() => {
  method?.unInit()
})
</script>
<style lang="scss">
@import './style.scss';
</style>
