物业之前,新工作台

This commit is contained in:
Zy
2026-04-16 21:03:35 +08:00
parent cf9a1f1585
commit 4184f1c55d
91 changed files with 1781 additions and 588 deletions

View File

@@ -1,4 +1,4 @@
import { getCommunitylistAPI } from '@/api/system/community';
import { getCommunitylistAPI, getVillageByIdAPI } from '@/api/system/community';
import { communitylist_rows_type } from '@/api/system/community/type';
import { deleteHouseApi, getBuildinglistAPI, getHouselistAPI, getVillageTree } from '@/api/system/house';
import type { addBuildingType, BuildingUnit, BuildingVo } from '@/api/system/house/type';
@@ -51,38 +51,55 @@ export const useHouseStore = defineStore(
// 当前楼栋 所有楼层数据
const currentFloorInfoList = computed(() => {
return (Array.from(floorslist.value) as string[]).sort(sortNumberStr);
return [...floorslist.value].sort(sortNumberStr);
});
// 楼层列表 set
const floorslist = ref<Set<string>>(new Set());
//
// 查找当前小区
const getviliageinfo = async (id) => {
const res = await getVillageByIdAPI(id);
currentVilageInfo.value = res.data;
};
// 更新小区信息
const updateVilageinfo = (data) => {
currentVilageInfo.value = data;
};
// 初始化
const initHouse = async (buildingtype: number) => {
// 查找当前小区
const res = await getCommunitylistAPI();
const currentVilage = res.rows.find((item) => item.choiceStatus === 0);
currentVilageInfo.value = currentVilage;
const initHouse = async (currentbuildingtype: number) => {
currentBuildingInfoList.value = [];
// 获取当前小区 所有楼栋信息
const res2 = await getBuildinglistAPI(currentVilage.villageId, buildingtype);
const res2 = await getBuildinglistAPI(currentVilageInfo.value.villageId, currentbuildingtype);
currentBuildingInfoList.value = res2.data;
// 获取当前小区 第一个楼栋信息
if (currentBuildingInfo.value.id === null) {
// ! 不同住宅类型
if ((currentBuildingInfo.value && currentBuildingInfo.value.id === null) || buildingtype.value !== currentbuildingtype) {
currentBuildingInfo.value = res2.data[0];
} else {
// ! 相同住宅类型
} else if (buildingtype.value === currentbuildingtype) {
// 更新当前楼栋的 信息
currentBuildingInfo.value = res2.data.find((item) => item.id === currentBuildingInfo.value.id);
}
// 获取当前 第一个楼栋的所有信息
const res3 = await getHouselistAPI(currentBuildingInfo.value.id);
currentHouseInfoList.value = res3.data;
floorslist.value = new Set();
// 得到所有的有房屋的 楼层 数组
currentHouseInfoList.value.units.forEach((item) => {
item.floors.forEach((floor) => {
floorslist.value.add(floor.floorNo);
if (currentBuildingInfo.value && currentBuildingInfo.value.id) {
// 获取当前 第一个楼栋的所有信息
const res3 = await getHouselistAPI(currentBuildingInfo.value.id);
currentHouseInfoList.value = res3.data;
floorslist.value = new Set();
// 得到所有的有房屋的 楼层 数组
currentHouseInfoList.value.units.forEach((item) => {
item.floors.forEach((floor) => {
floorslist.value.add(floor.floorNo);
});
});
});
if (buildingtype.value !== currentbuildingtype) {
buildingtype.value = currentbuildingtype;
}
}
};
// 选中的房屋
@@ -93,18 +110,59 @@ export const useHouseStore = defineStore(
};
// 切换住宅类型
const switchHouseType = (housetype: number) => {
getBuildinglistAPI(currentVilageInfo.value.villageId, housetype)
.then(() => {
buildingtype.value = housetype;
initHouse(housetype);
ElMessage.success('切换成功');
})
.catch(() => ElMessage.error('切换失败'));
const switchHouseType = async (housetype: number) => {
// 清空
currentBuildingInfoList.value = [];
// 获取当前小区 所有楼栋信息
const res2 = await getBuildinglistAPI(currentVilageInfo.value.villageId, housetype);
currentBuildingInfoList.value = res2.data;
// 获取当前小区 第一个楼栋信息
if ((currentBuildingInfo.value && currentBuildingInfo.value.id === null) || buildingtype.value !== housetype) {
if (res2.data.length > 0) {
currentBuildingInfo.value = res2.data[0];
} else {
currentBuildingInfo.value = {
'id': null,
'villageId': null,
'villageName': '',
'buildingName': '',
'buildingUse': null,
'buildToward': '',
'buildTall': '',
'buildStructure': '',
'unitCount': null,
'floorCount': null,
'remark': ''
};
}
}
if (currentBuildingInfo.value.id !== null) {
switchBuilding(currentBuildingInfo.value.id);
} else {
floorslist.value = new Set();
}
buildingtype.value = housetype;
console.log(housetype);
ElMessage.success('切换成功');
};
// 更新当前楼栋信息
const updateCureentBuilding = async () => {
currentHouseInfoList.value = null;
// 获取当前 楼栋的所有信息
const res3 = await getHouselistAPI(currentBuildingInfo.value.id);
currentHouseInfoList.value = res3.data;
floorslist.value = new Set();
// 得到所有的有房屋的 楼层 数组
currentHouseInfoList.value.units.forEach((item) => {
item.floors.forEach((floor) => {
floorslist.value.add(floor.floorNo);
});
});
};
// 切换楼栋
const switchBuilding = (buildingId: string) => {
if (!buildingId) return;
// 切换之前 清空当前楼栋信息
currentBuildingInfo.value = {
'id': null,
@@ -122,12 +180,11 @@ export const useHouseStore = defineStore(
currentHouseInfoList.value = null;
getHouselistAPI(buildingId).then((res) => {
currentHouseInfoList.value = res.data;
console.log(currentHouseInfoList.value);
// 获取当前楼栋信息并 赋值
currentBuildingInfo.value = currentBuildingInfoList.value.find((item) => item.id === buildingId);
// 清空 楼层信息
floorslist.value = new Set();
floorslist.value.clear();
// 重新获取楼层信息
currentHouseInfoList.value.units.forEach((item) => {
item.floors.forEach((floor) => {
@@ -144,7 +201,6 @@ export const useHouseStore = defineStore(
};
// 删除指定楼栋
const deleteBuildingFun = (buildingId: string) => {
console.log('删除楼栋');
// 手动 从 楼栋列表中删除 指定楼栋
currentBuildingInfoList.value = currentBuildingInfoList.value.filter((item) => item.id !== buildingId);
// 判断指定楼栋是 当前楼栋
@@ -159,12 +215,20 @@ export const useHouseStore = defineStore(
// 房屋 树状结构类型
const getCurrentVilageTreeHouse = async () => {
const res = await getCommunitylistAPI();
const currentVilage = res.rows.find((item) => item.choiceStatus === 0);
currentVilageInfo.value = currentVilage;
getVillageTree(currentVilageInfo.value.villageId).then((res) => {
treedata.value = convertBuildingToTree(res.data.buildings);
});
if (!currentVilageInfo.value?.villageId) {
treedata.value = [];
return treedata.value;
}
try {
treedata.value = [];
const res = await getVillageTree(currentVilageInfo.value.villageId);
treedata.value = convertBuildingToTree(res.data.buildings || []);
return treedata.value;
} catch (err) {
console.error('获取楼栋树失败:', err);
treedata.value = [];
return treedata.value;
}
};
return {
currentVilageInfo,
@@ -176,6 +240,9 @@ export const useHouseStore = defineStore(
buildingtype,
buildingtypelist,
treedata,
updateVilageinfo,
updateCureentBuilding,
getviliageinfo,
checkoutHousesFun,
initHouse,
switchHouseType,