临时添加
This commit is contained in:
@@ -3,7 +3,19 @@ import { communitylist_rows_type } from '@/api/system/community/type';
|
||||
import { getBuildinglistAPI, getHouselistAPI } from '@/api/system/house';
|
||||
import { BuildingUnit, BuildingVo } from '@/api/system/house/type';
|
||||
import { defineStore } from 'pinia';
|
||||
// 数字排序
|
||||
function sortNumberStr(a: string, b: string) {
|
||||
const numA = parseFloat(a);
|
||||
const numB = parseFloat(b);
|
||||
|
||||
// 如果都是有效数字 → 按数字大小排(支持负数、小数)
|
||||
if (!isNaN(numA) && !isNaN(numB)) {
|
||||
return numA - numB;
|
||||
}
|
||||
|
||||
// 否则按自然语言排
|
||||
return a.localeCompare(b, 'zh-CN', { numeric: true });
|
||||
}
|
||||
export const useHouseStore = defineStore('house', () => {
|
||||
// 当前小区信息
|
||||
const currentVilageInfo = ref<communitylist_rows_type>();
|
||||
@@ -11,13 +23,32 @@ export const useHouseStore = defineStore('house', () => {
|
||||
// 当前小区 所有楼栋信息
|
||||
const currentBuildingInfoList = ref<BuildingVo[]>([]);
|
||||
// 当前楼栋信息
|
||||
const currentBuildingInfo = ref<BuildingVo>();
|
||||
const currentBuildingInfo = ref<BuildingVo>({
|
||||
'id': null,
|
||||
'villageId': null,
|
||||
'villageName': '',
|
||||
'buildingName': '',
|
||||
'buildingUse': null,
|
||||
'buildToward': '',
|
||||
'buildTall': '',
|
||||
'buildStructure': '',
|
||||
'unitCount': null,
|
||||
'floorCount': null,
|
||||
'remark': ''
|
||||
});
|
||||
|
||||
// 当前楼栋 所有房屋信息
|
||||
const currentHouseInfoList = ref<BuildingUnit[]>([]);
|
||||
|
||||
// 当前楼栋 所有楼层数据
|
||||
const currentFloorInfoList = ref<string[]>([]);
|
||||
// 最大楼层
|
||||
const maxFloors = ref(0);
|
||||
// 楼层列表 set
|
||||
const floorslist = ref<Set<string>>(new Set());
|
||||
// 初始化
|
||||
const initHouse = async (buildingtype: number) => {
|
||||
// 查找当前小区
|
||||
const res = await getCommunitylistAPI();
|
||||
const currentVilage = res.rows.find((item) => item.choiceStatus === 0);
|
||||
currentVilageInfo.value = currentVilage;
|
||||
@@ -26,9 +57,20 @@ export const useHouseStore = defineStore('house', () => {
|
||||
currentBuildingInfoList.value = res2.data;
|
||||
// 获取当前小区 楼栋信息
|
||||
currentBuildingInfo.value = res2.data[0];
|
||||
console.log(currentBuildingInfo.value);
|
||||
|
||||
// 获取当前楼栋 所有房屋信息
|
||||
const res3 = await getHouselistAPI(currentBuildingInfo.value.id);
|
||||
currentHouseInfoList.value = res3.data;
|
||||
currentHouseInfoList.value.forEach((item) => {
|
||||
maxFloors.value = Math.max(maxFloors.value, item.actualFloorCount);
|
||||
item.floors_Json = JSON.parse(`[${item.floors.replaceAll('\\', '')}]`);
|
||||
item.floors_Json.forEach((floor) => {
|
||||
floorslist.value.add(floor.floorNo);
|
||||
});
|
||||
});
|
||||
// 对当前小区的 楼层进行排序
|
||||
currentFloorInfoList.value = (Array.from(floorslist.value) as string[]).sort(sortNumberStr);
|
||||
};
|
||||
|
||||
// 切换住宅类型
|
||||
@@ -48,6 +90,7 @@ export const useHouseStore = defineStore('house', () => {
|
||||
currentBuildingInfoList,
|
||||
currentBuildingInfo,
|
||||
currentHouseInfoList,
|
||||
currentFloorInfoList,
|
||||
initHouse,
|
||||
switchHouseType,
|
||||
switchBuilding
|
||||
|
||||
Reference in New Issue
Block a user