完成小区相关的接口对接
This commit is contained in:
@@ -1,16 +1,55 @@
|
||||
import { getCommunitylistAPI } from '@/api/system/community';
|
||||
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';
|
||||
import { reactive } from 'vue';
|
||||
|
||||
export const useHouseStore = defineStore('house', () => {
|
||||
const state = reactive({
|
||||
// 小区信息
|
||||
communityInfo: {},
|
||||
// 楼栋信息
|
||||
houseList: [],
|
||||
// 房屋信息
|
||||
houseInfo: {}
|
||||
});
|
||||
// 当前小区信息
|
||||
const currentVilageInfo = ref<communitylist_rows_type>();
|
||||
|
||||
// 当前小区 所有楼栋信息
|
||||
const currentBuildingInfoList = ref<BuildingVo[]>([]);
|
||||
// 当前楼栋信息
|
||||
const currentBuildingInfo = ref<BuildingVo>();
|
||||
|
||||
// 当前楼栋 所有房屋信息
|
||||
const currentHouseInfoList = ref<BuildingUnit[]>([]);
|
||||
|
||||
// 初始化
|
||||
const initHouse = async (buildingtype: number) => {
|
||||
const res = await getCommunitylistAPI();
|
||||
const currentVilage = res.rows.find((item) => item.choiceStatus === 0);
|
||||
currentVilageInfo.value = currentVilage;
|
||||
// 获取当前小区 所有楼栋信息
|
||||
const res2 = await getBuildinglistAPI(currentVilage.villageId, buildingtype);
|
||||
currentBuildingInfoList.value = res2.data;
|
||||
// 获取当前小区 楼栋信息
|
||||
currentBuildingInfo.value = res2.data[0];
|
||||
// 获取当前楼栋 所有房屋信息
|
||||
const res3 = await getHouselistAPI(currentBuildingInfo.value.id);
|
||||
currentHouseInfoList.value = res3.data;
|
||||
};
|
||||
|
||||
// 切换住宅类型
|
||||
const switchHouseType = (housetype: 0 | 1 | 2 | 3) => {
|
||||
getBuildinglistAPI(currentVilageInfo.value.villageId, housetype)
|
||||
.then(() => ElMessage.success('切换成功'))
|
||||
.catch(() => ElMessage.error('切换失败'));
|
||||
};
|
||||
|
||||
// 切换楼栋
|
||||
const switchBuilding = (buildingId: number) => {
|
||||
getHouselistAPI(buildingId).then(() => ElMessage.success('切换成功'));
|
||||
};
|
||||
|
||||
return {
|
||||
state
|
||||
currentVilageInfo,
|
||||
currentBuildingInfoList,
|
||||
currentBuildingInfo,
|
||||
currentHouseInfoList,
|
||||
initHouse,
|
||||
switchHouseType,
|
||||
switchBuilding
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user