Compare commits
2 Commits
41ba642155
...
df4df9365e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df4df9365e | ||
|
|
5d71534c18 |
@@ -99,6 +99,7 @@
|
||||
<template #default="scope">
|
||||
<el-switch
|
||||
v-if="scope.row.electricityRecord"
|
||||
:loading="isSwitchLoading(scope.row.deviceCode)"
|
||||
:active-value="true"
|
||||
:before-change="
|
||||
() => {
|
||||
@@ -299,6 +300,7 @@ import { useHouseStore } from '@/store/modules/house';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import { Upload } from '@element-plus/icons-vue';
|
||||
import { CascaderValue, genFileId, UploadProps, UploadRawFile } from 'element-plus';
|
||||
import { to } from 'await-to-js';
|
||||
import { exportImagesToZip } from '@/utils/exportZip';
|
||||
|
||||
const uploadUrl = import.meta.env.VITE_APP_BASE_API + '/electricityDevice/upload';
|
||||
@@ -615,8 +617,10 @@ const handleOpenDialog = (type: dialogTypeList, row?: ElectricityDeviceVO) => {
|
||||
};
|
||||
|
||||
// 解绑房屋
|
||||
function handleUnbind(data: ElectricityDeviceVO) {
|
||||
ElectricityDeviceUnbind(data.deviceCode)
|
||||
async function handleUnbind(row: ElectricityDeviceVO) {
|
||||
const [err] = await to(proxy?.$modal.confirm(`确定要解绑设备「${row.deviceCode}」与房屋「${row.houseName}」的绑定吗?`) as any);
|
||||
if (err) return;
|
||||
ElectricityDeviceUnbind(row.deviceCode)
|
||||
.then(() => {
|
||||
ElMessage.success('解绑成功');
|
||||
})
|
||||
@@ -642,18 +646,28 @@ function handleUpload(row: ElectricityDeviceVO) {
|
||||
getList();
|
||||
});
|
||||
}
|
||||
/** 正在启停中的设备编码,用于开关 loading */
|
||||
const switchLoadingCodes = ref<string[]>([]);
|
||||
const isSwitchLoading = (deviceCode: string) => switchLoadingCodes.value.includes(deviceCode);
|
||||
|
||||
/** 电表 启停*/
|
||||
const handleChangeWater = (val: number, row: ElectricityDeviceVO): Promise<boolean> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
switchLoadingCodes.value.push(row.deviceCode);
|
||||
setElectricityDeviceSwitchStatus({
|
||||
deviceCode: row.deviceCode,
|
||||
status: val
|
||||
})
|
||||
.then(() => {
|
||||
.then(async () => {
|
||||
proxy?.$modal.msgSuccess('操作成功');
|
||||
// 开关后刷新列表,同步最新的分合状态
|
||||
await getList();
|
||||
resolve(true);
|
||||
})
|
||||
.catch(() => reject(false));
|
||||
.catch(() => reject(false))
|
||||
.finally(() => {
|
||||
switchLoadingCodes.value = switchLoadingCodes.value.filter((code) => code !== row.deviceCode);
|
||||
});
|
||||
});
|
||||
};
|
||||
/** 提交按钮 */
|
||||
|
||||
@@ -1,208 +0,0 @@
|
||||
<template>
|
||||
<div class="AddBuildingBox">
|
||||
<PageHeader title="新建楼栋">
|
||||
<template #operate>
|
||||
<div class="BackBox" @click="goBack">返回</div>
|
||||
</template>
|
||||
</PageHeader>
|
||||
<div class="AddBuildingBody">
|
||||
<div class="title">基本信息</div>
|
||||
<div class="addBuildingFormBody">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" class="formBody" label-width="100px">
|
||||
<el-form-item label="楼栋名称" prop="buildingName">
|
||||
<el-input v-model.trim="form.buildingName" maxlength="6" placeholder="请输入楼栋名称" show-word-limit>
|
||||
<template #append>
|
||||
<span>栋</span>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="楼栋朝向" prop="buildToward">
|
||||
<el-select v-model="form.buildToward" placeholder="请选择楼栋朝向">
|
||||
<el-option v-for="item in houseFormat" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="楼高(m)" prop="buildTall">
|
||||
<el-input v-model.trim="form.buildTall" maxlength="4" placeholder="请输入楼高(m)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="楼栋结构" prop="buildStructure">
|
||||
<el-input v-model.trim="form.buildStructure" maxlength="30" placeholder="请输入楼栋结构" />
|
||||
</el-form-item>
|
||||
<el-form-item label="楼层" prop="floorCount">
|
||||
<el-input-number v-model.trim="form.floorCount" :max="200" :min="1" placeholder="楼层数" />
|
||||
</el-form-item>
|
||||
<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 lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import PageHeader from '@/components/Pageheader/index.vue';
|
||||
import { addBuildingApi, editBuildingApi } from '@/api/system/house';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useHouseStore } from '@/store/modules/house';
|
||||
import { validator } from '@/utils/Reg';
|
||||
|
||||
const houseStore = useHouseStore();
|
||||
const houseFormat = ['北', '东北', '东', '东南', '南', '西南', '西', '西北'];
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const formRef = ref();
|
||||
const form = ref({
|
||||
buildingName: '',
|
||||
buildToward: '',
|
||||
buildTall: '',
|
||||
buildStructure: '',
|
||||
floorCount: 1
|
||||
});
|
||||
const rules = ref({
|
||||
buildingName: [
|
||||
{ required: true, message: '请输入楼栋名称', trigger: 'blur' },
|
||||
{
|
||||
validator: (_: any, val: string | number, callback: (arg0?: Error) => void) => {
|
||||
if (val === '' || val === null || val === undefined) {
|
||||
return callback(new Error('请输入名称'));
|
||||
}
|
||||
return validator(val, 'Character') ? callback() : callback(new Error('请输入中文,字母,数字,-,_等字符'));
|
||||
}
|
||||
}
|
||||
],
|
||||
buildTall: [
|
||||
{ required: false, message: '请输入楼高', trigger: 'blur' },
|
||||
{
|
||||
validator: (_: any, val: string | number, callback: (arg0?: Error) => void) => {
|
||||
if (val === '') {
|
||||
return callback();
|
||||
}
|
||||
const num = Number(val);
|
||||
if (Number.isNaN(num)) {
|
||||
return callback(new Error('请输入数字'));
|
||||
}
|
||||
return validator(num, 'number') ? callback() : callback(new Error('请输入数字'));
|
||||
}
|
||||
}
|
||||
],
|
||||
unitCount: [{ required: true, message: '请输入单元数', trigger: 'blur' }],
|
||||
floorCount: [{ required: true, message: '请输入楼层数', trigger: 'blur' }]
|
||||
});
|
||||
// 判断新增还是编辑
|
||||
const buildingId = route.query.buildingId as string;
|
||||
if (buildingId) {
|
||||
getBuildingById();
|
||||
} else {
|
||||
}
|
||||
|
||||
/** 编辑楼栋 */
|
||||
function getBuildingById() {
|
||||
houseStore.currentBuildingInfoList.forEach((item) => {
|
||||
if (item.id == buildingId) {
|
||||
form.value.buildingName = item.buildingName;
|
||||
form.value.buildToward = item.buildToward;
|
||||
// form.value.buildingUse = item.buildingUse;
|
||||
form.value.buildTall = item.buildTall;
|
||||
form.value.buildStructure = item.buildStructure;
|
||||
// form.value.unitCount = item.unitCount;
|
||||
form.value.floorCount = item.floorCount;
|
||||
}
|
||||
});
|
||||
}
|
||||
const submitForm = () => {
|
||||
formRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
if (buildingId) {
|
||||
editBuildingApi({
|
||||
...form.value,
|
||||
id: buildingId
|
||||
})
|
||||
.then(() => {
|
||||
ElMessage.success('修改成功');
|
||||
houseStore.updateHouse();
|
||||
cancelForm();
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage.error('修改失败');
|
||||
});
|
||||
} else {
|
||||
addBuildingApi({
|
||||
...form.value
|
||||
})
|
||||
.then(() => {
|
||||
ElMessage.success('添加成功');
|
||||
houseStore.updateHouse();
|
||||
cancelForm();
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage.error('添加失败');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
const cancelForm = () => {
|
||||
formRef.value?.resetFields();
|
||||
goBack();
|
||||
};
|
||||
|
||||
function goBack() {
|
||||
router.back();
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.BackBox {
|
||||
width: 100px;
|
||||
height: 45px;
|
||||
line-height: 40px;
|
||||
text-align: center;
|
||||
border-radius: 5px;
|
||||
color: rgba(16, 16, 16, 1);
|
||||
border: 1px solid rgba(187, 187, 187, 1);
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
&:hover {
|
||||
box-shadow: 0 2px 6px 0 rgba(26, 117, 255, 0.1);
|
||||
}
|
||||
}
|
||||
.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;
|
||||
}
|
||||
.addBuildingFormBody {
|
||||
.formBody {
|
||||
width: 550px;
|
||||
margin: 0 auto;
|
||||
.el-form-item {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.el-button {
|
||||
width: 80px;
|
||||
height: 35px;
|
||||
margin-right: 20px;
|
||||
}
|
||||
}
|
||||
padding-bottom: 40px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,439 +0,0 @@
|
||||
<template>
|
||||
<div class="AddBuildingBox">
|
||||
<PageHeader></PageHeader>
|
||||
<div class="AddBuildingBody">
|
||||
<div class="title">基本信息</div>
|
||||
<div class="addBuildingFormBody">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" class="formBody" label-position="right" label-width="100px">
|
||||
<el-form-item label="楼栋" prop="buildingId">
|
||||
<el-select v-model="form.buildingId" placeholder="请选择" @change="handleChangeBuild">
|
||||
<el-option v-for="item in houseStore.currentBuildingInfoList" :key="item.id" :label="item.buildingName" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="房屋类型" prop="houseUseTypeId">
|
||||
<el-select v-model="form.houseUseTypeId" placeholder="请选择">
|
||||
<el-option v-for="item in houseUseTypeList" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="单元" prop="unitNoId">
|
||||
<el-select v-model="form.unitNoId" placeholder="请选择" @change="changeUnitNo">
|
||||
<el-option v-for="item in units" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="楼层" prop="floorNo">
|
||||
<el-select v-model.number="form.floorNo" placeholder="请选择">
|
||||
<el-option v-for="item in floors" :key="item.no" :label="item.name" :value="item.no" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="房间号" prop="houseNo">
|
||||
<el-input v-model.trim="form.houseNo" maxlength="15" placeholder="请输入房间号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="建筑面积" prop="houseArea">
|
||||
<div class="unitBox flex align-center">
|
||||
<el-input v-model.trim.number="form.houseArea" maxlength="8" placeholder="请输入建筑面积" />
|
||||
<span>㎡</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="套内面积" prop="internalArea">
|
||||
<div class="unitBox flex align-center">
|
||||
<el-input v-model.trim.number="form.internalArea" maxlength="8" placeholder="请输入套内面积" />
|
||||
<span>㎡</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="公摊面积" prop="shareArea">
|
||||
<div class="unitBox flex align-center">
|
||||
<el-input v-model.trim.number="form.shareArea" maxlength="8" placeholder="请输入公摊面积" />
|
||||
<span>㎡</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="房屋户型">
|
||||
<div class="houseTypebox">
|
||||
<el-input v-model.trim="houseType[0]" maxlength="3" placeholder="房间" @change="changeHouseType($event, 0)" />
|
||||
<span>室</span>
|
||||
<el-input v-model.trim="houseType[1]" maxlength="3" placeholder="客厅" @change="changeHouseType($event, 1)" />
|
||||
<span>厅</span>
|
||||
<el-input v-model.trim="houseType[2]" maxlength="3" placeholder="卫生间" @change="changeHouseType($event, 2)" />
|
||||
<span>卫</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="车位号" prop="parkingIds">
|
||||
<el-select v-model="form.parkingIds" class="m-2" multiple placeholder="请选择车位号">
|
||||
<el-option v-for="(item, index) in parkingList" :key="index" :label="item.parkingName" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="储藏室" prop="storeroomId">
|
||||
<el-select v-model="form.storeroomId" class="m-2" clearable placeholder="请选择储藏室" @clear="handleClearStoreRoomId">
|
||||
<el-option v-for="(item, index) in storeRoomList" :key="index" :label="item.storeroomName" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<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 lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import PageHeader from '@/components/Pageheader/index.vue';
|
||||
import { useHouseStore } from '@/store/modules/house';
|
||||
import { addHouseAPI, EditHouseApi, getHouseApi } from '@/api/system/house';
|
||||
import { addHouseType } from '@/api/system/house/type';
|
||||
import { GetVillageListParking } from '@/api/system/parking';
|
||||
import { GetVillagelistStoreroom } from '@/api/system/storeroom';
|
||||
import { listHouseUseType_add_house } from '@/api/system/houseUse';
|
||||
import { getByBUildingidtoUnitNo } from '@/api/system/houseUnit';
|
||||
import { validator } from '@/utils/Reg';
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const houseStore = useHouseStore();
|
||||
const formRef = ref();
|
||||
const form = ref<addHouseType>({
|
||||
buildingId: '',
|
||||
houseUseTypeId: '', // 房屋用途
|
||||
unitNoId: '',
|
||||
floorNo: '',
|
||||
houseNo: '', // 房 间 号
|
||||
houseArea: '', //建筑面积
|
||||
internalArea: '', //套内面积
|
||||
shareArea: '', // 公摊面积
|
||||
houseType: '', // 房屋户型
|
||||
storeroomId: '', // 储藏室
|
||||
parkingIds: [] // 车位
|
||||
});
|
||||
const rules = ref({
|
||||
buildingId: [{ required: true, message: '请输入楼栋', trigger: 'blur' }],
|
||||
unitNoId: [{ required: true, message: '请选择单元', trigger: 'blur' }],
|
||||
floorNo: [{ required: true, message: '请选择楼层', trigger: 'blur' }],
|
||||
houseUseTypeId: [{ required: true, message: '请选择房屋用途', trigger: 'blur' }],
|
||||
buildingName: [{ required: true, message: '请输入房间号', trigger: 'blur' }],
|
||||
houseNo: [
|
||||
{ required: true, message: '请输入房间号', trigger: 'blur' },
|
||||
{
|
||||
validator: (_: any, val: string | number, callback: (arg0?: Error) => void) => {
|
||||
if (val === '' || val === null || val === undefined) {
|
||||
return callback(new Error('请输入名称'));
|
||||
}
|
||||
return validator(val, 'Character') ? callback() : callback(new Error('请输入中文,字母,数字,-,_等字符'));
|
||||
}
|
||||
}
|
||||
],
|
||||
buildingArea: [{ required: true, message: '请输入建筑面积', trigger: 'blur' }],
|
||||
internalFloorArea: [{ required: true, message: '请输入套内面积', trigger: 'blur' }],
|
||||
CommonArea: [{ required: true, message: '请输入公摊面积', trigger: 'blur' }],
|
||||
houseArea: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入建筑面积',
|
||||
trigger: 'blur'
|
||||
},
|
||||
{
|
||||
validator: (_: any, value: string, callback: (arg0?: Error) => void) => {
|
||||
if (value === '' || value === null) {
|
||||
return callback(new Error('请输入建筑面积'));
|
||||
} else {
|
||||
const val = Number(value);
|
||||
if (Number.isNaN(val)) {
|
||||
return callback(new Error('请输入数字'));
|
||||
}
|
||||
if (val < 0 || val > 99999999) {
|
||||
ElMessage.error('房屋面积超出合法范围');
|
||||
return;
|
||||
}
|
||||
return callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
internalArea: [
|
||||
{
|
||||
required: false,
|
||||
message: '请输入套内面积',
|
||||
trigger: 'blur'
|
||||
},
|
||||
{
|
||||
validator: (_: any, value: string, callback: (arg0?: Error) => void) => {
|
||||
if (value === '' || value === null) {
|
||||
return callback();
|
||||
}
|
||||
const val = Number(value);
|
||||
if (Number.isNaN(val)) {
|
||||
return callback(new Error('请输入数字'));
|
||||
}
|
||||
if (val <= 0) {
|
||||
return callback(new Error('请输入大于0的数字'));
|
||||
}
|
||||
return callback();
|
||||
}
|
||||
}
|
||||
],
|
||||
shareArea: [
|
||||
{
|
||||
required: false,
|
||||
message: '请输入公摊面积',
|
||||
trigger: 'blur'
|
||||
},
|
||||
{
|
||||
validator: (_: any, value: string, callback: (arg0?: Error) => void) => {
|
||||
if (value === '' || value === null) {
|
||||
return callback();
|
||||
}
|
||||
const val = Number(value);
|
||||
if (Number.isNaN(val)) {
|
||||
return callback(new Error('请输入数字'));
|
||||
}
|
||||
if (val <= 0) {
|
||||
return callback(new Error('请输入大于0的数字'));
|
||||
}
|
||||
return callback();
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
const houseType = ref([]);
|
||||
const units = ref([]);
|
||||
const floors = ref([]);
|
||||
|
||||
const houseId = ref(null);
|
||||
|
||||
// 车位列表
|
||||
const parkingList = ref([]);
|
||||
// 储藏室列表
|
||||
const storeRoomList = ref([]);
|
||||
|
||||
const queryChangeStore = ref({
|
||||
// buildingId
|
||||
buildingId: null,
|
||||
// unitNo,
|
||||
unitNoId: null
|
||||
});
|
||||
const villageid = localStorage.getItem('villageid');
|
||||
async function init() {
|
||||
if (route.query.id) {
|
||||
houseId.value = route.query.id;
|
||||
}
|
||||
await nextTick(() => getEditInfo());
|
||||
}
|
||||
init();
|
||||
|
||||
const houseUseTypeList = ref([]);
|
||||
async function getEditInfo() {
|
||||
listHouseUseType_add_house().then((res) => {
|
||||
houseUseTypeList.value = res.data;
|
||||
});
|
||||
// 车位列表 = 当前房屋绑定车位 + 无人绑定车位
|
||||
GetVillageListParking(villageid, houseId.value).then((res) => {
|
||||
parkingList.value = res.data;
|
||||
});
|
||||
GetVillagelistStoreroom({
|
||||
...queryChangeStore.value,
|
||||
villageid: villageid,
|
||||
houseId: houseId.value
|
||||
}).then((res) => {
|
||||
storeRoomList.value = res.data.filter((item) => item);
|
||||
});
|
||||
|
||||
if (route.query.id) {
|
||||
getHouseApi(houseId.value).then((res) => {
|
||||
form.value = {
|
||||
...form.value,
|
||||
buildingId: res.data.buildingId, // 楼栋id
|
||||
houseId: res.data.houseId, // 房屋id
|
||||
unitNoId: res.data.unitNoId,
|
||||
floorNo: res.data.floorNo,
|
||||
houseNo: res.data.houseNo, // 房 间 号
|
||||
houseArea: res.data.houseArea, //建筑面积
|
||||
internalArea: res.data.internalArea, //套内面积
|
||||
storeroomId: res.data.storeroomId, //储藏室
|
||||
parkingIds: res.data.parkingIds ?? [], //车位
|
||||
houseUseTypeId: res.data.houseUseTypeId,
|
||||
shareArea: res.data.shareArea // 公摊面积
|
||||
};
|
||||
houseType.value = res.data.houseType ? res.data.houseType.split('') : [];
|
||||
queryChangeStore.value.buildingId = form.value.buildingId;
|
||||
changeBuild(res.data.buildingId);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 清空储藏室
|
||||
function handleClearStoreRoomId() {
|
||||
form.value.storeroomId = '';
|
||||
}
|
||||
// 选择楼栋
|
||||
function handleChangeBuild(id: string) {
|
||||
queryChangeStore.value.buildingId = id;
|
||||
form.value.unitNoId = '';
|
||||
form.value.floorNo = '';
|
||||
changeBuild(id);
|
||||
getStoreRoomList();
|
||||
}
|
||||
|
||||
function changeBuild(id: string) {
|
||||
// 根据楼栋id获取单元
|
||||
const arr = houseStore.currentBuildingInfoList;
|
||||
const find = arr.find((item) => item.id === id);
|
||||
if (find) {
|
||||
floors.value = Array.from({ length: find.floorCount }).map((_, index) => {
|
||||
return {
|
||||
no: index + 1,
|
||||
name: index + 1 + '楼'
|
||||
};
|
||||
});
|
||||
}
|
||||
// 获取单元
|
||||
getByBUildingidtoUnitNo(id).then((res) => {
|
||||
units.value = [];
|
||||
units.value = res.data;
|
||||
});
|
||||
}
|
||||
|
||||
// change unitNoId
|
||||
function changeUnitNo(id: string) {
|
||||
form.value.unitNoId = '';
|
||||
form.value.unitNoId = id;
|
||||
queryChangeStore.value.unitNoId = id;
|
||||
form.value.floorNo = '';
|
||||
getStoreRoomList();
|
||||
}
|
||||
|
||||
// 查询储藏室列表
|
||||
function getStoreRoomList() {
|
||||
GetVillagelistStoreroom({
|
||||
...queryChangeStore.value,
|
||||
villageid: villageid
|
||||
}).then((res) => {
|
||||
form.value.storeroomId = '';
|
||||
storeRoomList.value = [];
|
||||
storeRoomList.value = res.data;
|
||||
});
|
||||
}
|
||||
|
||||
// 客厅卫不能小于0个
|
||||
function changeHouseType(val: string, index: number) {
|
||||
const num = Number(val);
|
||||
if (Number.isNaN(num)) {
|
||||
houseType.value[index] = '0';
|
||||
} else {
|
||||
houseType.value[index] = num.toFixed(0);
|
||||
}
|
||||
}
|
||||
|
||||
const submitForm = () => {
|
||||
const houseArea = Number(form.value.houseArea) ?? 0;
|
||||
if (houseArea <= 0) {
|
||||
ElMessage.warning('建筑面积不能为0');
|
||||
return;
|
||||
}
|
||||
const shareArea = Number(form.value.shareArea) ?? 0;
|
||||
const internalArea = Number(form.value.internalArea) ?? 0;
|
||||
// 有 公摊面积 / 房屋面积
|
||||
if (shareArea || internalArea) {
|
||||
if (shareArea + internalArea !== Number(form.value.houseArea)) {
|
||||
return ElMessage.warning('填写的【套内面积】+【公摊面积】计算结果,和【建筑面积】不相等');
|
||||
}
|
||||
}
|
||||
formRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
const data = {
|
||||
...form.value,
|
||||
houseType: houseType.value.join(''),
|
||||
villageId: houseStore.currentBuildingInfo.villageId
|
||||
};
|
||||
if (houseId.value) {
|
||||
EditHouseApi(data).then(() => {
|
||||
ElMessage.success('修改成功');
|
||||
houseStore.updateCureentBuilding();
|
||||
router.push({
|
||||
path: '/house/houselist'
|
||||
});
|
||||
});
|
||||
} else {
|
||||
addHouseAPI(data).then(() => {
|
||||
ElMessage.success('添加成功');
|
||||
houseStore.updateCureentBuilding();
|
||||
router.push({
|
||||
path: '/house/houselist'
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const cancelForm = () => {
|
||||
formRef?.value.resetFields();
|
||||
router.back();
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.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;
|
||||
}
|
||||
|
||||
.addBuildingFormBody {
|
||||
.formBody {
|
||||
width: 550px;
|
||||
margin: 0 auto;
|
||||
|
||||
.el-form-item__content,
|
||||
.el-select,
|
||||
.el-input {
|
||||
width: 440px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
.el-form-item {
|
||||
margin-bottom: 20px;
|
||||
align-items: center;
|
||||
}
|
||||
.unitBox {
|
||||
.el-input {
|
||||
width: 440px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
}
|
||||
.el-button {
|
||||
width: 80px;
|
||||
height: 35px;
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
||||
.houseTypebox {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
.el-input {
|
||||
width: 100px;
|
||||
margin-right: 0;
|
||||
}
|
||||
span {
|
||||
margin: 0 20px;
|
||||
}
|
||||
}
|
||||
}
|
||||
padding-bottom: 40px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,181 +0,0 @@
|
||||
<template>
|
||||
<div class="AddBuildingBox">
|
||||
<PageHeader>
|
||||
<template #operate>
|
||||
<div class="BackBox" @click="goBack">返回</div>
|
||||
</template>
|
||||
</PageHeader>
|
||||
<div class="AddBuildingBody">
|
||||
<div class="title">基本信息</div>
|
||||
<div class="addBuildingFormBody">
|
||||
<el-form ref="unitNoFormRef" :model="form" :rules="rules" class="formBody" label-width="80px">
|
||||
<el-form-item label="单元名称" prop="name">
|
||||
<el-input v-model.trim="form.name" maxlength="6" placeholder="请输入单元名称" show-word-limit />
|
||||
</el-form-item>
|
||||
<el-form-item label="楼栋" prop="buildingId">
|
||||
<el-select v-model="form.buildingId" placeholder="请选择">
|
||||
<el-option v-for="item in houseStore.currentBuildingInfoList" :key="item.id" :label="item.buildingName" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<div class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">重 置</el-button>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import PageHeader from '@/components/Pageheader/index.vue';
|
||||
import { addUnitNo, getUnitNo, updateUnitNo } from '@/api/system/houseUnit';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useHouseStore } from '@/store/modules/house';
|
||||
import { validator } from '@/utils/Reg';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const houseStore = useHouseStore();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const unitNoFormRef = ref();
|
||||
const buttonLoading = ref(false);
|
||||
const form = ref({
|
||||
id: undefined,
|
||||
name: undefined,
|
||||
buildingId: undefined
|
||||
});
|
||||
const rules = ref({
|
||||
name: [
|
||||
{ required: true, message: '单元名称不能为空', trigger: 'blur' },
|
||||
{
|
||||
validator: (_: any, value: string, callback: (error?: Error) => void) => {
|
||||
if (!value || value.trim() === '') {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
// 使用 Character 正则验证(只允许字母、数字、中文、下划线、横线)
|
||||
const isValid = validator(value, 'Character');
|
||||
if (!isValid) {
|
||||
callback(new Error('只能输入中文、字母、数字、下划线和横线'));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
buildingId: [{ required: true, message: '所属楼栋不能为空', trigger: 'blur' }]
|
||||
});
|
||||
|
||||
function init() {
|
||||
const unitId = route.query.id as string;
|
||||
if (unitId) {
|
||||
getUnitNo(unitId).then((res) => {
|
||||
form.value = {
|
||||
id: res.data.id,
|
||||
name: res.data.name,
|
||||
buildingId: res.data.buildingId
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
onMounted(() => {
|
||||
init();
|
||||
});
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
unitNoFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
if (form.value.id) {
|
||||
await updateUnitNo(form.value)
|
||||
.then(() => {
|
||||
goBack();
|
||||
})
|
||||
.finally(() => {
|
||||
buttonLoading.value = false;
|
||||
});
|
||||
} else {
|
||||
await addUnitNo(form.value)
|
||||
.then(() => {
|
||||
goBack();
|
||||
})
|
||||
.finally(() => {
|
||||
buttonLoading.value = false;
|
||||
});
|
||||
}
|
||||
proxy?.$modal.msgSuccess('操作成功');
|
||||
}
|
||||
});
|
||||
};
|
||||
/** 取消按钮 */
|
||||
const cancel = () => {
|
||||
resetForm();
|
||||
};
|
||||
/** 表单重置 */
|
||||
const resetForm = () => {
|
||||
form.value = { id: undefined, name: undefined, buildingId: undefined };
|
||||
unitNoFormRef.value?.resetFields();
|
||||
init();
|
||||
};
|
||||
function goBack() {
|
||||
router.back();
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.BackBox {
|
||||
width: 100px;
|
||||
height: 45px;
|
||||
line-height: 40px;
|
||||
text-align: center;
|
||||
border-radius: 5px;
|
||||
color: rgba(16, 16, 16, 1);
|
||||
border: 1px solid rgba(187, 187, 187, 1);
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
&:hover {
|
||||
box-shadow: 0 2px 6px 0 rgba(26, 117, 255, 0.1);
|
||||
}
|
||||
}
|
||||
.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;
|
||||
}
|
||||
.addBuildingFormBody {
|
||||
.formBody {
|
||||
width: 550px;
|
||||
margin: 0 auto;
|
||||
.el-form-item {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.el-button {
|
||||
width: 80px;
|
||||
height: 35px;
|
||||
margin-right: 20px;
|
||||
}
|
||||
}
|
||||
padding-bottom: 40px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,57 +0,0 @@
|
||||
export interface Response {
|
||||
code: number;
|
||||
data: Data;
|
||||
msg: string;
|
||||
}
|
||||
|
||||
export interface Data {
|
||||
billResidentList: BillResidentList[];
|
||||
chargeItemList: string[];
|
||||
house: House;
|
||||
parking: null;
|
||||
residentList: ResidentList[];
|
||||
storeroom: Storeroom;
|
||||
}
|
||||
|
||||
export interface BillResidentList {
|
||||
billCode: string;
|
||||
billName: string;
|
||||
chargeItemId: string;
|
||||
chargeTypeName: string;
|
||||
money: string;
|
||||
payStatus: string;
|
||||
useCount: string;
|
||||
}
|
||||
|
||||
export interface House {
|
||||
buildingName: string;
|
||||
floorNo: number;
|
||||
houseArea: string;
|
||||
houseId: number;
|
||||
houseNo: string;
|
||||
houseType: string;
|
||||
internalArea: string;
|
||||
shareArea: string;
|
||||
unitNo: number;
|
||||
villageName: string;
|
||||
}
|
||||
|
||||
export interface ResidentList {
|
||||
gender: string;
|
||||
ownerRelationship: string;
|
||||
phone: string;
|
||||
residentId: string;
|
||||
residentName: string;
|
||||
residentStatus: string;
|
||||
residentType: string;
|
||||
}
|
||||
|
||||
export interface Storeroom {
|
||||
buildingName: string;
|
||||
houseArea: string;
|
||||
internalArea: string;
|
||||
shareArea: string;
|
||||
storeroomId: number;
|
||||
storeroomNo: string;
|
||||
unitNo: number;
|
||||
}
|
||||
@@ -45,21 +45,19 @@
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" border :data="list">
|
||||
<el-table-column label="项目" prop="villageName" align="center" min-width="100" />
|
||||
<el-table-column label="房号" prop="houseNo" align="center" min-width="90" />
|
||||
<el-table-column label="房屋名称" prop="houseName" align="center" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column label="承租方" align="center" min-width="100">
|
||||
<el-table-column label="房屋名称" prop="houseName" align="center" show-overflow-tooltip />
|
||||
<el-table-column label="承租方" align="center" >
|
||||
<template #default="scope">{{ scope.row.lesseeName || '--' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="联系电话" align="center" min-width="120">
|
||||
<el-table-column label="联系电话" align="center" >
|
||||
<template #default="scope">{{ scope.row.lesseePhone || '--' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="设备编码" prop="deviceCodes" align="center" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column label="设备数量" prop="deviceCount" align="center" width="90" />
|
||||
<el-table-column label="房屋用电量(度)" align="center" width="130">
|
||||
<el-table-column label="设备编码" prop="deviceCodes" align="center" show-overflow-tooltip />
|
||||
<el-table-column label="设备数量" prop="deviceCount" align="center" />
|
||||
<el-table-column label="房屋用电量(度)" align="center" >
|
||||
<template #default="scope">{{ formatNumber(scope.row.usageEnergy) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="公摊用电量(度)" align="center" width="130">
|
||||
<el-table-column label="公摊用电量(度)" align="center" >
|
||||
<template #default="scope">{{ formatNumber(scope.row.shareUsageEnergy) }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
Reference in New Issue
Block a user