<template>
  <view>
    <view class="update_header">
      <hs-steps :current="useModel?.current?.value" :items="['装修人信息', '施工方信息']" />
      <up-steps :list="[{ name: '装修人信息' }, { name: '施工方信息' }]" :current="0"></up-steps>
    </view>

    <view class="update_form_content">
      <template v-if="useModel?.current?.value === 0">
        <view class="form_card form_card_owner">
          <view class="form_card_title"> <text></text> 产权人信息 </view>
          <hs-cell title="姓名" required borderTop>
            <hs-input v-model:valueModel="useModel.formData.value.owner_name" textAlign="right" />
          </hs-cell>
          <hs-cell title="手机号" required borderTop>
            <hs-input
              v-model:valueModel="useModel.formData.value.owner_phone"
              maxLength="11"
              textAlign="right"
              type="number"
            />
          </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.owner_id_card"
              maxLength="18"
              textAlign="right"
            />
          </hs-cell>
          <hs-upload-id-card
            required
            borderTop
            v-model:valueFrontModel="useModel.formData.value.id_card_front"
            v-model:valueBackModel="useModel.formData.value.id_card_back"
          />
          <hs-upload
            title="上传房产证"
            :count="10"
            :size="4"
            required
            borderTop
            v-model:valueModel="useModel.formData.value.property_certificate"
          />
        </view>
        <!-- <view class="form_card">
          <hs-cell title="是否有保证金" required>
            <u-switch v-model="useModel.formData.value.is_deposit" activeColor="#2A7EFB"></u-switch>
          </hs-cell>
          <hs-cell title="保证金金额" v-if="useModel.formData.value.is_deposit" required borderTop>
            <hs-input
              v-model:valueModel="useModel.formData.value.deposit_amount"
              textAlign="right"
            />
          </hs-cell>
        </view> -->

        <view class="form_card" v-if="useModel?.showData?.value?.process_type === 'AgentProcess'">
          <view class="form_card_title"> <text></text> 代理人信息 </view>
          <hs-cell title="姓名" required borderTop>
            <hs-input v-model:valueModel="useModel.formData.value.agent_name" textAlign="right" />
          </hs-cell>
          <hs-cell title="手机号" required borderTop>
            <hs-input
              v-model:valueModel="useModel.formData.value.agent_phone"
              maxLength="11"
              textAlign="right"
              type="number"
            />
          </hs-cell>
          <hs-radio-cell-picker
            title="证件类型"
            required
            borderTop
            isLink
            :Enums="HouseOccupantsCardTypeEnum"
            v-model:valueModel="useModel.formData.value.agent_card_type"
          />
          <hs-cell title="证件号" required borderTop>
            <hs-input
              v-model:valueModel="useModel.formData.value.agent_id_card"
              maxLength="18"
              textAlign="right"
            />
          </hs-cell>
          <hs-upload-id-card
            required
            borderTop
            v-model:valueFrontModel="useModel.formData.value.agent_id_card_front"
            v-model:valueBackModel="useModel.formData.value.agent_id_card_back"
          />
          <hs-upload
            title="代理人授权书"
            :count="1"
            :size="4"
            required
            borderTop
            v-model:valueModel="useModel.formData.value.power_attorney"
          />
        </view>
      </template>
      <template v-if="useModel?.current?.value === 1">
        <view class="share_card">
          <view> 为保证信息正确，您可分享至施工方填写 </view>
          <view class="share_btn">
            <button open-type="share">
              分享转发 <uni-icons type="right" size="14" color="#fff"></uni-icons>
            </button>
          </view>
        </view>

        <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.construction_principal_name"
              textAlign="right"
            />
          </hs-cell>
          <hs-cell title="手机号" required borderTop>
            <hs-input
              v-model:valueModel="useModel.formData.value.construction_principal_phone"
              maxLength="11"
              textAlign="right"
            />
          </hs-cell>
          <hs-radio-cell-picker
            title="证件类型"
            required
            borderTop
            isLink
            :Enums="HouseOccupantsCardTypeEnum"
            v-model:valueModel="useModel.formData.value.construction_principal_card_type"
          />
          <hs-cell title="证件号" required borderTop>
            <hs-input
              v-model:valueModel="useModel.formData.value.construction_principal_id_card"
              maxLength="18"
              textAlign="right"
            />
          </hs-cell>
          <hs-upload-id-card
            required
            borderTop
            v-model:valueFrontModel="useModel.formData.value.construction_principal_id_card_front"
            v-model:valueBackModel="useModel.formData.value.construction_principal_id_card_back"
          />
        </view>

        <view class="form_card" v-if="useModel?.formData?.value?.type === 'RenovationCompany'">
          <view class="form_card_title"> <text></text> 施工公司信息 </view>
          <!-- <hs-cell title="装修公司法人名称" required borderTop>
            <hs-input
              v-model:valueModel="useModel.formData.value.company_principal_name"
              textAlign="right"
            />
          </hs-cell>
          <hs-cell title="装修公司法人手机" required borderTop>
            <hs-input
              v-model:valueModel="useModel.formData.value.company_principal_phone"
              maxLength="11"
              textAlign="right"
              type="number"
            />
          </hs-cell> -->
          <hs-cell title="装修公司全称" required borderTop>
            <hs-input v-model:valueModel="useModel.formData.value.company_name" textAlign="right" />
          </hs-cell>
          <hs-cell title="社会统一信用代码" required borderTop>
            <hs-input
              v-model:valueModel="useModel.formData.value.company_business_license_num"
              textAlign="right"
            />
          </hs-cell>
          <hs-upload
            title="营业执照照片"
            :count="1"
            :size="4"
            required
            borderTop
            v-model:valueModel="useModel.formData.value.company_business_license"
          />

          <hs-upload
            title="资质证明"
            :count="1"
            :size="4"
            required
            borderTop
            v-model:valueModel="useModel.formData.value.company_asset_certificate"
          />
          <hs-upload
            title="装修授权书"
            :count="1"
            :size="4"
            required
            borderTop
            v-model:valueModel="useModel.formData.value.company_power_attorney"
          />
        </view>
        <view class="form_card">
          <view class="form_card_title"> <text></text> 施工内容 </view>
          <hs-date-picker
            title="施工开始时间"
            v-model:valueModel="useModel.formData.value.construction_start_date"
            required
            borderTop
            isLink
          />
          <hs-date-picker
            title="施工结束时间"
            v-model:valueModel="useModel.formData.value.construction_end_date"
            required
            borderTop
            isLink
          />
          <hs-cell title="装修内容" borderTop required>
            <hs-radio
              :Enums="RenovationAppliesRenovationContentEnum"
              v-model:valueModel="useModel.formData.value.renovation_content"
              required
            />
          </hs-cell>

          <view class="refund_info">
            <view class="label"> 装修内容说明 </view>
            <view class="refund_reason">
              <textarea
                v-model="useModel.formData.value.renovation_remark"
                placeholder-style="color:#C9CDD4;font-size:28rpx;"
                placeholder="请输入装修内容说明，例如:厨卫墙地砖拆除、安装衣柜、更换地板、客厅吊顶、全屋刷漆等"
              />
            </view>
          </view>
        </view>
        <view class="form_card">
          <view class="form_card_title"> <text></text> 其他资料 </view>
          <hs-upload
            title="施工图"
            :count="10"
            :size="4"
            borderTop
            v-model:valueModel="useModel.formData.value.construction_draw"
          />
          <hs-upload
            title="装修承诺书"
            :count="1"
            :size="4"
            borderTop
            v-model:valueModel="useModel.formData.value.construction_commitment_letter"
          />
          <hs-upload
            title="其他附件"
            :count="20"
            :size="4"
            borderTop
            v-model:valueModel="useModel.formData.value.other_attachments"
          />
        </view>
      </template>
    </view>
    <hs-footer>
      <view class="footer_page">
        <view class="previous_btn" v-if="useModel?.current?.value" @click="method.handlePrev">
          <uni-icons type="undo-filled" color="#3D3D3D" size="24"></uni-icons>
          <view class="label"> 上一步 </view>
        </view>
        <view class="group_btn_content">
          <view class="next_btn" @click="method.handleSave(0)">
            <hs-button label="暂存" type="display" size="md" />
          </view>

          <view class="next_btn" @click="method.handleNextSubmit">
            <hs-button
              :label="useModel?.current?.value ? '提交' : '下一步'"
              type="primary"
              size="md"
            />
          </view>
        </view>
      </view>
    </hs-footer>
  </view>
</template>
<script setup lang="ts">
import { onLoad, onShareAppMessage, onShow, onUnload } from '@dcloudio/uni-app'
import method from './method'
import useModel from './model'
import { HouseOccupantsCardTypeEnum, RenovationAppliesRenovationContentEnum } from '@/gen/Enums'

onLoad((e: any) => {
  method?.getShow(e)
})

onUnload(() => {
  useModel.current.value = 0
  useModel.formData.value = {}
})

onShareAppMessage(() => {
  return {
    title: `邀请您填写装修登记`,
    path: `/ME/decoration/decoration_share/index?id=${useModel?.showData?.value?.id}`,
    imageUrl:
      'https://gc-test-1369486729.cos.ap-guangzhou.myqcloud.com/uploads/cs-test/01KAAG9TW1WMQ8JETENG7QWXD4.jpg'
  }
})
</script>

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