<template>
  <!-- 添加/编辑页面容器 -->
  <div class="addEdit-block">
    <!-- 表单组件 -->
    <el-form
        class="detail-form-content"
        ref="ruleForm"
        :model="ruleForm"
        :rules="rules"
        label-width="80px"
        :style="{backgroundColor:addEditForm.addEditBoxColor}"  <!-- 设置表单背景颜色 -->
    >
    <el-row>  <!-- 表单布局行 -->
      <el-col :span="12">  <!-- 左侧列，宽度为12 -->
        <el-form-item class="input" v-if="type!='info'"  label="房屋名称" prop="fangwumingcheng">  <!-- 房屋名称输入框 -->
          <el-input v-model="ruleForm.fangwumingcheng"
                    placeholder="房屋名称" clearable  :readonly="ro.fangwumingcheng"></el-input>
        </el-form-item>
        <div v-else>  <!-- 如果是查看模式，显示只读输入框 -->
          <el-form-item class="input" label="房屋名称" prop="fangwumingcheng">
            <el-input v-model="ruleForm.fangwumingcheng"
                      placeholder="房屋名称" readonly></el-input>
          </el-form-item>
        </div>
      </el-col>
      <el-col :span="12">  <!-- 右侧列，宽度为12 -->
        <el-form-item class="select" v-if="type!='info'"  label="房屋类型" prop="fangwuleixing">  <!-- 房屋类型选择框 -->
          <el-select v-model="ruleForm.fangwuleixing" placeholder="请选择房屋类型">
            <el-option
                v-for="(item,index) in fangwuleixingOptions"
                v-bind:key="index"
                :label="item"
                :value="item">
            </el-option>
          </el-select>
        </el-form-item>
        <div v-else>  <!-- 如果是查看模式，显示只读输入框 -->
          <el-form-item class="input" label="房屋类型" prop="fangwuleixing">
            <el-input v-model="ruleForm.fangwuleixing"
                      placeholder="房屋类型" readonly></el-input>
          </el-form-item>
        </div>
      </el-col>
      <el-col :span="24">  <!-- 占满整行 -->
        <el-form-item class="upload" v-if="type!='info' && !ro.tupian" label="图片" prop="tupian">  <!-- 图片上传组件 -->
          <file-upload
              tip="点击上传图片"
              action="file/upload"
              :limit="3"
              :multiple="true"
              :fileUrls="ruleForm.tupian?ruleForm.tupian:''"
              @change="tupianUploadChange"
          ></file-upload>
        </el-form-item>
        <div v-else>  <!-- 如果是查看模式或只读，显示图片 -->
          <el-form-item v-if="ruleForm.tupian" label="图片" prop="tupian">
            <img style="margin-right:20px;" v-bind:key="index" v-for="(item,index) in ruleForm.tupian.split(',')" :src="item" width="100" height="100">
          </el-form-item>
        </div>
      </el-col>
      <el-col :span="12">  <!-- 左侧列，宽度为12 -->
        <el-form-item class="select" v-if="type!='info'"  label="租赁方式" prop="zulinfangshi">  <!-- 租赁方式选择框 -->
          <el-select v-model="ruleForm.zulinfangshi" placeholder="请选择租赁方式">
            <el-option
                v-for="(item,index) in zulinfangshiOptions"
                v-bind:key="index"
                :label="item"
                :value="item">
            </el-option>
          </el-select>
        </el-form-item>
        <div v-else>  <!-- 如果是查看模式，显示只读输入框 -->
          <el-form-item class="input" label="租赁方式" prop="zulinfangshi">
            <el-input v-model="ruleForm.zulinfangshi"
                      placeholder="租赁方式" readonly></el-input>
          </el-form-item>
        </div>
      </el-col>
      <el-col :span="12">  <!-- 右侧列，宽度为12 -->
        <el-form-item class="input" v-if="type!='info'"  label="朝向楼层" prop="chaoxianglouceng">  <!-- 朝向楼层输入框 -->
          <el-input v-model="ruleForm.chaoxianglouceng"
                    placeholder="朝向楼层" clearable  :readonly="ro.chaoxianglouceng"></el-input>
        </el-form-item>
        <div v-else>  <!-- 如果是查看模式，显示只读输入框 -->
          <el-form-item class="input" label="朝向楼层" prop="chaoxianglouceng">
            <el-input v-model="ruleForm.chaoxianglouceng"
                      placeholder="朝向楼层" readonly></el-input>
          </el-form-item>
        </div>
      </el-col>
      <el-col :span="12">  <!-- 左侧列，宽度为12 -->
        <el-form-item class="input" v-if="type!='info'"  label="面积" prop="mianji">  <!-- 面积输入框 -->
          <el-input v-model="ruleForm.mianji"
                    placeholder="面积" clearable  :readonly="ro.mianji"></el-input>
        </el-form-item>
        <div v-else>  <!-- 如果是查看模式，显示只读输入框 -->
          <el-form-item class="input" label="面积" prop="mianji">
            <el-input v-model="ruleForm.mianji"
                      placeholder="面积" readonly></el-input>
          </el-form-item>
        </div>
      </el-col>
      <el-col :span="12">  <!-- 右侧列，宽度为12 -->
        <el-form-item class="select" v-if="type!='info'"  label="房屋状态" prop="fangwuzhuangtai">  <!-- 房屋状态选择框 -->
          <el-select v-model="ruleForm.fangwuzhuangtai" placeholder="请选择房屋状态">
            <el-option
                v-for="(item,index) in fangwuzhuangtaiOptions"
                v-bind:key="index"
                :label="item"
                :value="item">
            </el-option>
          </el-select>
        </el-form-item>
        <div v-else>  <!-- 如果是查看模式，显示只读输入框 -->
          <el-form-item class="input" label="房屋状态" prop="fangwuzhuangtai">
            <el-input v-model="ruleForm.fangwuzhuangtai"
                      placeholder="房屋状态" readonly></el-input>
          </el-form-item>
        </div>
      </el-col>
      <el-col :span="12">  <!-- 左侧列，宽度为12 -->
        <el-form-item class="input" v-if="type!='info'"  label="小区" prop="xiaoqu">  <!-- 小区输入框 -->
          <el-input v-model="ruleForm.xiaoqu"
                    placeholder="小区" clearable  :readonly="ro.xiaoqu"></el-input>
        </el-form-item>
        <div v-else>  <!-- 如果是查看模式，显示只读输入框 -->
          <el-form-item class="input" label="小区" prop="xiaoqu">
            <el-input v-model="ruleForm.xiaoqu"
                      placeholder="小区" readonly></el-input>
          </el-form-item>
        </div>
      </el-col>
      <el-col :span="12">  <!-- 右侧列，宽度为12 -->
        <el-form-item class="input" v-if="type!='info'"  label="详细地址" prop="xiangxidizhi">  <!-- 详细地址输入框 -->
          <el-input v-model="ruleForm.xiangxidizhi"
                    placeholder="详细地址" clearable  :readonly="ro.xiangxidizhi"></el-input>
        </el-form-item>
        <div v-else>  <!-- 如果是查看模式，显示只读输入框 -->
          <el-form-item class="input" label="详细地址" prop="xiangxidizhi">
            <el-input v-model="ruleForm.xiangxidizhi"
                      placeholder="详细地址" readonly></el-input>
          </el-form-item>
        </div>
      </el-col>
      <el-col :span="12">  <!-- 左侧列，宽度为12 -->
        <el-form-item class="input" v-if="type!='info'"  label="月租价格" prop="yuezujiage">  <!-- 月租价格输入框 -->
          <el-input v-model="ruleForm.yuezujiage"
                    placeholder="月租价格" clearable  :readonly="ro.yuezujiage"></el-input>
        </el-form-item>
        <div v-else>  <!-- 如果是查看模式，显示只读输入框 -->
          <el-form-item class="input" label="月租价格" prop="yuezujiage">
            <el-input v-model="ruleForm.yuezujiage"
                      placeholder="月租价格" readonly></el-input>
          </el-form-item>
        </div>
      </el-col>
      <el-col :span="12">  <!-- 右侧列，宽度为12 -->
        <el-form-item class="input" v-if="type!='info'"  label="押金" prop="yajin">  <!-- 押金输入框 -->
          <el-input v-model="ruleForm.yajin"
                    placeholder="押金" clearable  :readonly="ro.yajin"></el-input>
        </el-form-item>
        <div v-else>  <!-- 如果是查看模式，显示只读输入框 -->
          <el-form-item class="input" label="押金" prop="yajin">
            <el-input v-model="ruleForm.yajin"
                      placeholder="押金" readonly></el-input>
          </el-form-item>
        </div>
      </el-col>
      <el-col :span="12">  <!-- 左侧列，宽度为12 -->
        <el-form-item class="input" v-if="type!='info'"  label="房屋设施" prop="fangwusheshi">  <!-- 房屋设施输入框 -->
          <el-input v-model="ruleForm.fangwusheshi"
                    placeholder="房屋设施" clearable  :readonly="ro.fangwusheshi"></el-input>
        </el-form-item>
        <div v-else>  <!-- 如果是查看模式，显示只读输入框 -->
          <el-form-item class="input" label="房屋设施" prop="fangwusheshi">
            <el-input v-model="ruleForm.fangwusheshi"
                      placeholder="房屋设施" readonly></el-input>
          </el-form-item>
        </div>
      </el-col>
      <el-col :span="12">  <!-- 右侧列，宽度为12 -->
        <el-form-item class="date" v-if="type!='info'" label="发布日期" prop="faburiqi">  <!-- 发布日期选择器 -->
          <el-date-picker
              format="yyyy 年 MM 月 dd 日"
              value-format="yyyy-MM-dd"
              v-model="ruleForm.faburiqi"
              type="date"
              placeholder="发布日期">
          </el-date-picker>
        </el-form-item>
        <div v-else>  <!-- 如果是查看模式，显示只读输入框 -->
          <el-form-item class="input" v-if="ruleForm.faburiqi" label="发布日期" prop="faburiqi">
            <el-input v-model="ruleForm.faburiqi"
                      placeholder="发布日期" readonly></el-input>
          </el-form-item>
        </div>
      </el-col>
      <el-col :span="12">  <!-- 左侧列，宽度为12 -->
        <el-form-item class="select" v-if="type!='info'" label="房主账号" prop="fangzhuzhanghao">  <!-- 房主账号选择框 -->
          <el-select  @change="fangzhuzhanghaoChange" v-model="ruleForm.fangzhuzhanghao" placeholder="请选择房主账号">
            <el-option
                v-for="(item,index) in fangzhuzhanghaoOptions"
                v-bind:key="index"
                :label="item"
                :value="item">
            </el-option>
          </el-select>
        </el-form-item>
        <div v-else>  <!-- 如果是查看模式，显示只读输入框 -->
          <el-form-item class="input"v-if="ruleForm.fangzhuzhanghao" label="房主账号" prop="fangzhuzhanghao">
            <el-input v-model="ruleForm.fangzhuzhanghao"
                      placeholder="房主账号" readonly></el-input>
          </el-form-item>
        </div>
      </el-col>
      <el-col :span="12">  <!-- 右侧列，宽度为12 -->
        <el-form-item class="input" v-if="type!='info'"  label="房主姓名" prop="fangzhuxingming">  <!-- 房主姓名输入框 -->
          <el-input v-model="ruleForm.fangzhuxingming"
                    placeholder="房主姓名" clearable  :readonly="ro.fangzhuxingming"></el-input>
        </el-form-item>
        <div v-else>  <!-- 如果是查看模式，显示只读输入框 -->
          <el-form-item class="input" label="房主姓名" prop="fangzhuxingming">
            <el-input v-model="ruleForm.fangzhuxingming"
                      placeholder="房主姓名" readonly></el-input>
          </el-form-item>
        </div>
      </el-col>
    </el-row>

    <el-row>  <!-- 新的表单布局行 -->
      <el-col :span="24">  <!-- 占满整行 -->
        <el-form-item v-if="type!='info'"  label="房屋详情" prop="fangwuxiangqing">  <!-- 房屋详情编辑器 -->
          <editor
              style="min-width: 200px; max-width: 600px;"
              v-model="ruleForm.fangwuxiangqing"
              class="editor"
              action="file/upload">
          </editor>
        </el-form-item>
        <div v-else>  <!-- 如果是查看模式，显示富文本内容 -->
          <el-form-item v-if="ruleForm.fangwuxiangqing" label="房屋详情" prop="fangwuxiangqing">
            <span v-html="ruleForm.fangwuxiangqing"></span>
          </el-form-item>
        </div>
      </el-col>
    </el-row>
    <el-form-item class="btn">  <!-- 按钮容器 -->
      <el-button v-if="type!='info'" type="primary" class="btn-success" @click="onSubmit">提交</el-button>  <!-- 提交按钮 -->
      <el-button v-if="type!='info'" class="btn-close" @click="back()">取消</el-button>  <!-- 取消按钮 -->
      <el-button v-if="type=='info'" class="btn-close" @click="back()">返回</el-button>  <!-- 返回按钮 -->
    </el-form-item>
    </el-form>
  </div>
</template>

<script>
// 引入验证工具函数
import { isNumber,isIntNumer,isEmail,isPhone, isMobile,isURL,checkIdCard } from "@/utils/validate";

export default {
  data() {
    let self = this
    // 定义身份证验证规则
    var validateIdCard = (rule, value, callback) => {
      if(!value){
        callback();
      } else if (!checkIdCard(value)) {
        callback(new Error("请输入正确的身份证号码"));
      } else {
        callback();
      }
    };
    // 定义URL验证规则
    var validateUrl = (rule, value, callback) => {
      if(!value){
        callback();
      } else if (!isURL(value)) {
        callback(new Error("请输入正确的URL地址"));
      } else {
        callback();
      }
    };
    // 定义手机号验证规则
    var validateMobile = (rule, value, callback) => {
      if(!value){
        callback();
      } else if (!isMobile(value)) {
        callback(new Error("请输入正确的手机号码"));
      } else {
        callback();
      }
    };
    // 定义电话号验证规则
    var validatePhone = (rule, value, callback) => {
      if(!value){
        callback();
      } else if (!isPhone(value)) {
        callback(new Error("请输入正确的电话号码"));
      } else {
        callback();
      }
    };
    // 定义邮箱验证规则
    var validateEmail = (rule, value, callback) => {
      if(!value){
        callback();
      } else if (!isEmail(value)) {
        callback(new Error("请输入正确的邮箱地址"));
      } else {
        callback();
      }
    };
    // 定义数字验证规则
    var validateNumber = (rule, value, callback) => {
      if(!value){
        callback();
      } else if (!isNumber(value)) {
        callback(new Error("请输入数字"));
      } else {
        callback();
      }
    };
    // 定义整数验证规则
    var validateIntNumber = (rule, value, callback) => {
      if(!value){
        callback();
      } else if (!isIntNumer(value)) {
        callback(new Error("请输入整数"));
      } else {
        callback();
      }
    };
    return {
      // 表单样式配置
      addEditForm: { /* 样式配置参数 */ },
      id: '',
      type: '',
      ro:{
        // 各字段只读状态配置
        fangwumingcheng : false,
        fangwuleixing : false,
        tupian : false,
        zulinfangshi : false,
        chaoxianglouceng : false,
        mianji : false,
        fangwuzhuangtai : false,
        xiaoqu : false,
        xiangxidizhi : false,
        yuezujiage : false,
        yajin : false,
        fangwusheshi : false,
        fangwuxiangqing : false,
        faburiqi : false,
        fangzhuzhanghao : false,
        fangzhuxingming : false,
      },
      // 表单数据模型
      ruleForm: {
        fangwumingcheng: '',
        fangwuleixing: '',
        tupian: '',
        zulinfangshi: '',
        chaoxianglouceng: '',
        mianji: '',
        fangwuzhuangtai: '',
        xiaoqu: '',
        xiangxidizhi: '',
        yuezujiage: '',
        yajin: '',
        fangwusheshi: '',
        fangwuxiangqing: '',
        faburiqi: '',
        fangzhuzhanghao: '',
        fangzhuxingming: '',
      },
      // 房屋类型选项
      fangwuleixingOptions: [],
      // 租赁方式选项
      zulinfangshiOptions: [],
      // 房屋状态选项
      fangwuzhuangtaiOptions: [],
      // 房主账号选项
      fangzhuzhanghaoOptions: [],
      // 表单验证规则
      rules: {
        fangwumingcheng: [
          { required: true, message: '房屋名称不能为空', trigger: 'blur' },  // 必填验证
        ],
        fangwuleixing: [
          { required: true, message: '房屋类型不能为空', trigger: 'blur' },  // 必填验证
        ],
        tupian: [
          { required: true, message: '图片不能为空', trigger: 'blur' },  // 必填验证
        ],
        zulinfangshi: [
        ],
        chaoxianglouceng: [
        ],
        mianji: [
        ],
        fangwuzhuangtai: [
        ],
        xiaoqu: [
        ],
        xiangxidizhi: [
        ],
        yuezujiage: [
          { validator: validateIntNumber, trigger: 'blur' },  // 整数验证
        ],
        yajin: [
          { validator: validateIntNumber, trigger: 'blur' },  // 整数验证
        ],
        fangwusheshi: [
        ],
        fangwuxiangqing: [
        ],
        faburiqi: [
        ],
        fangzhuzhanghao: [
        ],
        fangzhuxingming: [
        ],
      }
    };
  },
  props: ["parent"],  // 定义父组件传入的属性
  computed: {
  },
  created() {
    this.addEditStyleChange()  // 调用样式更新方法
    this.addEditUploadStyleChange()  // 调用上传组件样式更新方法
  },
  methods: {
    // 下载文件方法
    download(file){
      window.open(`${file}`)
    },
    // 初始化方法
    init(id,type) {
      if (id) {
        this.id = id;  // 设置当前ID
        this.type = type;  // 设置当前类型
      }
      if(this.type=='info'||this.type=='else'){  // 如果是查看或编辑模式
        this.info(id);  // 获取详细信息
      }else if(this.type=='cross'){  // 如果是关联模式
        var obj = this.$storage.getObj('crossObj');  // 获取关联对象
        for (var o in obj){  // 遍历关联对象属性
          if(o=='fangwumingcheng'){
            this.ruleForm.fangwumingcheng = obj[o];  // 设置房屋名称
            this.ro.fangwumingcheng = true;  // 设置为只读
            continue;
          }
          if(o=='fangwuleixing'){
            this.ruleForm.fangwuleixing = obj[o];  // 设置房屋类型
            this.ro.fangwuleixing = true;  // 设置为只读
            continue;
          }
          if(o=='tupian'){
            this.ruleForm.tupian = obj[o];  // 设置图片
            this.ro.tupian = true;  // 设置为只读
            continue;
          }
          if(o=='zulinfangshi'){
            this.ruleForm.zulinfangshi = obj[o];  // 设置租赁方式
            this.ro.zulinfangshi = true;  // 设置为只读
            continue;
          }
          if(o=='chaoxianglouceng'){
            this.ruleForm.chaoxianglouceng = obj[o];  // 设置朝向楼层
            this.ro.chaoxianglouceng = true;  // 设置为只读
            continue;
          }
          if(o=='mianji'){
            this.ruleForm.mianji = obj[o];  // 设置面积
            this.ro.mianji = true;  // 设置为只读
            continue;
          }
          if(o=='fangwuzhuangtai'){
            this.ruleForm.fangwuzhuangtai = obj[o];  // 设置房屋状态
            this.ro.fangwuzhuangtai = true;  // 设置为只读
            continue;
          }
          if(o=='xiaoqu'){
            this.ruleForm.xiaoqu = obj[o];  // 设置小区
            this.ro.xiaoqu = true;  // 设置为只读
            continue;
          }
          if(o=='xiangxidizhi'){
            this.ruleForm.xiangxidizhi = obj[o];  // 设置详细地址
            this.ro.xiangxidizhi = true;  // 设置为只读
            continue;
          }
          if(o=='yuezujiage'){
            this.ruleForm.yuezujiage = obj[o];  // 设置月租价格
            this.ro.yuezujiage = true;  // 设置为只读
            continue;
          }
          if(o=='yajin'){
            this.ruleForm.yajin = obj[o];  // 设置押金
            this.ro.yajin = true;  // 设置为只读
            continue;
          }
          if(o=='fangwusheshi'){
            this.ruleForm.fangwusheshi = obj[o];  // 设置房屋设施
            this.ro.fangwusheshi = true;  // 设置为只读
            continue;
          }
          if(o=='fangwuxiangqing'){
            this.ruleForm.fangwuxiangqing = obj[o];  // 设置房屋详情
            this.ro.fangwuxiangqing = true;  // 设置为只读
            continue;
          }
          if(o=='faburiqi'){
            this.ruleForm.faburiqi = obj[o];  // 设置发布日期
            this.ro.faburiqi = true;  // 设置为只读
            continue;
          }
          if(o=='fangzhuzhanghao'){
            this.ruleForm.fangzhuzhanghao = obj[o];  // 设置房主账号
            this.ro.fangzhuzhanghao = true;  // 设置为只读
            continue;
          }
          if(o=='fangzhuxingming'){
            this.ruleForm.fangzhuxingming = obj[o];  // 设置房主姓名
            this.ro.fangzhuxingming = true;  // 设置为只读
            continue;
          }
        }
      }
      // 获取当前用户信息
      this.$http({
        url: `${this.$storage.get('sessionTable')}/session`,
        method: "get"
      }).then(({ data }) => {
        if (data && data.code === 0) {
          var json = data.data;
        } else {
          this.$message.error(data.msg);
        }
      });
      // 获取房屋类型选项
      this.$http({
        url: `option/fangwuleixing/fangwuleixing`,
        method: "get"
      }).then(({ data }) => {
        if (data && data.code === 0) {
          this.fangwuleixingOptions = data.data;
        } else {
          this.$message.error(data.msg);
        }
      });

      // 设置租赁方式选项
      this.zulinfangshiOptions = "整租,合租".split(',');
      // 设置房屋状态选项
      this.fangwuzhuangtaiOptions = "可租,已租".split(',');
      // 获取房主账号选项
      this.$http({
        url: `option/fangzhu/fangzhuzhanghao`,
        method: "get"
      }).then(({ data }) => {
        if (data && data.code === 0) {
          this.fangzhuzhanghaoOptions = data.data;
        } else {
          this.$message.error(data.msg);
        }
      });
    },
    // 房主账号变更时的级联查询
    fangzhuzhanghaoChange () {
      this.$http({
        url: `follow/fangzhu/fangzhuzhanghao?columnValue=`+ this.ruleForm.fangzhuzhanghao,
        method: "get"
      }).then(({ data }) => {
        if (data && data.code === 0) {
          if(data.data.fangzhuxingming){
            this.ruleForm.fangzhuxingming = data.data.fangzhuxingming  // 更新房主姓名
          }
        } else {
          this.$message.error(data.msg);
        }
      });
    },
    // 获取详细信息方法
    info(id) {
      this.$http({
        url: `fangwuxinxi/info/${id}`,
        method: "get"
      }).then(({ data }) => {
        if (data && data.code === 0) {
          this.ruleForm = data.data;  // 更新表单数据
        } else {
          this.$message.error(data.msg);
        }
      });
    },
    // 提交表单方法
    onSubmit() {
      // 表单验证并提交
      this.$refs["ruleForm"].validate(valid => {
        if (valid) {
          this.$http({
            url: `fangwuxinxi/${!this.ruleForm.id ? "save" : "update"}`,  // 请求保存或更新接口
            method: "post",
            data: this.ruleForm
          }).then(({ data }) => {
            if (data && data.code === 0) {
              this.$message({
                message: "操作成功",  // 显示成功消息
                type: "success",
                duration: 1500,
                onClose: () => {
                  this.parent.showFlag = true;  // 显示列表页
                  this.parent.addOrUpdateFlag = false;  // 隐藏表单页
                  this.parent.fangwuxinxiCrossAddOrUpdateFlag = false;  // 隐藏关联表单页
                  this.parent.search();  // 刷新列表
                  this.parent.contentStyleChange();  // 更新列表样式
                }
              });
            } else {
              this.$message.error(data.msg);  // 显示错误消息
            }
          });
        }
      });
    },
    // 获取唯一标识符方法
    getUUID () {
      return new Date().getTime();
    },
    // 返回方法
    back() {
      this.parent.showFlag = true;  // 显示列表页
      this.parent.addOrUpdateFlag = false;  // 隐藏表单页
      this.parent.fangwuxinxiCrossAddOrUpdateFlag = false;  // 隐藏关联表单页
      this.parent.contentStyleChange();  // 更新列表样式
    },
    // 图片上传变更方法
    tupianUploadChange(fileUrls) {
      this.ruleForm.tupian = fileUrls;  // 更新图片数据
      this.addEditUploadStyleChange();  // 更新上传组件样式
    },
    addEditStyleChange() {  // 更新表单样式方法
      this.$nextTick(()=>{  // 在DOM更新后执行
        // 更新input样式
        document.querySelectorAll('.addEdit-block .input .el-input__inner').forEach(el=>{
          el.style.height = this.addEditForm.inputHeight;
          el.style.color = this.addEditForm.inputFontColor;
          el.style.fontSize = this.addEditForm.inputFontSize;
          el.style.borderWidth = this.addEditForm.inputBorderWidth;
          el.style.borderStyle = this.addEditForm.inputBorderStyle;
          el.style.borderColor = this.addEditForm.inputBorderColor;
          el.style.borderRadius = this.addEditForm.inputBorderRadius;
          el.style.backgroundColor = this.addEditForm.inputBgColor;
        });
        document.querySelectorAll('.addEdit-block .input .el-form-item__label').forEach(el=>{
          el.style.lineHeight = this.addEditForm.inputHeight;
          el.style.color = this.addEditForm.inputLableColor;
          el.style.fontSize = this.addEditForm.inputLableFontSize;
        });
        // 更新select样式
        document.querySelectorAll('.addEdit-block .select .el-input__inner').forEach(el=>{
          el.style.height = this.addEditForm.selectHeight;
          el.style.color = this.addEditForm.selectFontColor;
          el.style.fontSize = this.addEditForm.selectFontSize;
          el.style.borderWidth = this.addEditForm.selectBorderWidth;
          el.style.borderStyle = this.addEditForm.selectBorderStyle;
          el.style.borderColor = this.addEditForm.selectBorderColor;
          el.style.borderRadius = this.addEditForm.selectBorderRadius;
          el.style.backgroundColor = this.addEditForm.selectBgColor;
        });
        document.querySelectorAll('.addEdit-block .select .el-form-item__label').forEach(el=>{
          el.style.lineHeight = this.addEditForm.selectHeight;
          el.style.color = this.addEditForm.selectLableColor;
          el.style.fontSize = this.addEditForm.selectLableFontSize;
        });
        document.querySelectorAll('.addEdit-block .select .el-select__caret').forEach(el=>{
          el.style.color = this.addEditForm.selectIconFontColor;
          el.style.fontSize = this.addEditForm.selectIconFontSize;
        });
        // 更新date样式
        document.querySelectorAll('.addEdit-block .date .el-input__inner').forEach(el=>{
          el.style.height = this.addEditForm.dateHeight;
          el.style.color = this.addEditForm.dateFontColor;
          el.style.fontSize = this.addEditForm.dateFontSize;
          el.style.borderWidth = this.addEditForm.dateBorderWidth;
          el.style.borderStyle = this.addEditForm.dateBorderStyle;
          el.style.borderColor = this.addEditForm.dateBorderColor;
          el.style.borderRadius = this.addEditForm.dateBorderRadius;
          el.style.backgroundColor = this.addEditForm.dateBgColor;
        });
        document.querySelectorAll('.addEdit-block .date .el-form-item__label').forEach(el=>{
          el.style.lineHeight = this.addEditForm.dateHeight;
          el.style.color = this.addEditForm.dateLableColor;
          el.style.fontSize = this.addEditForm.dateLableFontSize;
        });
        document.querySelectorAll('.addEdit-block .date .el-input__icon').forEach(el=>{
          el.style.color = this.addEditForm.dateIconFontColor;
          el.style.fontSize = this.addEditForm.dateIconFontSize;
          el.style.lineHeight = this.addEditForm.dateHeight;
        });
        // 更新upload样式
        let iconLineHeight = parseInt(this.addEditForm.uploadHeight) - parseInt(this.addEditForm.uploadBorderWidth) * 2 + 'px';
        document.querySelectorAll('.addEdit-block .upload .el-upload--picture-card').forEach(el=>{
          el.style.width = this.addEditForm.uploadHeight;
          el.style.height = this.addEditForm.uploadHeight;
          el.style.borderWidth = this.addEditForm.uploadBorderWidth;
          el.style.borderStyle = this.addEditForm.uploadBorderStyle;
          el.style.borderColor = this.addEditForm.uploadBorderColor;
          el.style.borderRadius = this.addEditForm.uploadBorderRadius;
          el.style.backgroundColor = this.addEditForm.uploadBgColor;
        });
        document.querySelectorAll('.addEdit-block .upload .el-form-item__label').forEach(el=>{
          el.style.lineHeight = this.addEditForm.uploadHeight;
          el.style.color = this.addEditForm.uploadLableColor;
          el.style.fontSize = this.addEditForm.uploadLableFontSize;
        });
        document.querySelectorAll('.addEdit-block .upload .el-icon-plus').forEach(el=>{
          el.style.color = this.addEditForm.uploadIconFontColor;
          el.style.fontSize = this.addEditForm.uploadIconFontSize;
          el.style.lineHeight = iconLineHeight;
          el.style.display = 'block';
        });
        // 更新textarea样式
        document.querySelectorAll('.addEdit-block .textarea .el-textarea__inner').forEach(el=>{
          el.style.height = this.addEditForm.textareaHeight;
          el.style.color = this.addEditForm.textareaFontColor;
          el.style.fontSize = this.addEditForm.textareaFontSize;
          el.style.borderWidth = this.addEditForm.textareaBorderWidth;
          el.style.borderStyle = this.addEditForm.textareaBorderStyle;
          el.style.borderColor = this.addEditForm.textareaBorderColor;
          el.style.borderRadius = this.addEditForm.textareaBorderRadius;
          el.style.backgroundColor = this.addEditForm.textareaBgColor;
        });
        document.querySelectorAll('.addEdit-block .textarea .el-form-item__label').forEach(el=>{
          // el.style.lineHeight = this.addEditForm.textareaHeight
          el.style.color = this.addEditForm.textareaLableColor;
          el.style.fontSize = this.addEditForm.textareaLableFontSize;
        });
        // 更新按钮样式
        document.querySelectorAll('.addEdit-block .btn .btn-success').forEach(el=>{
          el.style.width = this.addEditForm.btnSaveWidth;
          el.style.height = this.addEditForm.btnSaveHeight;
          el.style.color = this.addEditForm.btnSaveFontColor;
          el.style.fontSize = this.addEditForm.btnSaveFontSize;
          el.style.borderWidth = this.addEditForm.btnSaveBorderWidth;
          el.style.borderStyle = this.addEditForm.btnSaveBorderStyle;
          el.style.borderColor = this.addEditForm.btnSaveBorderColor;
          el.style.borderRadius = this.addEditForm.btnSaveBorderRadius;
          el.style.backgroundColor = this.addEditForm.btnSaveBgColor;
        });
        // 更新取消按钮样式
        document.querySelectorAll('.addEdit-block .btn .btn-close').forEach(el=>{
          el.style.width = this.addEditForm.btnCancelWidth;
          el.style.height = this.addEditForm.btnCancelHeight;
          el.style.color = this.addEditForm.btnCancelFontColor;
          el.style.fontSize = this.addEditForm.btnCancelFontSize;
          el.style.borderWidth = this.addEditForm.btnCancelBorderWidth;
          el.style.borderStyle = this.addEditForm.btnCancelBorderStyle;
          el.style.borderColor = this.addEditForm.btnCancelBorderColor;
          el.style.borderRadius = this.addEditForm.btnCancelBorderRadius;
          el.style.backgroundColor = this.addEditForm.btnCancelBgColor;
        });
      });
    },
    addEditUploadStyleChange() {  // 更新上传组件样式方法
      this.$nextTick(()=>{  // 在DOM更新后执行
        document.querySelectorAll('.addEdit-block .upload .el-upload-list--picture-card .el-upload-list__item').forEach(el=>{
          el.style.width = this.addEditForm.uploadHeight;
          el.style.height = this.addEditForm.uploadHeight;
          el.style.borderWidth = this.addEditForm.uploadBorderWidth;
          el.style.borderStyle = this.addEditForm.uploadBorderStyle;
          el.style.borderColor = this.addEditForm.uploadBorderColor;
          el.style.borderRadius = this.addEditForm.uploadBorderRadius;
          el.style.backgroundColor = this.addEditForm.uploadBgColor;
        });
      });
    },
  }
};
</script>

<style lang="scss">
.editor{
  height: 500px;  <!-- 编辑器高度 -->

  & /deep/ .ql-container {  <!-- 编辑器内容区域 -->
    height: 310px;  <!-- 设置内容区域高度 -->
  }
}
.amap-wrapper {  <!-- 地图容器 -->
  width: 100%;  <!-- 宽度为100% -->
  height: 500px;  <!-- 高度为500px -->
}
.search-box {  <!-- 搜索和筛选组件 -->
  position: absolute;  <!-- 绝对定位 -->
}
.addEdit-block {  <!-- 表单容器 -->
  margin: -10px;  <!-- 外边距 -->
}
.detail-form-content {  <!-- 表单内容 -->
  padding: 12px;  <!-- 内边距 -->
}
.btn .el-button {  <!-- 按钮样式 -->
  padding: 0;  <!-- 无内边距 -->
}
</style>