5.1日 暂定 水电表管理

This commit is contained in:
Zy
2026-05-01 18:36:37 +08:00
parent 7b89144dd4
commit a8bb4e66ad
103 changed files with 1071 additions and 533 deletions

View File

@@ -23,7 +23,7 @@ export const useHouseStore = defineStore(
// 当前小区信息
const currentVilageInfo = ref<communitylist_rows_type>();
// 住宅类型
const buildingtype = ref<number>(0);
const buildingtype = ref<string>('0');
// 住宅列表
const buildingtypelist = ref([]);
// 房屋树状结构
@@ -51,6 +51,9 @@ export const useHouseStore = defineStore(
// 当前楼栋 所有楼层数据
const currentFloorInfoList = computed(() => {
if (floorslist.value.size === 0) {
return [];
}
return [...floorslist.value].sort(sortNumberStr);
});
// 楼层列表 set
@@ -70,10 +73,10 @@ export const useHouseStore = defineStore(
};
// 初始化
const initHouse = async (currentbuildingtype: number) => {
const initHouse = async (currentbuildingtype: string) => {
currentBuildingInfoList.value = [];
// 获取当前小区 所有楼栋信息
const res2 = await getBuildinglistAPI(currentVilageInfo.value.villageId, currentbuildingtype);
const res2 = await getBuildinglistAPI(currentbuildingtype);
currentBuildingInfoList.value = res2.data;
// 获取当前小区 第一个楼栋信息
@@ -111,11 +114,11 @@ export const useHouseStore = defineStore(
};
// 切换住宅类型
const switchHouseType = async (housetype: number) => {
const switchHouseType = async (housetype: string) => {
// 清空
currentBuildingInfoList.value = [];
// 获取当前小区 所有楼栋信息
const res2 = await getBuildinglistAPI(currentVilageInfo.value.villageId, housetype);
const res2 = await getBuildinglistAPI(housetype);
currentBuildingInfoList.value = res2.data;
// 获取当前小区 第一个楼栋信息
if ((currentBuildingInfo.value && currentBuildingInfo.value.id === null) || buildingtype.value !== housetype) {
@@ -143,7 +146,6 @@ export const useHouseStore = defineStore(
floorslist.value = new Set();
}
buildingtype.value = housetype;
console.log(housetype);
ElMessage.success('切换成功');
};

View File

@@ -89,11 +89,9 @@ export const usePermissionStore = defineStore('permission', () => {
const generateRoutes = async (): Promise<RouteRecordRaw[]> => {
const res = await getRouters();
const { data } = res;
console.log('后端原始路由:', data);
// 🔥 关键:先把后端扁平路由转成嵌套格式
const nestedData = transformRoutes(data);
console.log('转换后的嵌套路由:', nestedData);
// 深拷贝数据(保留原有逻辑)
const sdata = JSON.parse(JSON.stringify(nestedData));
@@ -161,6 +159,14 @@ export const usePermissionStore = defineStore('permission', () => {
});
return children;
};
const resetRoutes = () => {
routes.value = [];
addRoutes.value = [];
defaultRoutes.value = [];
topbarRouters.value = [];
sidebarRouters.value = [];
};
return {
routes,
topbarRouters,
@@ -174,7 +180,8 @@ export const usePermissionStore = defineStore('permission', () => {
setRoutes,
generateRoutes,
setSidebarRouters
setSidebarRouters,
resetRoutes
};
});

View File

@@ -42,9 +42,10 @@ export const useUserStore = defineStore('user', () => {
const data = res.data;
const user = data.user;
const profile = user.avatar == '' || user.avatar == null ? defAva : user.avatar;
if (data.user.userId !== 1) {
localStorage.setItem('villageid', data.user.villageId);
}
roles.value = [];
permissions.value = [];
if (data.roles && data.roles.length > 0) {
// 验证返回的roles是否是一个非空数组
roles.value = data.roles;