车位区域管理完成
This commit is contained in:
485
src/views/system/houseRental/addhouseResident.vue
Normal file
485
src/views/system/houseRental/addhouseResident.vue
Normal file
@@ -0,0 +1,485 @@
|
||||
<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-cascader @change="handleChange" v-model="userHousepath" :options="treedata" />
|
||||
</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="form.rentalName" placeholder="请输入住户姓名" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row>
|
||||
<el-col :span="11">
|
||||
<el-form-item label="租赁状态" prop="rentalStatus">
|
||||
<el-select v-model.number="form.rentalStatus" class="m-2" placeholder="请选择">
|
||||
<el-option v-for="(item, index) in com_rental_status" :key="index" :label="item.label" :value="Number(item.value)" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="2"></el-col>
|
||||
<el-col :span="11">
|
||||
<el-form-item label="房屋用途" prop="houseUse">
|
||||
<el-select v-model.number="form.houseUse" class="m-2" placeholder="请选择">
|
||||
<el-option v-for="(item, index) in com_house_use" :key="index" :label="item.label" :value="Number(item.value)" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="11">
|
||||
<el-form-item label="租金" prop="rent">
|
||||
<el-input v-model="form.rent" placeholder="请输入租金">
|
||||
<template #suffix>¥</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="2"></el-col>
|
||||
<el-col :span="11">
|
||||
<el-form-item label="租赁方式" prop="rentalType">
|
||||
<el-radio-group v-model="form.rentalType">
|
||||
<el-radio v-for="item in com_rental_method" :key="item.value" :value="Number(item.value)">{{ item.label }}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row>
|
||||
<el-col :span="11">
|
||||
<el-form-item label="房屋朝向" prop="type">
|
||||
<el-select v-model.number="form.houseFace" class="m-2" placeholder="请选择">
|
||||
<el-option v-for="(item, index) in houseformat" :key="index" :label="item" :value="item" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="2"></el-col>
|
||||
<el-col :span="11">
|
||||
<el-form-item label="房屋面积" prop="houseArea">
|
||||
<el-input v-model.number="form.houseArea" placeholder="请输入房屋面积">
|
||||
<template #suffix> ㎡ </template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="11">
|
||||
<el-form-item label="房屋楼层" prop="floorNo">
|
||||
<el-input-number v-model.number="form.floorNo" placeholder="请输入" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="2"></el-col>
|
||||
<el-col :span="11">
|
||||
<el-form-item label="入住时间" prop="inTime">
|
||||
<el-date-picker
|
||||
value-format="YYYY-MM-DD"
|
||||
tag-effect="dark"
|
||||
tag-type="primary"
|
||||
v-model="form.inTime"
|
||||
type="date"
|
||||
placeholder="选择入住时间"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="房屋设施" prop="type">
|
||||
<div class="housedevicesbox">
|
||||
<div
|
||||
v-for="item in com_house_rental_facilities"
|
||||
:key="item.value"
|
||||
@click="handleClick(item.value)"
|
||||
class="housedevices_item"
|
||||
:class="{
|
||||
active: housedeviceslist.includes(item.value)
|
||||
}"
|
||||
>
|
||||
<span class="checked">√</span>
|
||||
<span class="ml-2">{{ item.label }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="上传房屋照片">
|
||||
<el-upload
|
||||
ref="uploadRef"
|
||||
accept=".png, .jpg"
|
||||
v-model:file-list="fileList"
|
||||
class="avatar-uploader"
|
||||
:action="uploadUrl"
|
||||
name="files"
|
||||
:multiple="true"
|
||||
:auto-upload="false"
|
||||
list-type="picture-card"
|
||||
:on-preview="handlePictureCardPreview"
|
||||
:on-remove="handleRemove"
|
||||
:on-success="handleAvatarSuccess"
|
||||
>
|
||||
<el-icon><Plus /></el-icon>
|
||||
<template #tip>
|
||||
<div class="el-upload__tip">jpg/png 文件格式</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
<el-dialog v-model="dialogVisible">
|
||||
<img w-full :src="dialogImageUrl" alt="Preview Image" />
|
||||
</el-dialog>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-form-item label="补充房屋信息" prop="remark">
|
||||
<el-input type="textarea" :rows="5" v-model.number="form.supInfo" placeholder="请输入补充房屋信息" />
|
||||
</el-form-item>
|
||||
<el-row>
|
||||
<el-col :span="11">
|
||||
<el-form-item label="手机号" prop="phone">
|
||||
<el-input v-model.number="form.phone" placeholder="请输入手机号码" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="2"></el-col>
|
||||
<el-col :span="11">
|
||||
<el-form-item label="微信" prop="vx">
|
||||
<el-input v-model.number="form.vx" placeholder="请输入微信号码" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="邮箱" prop="email">
|
||||
<el-input v-model.number="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';
|
||||
import { HouseRentalVO } from '@/api/system/houseRental/type';
|
||||
import { CascaderValue, UploadFiles, UploadInstance, UploadProps, UploadRawFile, UploadUserFile } from 'element-plus';
|
||||
|
||||
import { getCommunitylistAPI } from '@/api/system/community';
|
||||
import { getVillageTree } from '@/api/system/house';
|
||||
import { convertBuildingToTree, getHousePathById, hasFormData, splitStringUrl } from '@/utils/house';
|
||||
import { addHouseRental, getHouseRental, updateHouseRental, uploadHouseImage } from '@/api/system/houseRental';
|
||||
|
||||
const uploadUrl = import.meta.env.VITE_APP_BASE_API + '/houseRental/uploadImages';
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { com_rental_method } = toRefs<any>(proxy?.useDict('com_rental_method'));
|
||||
const { com_house_rental_facilities } = toRefs<any>(proxy?.useDict('com_house_rental_facilities') || {});
|
||||
const { com_rental_status } = toRefs<any>(proxy?.useDict('com_rental_status'));
|
||||
const { com_house_use } = toRefs<any>(proxy?.useDict('com_house_use'));
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
||||
const formRef = ref();
|
||||
const houseformat = ['东', '西', '南', '北'];
|
||||
const form = ref<HouseRentalVO>({
|
||||
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 userHousepath = ref<CascaderValue>([]);
|
||||
const rules = ref({
|
||||
houseId: [{ required: true, message: '请选择房屋', trigger: 'blur' }],
|
||||
rentalName: [{ required: true, message: '请输入名称', trigger: 'blur' }],
|
||||
phone: [
|
||||
{ required: true, message: '请输入手机号', trigger: 'blur' },
|
||||
{
|
||||
validator: (_, value) => {
|
||||
return /^1[3-9]\d{9}$/.test(value);
|
||||
},
|
||||
message: '请输入正确的手机号码',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
// ! 编辑租赁-=================================================================================
|
||||
const userid = ref(null);
|
||||
// !== 楼栋房屋 =============================================================================
|
||||
const treedata = ref([]);
|
||||
function gettreedata() {
|
||||
getCommunitylistAPI().then((res) => {
|
||||
const currentviliage = res.rows.find((item) => item.choiceStatus === 0);
|
||||
if (currentviliage.villageId) {
|
||||
getVillageTree(currentviliage.villageId).then((res) => {
|
||||
treedata.value = convertBuildingToTree(res.data.buildings);
|
||||
console.log(treedata.value);
|
||||
// !== 编辑用户 =============================================================================
|
||||
if (route.query.id) {
|
||||
userid.value = route.query.id;
|
||||
getHouseRental(userid.value).then((res) => {
|
||||
console.log(res);
|
||||
form.value = {
|
||||
...form.value,
|
||||
...res.data
|
||||
};
|
||||
const imgurllist = splitStringUrl(form.value.houseImageUrl);
|
||||
fileList.value = imgurllist;
|
||||
const arr = getHousePathById(treedata.value, form.value.houseId);
|
||||
userHousepath.value = arr;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
gettreedata();
|
||||
|
||||
// 获取房屋
|
||||
function handleChange(val: CascaderValue) {
|
||||
userHousepath.value = val;
|
||||
form.value.houseId = val[2];
|
||||
}
|
||||
// !== 上传文件 =============================================================================
|
||||
const fileList = ref<UploadUserFile[]>([]);
|
||||
const dialogImageUrl = ref('');
|
||||
const dialogVisible = ref(false);
|
||||
// 上传文件成功
|
||||
const uploadRef = ref<UploadInstance>();
|
||||
const handleAvatarSuccess: UploadProps['onSuccess'] = (response, uploadFile) => {
|
||||
if (response.data && response.data.error.length > 0) {
|
||||
ElMessage.error('图片上传失败,请稍后再试');
|
||||
}
|
||||
};
|
||||
const handlePictureCardPreview: UploadProps['onPreview'] = (uploadFile) => {
|
||||
dialogImageUrl.value = uploadFile.url!;
|
||||
dialogVisible.value = true;
|
||||
};
|
||||
const handleRemove: UploadProps['onRemove'] = (uploadFile, uploadFiles) => {
|
||||
console.log(uploadFile, uploadFiles);
|
||||
};
|
||||
|
||||
// !== 家电 =============================================================================
|
||||
|
||||
// 家电
|
||||
const housedeviceslist = ref([]);
|
||||
watch(
|
||||
() => com_house_rental_facilities.value,
|
||||
(newVal) => {
|
||||
housedeviceslist.value = (newVal || []).map((item) => item.value);
|
||||
},
|
||||
{ deep: true, immediate: true }
|
||||
);
|
||||
function handleClick(index: number) {
|
||||
if (housedeviceslist.value.includes(index)) {
|
||||
housedeviceslist.value = housedeviceslist.value.filter((item) => item !== index);
|
||||
} else {
|
||||
housedeviceslist.value.push(index);
|
||||
}
|
||||
}
|
||||
|
||||
// !== 提交 =============================================================================
|
||||
|
||||
// 提交
|
||||
const submitForm = () => {
|
||||
formRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
form.value.facilities = housedeviceslist.value.join(',');
|
||||
let str = '';
|
||||
// 判断有无图片
|
||||
if (fileList.value.length > 0) {
|
||||
const formdata = new FormData();
|
||||
fileList.value.forEach((item) => {
|
||||
// 只处理 新增的图片
|
||||
if (item.raw && item.raw instanceof File) {
|
||||
formdata.append('files', item.raw);
|
||||
} else {
|
||||
str += item.url;
|
||||
}
|
||||
});
|
||||
console.log(formdata);
|
||||
if (!hasFormData(formdata)) return sendForm();
|
||||
uploadHouseImage(formdata)
|
||||
.then((res) => {
|
||||
if (res.data.success.length > 0) {
|
||||
const successlist = res.data.success;
|
||||
successlist.forEach((item) => {
|
||||
str += item.url + ',';
|
||||
});
|
||||
//
|
||||
form.value.houseImageUrl = str;
|
||||
}
|
||||
if (res.data.error.length > 0) {
|
||||
const str = res.data.error.join(',');
|
||||
res.data.error.forEach((item) => {
|
||||
fileList.value = fileList.value.filter((file) => file.name !== item);
|
||||
});
|
||||
ElMessage.error('图片:' + str + ' 上传失败!');
|
||||
}
|
||||
sendForm();
|
||||
})
|
||||
.catch((err) => {
|
||||
if (err && err.data && err.data.error.length > 0) {
|
||||
const str = err.data.error.join(',');
|
||||
err.data.error.forEach((item) => {
|
||||
fileList.value = fileList.value.filter((file) => file.name !== item);
|
||||
});
|
||||
ElMessage.error('图片:' + str + ' 上传失败!,请重新上传');
|
||||
}
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
sendForm();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
const sendForm = () => {
|
||||
// edit or add
|
||||
if (userid.value) {
|
||||
console.log('edit');
|
||||
console.log(form.value);
|
||||
updateHouseRental(form.value).then(() => {
|
||||
ElMessage.success('编辑成功');
|
||||
cancelForm();
|
||||
});
|
||||
} else {
|
||||
addHouseRental(form.value).then((res) => {
|
||||
ElMessage.success('添加成功');
|
||||
cancelForm();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 推出
|
||||
const cancelForm = () => {
|
||||
router.push({
|
||||
path: '/house/houseRental'
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.avatar-uploader .avatar {
|
||||
width: 178px;
|
||||
height: 178px;
|
||||
display: block;
|
||||
object-fit: cover;
|
||||
}
|
||||
.avatar-uploader .el-upload {
|
||||
border: 1px dashed var(--el-border-color);
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
transition: var(--el-transition-duration-fast);
|
||||
}
|
||||
|
||||
.avatar-uploader .el-upload:hover {
|
||||
border-color: var(--el-color-primary);
|
||||
}
|
||||
.avatar {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.el-icon.avatar-uploader-icon {
|
||||
font-size: 28px;
|
||||
color: #8c939d;
|
||||
width: 178px;
|
||||
height: 178px;
|
||||
text-align: center;
|
||||
}
|
||||
.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;
|
||||
.housedevicesbox {
|
||||
display: grid;
|
||||
margin-bottom: 20px;
|
||||
gap: 10px 20px;
|
||||
grid-template-columns: repeat(6, 1fr);
|
||||
grid-template-rows: repeat(2, 1fr);
|
||||
.housedevices_item {
|
||||
width: 95px;
|
||||
height: 35px;
|
||||
background-color: #ccc;
|
||||
border-radius: 5px;
|
||||
text-align: center;
|
||||
line-height: 35px;
|
||||
cursor: pointer;
|
||||
&.active {
|
||||
background-color: rgb(232, 241, 255);
|
||||
color: #267cff;
|
||||
}
|
||||
}
|
||||
}
|
||||
&: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>
|
||||
245
src/views/system/houseRental/index.vue
Normal file
245
src/views/system/houseRental/index.vue
Normal file
@@ -0,0 +1,245 @@
|
||||
<template>
|
||||
<div class="p-2">
|
||||
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
||||
<div v-show="showSearch" class="mb-[10px]">
|
||||
<el-card shadow="hover">
|
||||
<el-form label-width="120px" ref="queryFormRef" :model="queryParams" :inline="true">
|
||||
<el-form-item label="房屋用途" prop="houseUse">
|
||||
<el-select v-model="queryParams.houseUse" placeholder="选择房屋用途" style="width: 240px">
|
||||
<el-option v-for="item in com_house_use" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="发布人" prop="houseId">
|
||||
<el-input v-model="queryParams.rentalName" placeholder="请输入" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['houseRental:houseRental:add']">新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['houseRental:houseRental:edit']"
|
||||
>修改</el-button
|
||||
>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['houseRental:houseRental:remove']"
|
||||
>删除</el-button
|
||||
>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" border :data="houseRentalList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="房屋信息" align="center" prop="rentalName" />
|
||||
<el-table-column label="租赁状态" align="center" prop="rent" />
|
||||
<el-table-column label="发布人" align="center" prop="rentalName" />
|
||||
<el-table-column label="联系方式" align="center" prop="rent" />
|
||||
<el-table-column label="发布时间" align="center" prop="pubTime" />
|
||||
<el-table-column label="房屋用途" align="center" prop="rent">
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.houseUse === 0">普通住宅</span>
|
||||
<span v-else-if="row.houseUse === 1"> 商业用地 </span>
|
||||
<span v-else-if="row.houseUse === 2">商住两用</span>
|
||||
<span v-else>其他</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="租赁方式" align="center" prop="rentalType">
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="row.rentalType === 0">整租</el-tag>
|
||||
<el-tag type="success" v-else>合租</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="修改" placement="top">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['houseRental:houseRental:edit']"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="删除" placement="top">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
icon="Delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['houseRental:houseRental:remove']"
|
||||
></el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="HouseRental" lang="ts">
|
||||
import { listHouseRental, delHouseRental, addHouseRental, updateHouseRental } from '@/api/system/houseRental/index';
|
||||
import { HouseRentalVO, HouseRentalQuery, HouseRentalForm } from '@/api/system/houseRental/type';
|
||||
import { getDictLabel } from '@/utils/house';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { com_house_use } = toRefs<any>(proxy?.useDict('com_house_use'));
|
||||
const { com_rental_method } = toRefs<any>(proxy?.useDict('com_rental_method'));
|
||||
|
||||
const router = useRouter();
|
||||
const houseRentalList = ref<HouseRentalVO[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref<Array<string | number>>([]);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const total = ref(0);
|
||||
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const houseRentalFormRef = ref<ElFormInstance>();
|
||||
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
const initFormData: HouseRentalForm = {
|
||||
id: undefined,
|
||||
rentalName: undefined,
|
||||
rent: undefined,
|
||||
rentalType: undefined,
|
||||
houseFace: undefined,
|
||||
houseArea: undefined,
|
||||
floorNo: undefined,
|
||||
inTime: undefined,
|
||||
facilities: undefined,
|
||||
houseImageUrl: undefined,
|
||||
supInfo: undefined,
|
||||
phone: undefined,
|
||||
vx: undefined,
|
||||
email: undefined,
|
||||
houseId: undefined
|
||||
};
|
||||
const data = reactive<PageData<HouseRentalForm, HouseRentalQuery>>({
|
||||
form: { ...initFormData },
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
|
||||
houseUse: undefined,
|
||||
rentalName: undefined,
|
||||
rent: undefined,
|
||||
rentalType: undefined,
|
||||
houseFace: undefined,
|
||||
houseArea: undefined,
|
||||
floorNo: undefined,
|
||||
inTime: undefined,
|
||||
facilities: undefined,
|
||||
houseImageUrl: undefined,
|
||||
supInfo: undefined,
|
||||
phone: undefined,
|
||||
vx: undefined,
|
||||
email: undefined,
|
||||
houseId: undefined,
|
||||
params: {}
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form } = toRefs(data);
|
||||
|
||||
/** 查询房屋租赁管理列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
const res = await listHouseRental(queryParams.value);
|
||||
houseRentalList.value = res.rows;
|
||||
total.value = res.total;
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
/** 取消按钮 */
|
||||
const cancel = () => {
|
||||
reset();
|
||||
dialog.visible = false;
|
||||
};
|
||||
|
||||
/** 表单重置 */
|
||||
const reset = () => {
|
||||
form.value = { ...initFormData };
|
||||
houseRentalFormRef.value?.resetFields();
|
||||
};
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
};
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
/** 多选框选中数据 */
|
||||
const handleSelectionChange = (selection: HouseRentalVO[]) => {
|
||||
ids.value = selection.map((item) => item.id);
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
};
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = () => {
|
||||
router.push({
|
||||
path: '/house/addhouseRental'
|
||||
});
|
||||
};
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = async (row?: HouseRentalVO) => {
|
||||
router.push({
|
||||
path: '/house/addhouseRental',
|
||||
query: {
|
||||
id: row.id
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
houseRentalFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
if (form.value.id) {
|
||||
await updateHouseRental(form.value).finally(() => (buttonLoading.value = false));
|
||||
} else {
|
||||
await addHouseRental(form.value).finally(() => (buttonLoading.value = false));
|
||||
}
|
||||
proxy?.$modal.msgSuccess('操作成功');
|
||||
dialog.visible = false;
|
||||
await getList();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row?: HouseRentalVO) => {
|
||||
const _ids = row?.id || ids.value;
|
||||
await proxy?.$modal.confirm('是否确认删除房屋租赁管理编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
|
||||
await delHouseRental(_ids);
|
||||
proxy?.$modal.msgSuccess('删除成功');
|
||||
await getList();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
362
src/views/system/houseRental/index2.vue
Normal file
362
src/views/system/houseRental/index2.vue
Normal file
@@ -0,0 +1,362 @@
|
||||
<template>
|
||||
<div class="p-2">
|
||||
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
||||
<div v-show="showSearch" class="mb-[10px]">
|
||||
<el-card shadow="hover">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
||||
<el-form-item label="房屋id" prop="houseId">
|
||||
<el-input v-model="queryParams.houseId" placeholder="请输入房屋id" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="租户姓名" prop="rentalName">
|
||||
<el-input v-model="queryParams.rentalName" placeholder="请输入租户姓名" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="租金 单位元" prop="rent">
|
||||
<el-input v-model="queryParams.rent" placeholder="请输入租金 单位元" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="租赁状态 0未租 1出租中 2退租" prop="rentalStatus">
|
||||
<el-select v-model="queryParams.rentalStatus" placeholder="请选择租赁状态 0未租 1出租中 2退租" clearable >
|
||||
<el-option v-for="dict in com_rental_status" :key="dict.value" :label="dict.label" :value="dict.value"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="房屋朝向" prop="houseFace">
|
||||
<el-input v-model="queryParams.houseFace" placeholder="请输入房屋朝向" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="房屋面积" prop="houseArea">
|
||||
<el-input v-model="queryParams.houseArea" placeholder="请输入房屋面积" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="楼层号" prop="floorNo">
|
||||
<el-input v-model="queryParams.floorNo" placeholder="请输入楼层号" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="入住时间" prop="inTime">
|
||||
<el-date-picker clearable
|
||||
v-model="queryParams.inTime"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="请选择入住时间"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="房屋设施" prop="facilities">
|
||||
<el-input v-model="queryParams.facilities" placeholder="请输入房屋设施" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="房屋照片url( "," 隔开)" prop="houseImageUrl">
|
||||
<el-input v-model="queryParams.houseImageUrl" placeholder="请输入房屋照片url( "," 隔开)" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="补充租房信息" prop="supInfo">
|
||||
<el-input v-model="queryParams.supInfo" placeholder="请输入补充租房信息" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号" prop="phone">
|
||||
<el-input v-model="queryParams.phone" placeholder="请输入手机号" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="微信" prop="vx">
|
||||
<el-input v-model="queryParams.vx" placeholder="请输入微信" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="邮箱" prop="email">
|
||||
<el-input v-model="queryParams.email" placeholder="请输入邮箱" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['houseRental:houseRental:add']">新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['houseRental:houseRental:edit']">修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['houseRental:houseRental:remove']">删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['houseRental:houseRental:export']">导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" border :data="houseRentalList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="id 房屋租赁表id" align="center" prop="id" v-if="true" />
|
||||
<el-table-column label="房屋id" align="center" prop="houseId" />
|
||||
<el-table-column label="租户姓名" align="center" prop="rentalName" />
|
||||
<el-table-column label="租金 单位元" align="center" prop="rent" />
|
||||
<el-table-column label="0 整租 1 合租" align="center" prop="rentalType" />
|
||||
<el-table-column label="租赁状态 0未租 1出租中 2退租" align="center" prop="rentalStatus">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="com_rental_status" :value="scope.row.rentalStatus"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="房屋朝向" align="center" prop="houseFace" />
|
||||
<el-table-column label="房屋面积" align="center" prop="houseArea" />
|
||||
<el-table-column label="楼层号" align="center" prop="floorNo" />
|
||||
<el-table-column label="入住时间" align="center" prop="inTime" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.inTime, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="房屋设施" align="center" prop="facilities">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="com_house_rental_facilities" :value="scope.row.facilities"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="房屋照片url( "," 隔开)" align="center" prop="houseImageUrl" />
|
||||
<el-table-column label="补充租房信息" align="center" prop="supInfo" />
|
||||
<el-table-column label="手机号" align="center" prop="phone" />
|
||||
<el-table-column label="微信" align="center" prop="vx" />
|
||||
<el-table-column label="邮箱" align="center" prop="email" />
|
||||
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="修改" placement="top">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['houseRental:houseRental:edit']"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="删除" placement="top">
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['houseRental:houseRental:remove']"></el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
</el-card>
|
||||
<!-- 添加或修改房屋租赁管理对话框 -->
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
||||
<el-form ref="houseRentalFormRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="房屋id" prop="houseId">
|
||||
<el-input v-model="form.houseId" placeholder="请输入房屋id" />
|
||||
</el-form-item>
|
||||
<el-form-item label="租户姓名" prop="rentalName">
|
||||
<el-input v-model="form.rentalName" placeholder="请输入租户姓名" />
|
||||
</el-form-item>
|
||||
<el-form-item label="租金 单位元" prop="rent">
|
||||
<el-input v-model="form.rent" placeholder="请输入租金 单位元" />
|
||||
</el-form-item>
|
||||
<el-form-item label="租赁状态 0未租 1出租中 2退租" prop="rentalStatus">
|
||||
<el-radio-group v-model="form.rentalStatus">
|
||||
<el-radio
|
||||
v-for="dict in com_rental_status"
|
||||
:key="dict.value"
|
||||
:value="parseInt(dict.value)"
|
||||
>{{dict.label}}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="房屋朝向" prop="houseFace">
|
||||
<el-input v-model="form.houseFace" placeholder="请输入房屋朝向" />
|
||||
</el-form-item>
|
||||
<el-form-item label="房屋面积" prop="houseArea">
|
||||
<el-input v-model="form.houseArea" placeholder="请输入房屋面积" />
|
||||
</el-form-item>
|
||||
<el-form-item label="楼层号" prop="floorNo">
|
||||
<el-input v-model="form.floorNo" placeholder="请输入楼层号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="入住时间" prop="inTime">
|
||||
<el-date-picker clearable
|
||||
v-model="form.inTime"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
placeholder="请选择入住时间">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="房屋设施" prop="facilities">
|
||||
<el-input v-model="form.facilities" placeholder="请输入房屋设施" />
|
||||
</el-form-item>
|
||||
<el-form-item label="房屋照片url( "," 隔开)" prop="houseImageUrl">
|
||||
<el-input v-model="form.houseImageUrl" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
<el-form-item label="补充租房信息" prop="supInfo">
|
||||
<el-input v-model="form.supInfo" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号" prop="phone">
|
||||
<el-input v-model="form.phone" placeholder="请输入手机号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="微信" prop="vx">
|
||||
<el-input v-model="form.vx" placeholder="请输入微信" />
|
||||
</el-form-item>
|
||||
<el-form-item label="邮箱" prop="email">
|
||||
<el-input v-model="form.email" placeholder="请输入邮箱" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="HouseRental" lang="ts">
|
||||
import { listHouseRental, getHouseRental, delHouseRental, addHouseRental, updateHouseRental } from '@/api/houseRental/houseRental';
|
||||
import { HouseRentalVO, HouseRentalQuery, HouseRentalForm } from '@/api/houseRental/houseRental/types';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { com_rental_status } = toRefs<any>(proxy?.useDict('com_rental_status'));
|
||||
|
||||
const houseRentalList = ref<HouseRentalVO[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref<Array<string | number>>([]);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const total = ref(0);
|
||||
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const houseRentalFormRef = ref<ElFormInstance>();
|
||||
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
const initFormData: HouseRentalForm = {
|
||||
id: undefined,
|
||||
houseId: undefined,
|
||||
rentalName: undefined,
|
||||
rent: undefined,
|
||||
rentalType: undefined,
|
||||
rentalStatus: undefined,
|
||||
houseFace: undefined,
|
||||
houseArea: undefined,
|
||||
floorNo: undefined,
|
||||
inTime: undefined,
|
||||
facilities: undefined,
|
||||
houseImageUrl: undefined,
|
||||
supInfo: undefined,
|
||||
phone: undefined,
|
||||
vx: undefined,
|
||||
email: undefined,
|
||||
}
|
||||
const data = reactive<PageData<HouseRentalForm, HouseRentalQuery>>({
|
||||
form: {...initFormData},
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
houseId: undefined,
|
||||
rentalName: undefined,
|
||||
rent: undefined,
|
||||
rentalType: undefined,
|
||||
rentalStatus: undefined,
|
||||
houseFace: undefined,
|
||||
houseArea: undefined,
|
||||
floorNo: undefined,
|
||||
inTime: undefined,
|
||||
facilities: undefined,
|
||||
houseImageUrl: undefined,
|
||||
supInfo: undefined,
|
||||
phone: undefined,
|
||||
vx: undefined,
|
||||
email: undefined,
|
||||
params: {
|
||||
}
|
||||
},
|
||||
rules: {
|
||||
id: [
|
||||
{ required: true, message: "id 房屋租赁表id不能为空", trigger: "blur" }
|
||||
],
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
/** 查询房屋租赁管理列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
const res = await listHouseRental(queryParams.value);
|
||||
houseRentalList.value = res.rows;
|
||||
total.value = res.total;
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
/** 取消按钮 */
|
||||
const cancel = () => {
|
||||
reset();
|
||||
dialog.visible = false;
|
||||
}
|
||||
|
||||
/** 表单重置 */
|
||||
const reset = () => {
|
||||
form.value = {...initFormData};
|
||||
houseRentalFormRef.value?.resetFields();
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
}
|
||||
|
||||
/** 多选框选中数据 */
|
||||
const handleSelectionChange = (selection: HouseRentalVO[]) => {
|
||||
ids.value = selection.map(item => item.id);
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
}
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = () => {
|
||||
reset();
|
||||
dialog.visible = true;
|
||||
dialog.title = "添加房屋租赁管理";
|
||||
}
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = async (row?: HouseRentalVO) => {
|
||||
reset();
|
||||
const _id = row?.id || ids.value[0]
|
||||
const res = await getHouseRental(_id);
|
||||
Object.assign(form.value, res.data);
|
||||
dialog.visible = true;
|
||||
dialog.title = "修改房屋租赁管理";
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
houseRentalFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
if (form.value.id) {
|
||||
await updateHouseRental(form.value).finally(() => buttonLoading.value = false);
|
||||
} else {
|
||||
await addHouseRental(form.value).finally(() => buttonLoading.value = false);
|
||||
}
|
||||
proxy?.$modal.msgSuccess("操作成功");
|
||||
dialog.visible = false;
|
||||
await getList();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row?: HouseRentalVO) => {
|
||||
const _ids = row?.id || ids.value;
|
||||
await proxy?.$modal.confirm('是否确认删除房屋租赁管理编号为"' + _ids + '"的数据项?').finally(() => loading.value = false);
|
||||
await delHouseRental(_ids);
|
||||
proxy?.$modal.msgSuccess("删除成功");
|
||||
await getList();
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = () => {
|
||||
proxy?.download('houseRental/houseRental/export', {
|
||||
...queryParams.value
|
||||
}, `houseRental_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user