<template>
  <div class="dialog-box" style="position: relative">
    <el-scrollbar class="custom-scroll content-box">
      <el-form
        ref="formEditTourHouseRentInfoRef"
        :model="formData"
        :size="layoutStore.defaultFormItemSize"
        :rules="rules"
        label-width="120px"
        label-position="right"
        @submit.prevent
      >
        <el-row :gutter="16">
          <el-col :span="24">
            <el-form-item label="房屋标题" prop="TourHouseRentInfo.houseTitle">
              <el-input
                class="input-item"
                v-model="formData.TourHouseRentInfo.houseTitle"
                type="textarea"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength="255"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="所属地区类型" prop="TourHouseRentInfo.areaId">
              <el-cascader
                class="input-item"
                v-model="areaIdPath"
                :options="areaIdWidgetDropdownList"
                placeholder=""
                :clearable="true"
                :filterable="true"
                :show-all-levels="false"
                :props="{ value: 'id', label: 'name', children: 'children', checkStrictly: true }"
                @change="onAreaIdValueChange"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="选择顾问" prop="TourHouseRentInfo.advisorId">
              <SelectHouseAdvisor
                class="input-item"
                v-model="formData.TourHouseRentInfo.advisorId"
                placeholder=""
                :required="true"
                :disabled="false"
                :props="{
                  label: 'name',
                  value: 'id'
                }"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="楼层类型" prop="TourHouseRentInfo.floorType">
              <el-select
                class="input-item"
                v-model="formData.TourHouseRentInfo.floorType"
                placeholder=""
                :clearable="true"
                :filterable="true"
                @visible-change="floorTypeWidget.onVisibleChange"
              >
                <el-option
                  v-for="item in floorTypeWidgetDropdownList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="租赁方式" prop="TourHouseRentInfo.rentType">
              <el-select
                class="input-item"
                v-model="formData.TourHouseRentInfo.rentType"
                placeholder=""
                :clearable="true"
                :filterable="true"
                @visible-change="rentTypeWidget.onVisibleChange"
              >
                <el-option
                  v-for="item in rentTypeWidgetDropdownList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否热推房源" prop="TourHouseRentInfo.isHotPush">
              <el-radio-group
                class="input-item"
                v-model="formData.TourHouseRentInfo.isHotPush"
              >
                <el-radio
                  v-for="item in isHotPushWidgetDropdownList"
                  :key="item.id"
                  :label="item.id"
                >
                  {{ item.name }}
                </el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="面积" prop="TourHouseRentInfo.area">
              <el-input-number
                class="input-item"
                v-model="formData.TourHouseRentInfo.area"
                placeholder=""
                :clearable="true"
                :step="1"
                :precision="2"
                :controls="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="租金" prop="TourHouseRentInfo.rentPrice">
              <el-input-number
                class="input-item"
                v-model="formData.TourHouseRentInfo.rentPrice"
                placeholder=""
                :clearable="true"
                :step="1"
                :controls="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="货币单位" prop="TourHouseRentInfo.currency">
              <el-input
                class="input-item"
                v-model="formData.TourHouseRentInfo.currency"
                type="text"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength=""
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="租金类型" prop="TourHouseRentInfo.rentKind">
              <el-select
                class="input-item"
                v-model="formData.TourHouseRentInfo.rentKind"
                placeholder=""
                :clearable="true"
                :filterable="true"
                @visible-change="rentKindWidget.onVisibleChange"
              >
                <el-option
                  v-for="item in rentKindWidgetDropdownList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="厅室类型" prop="TourHouseRentInfo.officeType">
              <el-select
                class="input-item"
                v-model="formData.TourHouseRentInfo.officeType"
                placeholder=""
                :clearable="true"
                :filterable="true"
                @visible-change="officeTypeWidget.onVisibleChange"
              >
                <el-option
                  v-for="item in officeTypeWidgetDropdownList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="房屋类型" prop="TourHouseRentInfo.houseType">
              <el-select
                class="input-item"
                v-model="formData.TourHouseRentInfo.houseType"
                placeholder=""
                :clearable="true"
                :filterable="true"
                @visible-change="houseTypeWidget.onVisibleChange"
              >
                <el-option
                  v-for="item in houseTypeWidgetDropdownList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="朝向类型" prop="TourHouseRentInfo.orientation">
              <el-select
                class="input-item"
                v-model="formData.TourHouseRentInfo.orientation"
                placeholder=""
                :clearable="true"
                :filterable="true"
                @visible-change="orientationWidget.onVisibleChange"
              >
                <el-option
                  v-for="item in orientationWidgetDropdownList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="所在楼层" prop="TourHouseRentInfo.currentFloor">
              <el-input-number
                class="input-item"
                v-model="formData.TourHouseRentInfo.currentFloor"
                placeholder=""
                :clearable="true"
                :step="1"
                :controls="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="总楼层" prop="TourHouseRentInfo.totalFloor">
              <el-input-number
                class="input-item"
                v-model="formData.TourHouseRentInfo.totalFloor"
                placeholder=""
                :clearable="true"
                :step="1"
                :controls="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="装修类型" prop="TourHouseRentInfo.decoration">
              <el-select
                class="input-item"
                v-model="formData.TourHouseRentInfo.decoration"
                placeholder=""
                :clearable="true"
                :filterable="true"
                @visible-change="decorationWidget.onVisibleChange"
              >
                <el-option
                  v-for="item in decorationWidgetDropdownList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="楼盘名称/所属小区" prop="TourHouseRentInfo.communityName">
              <el-input
                class="input-item"
                v-model="formData.TourHouseRentInfo.communityName"
                type="textarea"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength=""
              />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="地址" prop="TourHouseRentInfo.address">
              <el-input
                class="input-item"
                v-model="formData.TourHouseRentInfo.address"
                type="textarea"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength=""
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="所属区域" prop="TourHouseRentInfo.region">
              <el-input
                class="input-item"
                v-model="formData.TourHouseRentInfo.region"
                type="text"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength=""
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="封面图" prop="TourHouseRentInfo.coverUrl">
              <el-upload
                class="upload-image-item"
                name="uploadFile"
                :headers="getUploadHeaders"
                :action="getUploadActionUrl('/admin/app/tourHouseRentInfo/upload')"
                :data="{fieldName: 'coverUrl', asImage: true}"
                :on-success="onCoverUrlUploadSuccess"
                :on-remove="onCoverUrlRemoveFile"
                :on-error="onUploadError"
                :show-file-list="false"
              >
              <div v-if="coverUrlWidgetFileList && coverUrlWidgetFileList[0] != null" style="position: relative">
                <img class="upload-image-show"
                  :src="coverUrlWidgetFileList[0].url" />
                <div class="upload-img-del el-icon-close"
                  @click.stop="onCoverUrlRemoveFile(null, null)" />
              </div>
              <i v-else class="el-icon-plus upload-image-item"></i>
              </el-upload>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="房屋详情图(最多可上传六张图片)" prop="TourHouseRentInfo.tourHouseEquipment.houseDetailImage">
              <el-upload
                class="upload-image-item upload-image-multi"
                name="uploadFile"
                :headers="getUploadHeaders"
                :action="getUploadActionUrl('/admin/app/tourHouseEquipment/upload')"
                :data="{fieldName: 'houseDetailImage', asImage: true}"
                :on-success="onHouseDetailImageUploadSuccess"
                :on-remove="onHouseDetailImageRemoveFile"
                :on-error="onUploadError"
                :on-exceed="onUploadLimit"
                list-type="picture-card"
                :file-list="houseDetailImageWidgetFileList"
                :limit="houseDetailImageWidgetMaxCount"
                :show-file-list="true"
              >
              <i class="el-icon-plus upload-image-item"></i>
              </el-upload>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="排序顺序" prop="TourHouseRentInfo.showOrder">
              <el-input-number
                class="input-item"
                v-model="formData.TourHouseRentInfo.showOrder"
                placeholder=""
                :clearable="true"
                :step="1"
                :controls="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="有无冰箱" prop="TourHouseRentInfo.tourHouseEquipment.icebox">
              <el-switch
                class="input-item"
                v-model="formData.TourHouseRentInfo.tourHouseEquipment.icebox"
                :active-value = "1"
                :inactive-value= "0"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="有无洗衣机" prop="TourHouseRentInfo.tourHouseEquipment.washer">
              <el-switch
                class="input-item"
                v-model="formData.TourHouseRentInfo.tourHouseEquipment.washer"
                :active-value="1"
                :inactive-value="0"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="有无热水器" prop="TourHouseRentInfo.tourHouseEquipment.calorifier">
              <el-switch
                class="input-item"
                v-model="formData.TourHouseRentInfo.tourHouseEquipment.calorifier"
                :active-value="1"
                :inactive-value="0"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="有无宽带" prop="TourHouseRentInfo.tourHouseEquipment.broadband">
              <el-switch
                class="input-item"
                v-model="formData.TourHouseRentInfo.tourHouseEquipment.broadband"
                :active-value="1"
                :inactive-value="0"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="有无沙发" prop="TourHouseRentInfo.tourHouseEquipment.sofa">
              <el-switch
                class="input-item"
                v-model="formData.TourHouseRentInfo.tourHouseEquipment.sofa"
                :active-value="1"
                :inactive-value="0"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="有无油烟机" prop="TourHouseRentInfo.tourHouseEquipment.rangeHood">
              <el-switch
                class="input-item"
                v-model="formData.TourHouseRentInfo.tourHouseEquipment.rangeHood"
                :active-value="1"
                :inactive-value="0"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="有无燃气灶" prop="TourHouseRentInfo.tourHouseEquipment.gasStove">
              <el-switch
                class="input-item"
                v-model="formData.TourHouseRentInfo.tourHouseEquipment.gasStove"
                :active-value="1"
                :inactive-value="0"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="能否做饭" prop="TourHouseRentInfo.tourHouseEquipment.ableCook">
              <el-switch
                class="input-item"
                v-model="formData.TourHouseRentInfo.tourHouseEquipment.ableCook"
                :active-value="1"
                :inactive-value="0"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="有无电视" prop="TourHouseRentInfo.tourHouseEquipment.television">
              <el-switch
                class="input-item"
                v-model="formData.TourHouseRentInfo.tourHouseEquipment.television"
                :active-value="1"
                :inactive-value="0"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="有无空调" prop="TourHouseRentInfo.tourHouseEquipment.airConditioner">
              <el-switch
                class="input-item"
                v-model="formData.TourHouseRentInfo.tourHouseEquipment.airConditioner"
                :active-value="1"
                :inactive-value="0"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="有无衣柜" prop="TourHouseRentInfo.tourHouseEquipment.wardrobe">
              <el-switch
                class="input-item"
                v-model="formData.TourHouseRentInfo.tourHouseEquipment.wardrobe"
                :active-value="1"
                :inactive-value="0"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="有无床" prop="TourHouseRentInfo.tourHouseEquipment.bed">
              <el-switch
                class="input-item"
                v-model="formData.TourHouseRentInfo.tourHouseEquipment.bed"
                :active-value="1"
                :inactive-value="0"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="有无卫生间" prop="TourHouseRentInfo.tourHouseEquipment.restRoom">
              <el-switch
                class="input-item"
                v-model="formData.TourHouseRentInfo.tourHouseEquipment.restRoom"
                :active-value="1"
                :inactive-value="0"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="有无智能门锁" prop="TourHouseRentInfo.tourHouseEquipment.smartDoorLock">
              <el-switch
                class="input-item"
                v-model="formData.TourHouseRentInfo.tourHouseEquipment.smartDoorLock"
                :active-value="1"
                :inactive-value="0"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="有无阳台" prop="TourHouseRentInfo.tourHouseEquipment.balcony">
              <el-switch
                class="input-item"
                v-model="formData.TourHouseRentInfo.tourHouseEquipment.balcony"
                :active-value="1"
                :inactive-value="0"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="有无暖气" prop="TourHouseRentInfo.tourHouseEquipment.heating">
              <el-switch
                class="input-item"
                v-model="formData.TourHouseRentInfo.tourHouseEquipment.heating"
                :active-value="1"
                :inactive-value="0"
              />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="周边配套描述" prop="TourHouseRentInfo.tourHouseEquipment.surroundingSupport">
              <el-input
                class="input-item"
                v-model="formData.TourHouseRentInfo.tourHouseEquipment.surroundingSupport"
                type="textarea"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength="500"
              />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="周边配套的图片(最多可上传六张图片)" prop="TourHouseRentInfo.tourHouseEquipment.surroundingSupportImage">
              <el-upload
                class="upload-image-item upload-image-multi"
                name="uploadFile"
                :headers="getUploadHeaders"
                :action="getUploadActionUrl('/admin/app/tourHouseEquipment/upload')"
                :data="{fieldName: 'surroundingSupportImage', asImage: true}"
                :on-success="onSurroundingSupportImageUploadSuccess"
                :on-remove="onSurroundingSupportImageRemoveFile"
                :on-error="onUploadError"
                :on-exceed="onUploadLimit"
                list-type="picture-card"
                :file-list="surroundingSupportImageWidgetFileList"
                :limit="houseDetailImageWidgetMaxCount"
                :show-file-list="true"
              >
              <i class="el-icon-plus upload-image-item"></i>
              </el-upload>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="小区介绍" prop="TourHouseRentInfo.tourHouseEquipment.plotIntroduction">
              <el-input
                class="input-item"
                v-model="formData.TourHouseRentInfo.tourHouseEquipment.plotIntroduction"
                type="textarea"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength="500"
              />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="小区介绍的图片(最多可上传六张图片)" prop="TourHouseRentInfo.tourHouseEquipment.plotIntroductionImage">
              <el-upload
                class="upload-image-item upload-image-multi"
                name="uploadFile"
                :headers="getUploadHeaders"
                :action="getUploadActionUrl('/admin/app/tourHouseEquipment/upload')"
                :data="{fieldName: 'plotIntroductionImage', asImage: true}"
                :on-success="onPlotIntroductionImageUploadSuccess"
                :on-remove="onPlotIntroductionImageRemoveFile"
                :on-error="onUploadError"
                :on-exceed="onUploadLimit"
                list-type="picture-card"
                :file-list="plotIntroductionImageWidgetFileList"
                :limit="houseDetailImageWidgetMaxCount"
                :show-file-list="true"
              >
              <i class="el-icon-plus upload-image-item"></i>
              </el-upload>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-scrollbar>
    <el-row class="footer-box" type="flex" justify="end" align="middle">
      <el-button :size="layoutStore.defaultFormItemSize" @click="onCancel()">取消</el-button>
      <el-button :size="layoutStore.defaultFormItemSize" type="primary" @click="onSaveClick()">保存</el-button>
    </el-row>
  </div>
</template>

<script lang="ts">
export default {
  name: 'formEditTourHouseRentInfo',
};
</script>

<script setup lang="ts">
import { DialogProp } from '@/components/Dialog/types';
import { VxeColumn, VxeTable } from 'vxe-table';
import { ANY_OBJECT } from '@/types/generic';
import { DictData, DictionaryBase } from '@/common/staticDict/types';
import { ElMessage, ElMessageBox, UploadFile } from 'element-plus';
import { useRoute, useRouter } from 'vue-router';
import { useCommon } from '@/common/hooks/useCommon';
import { useLayoutStore, useStaticDictStore } from '@/store';
import { useDownload } from '@/common/hooks/useDownload';
import { useDropdown } from '@/common/hooks/useDropdown';
import { DropdownOptions, ListData } from '@/common/types/list';
import { useTable } from '@/common/hooks/useTable';
import { TableOptions } from '@/common/types/pagination';
import { useUpload } from '@/common/hooks/useUpload';
import { useUploadWidget } from '@/common/hooks/useUploadWidget';
import { DictionaryController } from '@/api/system';
import { treeDataTranslate, findItemFromList, findTreeNodePath, findTreeNode, stringCase } from '@/common/utils';
import { TourHouseRentInfoData } from '@/api/generated/tourHouseRentInfoController';
import { TourHouseEquipmentData } from '@/api/generated/tourHouseEquipmentController';
import { TourHouseAdvisorInfoData } from '@/api/generated/tourHouseAdvisorInfoController';
import { TourHouseRentInfoController, TourHouseEquipmentController, TourHouseAdvisorInfoController } from '@/api/generated';
import SelectHouseAdvisor from '@/pages/tourHouseRentInfo/selectHouseAdvisor/index.vue';

const router = useRouter();
const route = useRoute();
const layoutStore = useLayoutStore();
const { downloadFile } = useDownload();
const { getUploadHeaders, getUploadActionUrl, fileListToJson, parseUploadData, getPictureList } = useUpload();
const { 
  Delete,
  Search,
  Edit,
  Plus,
  Refresh,
  Picture,
  Dialog,
  mainContextHeight,
  clientHeight,
  checkPermCodeExist,
  parseParams,
  parseArrayParams,
  formatDateByStatsType,
  getDateRangeFilter,
} = useCommon();
// 静态字典
const { staticDict: StaticDict } = useStaticDictStore();

const props = withDefaults(
  defineProps<{
    subPage?: number | string | boolean;
    id?: ANY_OBJECT;
    saveOnSubmit?: boolean;
    rowData?: ANY_OBJECT;
    // 当使用Dialog.show弹出组件时，须定义该prop属性，以便对dialog进行回调
    dialog?: DialogProp<ANY_OBJECT[]>;
  }>(),
  {
    subPage: 0,
    id: undefined,
    saveOnSubmit: true,
    rowData: undefined,
    dialog: undefined,
  },
);

const formEditTourHouseRentInfoRef = ref();
// 表单数据定义
type FormEditTourHouseRentInfoData = {
  TourHouseRentInfo: TourHouseRentInfoData;
};
// 表单数据
const formData = reactive<FormEditTourHouseRentInfoData>({
  TourHouseRentInfo: {
    // 主键
    id: undefined,
    // 所属地区类型
    areaId: undefined,
    // 顾问id
    advisorId: undefined,
    // 租赁方式 0整租 1合租 2个人房源 3短租
    rentType: undefined,
    // 厅室类型
    officeType: undefined,
    // 租金
    rentPrice: undefined,
    // 面积
    area: undefined,
    // 房屋类型 别墅、公寓...
    houseType: undefined,
    // 租金类型(0无租金;1押一付一;2押一付二;3押一付三....)
    rentKind: undefined,
    // 朝向类型
    orientation: undefined,
    // 所在楼层
    currentFloor: undefined,
    // 装修类型
    decoration: undefined,
    // 楼盘名称/所属小区
    communityName: undefined,
    // 地址
    address: undefined,
    // 货币单位
    currency: undefined,
    // 所属区域
    region: undefined,
    // 首页封面图
    coverUrl: undefined,
    // 房屋标题
    houseTitle: undefined,
    // 总楼层
    totalFloor: undefined,
    // 二维码
    code: undefined,
    // 联系电话
    mobile: undefined,
    // 删除标记(1: 正常 -1: 已删除)
    dataState: undefined,
    // 创建人
    createUserId: undefined,
    // 创建时间
    createTime: undefined,
    // 备注
    remark: undefined,
    // 修改人
    updateUserId: undefined,
    // 修改时间
    updateTime: undefined,
    // 排序顺序
    showOrder: undefined,
    // 租房状态(0:未租出;1:已租出)
    rentState: undefined,
    // 楼层类型(1:低楼层;2:中楼层;3:高楼层)
    floorType: undefined,
    // 是否热推房源
    isHotPush: undefined,
    tourHouseEquipment: {
      // 主键
      id: undefined,
      // 房屋表id
      houseId: undefined,
      // 房屋详情图(多张图片)
      houseDetailImage: undefined,
      // 冰箱
      icebox: undefined,
      // 洗衣机
      washer: undefined,
      // 热水器
      calorifier: undefined,
      // 宽带
      broadband: undefined,
      // 沙发
      sofa: undefined,
      // 油烟机
      rangeHood: undefined,
      // 燃气灶
      gasStove: undefined,
      // 做饭
      ableCook: undefined,
      // 电视
      television: undefined,
      // 空调
      airConditioner: undefined,
      // 衣柜
      wardrobe: undefined,
      // 床
      bed: undefined,
      // 卫生间
      restRoom: undefined,
      // 智能门锁
      smartDoorLock: undefined,
      // 阳台
      balcony: undefined,
      // 暖气
      heating: undefined,
      // 周边配套描述
      surroundingSupport: undefined,
      // 周边配套的图片(多张图片)
      surroundingSupportImage: undefined,
      // 小区介绍
      plotIntroduction: undefined,
      // 小区介绍图片(多张图片)
      plotIntroductionImage: undefined,
      // 删除标记(1: 正常 -1: 已删除)
      dataState: undefined,
      // 创建人
      createUserId: undefined,
      // 创建时间
      createTime: undefined,
      // 修改人
      updateUserId: undefined,
      // 修改时间
      updateTime: undefined,
    },
    tourHouseAdvisorInfo: {
      // 主键
      id: undefined,
      // 所属开发商
      developersId: undefined,
      // 顾问类型 0.顾问 1.房东
      type: undefined,
      // 姓名
      name: undefined,
      // 行业经验年限
      experienceAge: undefined,
      // 房屋id
      housedId: undefined,
      // 成功交房数量
      successfulDeliveryCount: undefined,
      // 是否金牌顾问 0不是 1是
      isGoldAdvisor: undefined,
      // 头像url
      avatarUrl: undefined,
      // 备案编号
      recordNumber: undefined,
      // 公司名称
      companyName: undefined,
      // 二维码
      code: undefined,
      // 是否启用，0禁用，1启用
      enable: undefined,
      // 删除标记(1: 正常 -1: 已删除)
      dataState: undefined,
      // 手机号
      mobile: undefined,
      // 创建人
      createUserId: undefined,
      // 创建时间
      createTime: undefined,
      // 修改人
      updateUserId: undefined,
      // 修改时间
      updateTime: undefined,
    },
  },
},
);
// 表单验证规则
const rules = reactive({
  'TourHouseRentInfo.isHotPush': [
    {required: true, message: '请输入是否热推房源', trigger: 'blur'}
  ],
  'TourHouseRentInfo.coverUrl': [
    {required: true, message: '请输入封面图', trigger: 'blur'}
  ],
  'TourHouseRentInfo.region': [
    {required: true, message: '请输入所属商圈', trigger: 'blur'}
  ],
  'TourHouseRentInfo.totalFloor': [
    {required: true, message: '请输入总楼层', trigger: 'blur'}
  ],
  'TourHouseRentInfo.floorType': [
    {required: true, message: '请输入楼层类型', trigger: 'blur'}
  ],
  'TourHouseRentInfo.advisorId': [
    {required: true, message: '请输入选择顾问', trigger: 'blur'}
  ],
  'TourHouseRentInfo.tourHouseEquipment.houseDetailImage': [
    {required: true, message: '请输入房屋详情图(可上传多张图片)', trigger: 'blur'}
  ],
  'TourHouseRentInfo.rentKind': [
  ],
  'TourHouseRentInfo.area': [
    {required: true, message: '请输入面积', trigger: 'blur'}
  ],
  'TourHouseRentInfo.showOrder': [
    {required: true, message: '请输入排序顺序', trigger: 'blur'}
  ],
  'TourHouseRentInfo.officeType': [
    {required: true, message: '请输入厅室类型', trigger: 'blur'}
  ],
  'TourHouseRentInfo.areaId': [
    {required: true, message: '请输入所属地区类型', trigger: 'blur'}
  ],
  'TourHouseRentInfo.rentType': [
    {required: true, message: '请输入租赁方式', trigger: 'blur'}
  ],
  'TourHouseRentInfo.communityName': [
    {required: true, message: '请输入楼盘名称/所属小区', trigger: 'blur'}
  ],
  'TourHouseRentInfo.address': [
    {required: true, message: '请输入地址', trigger: 'blur'}
  ],
  'TourHouseRentInfo.currentFloor': [
    {required: true, message: '请输入所在楼层', trigger: 'blur'}
  ],
  'TourHouseRentInfo.decoration': [
    {required: true, message: '请输入装修类型', trigger: 'blur'}
  ],
  'TourHouseRentInfo.houseType': [
    {required: true, message: '请输入房屋类型', trigger: 'blur'}
  ],
  'TourHouseRentInfo.orientation': [
    {required: true, message: '请输入朝向类型', trigger: 'blur'}
  ],
  'TourHouseRentInfo.rentPrice': [
    {required: true, message: '请输入租金', trigger: 'blur'}
  ],
  'TourHouseRentInfo.tourHouseEquipment.plotIntroductionImage': [
    {required: true, message: '请输入小区介绍的图片(可上传多张图片)', trigger: 'blur'}
  ],
  'TourHouseRentInfo.tourHouseEquipment.surroundingSupport': [
    {required: true, message: '请输入周边配套描述', trigger: 'blur'}
  ],
  'TourHouseRentInfo.tourHouseEquipment.plotIntroduction': [
    {required: true, message: '请输入小区介绍', trigger: 'blur'}
  ],
  'TourHouseRentInfo.tourHouseEquipment.surroundingSupportImage': [
    {required: true, message: '请输入周边配套的图片(可上传多张图片)', trigger: 'blur'}
  ],

});

const onCancel = () => {
  if (props.dialog) {
    props.dialog.cancel();
  }
};

const isEdit = computed(() => {
  return props.saveOnSubmit ? props.id != null : props.rowData != null;
});

// 初始化页面数据
const loadTourHouseRentInfoData = () => {
  return new Promise<void>((resolve, reject) => {
    if (!isEdit.value) {
      resolve();
      return;
    }
    if (!props.saveOnSubmit && props.rowData != null) {
      formData.TourHouseRentInfo = JSON.parse(JSON.stringify(props.rowData));
      resolve();
      return;
    }
    let params: ANY_OBJECT = {
      id: props.id
    };
    TourHouseRentInfoController.view(params).then(res => {
      formData.TourHouseRentInfo = { ...res.data };
      if (formData.TourHouseRentInfo.tourHouseEquipment == null) {
        formData.TourHouseRentInfo.tourHouseEquipment = {
          id: undefined,
          houseId: undefined,
          houseDetailImage: undefined,
          icebox: undefined,
          washer: undefined,
          calorifier: undefined,
          broadband: undefined,
          sofa: undefined,
          rangeHood: undefined,
          gasStove: undefined,
          ableCook: undefined,
          television: undefined,
          airConditioner: undefined,
          wardrobe: undefined,
          bed: undefined,
          restRoom: undefined,
          smartDoorLock: undefined,
          balcony: undefined,
          heating: undefined,
          surroundingSupport: undefined,
          surroundingSupportImage: undefined,
          plotIntroduction: undefined,
          plotIntroductionImage: undefined,
          dataState: undefined,
          createUserId: undefined,
          createTime: undefined,
          updateUserId: undefined,
          updateTime: undefined
        };
      }
      if (formData.TourHouseRentInfo.tourHouseAdvisorInfo == null) {
        formData.TourHouseRentInfo.tourHouseAdvisorInfo = {
          id: undefined,
          developersId: undefined,
          type: undefined,
          name: undefined,
          experienceAge: undefined,
          housedId: undefined,
          successfulDeliveryCount: undefined,
          isGoldAdvisor: undefined,
          avatarUrl: undefined,
          recordNumber: undefined,
          companyName: undefined,
          code: undefined,
          enable: undefined,
          dataState: undefined,
          mobile: undefined,
          createUserId: undefined,
          createTime: undefined,
          updateUserId: undefined,
          updateTime: undefined
        };
      }
      resolve();
    }).catch(e => {
      reject(e);
    });
  });
};
/**
 * 所属地区类型下拉数据获取函数
 */
const loadAreaIdDropdownList = (): Promise<ListData<DictData>> => {
  return new Promise((resolve, reject) => {
    const params = {
    };
    DictionaryController.dictTourHouseAreaMenu(params).then(res => {
      resolve({
        dataList: res.getList(),
      });
    }).catch(e => {
      reject(e);
    });
  });
};
/**
 * 所属地区类型选中值改变
 */
const onAreaIdValueChange = (value) => {
  formData.TourHouseRentInfo.areaId = Array.isArray(value) ? value[value.length - 1] : value;
};
// 所属地区类型配置参数
const areaIdOptions: DropdownOptions<DictData> = {
  loadData: loadAreaIdDropdownList,
  isTree: true,
};
// 所属地区类型选中数据
const areaIdPath = ref<Array<string | number>>([]);
// 所属地区类型下拉组件
const areaIdWidget = useDropdown(areaIdOptions);
const { dropdownList: areaIdWidgetDropdownList } = areaIdWidget
/**
 * 楼层类型下拉数据获取函数
 */
const loadFloorTypeDropdownList = (): Promise<ListData<DictData>> => {
  return new Promise((resolve, reject) => {
    DictionaryController.dictGlobalDict({ dictCode: 'HouseFloorType', itemIdType: 'Integer' }).then(res => {
      resolve({
        dataList: res.getList(),
      });
    }).catch(e => {
      reject(e);
    });
  });
};
// 楼层类型配置参数
const floorTypeOptions: DropdownOptions<DictData> = {
  loadData: loadFloorTypeDropdownList,
  isTree: false,
};
// 楼层类型下拉组件
const floorTypeWidget = useDropdown(floorTypeOptions);
const { dropdownList: floorTypeWidgetDropdownList } = floorTypeWidget
/**
 * 租赁方式下拉数据获取函数
 */
const loadRentTypeDropdownList = (): Promise<ListData<DictData>> => {
  return new Promise((resolve, reject) => {
    DictionaryController.dictGlobalDict({ dictCode: 'HouseRentType', itemIdType: 'Integer' }).then(res => {
      resolve({
        dataList: res.getList(),
      });
    }).catch(e => {
      reject(e);
    });
  });
};
// 租赁方式配置参数
const rentTypeOptions: DropdownOptions<DictData> = {
  loadData: loadRentTypeDropdownList,
  isTree: false,
};
// 租赁方式下拉组件
const rentTypeWidget = useDropdown(rentTypeOptions);
const { dropdownList: rentTypeWidgetDropdownList } = rentTypeWidget
/**
 * 是否热推房源下拉数据获取函数
 */
const loadIsHotPushDropdownList = (): Promise<ListData<DictData>> => {
  return Promise.resolve({
    dataList: StaticDict.IsTrue.getList(),
  });
};
// 是否热推房源配置参数
const isHotPushOptions: DropdownOptions<DictData> = {
  loadData: loadIsHotPushDropdownList,
  isTree: false,
};
// 是否热推房源下拉组件
const isHotPushWidget = useDropdown(isHotPushOptions);
const { dropdownList: isHotPushWidgetDropdownList } = isHotPushWidget
/**
 * 租金类型下拉数据获取函数
 */
const loadRentKindDropdownList = (): Promise<ListData<DictData>> => {
  return new Promise((resolve, reject) => {
    DictionaryController.dictGlobalDict({ dictCode: 'RentKind', itemIdType: 'Integer' }).then(res => {
      resolve({
        dataList: res.getList(),
      });
    }).catch(e => {
      reject(e);
    });
  });
};
// 租金类型配置参数
const rentKindOptions: DropdownOptions<DictData> = {
  loadData: loadRentKindDropdownList,
  isTree: false,
};
// 租金类型下拉组件
const rentKindWidget = useDropdown(rentKindOptions);
const { dropdownList: rentKindWidgetDropdownList } = rentKindWidget
/**
 * 厅室类型下拉数据获取函数
 */
const loadOfficeTypeDropdownList = (): Promise<ListData<DictData>> => {
  return new Promise((resolve, reject) => {
    DictionaryController.dictGlobalDict({ dictCode: 'OfficeType', itemIdType: 'Integer' }).then(res => {
      resolve({
        dataList: res.getList(),
      });
    }).catch(e => {
      reject(e);
    });
  });
};
// 厅室类型配置参数
const officeTypeOptions: DropdownOptions<DictData> = {
  loadData: loadOfficeTypeDropdownList,
  isTree: false,
};
// 厅室类型下拉组件
const officeTypeWidget = useDropdown(officeTypeOptions);
const { dropdownList: officeTypeWidgetDropdownList } = officeTypeWidget
/**
 * 房屋类型下拉数据获取函数
 */
const loadHouseTypeDropdownList = (): Promise<ListData<DictData>> => {
  return new Promise((resolve, reject) => {
    DictionaryController.dictGlobalDict({ dictCode: 'HouseType', itemIdType: 'Integer' }).then(res => {
      resolve({
        dataList: res.getList(),
      });
    }).catch(e => {
      reject(e);
    });
  });
};
// 房屋类型配置参数
const houseTypeOptions: DropdownOptions<DictData> = {
  loadData: loadHouseTypeDropdownList,
  isTree: false,
};
// 房屋类型下拉组件
const houseTypeWidget = useDropdown(houseTypeOptions);
const { dropdownList: houseTypeWidgetDropdownList } = houseTypeWidget
/**
 * 朝向类型下拉数据获取函数
 */
const loadOrientationDropdownList = (): Promise<ListData<DictData>> => {
  return new Promise((resolve, reject) => {
    DictionaryController.dictGlobalDict({ dictCode: 'Orientation', itemIdType: 'Integer' }).then(res => {
      resolve({
        dataList: res.getList(),
      });
    }).catch(e => {
      reject(e);
    });
  });
};
// 朝向类型配置参数
const orientationOptions: DropdownOptions<DictData> = {
  loadData: loadOrientationDropdownList,
  isTree: false,
};
// 朝向类型下拉组件
const orientationWidget = useDropdown(orientationOptions);
const { dropdownList: orientationWidgetDropdownList } = orientationWidget
/**
 * 装修类型下拉数据获取函数
 */
const loadDecorationDropdownList = (): Promise<ListData<DictData>> => {
  return new Promise((resolve, reject) => {
    DictionaryController.dictGlobalDict({ dictCode: 'Decoration', itemIdType: 'Integer' }).then(res => {
      resolve({
        dataList: res.getList(),
      });
    }).catch(e => {
      reject(e);
    });
  });
};
// 装修类型配置参数
const decorationOptions: DropdownOptions<DictData> = {
  loadData: loadDecorationDropdownList,
  isTree: false,
};
// 装修类型下拉组件
const decorationWidget = useDropdown(decorationOptions);
const { dropdownList: decorationWidgetDropdownList } = decorationWidget
/**
 * 封面图上传成功
 */
const onCoverUrlUploadSuccess = (
  response: ANY_OBJECT,
  file: UploadFile,
  fileList: UploadFile[],
) => {
  if (response.success) {
    file.downloadUri = response.data.downloadUri;
    file.filename = response.data.filename;
    file.uploadPath = response.data.uploadPath;
    file.url = URL.createObjectURL(file.raw);
    coverUrlWidget.onFileChange(file, fileList);
    formData.TourHouseRentInfo.coverUrl = fileListToJson(coverUrlWidgetFileList.value);
  } else {
    ElMessage.error(response.message);
  }
};
/**
 * 移除封面图
 */
const onCoverUrlRemoveFile = (file: UploadFile | null, fileList: UploadFile[] | null) => {
  coverUrlWidget.onFileChange(file, fileList);
  formData.TourHouseRentInfo.coverUrl = fileListToJson(coverUrlWidgetFileList.value);
};
// 封面图上传文件组件
const coverUrlWidget = useUploadWidget(1);
const { fileList: coverUrlWidgetFileList, maxCount: coverUrlWidgetMaxCount } = coverUrlWidget;
/**
 * 房屋详情图(可上传多张图片)上传成功
 */
const onHouseDetailImageUploadSuccess = (
  response: ANY_OBJECT,
  file: UploadFile,
  fileList: UploadFile[],
) => {
  if (response.success) {
    file.downloadUri = response.data.downloadUri;
    file.filename = response.data.filename;
    file.uploadPath = response.data.uploadPath;
    file.url = URL.createObjectURL(file.raw);
    houseDetailImageWidget.onFileChange(file, fileList);
    formData.TourHouseRentInfo.tourHouseEquipment.houseDetailImage = fileListToJson(houseDetailImageWidgetFileList.value);
  } else {
    ElMessage.error(response.message);
  }
};
/**
 * 移除房屋详情图(可上传多张图片)
 */
const onHouseDetailImageRemoveFile = (file: UploadFile | null, fileList: UploadFile[] | null) => {
  houseDetailImageWidget.onFileChange(file, fileList);
  formData.TourHouseRentInfo.tourHouseEquipment.houseDetailImage = fileListToJson(houseDetailImageWidgetFileList.value);
};
// 房屋详情图(可上传多张图片)上传文件组件
const houseDetailImageWidget = useUploadWidget(6);
const { fileList: houseDetailImageWidgetFileList, maxCount: houseDetailImageWidgetMaxCount } = houseDetailImageWidget;
/**
 * 周边配套的图片(可上传多张图片)上传成功
 */
const onSurroundingSupportImageUploadSuccess = (
  response: ANY_OBJECT,
  file: UploadFile,
  fileList: UploadFile[],
) => {
  if (response.success) {
    file.downloadUri = response.data.downloadUri;
    file.filename = response.data.filename;
    file.uploadPath = response.data.uploadPath;
    file.url = URL.createObjectURL(file.raw);
    surroundingSupportImageWidget.onFileChange(file, fileList);
    formData.TourHouseRentInfo.tourHouseEquipment.surroundingSupportImage = fileListToJson(surroundingSupportImageWidgetFileList.value);
  } else {
    ElMessage.error(response.message);
  }
};
/**
 * 移除周边配套的图片(可上传多张图片)
 */
const onSurroundingSupportImageRemoveFile = (file: UploadFile | null, fileList: UploadFile[] | null) => {
  surroundingSupportImageWidget.onFileChange(file, fileList);
  formData.TourHouseRentInfo.tourHouseEquipment.surroundingSupportImage = fileListToJson(surroundingSupportImageWidgetFileList.value);
};
// 周边配套的图片(可上传多张图片)上传文件组件
const surroundingSupportImageWidget = useUploadWidget(6);
const { fileList: surroundingSupportImageWidgetFileList, maxCount: surroundingSupportImageWidgetMaxCount } = surroundingSupportImageWidget;
/**
 * 小区介绍的图片(可上传多张图片)上传成功
 */
const onPlotIntroductionImageUploadSuccess = (
  response: ANY_OBJECT,
  file: UploadFile,
  fileList: UploadFile[],
) => {
  if (response.success) {
    file.downloadUri = response.data.downloadUri;
    file.filename = response.data.filename;
    file.uploadPath = response.data.uploadPath;
    file.url = URL.createObjectURL(file.raw);
    plotIntroductionImageWidget.onFileChange(file, fileList);
    formData.TourHouseRentInfo.tourHouseEquipment.plotIntroductionImage = fileListToJson(plotIntroductionImageWidgetFileList.value);
  } else {
    ElMessage.error(response.message);
  }
};
/**
 * 移除小区介绍的图片(可上传多张图片)
 */
const onPlotIntroductionImageRemoveFile = (file: UploadFile | null, fileList: UploadFile[] | null) => {
  plotIntroductionImageWidget.onFileChange(file, fileList);
  formData.TourHouseRentInfo.tourHouseEquipment.plotIntroductionImage = fileListToJson(plotIntroductionImageWidgetFileList.value);
};
// 小区介绍的图片(可上传多张图片)上传文件组件
const plotIntroductionImageWidget = useUploadWidget(6);
const { fileList: plotIntroductionImageWidgetFileList, maxCount: plotIntroductionImageWidgetMaxCount } = plotIntroductionImageWidget;
const onUploadError = () => {
  ElMessage.error('文件上传失败');
};
const onUploadLimit = () => {
  ElMessage.error('已经超出最大上传个数限制');
};
const refreshFormEditTourHouseRentInfo = () => {
  // 刷新段落
};
/**
 * 重置过滤值
 */
const resetFormEditTourHouseRentInfo = () => {
  refreshFormEditTourHouseRentInfo();
};
/**
 * 重置所有过滤值
 */
const resetFilter = () => {
  resetFormEditTourHouseRentInfo();
};
/**
 * 保存
 */
const onSaveClick = () => {
  console.log(99999999999999);
  formEditTourHouseRentInfoRef.value.validate((valid) => {
    console.log(8888888888888888);
    console.log(valid);
    if (!valid) return;
    // 级联操作
    if (!props.saveOnSubmit) {
      let retFormData = {
        ...formData.TourHouseRentInfo
      };
    retFormData.areaIdDictMap = findTreeNode(areaIdWidgetDropdownList, retFormData.areaId, 'id');
    retFormData.floorTypeDictMap = findItemFromList(floorTypeWidgetDropdownList, retFormData.floorType, 'id');
    retFormData.rentTypeDictMap = findItemFromList(rentTypeWidgetDropdownList, retFormData.rentType, 'id');
    retFormData.rentKindDictMap = findItemFromList(rentKindWidgetDropdownList, retFormData.rentKind, 'id');
    retFormData.officeTypeDictMap = findItemFromList(officeTypeWidgetDropdownList, retFormData.officeType, 'id');
    retFormData.houseTypeDictMap = findItemFromList(houseTypeWidgetDropdownList, retFormData.houseType, 'id');
    retFormData.orientationDictMap = findItemFromList(orientationWidgetDropdownList, retFormData.orientation, 'id');
    retFormData.decorationDictMap = findItemFromList(decorationWidgetDropdownList, retFormData.decoration, 'id');
    retFormData.isHotPushDictMap = findItemFromList(isHotPushWidgetDropdownList, retFormData.isHotPush, 'id');
  props.dialog?.submit(retFormData);
      return;
    }
    let params: ANY_OBJECT = {
      tourHouseRentInfoDto: {
        id: formData.TourHouseRentInfo.id,
        isHotPush: formData.TourHouseRentInfo.isHotPush,
        rentPrice: formData.TourHouseRentInfo.rentPrice,
        rentKind: formData.TourHouseRentInfo.rentKind,
        advisorId: formData.TourHouseRentInfo.advisorId,
        floorType: formData.TourHouseRentInfo.floorType,
        areaId: formData.TourHouseRentInfo.areaId,
        rentType: formData.TourHouseRentInfo.rentType,
        officeType: formData.TourHouseRentInfo.officeType,
        area: formData.TourHouseRentInfo.area,
        houseType: formData.TourHouseRentInfo.houseType,
        orientation: formData.TourHouseRentInfo.orientation,
        currentFloor: formData.TourHouseRentInfo.currentFloor,
        decoration: formData.TourHouseRentInfo.decoration,
        communityName: formData.TourHouseRentInfo.communityName,
        address: formData.TourHouseRentInfo.address,
        currency: formData.TourHouseRentInfo.currency,
        region: formData.TourHouseRentInfo.region,
        coverUrl: formData.TourHouseRentInfo.coverUrl,
        houseTitle: formData.TourHouseRentInfo.houseTitle,
        totalFloor: formData.TourHouseRentInfo.totalFloor,
        code: formData.TourHouseRentInfo.code,
        mobile: formData.TourHouseRentInfo.mobile,
        createUserId: formData.TourHouseRentInfo.createUserId,
        createTime: formData.TourHouseRentInfo.createTime,
        remark: formData.TourHouseRentInfo.remark,
        updateUserId: formData.TourHouseRentInfo.updateUserId,
        updateTime: formData.TourHouseRentInfo.updateTime,
        showOrder: formData.TourHouseRentInfo.showOrder,
        rentState: formData.TourHouseRentInfo.rentState,
      },
      tourHouseEquipmentDto: {
        id: formData.TourHouseRentInfo.tourHouseEquipment.id,
        houseDetailImage: formData.TourHouseRentInfo.tourHouseEquipment.houseDetailImage,
        icebox: formData.TourHouseRentInfo.tourHouseEquipment.icebox,
        washer: formData.TourHouseRentInfo.tourHouseEquipment.washer,
        calorifier: formData.TourHouseRentInfo.tourHouseEquipment.calorifier,
        broadband: formData.TourHouseRentInfo.tourHouseEquipment.broadband,
        sofa: formData.TourHouseRentInfo.tourHouseEquipment.sofa,
        rangeHood: formData.TourHouseRentInfo.tourHouseEquipment.rangeHood,
        gasStove: formData.TourHouseRentInfo.tourHouseEquipment.gasStove,
        ableCook: formData.TourHouseRentInfo.tourHouseEquipment.ableCook,
        television: formData.TourHouseRentInfo.tourHouseEquipment.television,
        airConditioner: formData.TourHouseRentInfo.tourHouseEquipment.airConditioner,
        wardrobe: formData.TourHouseRentInfo.tourHouseEquipment.wardrobe,
        bed: formData.TourHouseRentInfo.tourHouseEquipment.bed,
        restRoom: formData.TourHouseRentInfo.tourHouseEquipment.restRoom,
        smartDoorLock: formData.TourHouseRentInfo.tourHouseEquipment.smartDoorLock,
        balcony: formData.TourHouseRentInfo.tourHouseEquipment.balcony,
        heating: formData.TourHouseRentInfo.tourHouseEquipment.heating,
        surroundingSupport: formData.TourHouseRentInfo.tourHouseEquipment.surroundingSupport,
        surroundingSupportImage: formData.TourHouseRentInfo.tourHouseEquipment.surroundingSupportImage,
        plotIntroduction: formData.TourHouseRentInfo.tourHouseEquipment.plotIntroduction,
        plotIntroductionImage: formData.TourHouseRentInfo.tourHouseEquipment.plotIntroductionImage,
      }
    };
    let httpCall = isEdit.value ? TourHouseRentInfoController.update : TourHouseRentInfoController.add;
    httpCall(params).then(res => {
      ElMessage.success('保存成功');
      props.dialog?.submit();
    }).catch(e => {
      // TODO: 异常处理
      console.error(e);
    });
  });
};
const formInit = () => {
  loadTourHouseRentInfoData().then(res => {
    areaIdWidget.onVisibleChange(true).then(res => {
      // TODO: 获取级联选中路径
      areaIdPath.value = findTreeNodePath(res, formData.TourHouseRentInfo.areaId);
    }).catch(e => {
      // TODO: 异常处理
      console.error(e);
    });
    floorTypeWidget.onVisibleChange(true).catch(e => {console.error(e)});
    rentTypeWidget.onVisibleChange(true).catch(e => {console.error(e)});
    rentKindWidget.onVisibleChange(true).catch(e => {console.error(e)});
    officeTypeWidget.onVisibleChange(true).catch(e => {console.error(e)});
    houseTypeWidget.onVisibleChange(true).catch(e => {console.error(e)});
    orientationWidget.onVisibleChange(true).catch(e => {console.error(e)});
    decorationWidget.onVisibleChange(true).catch(e => {console.error(e)});
    isHotPushWidget.onVisibleChange(true).catch(e => {console.error(e)});
    let coverUrlDownloadParams = {
      id: formData.TourHouseRentInfo.id,
      fieldName: 'coverUrl',
      asImage: true
    };
    coverUrlWidgetFileList.value = parseUploadData(formData.TourHouseRentInfo.coverUrl, coverUrlDownloadParams);
    let houseDetailImageDownloadParams = {
      id: formData.TourHouseRentInfo.tourHouseEquipment.id,
      fieldName: 'houseDetailImage',
      asImage: true
    };
    houseDetailImageWidgetFileList.value = parseUploadData(formData.TourHouseRentInfo.tourHouseEquipment.houseDetailImage, houseDetailImageDownloadParams);
    let surroundingSupportImageDownloadParams = {
      id: formData.TourHouseRentInfo.tourHouseEquipment.id,
      fieldName: 'surroundingSupportImage',
      asImage: true
    };
    surroundingSupportImageWidgetFileList.value = parseUploadData(formData.TourHouseRentInfo.tourHouseEquipment.surroundingSupportImage, surroundingSupportImageDownloadParams);
    let plotIntroductionImageDownloadParams = {
      id: formData.TourHouseRentInfo.tourHouseEquipment.id,
      fieldName: 'plotIntroductionImage',
      asImage: true
    };
    plotIntroductionImageWidgetFileList.value = parseUploadData(formData.TourHouseRentInfo.tourHouseEquipment.plotIntroductionImage, plotIntroductionImageDownloadParams);
    if (isEdit.value) refreshFormEditTourHouseRentInfo();
  }).catch(e => {
    // TODO: 异常处理
    console.error(e);
  });
};

onMounted(() => {
  formInit();
});
</script>
