<template>
  <div class="AddBuildingBox">
    <PageHeader :title="userid ? '编辑房屋租赁' : '添加房屋租赁'"></PageHeader>
    <div class="AddBuildingBody">
      <div class="title">基本信息</div>
      <div class="addBuildingFormBody">
        <el-form class="formBody" label-position="left" ref="formRef" :model="form" :rules="rules" label-width="130px">
          <el-row>
            <el-col :span="11">
              <el-form-item label="区域名称" prop="houseId">
                <el-input v-model.trim="form.rentalName" placeholder="请输入住户姓名" />
              </el-form-item>
            </el-col>
            <el-col :span="2"></el-col>
            <el-col :span="11">
              <el-form-item label="区域编号" prop="rentalName">
                <el-input v-model.trim="form.rentalName" placeholder="请输入住户姓名" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="11">
              <el-form-item label="区域面积" prop="remark">
                <el-input type="textarea" :rows="5" v-model.number="form.supInfo" placeholder="请输入补充房屋信息" />
              </el-form-item>
            </el-col>
            <el-col :span="2"></el-col>
            <el-col :span="11">
              <el-form-item label="车位数量" prop="phone">
                <el-input v-model.number="form.phone" placeholder="请输入手机号码" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="备注" prop="email">
                <el-input type="textarea" :rows="5" v-model.trim="form.email" placeholder="请输入" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-form-item style="margin-top: 30px">
            <el-button type="primary" @click="submitForm">提交</el-button>
            <el-button @click="cancelForm">返回</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import PageHeader from '@/components/Pageheader/index.vue';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;

const router = useRouter();
const route = useRoute();

const formRef = ref();
const houseformat = ['东', '西', '南', '北'];
const form = ref({
  id: null,
  houseId: null,
  rentalName: '', // 租户姓名
  rent: null, // 租金
  houseFace: '', // 房屋朝向
  rentalType: 0, //  整租合租
  phone: null, //手机号
  houseArea: null, // 房屋面积
  floorNo: null, //楼层号
  inTime: '', //入住时间
  facilities: '', //房屋设施
  houseImageUrl: '', //房屋图片
  supInfo: '', //补充租房信息
  vx: '', //微信
  houseUse: 0, //房屋用途
  rentalStatus: 0, //租赁状态
  email: '' //邮箱
});
const rules = ref({
  houseId: [{ required: true, message: '请选择房屋', trigger: 'blur' }],
  rentalName: [{ required: true, message: '请输入名称', trigger: 'blur' }]
});
const userid = ref(null);

// !== 提交 =============================================================================
// 提交
const submitForm = () => {
  formRef.value?.validate(async (valid: boolean) => {
    if (valid) {
    }
  });
};
// 推出
const cancelForm = () => {
  router.push({
    path: '/house/parkingList'
  });
};
</script>

<style scoped lang="scss">
.AddBuildingBox {
  padding: 15px;
  height: 100%;
  width: 100%;
}
.AddBuildingBody {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background-color: white;
  padding: 15px;
  .title {
    height: 40px;
    line-height: 40px;
    padding-left: 20px;
    background-color: rgba(255, 255, 255, 1);
    color: rgba(16, 16, 16, 1);
    border-bottom: 1px solid #bbbbbb;
    margin-bottom: 60px;
  }

  .formBody {
    width: 1050px;
    margin: 0 auto;
    &:deep(.el-form-item__content, .el-select, .el-input) {
      width: 350px !important;
      margin-right: 10px;
      .el-cascader {
        width: 100%;
      }
    }
    .el-form-item {
      margin-bottom: 20px;
      align-items: center;
    }
    .el-button {
      width: 80px;
      height: 35px;
      margin-right: 20px;
    }
  }
}
</style>
