<template>
    <a-modal :open="modal.open" :title="modal.title" :width="800" :confirm-loading="modal.confirmLoading"
        :after-close="onAfterClose" :cancel-text="cancelText" :ok-text="okText" @ok="handleOk" @cancel="handleCancel">
        <a-spin :spinning="spining">
            <a-form ref="formRef" :model="formData" :rules="formRules">
                <a-card class="mb-8-2">
                    <a-tabs v-model:activeKey="activeKey">
                        <a-tab-pane key="1" tab="基本信息">
                            <a-row :gutter="12">
                                <a-col :span="12">
                                    <a-form-item :label="'楼盘名称'" name="name">
                                        <a-input :placeholder="'请输入楼盘名称'" v-model:value="formData.name"></a-input>
                                    </a-form-item>
                                </a-col>

                                <a-col :span="12">
                                    <a-form-item :label="'楼盘地址'" name="address">
                                        <a-input :placeholder="'请输入楼盘地址'" v-model:value="formData.address"></a-input>
                                    </a-form-item>
                                </a-col>

                                <a-col :span="12">
                                    <a-form-item :label="'主力户型'" name="masterType">
                                        <a-input :placeholder="'请输入主力户型'" v-model:value="formData.masterType"></a-input>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'开盘时间'" name="openAt">
                                        <a-input :placeholder="'请输入开盘时间'" v-model:value="formData.openAt"></a-input>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'楼盘均价'" name="price">
                                        <a-input :placeholder="'请输入均价'" v-model:value="formData.price"
                                            style="width:100%"></a-input>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'楼盘类型'" name="type">
                                        <a-input :placeholder="'请输入楼盘类型'" v-model:value="formData.type"
                                            style="width:100%"></a-input>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'待售状态'" name="daiShowStatus">
                                        <a-input :placeholder="'请输入待售状态'"
                                            v-model:value="formData.daiShowStatus"></a-input>
                                    </a-form-item>
                                </a-col>

                                <a-col :span="12">
                                    <a-form-item :label="'所属区域'" name="areaId">
                                        <a-select ref="select" v-model:value="formData.areaId">
                                            <a-select-option v-for="item in areaEnum.getAll()" :value="item.value">{{
                                                item.name }}</a-select-option>
                                        </a-select>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'楼盘特点'" name="title">
                                        <a-input :placeholder="'请输入楼盘特点'" v-model:value="formData.title"></a-input>
                                    </a-form-item>
                                </a-col>

                                <a-col :span="12">
                                    <a-form-item :label="'楼盘经度'" name="longitude">
                                        <a-input-number :placeholder="'请输入经度'" style="width: 100%;" :precision="2"
                                            v-model:value="formData.longitude"></a-input-number>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'楼盘纬度'" name="latitude">
                                        <a-input-number :placeholder="'请输入纬度'" style="width: 100%;" :precision="2"
                                            v-model:value="formData.latitude"></a-input-number>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'展厅地址'" name="showAddress">
                                        <a-input :placeholder="'请输入展厅地址'"
                                            v-model:value="formData.showAddress"></a-input>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="24">
                                    <a-form-item :label="'楼盘标签'" name="labels">
                                        <div
                                            style="display: flex;justify-content: space-around;gap:5px 20px;flex-wrap: wrap;">
                                            <div v-for="(item, index) in formData.labels" :key="index"
                                                style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;flex: 1; min-width: calc(50% - 10px);">
                                                <a-input :placeholder="'请输入标签'" :value="item"
                                                    @change="(e) => updateLabel(index, e.target.value)">
                                                </a-input>
                                                <div
                                                    style="width: 50px;display: flex;justify-content: flex-end;align-items: center;">
                                                    <a-button v-if="index === formData.labels.length - 1" type="primary"
                                                        :icon="h(PlusOutlined)" @click="addLabel" />
                                                    <a-button v-else danger :icon="h(MinusOutlined)"
                                                        @click="removeLabel(index)" />
                                                </div>
                                            </div>
                                        </div>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="24">
                                    <a-form-item :label="'占地面积'" name="basicArea">
                                        <a-input :placeholder="'请输入占地面积'" v-model:value="formData.basicArea"></a-input>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'楼盘图片'">
                                        <gx-upload v-model="formData.imgList" accept-types=".jpg,.png,.webp"
                                            :fileNumber="20" @uploadSuccess="uploadSuccess" />
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'楼盘视频'">
                                        <gx-upload v-model="formData.videos"
                                            accept-types=".avi,.mp4,.mov,.wmv,.mkv,.m4v" :fileNumber="20" />
                                    </a-form-item>
                                </a-col>
                            </a-row>
                        </a-tab-pane>
                        <a-tab-pane key="2" tab="户型信息">
                            <div style="width: 100%;margin-bottom: 10px; display: flex;justify-content: flex-end;">
                                <a-button type="primary" @click="addLayout">
                                    <template #icon>
                                        <PlusOutlined />
                                    </template>
                                    户型
                                </a-button>
                            </div>
                            <div style="display: flex;justify-content: space-around;gap:20px;flex-wrap: wrap;">
                                <a-card hoverable style="flex: 1; min-width: calc(30% - 10px);"
                                    v-for="(child, index) of formData.layOuts" :key="index">
                                    <a-col :span="24">
                                        <a-form-item :label="'标题'" name="title">
                                            <a-input :placeholder="'请输入标题'" v-model:value="child.title"></a-input>
                                        </a-form-item>
                                    </a-col>
                                    <a-col :span="24">
                                        <a-form-item :label="'单价'">
                                            <a-input :placeholder="'请输入单价'" v-model:value="child.price"></a-input>
                                        </a-form-item>
                                    </a-col>
                                    <a-col :span="24">
                                        <a-form-item :label="'朝向'" name="direction">
                                            <a-input :placeholder="'请输入朝向'" v-model:value="child.direction"></a-input>
                                        </a-form-item>
                                    </a-col>
                                    <a-col :span="24">
                                        <a-form-item :label="'面积'" name="area">
                                            <a-input :placeholder="'请输入建筑面积'" v-model:value="child.area"></a-input>
                                        </a-form-item>
                                    </a-col>
                                    <a-col :span="24">
                                        <a-form-item :label="'图片'">
                                            <gx-upload v-model="child.layImgList" accept-types=".jpg,.png,.webp"
                                                :fileNumber="1" @uploadSuccess="uploadSuccess" />
                                        </a-form-item>
                                    </a-col>
                                    <template #actions>
                                        <a-button type="text" @click="delLayOut(index)">删 除</a-button>
                                    </template>
                                </a-card>
                            </div>

                        </a-tab-pane>
                        <a-tab-pane key="3" tab="楼盘周边">
                            <a-row :gutter="12">
                                <a-col :span="12">
                                    <a-form-item :label="'公交'" name="busNum">
                                        <a-input-number :placeholder="'请输入公交个数'" v-model:value="formData.busNum"
                                            style="width: 100%;"></a-input-number>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'医院'" name="hospitalNum">
                                        <a-input-number :placeholder="'请输入医院个数'" v-model:value="formData.hospitalNum"
                                            style="width: 100%;"></a-input-number>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'生活'" name="lifeNum">
                                        <a-input-number :placeholder="'请输入公交个数'" v-model:value="formData.lifeNum"
                                            style="width: 100%;"></a-input-number>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'地铁'" name="metroNum">
                                        <a-input-number :placeholder="'请输入地铁个数'" v-model:value="formData.metroNum"
                                            style="width: 100%;"></a-input-number>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'学校'" name="schoolNum">
                                        <a-input-number :placeholder="'请输入学校个数'" v-model:value="formData.schoolNum"
                                            style="width: 100%;"></a-input-number>
                                    </a-form-item>
                                </a-col>
                            </a-row>

                        </a-tab-pane>
                        <a-tab-pane key="4" tab="楼盘顾问">
                            <div style="width: 100%;margin-bottom: 10px; display: flex;justify-content: flex-end;">
                                <a-button type="primary" @click="addAdviser">
                                    <template #icon>
                                        <PlusOutlined />
                                    </template>
                                    顾问
                                </a-button>
                            </div>
                            <div style="display: flex;justify-content: space-around;gap:20px;flex-wrap: wrap;">
                                <a-card hoverable style="flex: 1; min-width: calc(30% - 10px);"
                                    v-for="(child, index) of formData.advisers" :key="index">
                                    <a-col :span="24">
                                        <a-form-item :label="'姓名'" name="adviserName">
                                            <a-input :placeholder="'请输入顾问姓名'"
                                                v-model:value="child.adviserName"></a-input>
                                        </a-form-item>
                                    </a-col>
                                    <a-col :span="24">
                                        <a-form-item :label="'手机号'">
                                            <a-input :placeholder="'请输入手机号'"
                                                v-model:value="child.adviserPhone"></a-input>
                                        </a-form-item>
                                    </a-col>
                                    <a-col :span="24">
                                        <a-form-item :label="'头像'">
                                            <gx-upload v-model="child.adviserImg" accept-types=".jpg,.png,.webp"
                                                :fileNumber="1" />
                                        </a-form-item>
                                    </a-col>
                                    <template #actions>
                                        <a-button type="text" @click="delLayOut(index)">删 除</a-button>
                                    </template>
                                </a-card>
                            </div>

                        </a-tab-pane>
                        <a-tab-pane key="5" tab="销售信息">
                            <a-row :gutter="12">
                                <a-col :span="12">
                                    <a-form-item :label="'楼盘状态'" name="louPanStatus">
                                        <a-input :placeholder="'请输入楼盘状态'"
                                            v-model:value="formData.louPanStatus"></a-input>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'产权年限'" name="duration">
                                        <a-input :placeholder="'请输入产权年限'" v-model:value="formData.duration"
                                            style="width: 100%;"></a-input>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'在售户型'" name="salesType">
                                        <a-input :placeholder="'请输入在售户型'" v-model:value="formData.salesType"></a-input>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'售楼地址'" name="salesAddress">
                                        <a-input :placeholder="'请输入售楼地址'"
                                            v-model:value="formData.salesAddress"></a-input>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'售楼电话'" name="salesPhone">
                                        <a-input :placeholder="'请输入售楼电话'" v-model:value="formData.salesPhone"></a-input>
                                    </a-form-item>
                                </a-col>
                            </a-row>

                        </a-tab-pane>
                        <a-tab-pane key="6" tab="小区概况">
                            <a-row :gutter="12">
                                <a-col :span="12">
                                    <a-form-item :label="'车位数量'" name="packingNum">
                                        <a-input :placeholder="'请输入车位数量'" v-model:value="formData.packingNum"
                                            style="width: 100%;"></a-input>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'总户数'" name="roomNum">
                                        <a-input :placeholder="'请输入总户数'" v-model:value="formData.roomNum"
                                            style="width: 100%;"></a-input>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'绿化率'" name="greeningRate">
                                        <a-input :placeholder="'请输入绿化率'"
                                            v-model:value="formData.greeningRate"></a-input>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'车位比'" name="carRatio">
                                        <a-input :placeholder="'请输入车位比'" v-model:value="formData.carRatio"></a-input>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'容积率'" name="ratio">
                                        <a-input :placeholder="'请输入容积率'" v-model:value="formData.ratio"></a-input>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'R19009容积率'" name="r19009Ratio">
                                        <a-input :placeholder="'请输入R19009容积率'"
                                            v-model:value="formData.r19009Ratio"></a-input>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'R19010容积率'" name="r19009Ratio">
                                        <a-input :placeholder="'请输入R19010容积率'"
                                            v-model:value="formData.r19010Ratio"></a-input>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'R19011容积率'" name="r19011Ratio">
                                        <a-input :placeholder="'请输入R19011容积率'"
                                            v-model:value="formData.r19011Ratio"></a-input>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'物业类型'" name="propertyType">
                                        <a-input :placeholder="'请输入物业类型'"
                                            v-model:value="formData.propertyType"></a-input>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'物业公司'" name="propertyName">
                                        <a-input :placeholder="'请输入物业公司'"
                                            v-model:value="formData.propertyName"></a-input>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="12">
                                    <a-form-item :label="'物业费用'" name="propertyPrice">
                                        <a-input :placeholder="'请输入物业费用'"
                                            v-model:value="formData.propertyPrice"></a-input>
                                    </a-form-item>
                                </a-col>
                            </a-row>

                        </a-tab-pane>
                        <a-tab-pane key="7" tab="免责声明">
                            <x-editor v-model="formData.disclaimerContain" :uploadHandler="uploadHandler"
                                :height="300"></x-editor>
                        </a-tab-pane>
                    </a-tabs>

                </a-card>
            </a-form>
        </a-spin>
    </a-modal>
</template>

<script setup>
import { ref, h, onBeforeMount } from 'vue'
import { config } from '@/config'
import apis from '@/apis'
import { useForm, useModal, useSpining } from '@/hooks'
import { message } from 'ant-design-vue'
import { useI18n } from 'vue-i18n'
import { PlusOutlined, MinusOutlined, SettingOutlined } from '@ant-design/icons-vue';
import dayjs from 'dayjs'
import { customersEnum, areaEnum } from "@/enums/useEnum"
import { spliceUrl,decryptString,encryptString } from "@/utils/util.js"
const emit = defineEmits(['ok'])
const { t } = useI18n() // 解构出t方法
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
const { formRecord, formData, formRef, formRules, resetForm } = useForm()
const { spining, showSpining, hideSpining } = useSpining()
const cancelText = ref(t('button.cancel'))
const okText = ref(t('button.confirm'))
const layImgList = []
const activeKey = ref('1')
formRules.value = {
    name: { required: true, message: '请输入楼盘名称' },
    address: { required: true, message: '请输入楼盘地址' },
    masterType: { required: true, message: '请输入主力户型' },
    openAt: { required: true, message: '请输入开盘时间' },
    price: { required: true, message: '请输入楼盘均价' },
    status: [{ required: true, message: '请输入状态' }],
}

/**
 * 新建
 */
function handleCreate() {
    showModal({
        type: 'create',
        title: '新增楼盘',
    })
    // initData()
    formData.value.labels = ['', '']
    formData.value.areaId = 1
    formData.value.layOuts = [
        { area: '', price: '', direction: '', title: '', layImgList: [] },
        { area: '', price: '', direction: '', title: '', layImgList: [] },
        { area: '', price: '', direction: '', title: '', layImgList: [] },
    ]
    formData.value.advisers = [
        { adviserName: '', adviserPhone: '', adviserImg: [] },
        { adviserName: '', adviserPhone: '', adviserImg: [] },
        { adviserName: '', adviserPhone: '', adviserImg: [] },
    ]
}

/**
 * 编辑
 */
async function handleEdit(record = {}) {
    showModal({
        type: 'edit',
        title: '编辑楼盘',
    })
    try {
        showSpining()
        const { data, success } = await apis.house.getItem(record.id).catch()
        if (!success) {
            hideModal()
            return
        }
        hideSpining()
        formData.value = {
            id: data.id,
            address: data.address,
            areaId: data.areaId,//所属区域
            imgList: data.images ? data.images.map(item => config('http.apiBasic') + item) : [],
            labels: data.labels,
            latitude: data.latitude,
            longitude: data.longitude,
            masterType: data.masterType,
            name: data.name,
            openAt: data.openAt,
            price: data.price,
            status: data.status,
            basicArea: data.area,
            
            title: data.title,
            videos: data.videos ? data.videos.map(item => config('http.apiBasic') + item) : [],
            advisers: data.advisers ? data.advisers.map(item => ({ adviserName: item.name, adviserPhone: item.phone, adviserImg: item.avatar ? [config('http.apiBasic') + item.avatar] : [] })) : [{ adviserName: '', adviserPhone: '', adviserImg: [] },
            { adviserName: '', adviserPhone: '', adviserImg: [] },
            { adviserName: '', adviserPhone: '', adviserImg: [] },],
            address: data.detail.basicInfo.address,
            houseArea: data.detail.basicInfo.area,
            buildingarea: data.detail.basicInfo.buildingarea,
            showAddress: data.detail.basicInfo.showAddress,
            daiShowStatus: data.detail.basicInfo.status,
            type: data.detail.basicInfo.type,
            louPanStatus: data.detail.salesInfo.status,
            duration: data.detail.salesInfo.duration,
            salesType: data.detail.salesInfo.salesType,
            salesPhone: data.detail.salesInfo.salesPhone,
            salesAddress: data.detail.salesInfo.salesAddress,
            greeningRate: data.detail.communityInfo.greeningRate,
            packingNum: data.detail.communityInfo.packingNum,
            propertyName: data.detail.communityInfo.propertyName,
            propertyPrice: data.detail.communityInfo.propertyPrice,
            propertyType: data.detail.communityInfo.propertyType,
            r19009Ratio: data.detail.communityInfo.r19009Ratio,
            r19010Ratio: data.detail.communityInfo.r19010Ratio,
            r19011Ratio: data.detail.communityInfo.r19011Ratio,
            roomNum: data.detail.communityInfo.roomNum,
            carRatio: data.detail.communityInfo.carRatio,
            ratio: data.detail.communityInfo.ratio,
            layOuts: data.layOuts ? data.layOuts.map(item => ({ area: item.area, direction: item.direction, layImgList: item.img ? [config('http.apiBasic') + item.img] : [], price: item.price, title: item.title })) : [{ area: '', price: '', direction: '', title: '', layImgList: [] },
            { area: '', price: '', direction: '', title: '', layImgList: [] },
            { area: '', price: '', direction: '', title: '', layImgList: [] },],
            busNum: data.surroundings && data.surroundings.busNum,
            hospitalNum: data.surroundings && data.surroundings.hospitalNum,
            lifeNum: data.surroundings && data.surroundings.lifeNum,
            metroNum: data.surroundings && data.surroundings.metroNum,
            schoolNum: data.surroundings && data.surroundings.schoolNum,
            disclaimerContain: decryptString(data.disclaimerContain), 
        }
    } catch (error) {
        message.error({ content: error.message })
        hideSpining()
    }

}
/**
 * 确定
 */
function handleOk() {
    formRef.value.validateFields().then(async (values) => {
        try {
            showLoading()
            console.log(formData.value)
            const params = {
                address: formData.value.address,
                areaId: formData.value.areaId,//所属区域
                cover: formData.value.imgList && spliceUrl(formData.value.imgList[0]),
                images: formData.value.imgList && formData.value.imgList.map(item => spliceUrl(item)),
                labels: formData.value.labels,
                latitude: formData.value.latitude,
                longitude: formData.value.longitude,
                masterType: formData.value.masterType,
                name: formData.value.name,
                openAt: formData.value.openAt,
                price: formData.value.price,
                status: formData.value.status,
                title: formData.value.title,
                area: formData.value.basicArea,
                disclaimerContain: encryptString(formData.value.disclaimerContain),
                videos: formData.value.videos && formData.value.videos.map(item => spliceUrl(item)),
                advisers: formData.value.advisers && formData.value.advisers.map(item => ({ name: item.adviserName, phone: item.adviserPhone, avatar: item.adviserImg[0] && spliceUrl(item.adviserImg[0]) })),
                detail: {
                    basicInfo: {
                        address: formData.value.address,//楼盘地址
                        area: formData.value.houseArea,//占地面积
                        buildingarea: formData.value.buildingarea,//建筑面积
                        masterType: formData.value.masterType,//主力户型
                        status: formData.value.daiShowStatus,//待售状态
                        showAddress: formData.value.showAddress,//展厅位置
                        type: formData.value.type,//楼盘类型
                    },
                    salesInfo: {
                        status: formData.value.louPanStatus,//楼盘状态
                        duration: formData.value.duration,//产权年限
                        salesType: formData.value.salesType,//在售户型
                        salesAddress: formData.value.salesAddress,//售楼地址
                        salesPhone: formData.value.salesPhone//售楼电话
                    },
                    communityInfo: {
                        greeningRate: formData.value.greeningRate,
                        packingNum: formData.value.packingNum,
                        propertyName: formData.value.propertyName,
                        propertyPrice: formData.value.propertyPrice,
                        propertyType: formData.value.propertyType,
                        r19009Ratio: formData.value.r19009Ratio,
                        r19010Ratio: formData.value.r19010Ratio,
                        r19011Ratio: formData.value.r19011Ratio,
                        roomNum: formData.value.roomNum,
                        carRatio: formData.value.carRatio,
                        ratio: formData.value.ratio
                    }
                },
                layOuts: formData.value.layOuts && formData.value.layOuts.map(item => ({ area: item.area, direction: item.direction, img: item.layImgList[0] && spliceUrl(item.layImgList[0]), price: item.price, title: item.title })),
                surroundings: {
                    busNum: formData.value.busNum,
                    hospitalNum: formData.value.hospitalNum,
                    lifeNum: formData.value.lifeNum,
                    metroNum: formData.value.metroNum,
                    schoolNum: formData.value.schoolNum,
                }
            }
            let result = null
            switch (modal.value.type) {
                case 'create':
                    result = await apis.house.createProject(params).catch((error) => {
                        console.log(error.message)
                        throw new Error(error)
                    })
                    break
                case 'edit':

                    result = await apis.house.updateItem(formData.value.id, params).catch(() => {
                        console.log(error.message)
                        throw new Error(error)
                    })
                    break
            }
            hideLoading()
            if (config('http.code.success') === result?.success) {
                hideModal()
                emit('ok')
            }
        } catch (error) {
            message.error({ content: error.message })
            hideLoading()
        }
    })
        .catch((e) => {
            hideLoading()
        })
}

// 在 setup 中添加这些方法
const updateLabel = (index, value) => {
    formData.value.labels[index] = value;
};

const addLabel = () => {
    formData.value.labels.push('');
};

const removeLabel = (index) => {
    formData.value.labels.splice(index, 1);
};
const uploadHandler = async (file) => {
    const formData = new FormData();
    formData.append('file', file);
    const { data } = await apis.common.uploadImg(formData);
    return config('http.apiBasic') + data
}
/**
 * 取消
 */
function handleCancel() {

    hideModal()
}

/**
 * 关闭后
 */
function onAfterClose() {
    resetForm()
    hideLoading()
}

defineExpose({
    handleCreate,
    handleEdit,
})
//新增户型
const addLayout = () => {
    const params = { layImgList: [], area: '', price: '', direction: '', title: '' }
    formData.value.layOuts.push(params)
}
//新增顾问
const addAdviser = () => {
    const params = { adviserName: '', adviserPhone: '', adviserImg: [] }
    formData.value.advisers.push(params)
}
//删除户型
const delLayOut = (index) => {
    formData.value.layOuts.splice(index, 1)
}
</script>

<style lang="less" scoped></style>
