<template>
  <div class="dialog-box" style="position: relative">
    <el-scrollbar class="custom-scroll content-box">
      <el-form
        ref="formEditTourHouseSaleInfoRef"
        :model="formData"
        :size="layoutStore.defaultFormItemSize"
        :rules="rules"
        label-width="120px"
        label-position="right"
        @submit.prevent
      >
        <el-row :gutter="16">
          <el-col :span="12">
            <el-form-item label="所属地区类型" prop="TourHouseSaleInfo.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="TourHouseSaleInfo.isSaleByLandlord">
              <el-select
                class="input-item"
                v-model="formData.TourHouseSaleInfo.isSaleByLandlord"
                placeholder=""
                :clearable="true"
                :filterable="true"
                @visible-change="isSaleByLandlordWidget.onVisibleChange"
              >
                <el-option
                  v-for="item in isSaleByLandlordWidgetDropdownList"
                  :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="TourHouseSaleInfo.houseSourceType">
              <el-select
                class="input-item"
                v-model="formData.TourHouseSaleInfo.houseSourceType"
                placeholder=""
                :clearable="true"
                :filterable="true"
                @visible-change="houseSourceTypeWidget.onVisibleChange"
              >
                <el-option
                  v-for="item in houseSourceTypeWidgetDropdownList"
                  :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="TourHouseSaleInfo.totalPrice">
              <el-input-number
                class="input-item"
                v-model="formData.TourHouseSaleInfo.totalPrice"
                placeholder=""
                :clearable="true"
                :step="1"
                :controls="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="厅室类型" prop="TourHouseSaleInfo.officeType">
              <el-select
                class="input-item"
                v-model="formData.TourHouseSaleInfo.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="TourHouseSaleInfo.area">
              <el-input-number
                class="input-item"
                v-model="formData.TourHouseSaleInfo.area"
                placeholder=""
                :clearable="true"
                :step="1"
                :controls="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="房屋类型" prop="TourHouseSaleInfo.houseType">
              <el-select
                class="input-item"
                v-model="formData.TourHouseSaleInfo.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="TourHouseSaleInfo.orientation">
              <el-select
                class="input-item"
                v-model="formData.TourHouseSaleInfo.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="TourHouseSaleInfo.currentFloor">
              <el-input-number
                class="input-item"
                v-model="formData.TourHouseSaleInfo.currentFloor"
                placeholder=""
                :clearable="true"
                :step="1"
                :controls="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="装修类型" prop="TourHouseSaleInfo.decoration">
              <el-select
                class="input-item"
                v-model="formData.TourHouseSaleInfo.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="12">
            <el-form-item label="房龄" prop="TourHouseSaleInfo.houseAge">
              <el-input-number
                class="input-item"
                v-model="formData.TourHouseSaleInfo.houseAge"
                placeholder=""
                :clearable="true"
                :step="1"
                :controls="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="楼盘名称/所属小区" prop="TourHouseSaleInfo.communityName">
              <el-input
                class="input-item"
                v-model="formData.TourHouseSaleInfo.communityName"
                type="text"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength=""
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="地址" prop="TourHouseSaleInfo.address">
              <el-input
                class="input-item"
                v-model="formData.TourHouseSaleInfo.address"
                type="text"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength=""
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="均价" prop="TourHouseSaleInfo.averagePrice">
              <el-input-number
                class="input-item"
                v-model="formData.TourHouseSaleInfo.averagePrice"
                placeholder=""
                :clearable="true"
                :step="1"
                :controls="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="货币单位" prop="TourHouseSaleInfo.currency">
              <el-input
                class="input-item"
                v-model="formData.TourHouseSaleInfo.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="TourHouseSaleInfo.region">
              <el-input
                class="input-item"
                v-model="formData.TourHouseSaleInfo.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="TourHouseSaleInfo.coverUrl">
              <el-upload
                class="upload-image-item"
                name="uploadFile"
                :headers="getUploadHeaders"
                :action="getUploadActionUrl('/admin/app/tourHouseSaleInfo/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="12">
            <el-form-item label="是否在售" prop="TourHouseSaleInfo.isOnSale">
              <el-select
                class="input-item"
                v-model="formData.TourHouseSaleInfo.isOnSale"
                placeholder=""
                :clearable="true"
                :filterable="true"
                @visible-change="isOnSaleWidget.onVisibleChange"
              >
                <el-option
                  v-for="item in isOnSaleWidgetDropdownList"
                  :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="TourHouseSaleInfo.houseTitle">
              <el-input
                class="input-item"
                v-model="formData.TourHouseSaleInfo.houseTitle"
                type="text"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength=""
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="总楼层" prop="TourHouseSaleInfo.totalFloor">
              <el-input-number
                class="input-item"
                v-model="formData.TourHouseSaleInfo.totalFloor"
                placeholder=""
                :clearable="true"
                :step="1"
                :controls="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="建造年份" prop="TourHouseSaleInfo.yearOfBuild">
              <el-date-picker
                class="input-item"
                v-model="formData.TourHouseSaleInfo.yearOfBuild"
                type="date"
                placeholder=""
                :clearable="true"
                format="YYYY-MM-DD"
                value-format="YYYY-MM-DD"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="房屋标签" prop="TourHouseSaleInfo.tag">
              <el-input
                class="input-item"
                v-model="formData.TourHouseSaleInfo.tag"
                type="text"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength=""
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="竣工年份" prop="TourHouseSaleInfo.yearOfFinish">
              <el-date-picker
                class="input-item"
                v-model="formData.TourHouseSaleInfo.yearOfFinish"
                type="date"
                placeholder=""
                :clearable="true"
                format="YYYY-MM-DD"
                value-format="YYYY-MM-DD"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="开发商" prop="TourHouseSaleInfo.developersId">
              <el-select
                class="input-item"
                v-model="formData.TourHouseSaleInfo.developersId"
                placeholder=""
                :clearable="true"
                :filterable="true"
                @visible-change="developersIdWidget.onVisibleChange"
              >
                <el-option
                  v-for="item in developersIdWidgetDropdownList"
                  :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="TourHouseSaleInfo.code">
              <el-upload
                class="upload-image-item"
                name="uploadFile"
                :headers="getUploadHeaders"
                :action="getUploadActionUrl('/admin/app/tourHouseSaleInfo/upload')"
                :data="{fieldName: 'code', asImage: true}"
                :on-success="onCodeUploadSuccess"
                :on-remove="onCodeRemoveFile"
                :on-error="onUploadError"
                :show-file-list="false"
              >
              <div v-if="codeWidgetFileList && codeWidgetFileList[0] != null" style="position: relative">
                <img class="upload-image-show"
                  :src="codeWidgetFileList[0].url" />
                <div class="upload-img-del el-icon-close"
                  @click.stop="onCodeRemoveFile(null, null)" />
              </div>
              <i v-else class="el-icon-plus upload-image-item"></i>
              </el-upload>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="联系电话" prop="TourHouseSaleInfo.mobile">
              <el-input
                class="input-item"
                v-model="formData.TourHouseSaleInfo.mobile"
                type="text"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength=""
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="产权性质" prop="TourHouseSaleInfo.propertyRightNature">
              <el-input
                class="input-item"
                v-model="formData.TourHouseSaleInfo.propertyRightNature"
                type="text"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength=""
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="产权年限" prop="TourHouseSaleInfo.termOfOwnership">
              <el-input
                class="input-item"
                v-model="formData.TourHouseSaleInfo.termOfOwnership"
                type="text"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength=""
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物业类型" prop="TourHouseSaleInfo.propertyType">
              <el-input
                class="input-item"
                v-model="formData.TourHouseSaleInfo.propertyType"
                type="text"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength=""
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="房本年限" prop="TourHouseSaleInfo.housePrincipalLife">
              <el-input
                class="input-item"
                v-model="formData.TourHouseSaleInfo.housePrincipalLife"
                type="text"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength=""
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否唯一住房" prop="TourHouseSaleInfo.isSoleDwelling">
              <el-select
                class="input-item"
                v-model="formData.TourHouseSaleInfo.isSoleDwelling"
                placeholder=""
                :clearable="true"
                :filterable="true"
                @visible-change="isSoleDwellingWidget.onVisibleChange"
              >
                <el-option
                  v-for="item in isSoleDwellingWidgetDropdownList"
                  :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="TourHouseSaleInfo.publishingCompany">
              <el-input
                class="input-item"
                v-model="formData.TourHouseSaleInfo.publishingCompany"
                type="text"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength=""
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="营业执照" prop="TourHouseSaleInfo.businessLicense">
              <el-input
                class="input-item"
                v-model="formData.TourHouseSaleInfo.businessLicense"
                type="text"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength=""
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="发布日期" prop="TourHouseSaleInfo.releaseDate">
              <el-date-picker
                class="input-item"
                v-model="formData.TourHouseSaleInfo.releaseDate"
                type="date"
                placeholder=""
                :clearable="true"
                format="YYYY-MM-DD"
                value-format="YYYY-MM-DD"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="开盘时间" prop="TourHouseSaleInfo.openingTime">
              <el-date-picker
                class="input-item"
                v-model="formData.TourHouseSaleInfo.openingTime"
                type="date"
                placeholder=""
                :clearable="true"
                format="YYYY-MM-DD"
                value-format="YYYY-MM-DD"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="交房时间" prop="TourHouseSaleInfo.handingTime">
              <el-date-picker
                class="input-item"
                v-model="formData.TourHouseSaleInfo.handingTime"
                type="date"
                placeholder=""
                :clearable="true"
                format="YYYY-MM-DD"
                value-format="YYYY-MM-DD"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="周边配套描述" prop="TourHouseSaleInfo.surroundingSupport">
              <el-input
                class="input-item"
                v-model="formData.TourHouseSaleInfo.surroundingSupport"
                type="text"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength=""
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="小区介绍" prop="TourHouseSaleInfo.plotIntroduction">
              <el-input
                class="input-item"
                v-model="formData.TourHouseSaleInfo.plotIntroduction"
                type="text"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength=""
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="热度值" prop="TourHouseSaleInfo.hotValue">
              <el-input-number
                class="input-item"
                v-model="formData.TourHouseSaleInfo.hotValue"
                placeholder=""
                :clearable="true"
                :step="1"
                :controls="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="房屋图集" prop="TourHouseSaleInfo.houseUrl">
              <el-upload
                class="upload-image-item upload-image-multi"
                name="uploadFile"
                :headers="getUploadHeaders"
                :action="getUploadActionUrl('/admin/app/tourHouseSaleInfo/upload')"
                :data="{fieldName: 'houseUrl', asImage: true}"
                :on-success="onHouseUrlUploadSuccess"
                :on-remove="onHouseUrlRemoveFile"
                :on-error="onUploadError"
                :on-exceed="onUploadLimit"
                list-type="picture-card"
                :file-list="houseUrlWidgetFileList"
                :limit="houseUrlWidgetMaxCount"
                :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="TourHouseSaleInfo.introductionUrl">
              <el-upload
                class="upload-image-item upload-image-multi"
                name="uploadFile"
                :headers="getUploadHeaders"
                :action="getUploadActionUrl('/admin/app/tourHouseSaleInfo/upload')"
                :data="{fieldName: 'introductionUrl', asImage: true}"
                :on-success="onIntroductionUrlUploadSuccess"
                :on-remove="onIntroductionUrlRemoveFile"
                :on-error="onUploadError"
                :on-exceed="onUploadLimit"
                list-type="picture-card"
                :file-list="introductionUrlWidgetFileList"
                :limit="introductionUrlWidgetMaxCount"
                :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="TourHouseSaleInfo.surroundingsUrl">
              <el-upload
                class="upload-image-item upload-image-multi"
                name="uploadFile"
                :headers="getUploadHeaders"
                :action="getUploadActionUrl('/admin/app/tourHouseSaleInfo/upload')"
                :data="{fieldName: 'surroundingsUrl', asImage: true}"
                :on-success="onSurroundingsUrlUploadSuccess"
                :on-remove="onSurroundingsUrlRemoveFile"
                :on-error="onUploadError"
                :on-exceed="onUploadLimit"
                list-type="picture-card"
                :file-list="surroundingsUrlWidgetFileList"
                :limit="surroundingsUrlWidgetMaxCount"
                :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="onSubmitTourHouseSaleInfoClick()">保存</el-button>
    </el-row>
  </div>
</template>

<script lang="ts">
export default {
  name: 'formEditTourHouseSaleInfo',
};
</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 { TourHouseDevelopersTypeData } from '@/api/generated/tourHouseDevelopersTypeController';
import { TourHouseSaleInfoData } from '@/api/generated/tourHouseSaleInfoController';
import { TourHouseAdvisorInfoData } from '@/api/generated/tourHouseAdvisorInfoController';
import { TourHouseFilesData } from '@/api/generated/tourHouseFilesController';
import { TourHouseDevelopersTypeController, TourHouseSaleInfoController, TourHouseAdvisorInfoController, TourHouseFilesController } from '@/api/generated';

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 formEditTourHouseSaleInfoRef = ref();
// 表单数据定义
type FormEditTourHouseSaleInfoData = {
  TourHouseSaleInfo: TourHouseSaleInfoData;
};
// 表单数据
const formData = reactive<FormEditTourHouseSaleInfoData>({
  TourHouseSaleInfo: {
    // 主键
    id: undefined,
    // 所属地区类型
    areaId: undefined,
    // 是否房东自售 0不是 1是
    isSaleByLandlord: undefined,
    // 房源类型 0新房 1二手房
    houseSourceType: undefined,
    // 总价
    totalPrice: undefined,
    // 厅室类型
    officeType: undefined,
    // 面积
    area: undefined,
    // 房屋类型 别墅、公寓...
    houseType: undefined,
    // 朝向类型
    orientation: undefined,
    // 所在楼层
    currentFloor: undefined,
    // 装修类型
    decoration: undefined,
    // 房龄
    houseAge: undefined,
    // 楼盘名称/所属小区
    communityName: undefined,
    // 地址
    address: undefined,
    // 均价
    averagePrice: undefined,
    // 货币单位
    currency: undefined,
    // 所属区域
    region: undefined,
    // 首页封面图
    coverUrl: undefined,
    // 是否在售 0待售 1在售
    isOnSale: undefined,
    // 房屋标题
    houseTitle: undefined,
    // 总楼层
    totalFloor: undefined,
    // 建造年份
    yearOfBuild: undefined,
    // 房屋标签
    tag: undefined,
    // 竣工年份
    yearOfFinish: undefined,
    // 开发商id
    developersId: undefined,
    // 二维码
    code: undefined,
    // 联系电话
    mobile: undefined,
    // 产权性质
    propertyRightNature: undefined,
    // 产权年限
    termOfOwnership: undefined,
    // 物业类型
    propertyType: undefined,
    // 房本年限
    housePrincipalLife: undefined,
    // 是否唯一住房 0是 1不是
    isSoleDwelling: undefined,
    // 发布公司
    publishingCompany: undefined,
    // 营业执照
    businessLicense: undefined,
    // 发布日期
    releaseDate: undefined,
    // 开盘时间
    openingTime: undefined,
    // 交房时间
    handingTime: undefined,
    // 周边配套描述
    surroundingSupport: undefined,
    // 小区介绍
    plotIntroduction: undefined,
    // 删除标记(1: 正常 -1: 已删除)
    dataState: undefined,
    // 热度值
    hotValue: undefined,
    // 创建人
    createUserId: undefined,
    // 创建时间
    createTime: undefined,
    // 修改人
    updateUserId: undefined,
    // 修改时间
    updateTime: undefined,
    // 房屋图集
    houseUrl: undefined,
    // 周边配套图集
    surroundingsUrl: undefined,
    // 小区介绍图集
    introductionUrl: undefined,
    // 房屋图集信息管理数据
    tourHouseFilesList: [],
    tourHouseDevelopersType: {
      // 主键
      id: undefined,
      // 开发商名称
      name: undefined,
      // 是否启用，0禁用，1启用
      enable: undefined,
      // 删除标记(1: 正常 -1: 已删除)
      dataState: undefined,
      // 创建人
      createUserId: undefined,
      // 创建时间
      createTime: undefined,
      // 修改人
      updateUserId: undefined,
      // 修改时间
      updateTime: undefined,
    },
    // 房屋顾问信息管理数据
    tourHouseAdvisorInfoList: [],
  },
},
);
// 表单验证规则
const rules = reactive({
  'TourHouseSaleInfo.tag': [
  ],
  'TourHouseSaleInfo.totalPrice': [
    {required: true, message: '请输入总价', trigger: 'blur'}
  ],
  'TourHouseSaleInfo.mobile': [
  ],
  'TourHouseSaleInfo.houseSourceType': [
    {required: true, message: '请输入房源类型 ', trigger: 'blur'}
  ],
  'TourHouseSaleInfo.code': [
  ],
  'TourHouseSaleInfo.isSaleByLandlord': [
    {required: true, message: '请输入是否房东自售 ', trigger: 'blur'}
  ],
  'TourHouseSaleInfo.developersId': [
    {required: true, message: '请输入开发商id', trigger: 'blur'}
  ],
  'TourHouseSaleInfo.yearOfFinish': [
    {required: true, message: '请输入竣工年份', trigger: 'blur'}
  ],
  'TourHouseSaleInfo.orientation': [
  ],
  'TourHouseSaleInfo.housePrincipalLife': [
  ],
  'TourHouseSaleInfo.houseType': [
    {required: true, message: '请输入房屋类型', trigger: 'blur'}
  ],
  'TourHouseSaleInfo.propertyType': [
  ],
  'TourHouseSaleInfo.area': [
    {required: true, message: '请输入面积', trigger: 'blur'}
  ],
  'TourHouseSaleInfo.termOfOwnership': [
  ],
  'TourHouseSaleInfo.officeType': [
    {required: true, message: '请输入厅室类型', trigger: 'blur'}
  ],
  'TourHouseSaleInfo.propertyRightNature': [
  ],
  'TourHouseSaleInfo.houseAge': [
  ],
  'TourHouseSaleInfo.decoration': [
  ],
  'TourHouseSaleInfo.currentFloor': [
  ],
  'TourHouseSaleInfo.isSoleDwelling': [
  ],
  'TourHouseSaleInfo.hotValue': [
  ],
  'TourHouseSaleInfo.businessLicense': [
  ],
  'TourHouseSaleInfo.publishingCompany': [
  ],
  'TourHouseSaleInfo.currency': [
    {required: true, message: '请输入货币单位', trigger: 'blur'}
  ],
  'TourHouseSaleInfo.surroundingSupport': [
  ],
  'TourHouseSaleInfo.averagePrice': [
    {required: true, message: '请输入均价', trigger: 'blur'}
  ],
  'TourHouseSaleInfo.handingTime': [
  ],
  'TourHouseSaleInfo.address': [
    {required: true, message: '请输入地址', trigger: 'blur'}
  ],
  'TourHouseSaleInfo.openingTime': [
  ],
  'TourHouseSaleInfo.communityName': [
    {required: true, message: '请输入楼盘名称/所属小区', trigger: 'blur'}
  ],
  'TourHouseSaleInfo.releaseDate': [
  ],
  'TourHouseSaleInfo.houseTitle': [
    {required: true, message: '请输入房屋标题', trigger: 'blur'}
  ],
  'TourHouseSaleInfo.isOnSale': [
    {required: true, message: '请输入是否在售 0待售 1在售', trigger: 'blur'}
  ],
  'TourHouseSaleInfo.coverUrl': [
  ],
  'TourHouseSaleInfo.region': [
  ],
  'TourHouseSaleInfo.plotIntroduction': [
  ],
  'TourHouseSaleInfo.areaId': [
    {required: true, message: '请输入所属地区类型', trigger: 'blur'}
  ],
  'TourHouseSaleInfo.yearOfBuild': [
    {required: true, message: '请输入建造年份', trigger: 'blur'}
  ],
  'TourHouseSaleInfo.totalFloor': [
  ],
});

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

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

// 初始化页面数据
const loadTourHouseSaleInfoData = () => {
  return new Promise<void>((resolve, reject) => {
    if (!isEdit.value) {
      resolve();
      return;
    }
    if (!props.saveOnSubmit && props.rowData != null) {
      formData.TourHouseSaleInfo = JSON.parse(JSON.stringify(props.rowData));
      resolve();
      return;
    }
    let params: ANY_OBJECT = {
      id: props.id
    };
    TourHouseSaleInfoController.view(params).then(res => {
      formData.TourHouseSaleInfo = { ...res.data };
      if (formData.TourHouseSaleInfo.tourHouseDevelopersType == null) {
        formData.TourHouseSaleInfo.tourHouseDevelopersType = {
          id: undefined,
          name: undefined,
          enable: undefined,
          dataState: 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.TourHouseSaleInfo.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 loadIsSaleByLandlordDropdownList = (): Promise<ListData<DictData>> => {
  return Promise.resolve({
    dataList: StaticDict.IsSaleByLandlord.getList(),
  });
};
// 是否房东自售 配置参数
const isSaleByLandlordOptions: DropdownOptions<DictData> = {
  loadData: loadIsSaleByLandlordDropdownList,
  isTree: false,
};
// 是否房东自售 下拉组件
const isSaleByLandlordWidget = useDropdown(isSaleByLandlordOptions);
const { dropdownList: isSaleByLandlordWidgetDropdownList } = isSaleByLandlordWidget
/**
 * 房屋图集上传成功
 */
const onHouseUrlUploadSuccess = (
  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);
    houseUrlWidget.onFileChange(file, fileList);
    formData.TourHouseSaleInfo.houseUrl = fileListToJson(houseUrlWidgetFileList.value);
  } else {
    ElMessage.error(response.message);
  }
};
/**
 * 移除房屋图集
 */
const onHouseUrlRemoveFile = (file: UploadFile | null, fileList: UploadFile[] | null) => {
  houseUrlWidget.onFileChange(file, fileList);
  formData.TourHouseSaleInfo.houseUrl = fileListToJson(houseUrlWidgetFileList.value);
};
// 房屋图集上传文件组件
const houseUrlWidget = useUploadWidget(6);
const { fileList: houseUrlWidgetFileList, maxCount: houseUrlWidgetMaxCount } = houseUrlWidget;
/**
 * 小区介绍图集上传成功
 */
const onIntroductionUrlUploadSuccess = (
  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);
    introductionUrlWidget.onFileChange(file, fileList);
    formData.TourHouseSaleInfo.introductionUrl = fileListToJson(introductionUrlWidgetFileList.value);
  } else {
    ElMessage.error(response.message);
  }
};
/**
 * 移除小区介绍图集
 */
const onIntroductionUrlRemoveFile = (file: UploadFile | null, fileList: UploadFile[] | null) => {
  introductionUrlWidget.onFileChange(file, fileList);
  formData.TourHouseSaleInfo.introductionUrl = fileListToJson(introductionUrlWidgetFileList.value);
};
// 小区介绍图集上传文件组件
const introductionUrlWidget = useUploadWidget(6);
const { fileList: introductionUrlWidgetFileList, maxCount: introductionUrlWidgetMaxCount } = introductionUrlWidget;
/**
 * 周边配套图集上传成功
 */
const onSurroundingsUrlUploadSuccess = (
  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);
    surroundingsUrlWidget.onFileChange(file, fileList);
    formData.TourHouseSaleInfo.surroundingsUrl = fileListToJson(surroundingsUrlWidgetFileList.value);
  } else {
    ElMessage.error(response.message);
  }
};
/**
 * 移除周边配套图集
 */
const onSurroundingsUrlRemoveFile = (file: UploadFile | null, fileList: UploadFile[] | null) => {
  surroundingsUrlWidget.onFileChange(file, fileList);
  formData.TourHouseSaleInfo.surroundingsUrl = fileListToJson(surroundingsUrlWidgetFileList.value);
};
// 周边配套图集上传文件组件
const surroundingsUrlWidget = useUploadWidget(6);
const { fileList: surroundingsUrlWidgetFileList, maxCount: surroundingsUrlWidgetMaxCount } = surroundingsUrlWidget;
/**
 * 房源类型 下拉数据获取函数
 */
const loadHouseSourceTypeDropdownList = (): Promise<ListData<DictData>> => {
  return new Promise((resolve, reject) => {
    DictionaryController.dictGlobalDict({ dictCode: 'HouseSourceType', itemIdType: 'Integer' }).then(res => {
      resolve({
        dataList: res.getList(),
      });
    }).catch(e => {
      reject(e);
    });
  });
};
// 房源类型 配置参数
const houseSourceTypeOptions: DropdownOptions<DictData> = {
  loadData: loadHouseSourceTypeDropdownList,
  isTree: false,
};
// 房源类型 下拉组件
const houseSourceTypeWidget = useDropdown(houseSourceTypeOptions);
const { dropdownList: houseSourceTypeWidgetDropdownList } = houseSourceTypeWidget
/**
 * 厅室类型下拉数据获取函数
 */
const loadOfficeTypeDropdownList = (): Promise<ListData<DictData>> => {
  return new Promise((resolve, reject) => {
    DictionaryController.dictGlobalDict({ dictCode: 'OfficeType', itemIdType: 'String' }).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.TourHouseSaleInfo.coverUrl = fileListToJson(coverUrlWidgetFileList.value);
  } else {
    ElMessage.error(response.message);
  }
};
/**
 * 移除首页封面图
 */
const onCoverUrlRemoveFile = (file: UploadFile | null, fileList: UploadFile[] | null) => {
  coverUrlWidget.onFileChange(file, fileList);
  formData.TourHouseSaleInfo.coverUrl = fileListToJson(coverUrlWidgetFileList.value);
};
// 首页封面图上传文件组件
const coverUrlWidget = useUploadWidget(1);
const { fileList: coverUrlWidgetFileList, maxCount: coverUrlWidgetMaxCount } = coverUrlWidget;
/**
 * 是否在售 0待售 1在售下拉数据获取函数
 */
const loadIsOnSaleDropdownList = (): Promise<ListData<DictData>> => {
  return Promise.resolve({
    dataList: StaticDict.IsOnSale.getList(),
  });
};
// 是否在售 0待售 1在售配置参数
const isOnSaleOptions: DropdownOptions<DictData> = {
  loadData: loadIsOnSaleDropdownList,
  isTree: false,
};
// 是否在售 0待售 1在售下拉组件
const isOnSaleWidget = useDropdown(isOnSaleOptions);
const { dropdownList: isOnSaleWidgetDropdownList } = isOnSaleWidget
/**
 * 开发商id下拉数据获取函数
 */
const loadDevelopersIdDropdownList = (): Promise<ListData<DictData>> => {
  return new Promise((resolve, reject) => {
    const params = {
    };
    DictionaryController.dictTourHouseDevelopersType(params).then(res => {
      resolve({
        dataList: res.getList(),
      });
    }).catch(e => {
      reject(e);
    });
  });
};
// 开发商id配置参数
const developersIdOptions: DropdownOptions<DictData> = {
  loadData: loadDevelopersIdDropdownList,
  isTree: false,
};
// 开发商id下拉组件
const developersIdWidget = useDropdown(developersIdOptions);
const { dropdownList: developersIdWidgetDropdownList } = developersIdWidget
/**
 * 二维码上传成功
 */
const onCodeUploadSuccess = (
  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);
    codeWidget.onFileChange(file, fileList);
    formData.TourHouseSaleInfo.code = fileListToJson(codeWidgetFileList.value);
  } else {
    ElMessage.error(response.message);
  }
};
/**
 * 移除二维码
 */
const onCodeRemoveFile = (file: UploadFile | null, fileList: UploadFile[] | null) => {
  codeWidget.onFileChange(file, fileList);
  formData.TourHouseSaleInfo.code = fileListToJson(codeWidgetFileList.value);
};
// 二维码上传文件组件
const codeWidget = useUploadWidget(1);
const { fileList: codeWidgetFileList, maxCount: codeWidgetMaxCount } = codeWidget;
/**
 * 是否唯一住房 0是 1不是下拉数据获取函数
 */
const loadIsSoleDwellingDropdownList = (): Promise<ListData<DictData>> => {
  return Promise.resolve({
    dataList: StaticDict.IsSoleDwelling.getList(),
  });
};
// 是否唯一住房 0是 1不是配置参数
const isSoleDwellingOptions: DropdownOptions<DictData> = {
  loadData: loadIsSoleDwellingDropdownList,
  isTree: false,
};
// 是否唯一住房 0是 1不是下拉组件
const isSoleDwellingWidget = useDropdown(isSoleDwellingOptions);
const { dropdownList: isSoleDwellingWidgetDropdownList } = isSoleDwellingWidget
const onUploadError = () => {
  ElMessage.error('文件上传失败');
};
const onUploadLimit = () => {
  ElMessage.error('已经超出最大上传个数限制');
};
const refreshFormEditTourHouseSaleInfo = () => {
  // 刷新段落
};
/**
 * 重置过滤值
 */
const resetFormEditTourHouseSaleInfo = () => {
  refreshFormEditTourHouseSaleInfo();
};
/**
 * 重置所有过滤值
 */
const resetFilter = () => {
  resetFormEditTourHouseSaleInfo();
};
/**
 * 保存
 */
const onSubmitTourHouseSaleInfoClick = () => {
  formEditTourHouseSaleInfoRef.value.validate((valid) => {
    if (!valid) return;
    // 级联操作
    if (!props.saveOnSubmit) {
      let retFormData = {
        ...formData.TourHouseSaleInfo
      };
    retFormData.areaIdDictMap = findItemFromList(areaIdWidgetDropdownList, retFormData.areaId, 'id');
    retFormData.isSaleByLandlordDictMap = findItemFromList(isSaleByLandlordWidgetDropdownList, retFormData.isSaleByLandlord, 'id');
    retFormData.houseSourceTypeDictMap = findItemFromList(houseSourceTypeWidgetDropdownList, retFormData.houseSourceType, 'id');
    retFormData.officeTypeDictMap = findItemFromList(officeTypeWidgetDropdownList, retFormData.officeType, 'id');
    retFormData.orientationDictMap = findItemFromList(orientationWidgetDropdownList, retFormData.orientation, 'id');
    retFormData.decorationDictMap = findItemFromList(decorationWidgetDropdownList, retFormData.decoration, 'id');
    retFormData.houseTypeDictMap = findItemFromList(houseTypeWidgetDropdownList, retFormData.houseType, 'id');
    retFormData.isOnSaleDictMap = findItemFromList(isOnSaleWidgetDropdownList, retFormData.isOnSale, 'id');
    retFormData.developersIdDictMap = findItemFromList(developersIdWidgetDropdownList, retFormData.developersId, 'id');
    retFormData.isSoleDwellingDictMap = findItemFromList(isSoleDwellingWidgetDropdownList, retFormData.isSoleDwelling, 'id');
  props.dialog?.submit(retFormData);
      return;
    }
    let params: ANY_OBJECT = {
      tourHouseSaleInfoDto: {
        houseUrl: formData.TourHouseSaleInfo.houseUrl,
        surroundingsUrl: formData.TourHouseSaleInfo.surroundingsUrl,
        introductionUrl: formData.TourHouseSaleInfo.introductionUrl,
        id: formData.TourHouseSaleInfo.id,
        hotValue: formData.TourHouseSaleInfo.hotValue,
        areaId: formData.TourHouseSaleInfo.areaId,
        isSaleByLandlord: formData.TourHouseSaleInfo.isSaleByLandlord,
        houseSourceType: formData.TourHouseSaleInfo.houseSourceType,
        totalPrice: formData.TourHouseSaleInfo.totalPrice,
        officeType: formData.TourHouseSaleInfo.officeType,
        area: formData.TourHouseSaleInfo.area,
        houseType: formData.TourHouseSaleInfo.houseType,
        orientation: formData.TourHouseSaleInfo.orientation,
        currentFloor: formData.TourHouseSaleInfo.currentFloor,
        decoration: formData.TourHouseSaleInfo.decoration,
        houseAge: formData.TourHouseSaleInfo.houseAge,
        communityName: formData.TourHouseSaleInfo.communityName,
        address: formData.TourHouseSaleInfo.address,
        averagePrice: formData.TourHouseSaleInfo.averagePrice,
        currency: formData.TourHouseSaleInfo.currency,
        region: formData.TourHouseSaleInfo.region,
        coverUrl: formData.TourHouseSaleInfo.coverUrl,
        isOnSale: formData.TourHouseSaleInfo.isOnSale,
        houseTitle: formData.TourHouseSaleInfo.houseTitle,
        totalFloor: formData.TourHouseSaleInfo.totalFloor,
        yearOfBuild: formData.TourHouseSaleInfo.yearOfBuild,
        tag: formData.TourHouseSaleInfo.tag,
        yearOfFinish: formData.TourHouseSaleInfo.yearOfFinish,
        developersId: formData.TourHouseSaleInfo.developersId,
        code: formData.TourHouseSaleInfo.code,
        mobile: formData.TourHouseSaleInfo.mobile,
        propertyRightNature: formData.TourHouseSaleInfo.propertyRightNature,
        termOfOwnership: formData.TourHouseSaleInfo.termOfOwnership,
        propertyType: formData.TourHouseSaleInfo.propertyType,
        housePrincipalLife: formData.TourHouseSaleInfo.housePrincipalLife,
        isSoleDwelling: formData.TourHouseSaleInfo.isSoleDwelling,
        publishingCompany: formData.TourHouseSaleInfo.publishingCompany,
        businessLicense: formData.TourHouseSaleInfo.businessLicense,
        releaseDate: formData.TourHouseSaleInfo.releaseDate,
        openingTime: formData.TourHouseSaleInfo.openingTime,
        handingTime: formData.TourHouseSaleInfo.handingTime,
        surroundingSupport: formData.TourHouseSaleInfo.surroundingSupport,
        plotIntroduction: formData.TourHouseSaleInfo.plotIntroduction,
        createUserId: formData.TourHouseSaleInfo.createUserId,
        createTime: formData.TourHouseSaleInfo.createTime,
        updateUserId: formData.TourHouseSaleInfo.updateUserId,
        updateTime: formData.TourHouseSaleInfo.updateTime,
      }
    };

    let httpCall = isEdit.value ? TourHouseSaleInfoController.update : TourHouseSaleInfoController.add;
    httpCall(params).then(res => {
      ElMessage.success('保存成功');
      props.dialog?.submit();
    }).catch(e => {
      // TODO: 异常处理
      console.error(e);
    });
  });
};
const formInit = () => {
  loadTourHouseSaleInfoData().then(res => {
    areaIdWidget.onVisibleChange(true).then(res => {
      // TODO: 获取级联选中路径
      areaIdPath.value = findTreeNodePath(res, formData.TourHouseSaleInfo.areaId);
    }).catch(e => {
      // TODO: 异常处理
      console.error(e);
    });
    houseTypeWidget.onVisibleChange(true).catch(e => {console.error(e)});
    isSaleByLandlordWidget.onVisibleChange(true).catch(e => {console.error(e)});
    houseSourceTypeWidget.onVisibleChange(true).catch(e => {console.error(e)});
    officeTypeWidget.onVisibleChange(true).catch(e => {console.error(e)});
    orientationWidget.onVisibleChange(true).catch(e => {console.error(e)});
    decorationWidget.onVisibleChange(true).catch(e => {console.error(e)});
    let coverUrlDownloadParams = {
      id: formData.TourHouseSaleInfo.id,
      fieldName: 'coverUrl',
      asImage: true
    };
    coverUrlWidgetFileList.value = parseUploadData(formData.TourHouseSaleInfo.coverUrl, coverUrlDownloadParams);
    isOnSaleWidget.onVisibleChange(true).catch(e => {console.error(e)});
    let houseUrlDownloadParams = {
      id: formData.TourHouseSaleInfo.id,
      fieldName: 'houseUrl',
      asImage: true
    };
    houseUrlWidgetFileList.value = parseUploadData(formData.TourHouseSaleInfo.houseUrl, houseUrlDownloadParams);
    developersIdWidget.onVisibleChange(true).catch(e => {console.error(e)});
    let introductionUrlDownloadParams = {
      id: formData.TourHouseSaleInfo.id,
      fieldName: 'introductionUrl',
      asImage: true
    };
    introductionUrlWidgetFileList.value = parseUploadData(formData.TourHouseSaleInfo.introductionUrl, introductionUrlDownloadParams);
    let surroundingsUrlDownloadParams = {
      id: formData.TourHouseSaleInfo.id,
      fieldName: 'surroundingsUrl',
      asImage: true
    };
    surroundingsUrlWidgetFileList.value = parseUploadData(formData.TourHouseSaleInfo.surroundingsUrl, surroundingsUrlDownloadParams);
    let codeDownloadParams = {
      id: formData.TourHouseSaleInfo.id,
      fieldName: 'code',
      asImage: true
    };
    codeWidgetFileList.value = parseUploadData(formData.TourHouseSaleInfo.code, codeDownloadParams);
    isSoleDwellingWidget.onVisibleChange(true).catch(e => {console.error(e)});
    if (isEdit.value) refreshFormEditTourHouseSaleInfo();
  }).catch(e => {
    // TODO: 异常处理
    console.error(e);
  });
};

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