diff --git a/dist.7z b/dist.7z deleted file mode 100644 index ca995f8..0000000 Binary files a/dist.7z and /dev/null differ diff --git a/package.json b/package.json index f820836..9894194 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "jsencrypt": "3.5.4", "nprogress": "0.2.0", "pinia": "3.0.4", + "pinia-plugin-persistedstate": "^4.7.1", "screenfull": "6.0.2", "vue": "3.5.30", "vue-cropper": "1.1.4", diff --git a/src/api/system/house/index.ts b/src/api/system/house/index.ts index ed883a6..19001d6 100644 --- a/src/api/system/house/index.ts +++ b/src/api/system/house/index.ts @@ -1,10 +1,11 @@ import request from '@/utils/request'; import { AxiosPromise } from 'axios'; -import { addBuildingType, BuildingUnit, BuildingVo } from './type'; +import { addBuildingType, addHouseType, BuildingUnit, BuildingVo } from './type'; import { number } from 'vue-types'; // 楼栋--------------------------------------------------------------------------------------- -// 根据 小区id 和 类型 查询楼栋信息 + +/** 根据 小区id 和 类型 查询楼栋信息 */ export function getBuildinglistAPI(villageId: number, buildingUse: number): AxiosPromise { return request({ url: '/building/byVillage', @@ -15,6 +16,20 @@ export function getBuildinglistAPI(villageId: number, buildingUse: number): Axio } }); } +/** 获取所有楼栋 */ +export function getBuildinglists(): AxiosPromise { + return request({ + url: '/building/list', + method: 'get' + }); +} +/** 获取单一楼栋 */ +export function getBuildingOnly(buildingId: string): AxiosPromise { + return request({ + url: `/building/${buildingId}`, + method: 'get' + }); +} /** 添加楼栋 */ export function addBuildingApi(data: addBuildingType) { @@ -25,7 +40,7 @@ export function addBuildingApi(data: addBuildingType) { }); } /** 编辑楼栋 */ -export function editBuildingApi(data: addBuildingType & { id: number }) { +export function editBuildingApi(data: addBuildingType & { id: string }) { return request({ url: '/building', method: 'PUT', @@ -41,24 +56,42 @@ export function deleteBuildingApi(id: number) { } // 房屋---------------------------------------------------------------------------------------------- -// 根据 楼栋id 查询房屋信息 -export function getHouselistAPI(buildingId: number): AxiosPromise { +/** 根据 楼栋id 查询房屋信息 */ +export function getHouselistAPI(buildingId: string): AxiosPromise { return request({ url: `/house/groupByUnitTree/${buildingId}`, method: 'get' }); } // 添加房屋 -export function addHouseAPI() { +/** 添加房屋 */ +export function addHouseAPI(data: addHouseType) { return request({ url: `/house`, - method: 'POST' + method: 'POST', + data }); } // 删除房屋 -export function deleteHouseApi() { +export function deleteHouseApi(houseIds: string) { return request({ - url: `/house/{houseIds}`, + url: `/house/${houseIds}`, method: 'delete' }); } +// 查询 房屋信息 +export function getHouseApi(houseId: string) { + return request({ + url: `/house/${houseId}`, + method: 'GET' + }); +} + +// 编辑房屋信息 +export function EditHouseApi(data: addHouseType) { + return request({ + url: `/house`, + method: 'PUT', + data + }); +} diff --git a/src/api/system/house/type.ts b/src/api/system/house/type.ts index 913ad26..7435862 100644 --- a/src/api/system/house/type.ts +++ b/src/api/system/house/type.ts @@ -26,7 +26,7 @@ export interface BuildingVo { /** * 楼栋ID */ - id: number; + id: string; /** * 备注 */ @@ -46,6 +46,8 @@ export interface BuildingVo { export interface BuildingUnit { buildingId: number; buildingName: string; + floorCount: number; + unitCount: number; units: BuildingUnitlist[]; } // 单元 @@ -73,3 +75,16 @@ export interface addBuildingType { floorCount?: number; unitCount?: number; } + +export interface addHouseType { + 'houseId'?: string; + 'buildingId'?: string; + 'villageId'?: number; + 'unitNo': string; + 'floorNo': string; + 'houseNo': string; + 'houseArea': string; + 'internalArea': string; + 'shareArea': string; + 'houseType': string; +} diff --git a/src/api/system/resident/index.ts b/src/api/system/resident/index.ts new file mode 100644 index 0000000..213a00e --- /dev/null +++ b/src/api/system/resident/index.ts @@ -0,0 +1,63 @@ +import request from '@/utils/request'; +import { AxiosPromise } from 'axios'; +import { ResidentVO, ResidentForm, ResidentQuery } from '@/api/system/resident/type'; + +/** + * 查询住户管理列表 + * @param query + * @returns {*} + */ + +export const listResident = (query?: ResidentQuery): AxiosPromise => { + return request({ + url: '/resident/list', + method: 'get', + params: query + }); +}; + +/** + * 查询住户管理详细 + * @param id + */ +export const getResident = (id: string | number): AxiosPromise => { + return request({ + url: '/resident/' + id, + method: 'get' + }); +}; + +/** + * 新增住户管理 + * @param data + */ +export const addResident = (data: ResidentForm) => { + return request({ + url: '////resident', + method: 'post', + data: data + }); +}; + +/** + * 修改住户管理 + * @param data + */ +export const updateResident = (data: ResidentForm) => { + return request({ + url: '/resident', + method: 'put', + data: data + }); +}; + +/** + * 删除住户管理 + * @param id + */ +export const delResident = (id: string | number | Array) => { + return request({ + url: '/resident/' + id, + method: 'delete' + }); +}; diff --git a/src/api/system/resident/type.ts b/src/api/system/resident/type.ts new file mode 100644 index 0000000..7adb04c --- /dev/null +++ b/src/api/system/resident/type.ts @@ -0,0 +1,210 @@ +export interface ResidentVO { + /** + * 主键 住户管理id + */ + id: string | number; + + /** + * 住户编号 + */ + code: number; + + /** + * 姓名 + */ + name: string; + + /** + * 0业主 1租户 + */ + type: number; + + /** + * 0 男性 1女性 + */ + gender: number; + + /** + * 身份证号 + */ + idCard: string | number; + + /** + * 手机号码 + */ + phone: number; + + /** + * 小区id + */ + villageId: string | number; + + /** + * 楼栋id + */ + buildingId: string | number; + + /** + * 房屋表id + */ + houseId: string | number; + + /** + * 0审核中 1 已认证 + */ + status: number; + + /** + * 身份证正面照url + */ + cardImageFront: string; + + /** + * 身份证背面照url + */ + cardImageBack: string; + + /** + * 备注 + */ + remark: string; +} + +export interface ResidentForm extends BaseEntity { + /** + * 主键 住户管理id + */ + id?: string | number; + + /** + * 住户编号 + */ + code?: number; + + /** + * 姓名 + */ + name?: string; + + /** + * 0业主 1租户 + */ + type?: number; + + /** + * 0 男性 1女性 + */ + gender?: number; + + /** + * 身份证号 + */ + idCard?: string | number; + + /** + * 手机号码 + */ + phone?: number; + + /** + * 小区id + */ + villageId?: string | number; + + /** + * 楼栋id + */ + buildingId?: string | number; + + /** + * 房屋表id + */ + houseId?: string | number; + + /** + * 0审核中 1 已认证 + */ + status?: number; + + /** + * 身份证正面照url + */ + cardImageFront?: string; + + /** + * 身份证背面照url + */ + cardImageBack?: string; + + /** + * 备注 + */ + remark?: string; +} + +export interface ResidentQuery extends PageQuery { + /** + * 住户编号 + */ + code?: number; + + /** + * 姓名 + */ + name?: string; + + /** + * 0业主 1租户 + */ + type?: number; + + /** + * 0 男性 1女性 + */ + gender?: number; + + /** + * 身份证号 + */ + idCard?: string | number; + + /** + * 手机号码 + */ + phone?: number; + + /** + * 小区id + */ + villageId?: string | number; + + /** + * 楼栋id + */ + buildingId?: string | number; + + /** + * 房屋表id + */ + houseId?: string | number; + + /** + * 0审核中 1 已认证 + */ + status?: number; + + /** + * 身份证正面照url + */ + cardImageFront?: string; + + /** + * 身份证背面照url + */ + cardImageBack?: string; + + /** + * 日期范围参数 + */ + params?: any; +} diff --git a/src/api/system/storeroom/index.ts b/src/api/system/storeroom/index.ts new file mode 100644 index 0000000..5c1f0f1 --- /dev/null +++ b/src/api/system/storeroom/index.ts @@ -0,0 +1,63 @@ +import request from '@/utils/request'; +import { AxiosPromise } from 'axios'; +import { StoreroomVO, StoreroomForm, StoreroomQuery } from '@/api/system/storeroom/types'; + +/** + * 查询储藏室管理列表 + * @param query + * @returns {*} + */ + +export const listStoreroom = (query?: StoreroomQuery): AxiosPromise => { + return request({ + url: '/storeroom/list', + method: 'get', + params: query + }); +}; + +/** + * 查询储藏室管理详细 + * @param id + */ +export const getStoreroom = (id: string | number): AxiosPromise => { + return request({ + url: '/storeroom/' + id, + method: 'get' + }); +}; + +/** + * 新增储藏室管理 + * @param data + */ +export const addStoreroom = (data: StoreroomForm) => { + return request({ + url: '/storeroom', + method: 'post', + data: data + }); +}; + +/** + * 修改储藏室管理 + * @param data + */ +export const updateStoreroom = (data: StoreroomForm) => { + return request({ + url: '/storeroom', + method: 'put', + data: data + }); +}; + +/** + * 删除储藏室管理 + * @param id + */ +export const delStoreroom = (id: string | number | Array) => { + return request({ + url: '/storeroom/' + id, + method: 'delete' + }); +}; diff --git a/src/api/system/storeroom/types.ts b/src/api/system/storeroom/types.ts new file mode 100644 index 0000000..b874109 --- /dev/null +++ b/src/api/system/storeroom/types.ts @@ -0,0 +1,150 @@ +export interface StoreroomVO { + /** + * 储藏室ID + */ + id: string | number; + + /** + * 所属楼栋ID + */ + buildingId: string | number; + + /** + * 单元号 + */ + unitNo: string | number; + + /** + * 储藏室号 + */ + storeroomNo: string; + + /** + * 建筑面积(㎡) + */ + houseArea: number; + + /** + * 公摊面积(㎡) + */ + shareArea: number; + + /** + * 实用面积(㎡) + */ + internalArea: number; + + /** + * 关联房屋ID + */ + houseId: string | number; + + /** + * 状态(0正常 1停用) + */ + status: number; + + /** + * 备注 + */ + remark: string; +} + +export interface StoreroomForm extends BaseEntity { + /** + * 储藏室ID + */ + id?: string | number; + + /** + * 所属楼栋ID + */ + buildingId?: string | number; + + /** + * 单元号 + */ + unitNo?: string | number; + + /** + * 储藏室号 + */ + storeroomNo?: string; + + /** + * 建筑面积(㎡) + */ + houseArea?: number; + + /** + * 公摊面积(㎡) + */ + shareArea?: number; + + /** + * 实用面积(㎡) + */ + internalArea?: number; + + /** + * 关联房屋ID + */ + houseId?: string | number; + + /** + * 状态(0正常 1停用) + */ + status?: number; + + /** + * 备注 + */ + remark?: string; +} + +export interface StoreroomQuery extends PageQuery { + /** + * 所属楼栋ID + */ + buildingId?: string | number; + + /** + * 单元号 + */ + unitNo?: string; + + /** + * 储藏室号 + */ + storeroomNo?: string; + + /** + * 建筑面积(㎡) + */ + houseArea?: number; + + /** + * 公摊面积(㎡) + */ + shareArea?: number; + + /** + * 实用面积(㎡) + */ + internalArea?: number; + + /** + * 关联房屋ID + */ + houseId?: string | number; + + /** + * 状态(0正常 1停用) + */ + status?: number; + + /** + * 日期范围参数 + */ + params?: any; +} diff --git a/src/main.ts b/src/main.ts index b6d0c9e..92e0b00 100644 --- a/src/main.ts +++ b/src/main.ts @@ -7,6 +7,7 @@ import '@/assets/styles/index.scss'; // App、router、store import App from './App.vue'; import store from './store'; + import router from './router'; // 自定义指令 diff --git a/src/store/index.ts b/src/store/index.ts index 02ae96a..d988ecc 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1,5 +1,6 @@ import { createPinia } from 'pinia'; +import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'; const store = createPinia(); - +store.use(piniaPluginPersistedstate); export default store; diff --git a/src/store/modules/house.ts b/src/store/modules/house.ts index 57b45fa..4bdb378 100644 --- a/src/store/modules/house.ts +++ b/src/store/modules/house.ts @@ -1,6 +1,6 @@ import { getCommunitylistAPI } from '@/api/system/community'; import { communitylist_rows_type } from '@/api/system/community/type'; -import { getBuildinglistAPI, getHouselistAPI } from '@/api/system/house'; +import { deleteHouseApi, getBuildinglistAPI, getHouselistAPI } from '@/api/system/house'; import type { addBuildingType, BuildingUnit, BuildingVo } from '@/api/system/house/type'; import { defineStore } from 'pinia'; // 数字排序 @@ -16,89 +16,20 @@ function sortNumberStr(a: string, b: string) { // 否则按自然语言排 return a.localeCompare(b, 'zh-CN', { numeric: true }); } -export const useHouseStore = defineStore('house', () => { - // 当前小区信息 - const currentVilageInfo = ref(); +export const useHouseStore = defineStore( + 'house', + () => { + // 当前小区信息 + const currentVilageInfo = ref(); + // 住宅类型 + const buildingtype = ref(0); + // 住宅列表 + const buildingtypelist = ref([]); - const buildingtype = ref(0); - - // 当前小区 所有楼栋信息 - const currentBuildingInfoList = ref([]); - // 当前楼栋信息 - const currentBuildingInfo = ref({ - 'id': null, - 'villageId': null, - 'villageName': '', - 'buildingName': '', - 'buildingUse': null, - 'buildToward': '', - 'buildTall': '', - 'buildStructure': '', - 'unitCount': null, - 'floorCount': null, - 'remark': '' - }); - - // 当前楼栋 所有房屋信息 - const currentHouseInfoList = ref(); - - // 当前楼栋 所有楼层数据 - const currentFloorInfoList = computed(() => { - return (Array.from(floorslist.value) as string[]).sort(sortNumberStr); - }); - // 楼层列表 set - const floorslist = ref>(new Set()); - - // 初始化 - 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; - if (!currentBuildingInfo.value) { - // 获取当前小区 第一个楼栋信息 - currentBuildingInfo.value = res2.data[0]; - console.log(currentBuildingInfo.value); - } - - // 获取当前 第一个楼栋的所有信息 - const res3 = await getHouselistAPI(currentBuildingInfo.value.id); - currentHouseInfoList.value = res3.data; - console.log(currentHouseInfoList.value); - floorslist.value = new Set(); - // 得到所有的有房屋的 楼层 数组 - currentHouseInfoList.value.units.forEach((item) => { - item.floors.forEach((floor) => { - floorslist.value.add(floor.floorNo); - }); - }); - }; - - // 选中的房屋 - const checkoutHouses = ref([]); - // 选中的房屋方法 - const checkoutHousesFun = (data: string[]) => { - checkoutHouses.value = data; - }; - - // 切换住宅类型 - const switchHouseType = (housetype: number) => { - getBuildinglistAPI(currentVilageInfo.value.villageId, housetype) - .then(() => { - buildingtype.value = housetype; - initHouse(housetype); - ElMessage.success('切换成功'); - }) - .catch(() => ElMessage.error('切换失败')); - }; - - // 切换楼栋 - const switchBuilding = (buildingId: number) => { - // 切换之前 清空当前楼栋信息 - currentBuildingInfo.value = { + // 当前小区 所有楼栋信息 + const currentBuildingInfoList = ref([]); + // 当前楼栋信息 + const currentBuildingInfo = ref({ 'id': null, 'villageId': null, 'villageName': '', @@ -110,67 +41,139 @@ export const useHouseStore = defineStore('house', () => { 'unitCount': null, 'floorCount': null, 'remark': '' - }; - getHouselistAPI(buildingId).then((res) => { - currentHouseInfoList.value = res.data; - // 获取当前楼栋信息并 赋值 - currentBuildingInfo.value = currentBuildingInfoList.value.find((item) => item.id === buildingId); + }); - // 清空 楼层信息 + // 当前楼栋 所有房屋信息 + const currentHouseInfoList = ref(null); + + // 当前楼栋 所有楼层数据 + const currentFloorInfoList = computed(() => { + return (Array.from(floorslist.value) as string[]).sort(sortNumberStr); + }); + // 楼层列表 set + const floorslist = ref>(new Set()); + + // 初始化 + 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; + // 获取当前小区 第一个楼栋信息 + if (currentBuildingInfo.value.id === null) { + currentBuildingInfo.value = res2.data[0]; + } else { + // 更新当前楼栋的 信息 + 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); }); }); - ElMessage.success('切换成功'); - return; - }); - }; + }; - // 更新数据 - const updateHouse = () => { - initHouse(buildingtype.value); - }; - // 删除指定楼栋 - const deleteBuildingFun = (buildingId: number) => { - console.log('删除楼栋'); - // 手动 从 楼栋列表中删除 指定楼栋 - currentBuildingInfoList.value = currentBuildingInfoList.value.filter((item) => item.id !== buildingId); - // 判断指定楼栋是 当前楼栋 - if (currentBuildingInfo.value.id === buildingId) { - // 获取楼栋列表中的第一个楼栋,并切换到第一个楼栋 - if (currentBuildingInfoList.value[0]) { - currentBuildingInfo.value = currentBuildingInfoList.value[0]; - switchBuilding(currentBuildingInfo.value.id); + // 选中的房屋 + const checkoutHouses = ref([]); + // 选中的房屋方法 + const checkoutHousesFun = (data: string[]) => { + checkoutHouses.value = data; + }; + + // 切换住宅类型 + const switchHouseType = (housetype: number) => { + getBuildinglistAPI(currentVilageInfo.value.villageId, housetype) + .then(() => { + buildingtype.value = housetype; + initHouse(housetype); + ElMessage.success('切换成功'); + }) + .catch(() => ElMessage.error('切换失败')); + }; + + // 切换楼栋 + const switchBuilding = (buildingId: string) => { + // 切换之前 清空当前楼栋信息 + currentBuildingInfo.value = { + 'id': null, + 'villageId': null, + 'villageName': '', + 'buildingName': '', + 'buildingUse': null, + 'buildToward': '', + 'buildTall': '', + 'buildStructure': '', + 'unitCount': null, + 'floorCount': null, + 'remark': '' + }; + 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(); + // 重新获取楼层信息 + currentHouseInfoList.value.units.forEach((item) => { + item.floors.forEach((floor) => { + floorslist.value.add(floor.floorNo); + }); + }); + return; + }); + }; + + // 更新数据 + const updateHouse = () => { + initHouse(buildingtype.value); + }; + // 删除指定楼栋 + const deleteBuildingFun = (buildingId: string) => { + console.log('删除楼栋'); + // 手动 从 楼栋列表中删除 指定楼栋 + currentBuildingInfoList.value = currentBuildingInfoList.value.filter((item) => item.id !== buildingId); + // 判断指定楼栋是 当前楼栋 + if (currentBuildingInfo.value.id === buildingId) { + // 获取楼栋列表中的第一个楼栋,并切换到第一个楼栋 + if (currentBuildingInfoList.value[0]) { + currentBuildingInfo.value = currentBuildingInfoList.value[0]; + switchBuilding(currentBuildingInfo.value.id); + } } - } - }; - // 删除指定房屋 - const deleteHouseFun = (houseId: string | string[]) => { - console.log('删除房屋'); - if (typeof houseId === 'string') { - console.log('单条删除'); - } else if (Array.isArray(houseId)) { - console.log('批量删除'); - } - }; + }; - return { - currentVilageInfo, - currentBuildingInfoList, - currentBuildingInfo, - currentHouseInfoList, - currentFloorInfoList, - checkoutHouses, - buildingtype, - checkoutHousesFun, - initHouse, - switchHouseType, - switchBuilding, - deleteHouseFun, - updateHouse, - deleteBuildingFun - }; -}); + return { + currentVilageInfo, + currentBuildingInfoList, + currentBuildingInfo, + currentHouseInfoList, + currentFloorInfoList, + checkoutHouses, + buildingtype, + buildingtypelist, + checkoutHousesFun, + initHouse, + switchHouseType, + switchBuilding, + updateHouse, + deleteBuildingFun + }; + }, + { + persist: { + storage: sessionStorage + } + } +); diff --git a/src/views/system/house/AddBuilding.vue b/src/views/system/house/AddBuilding.vue index 62dfdfd..9fcd3e0 100644 --- a/src/views/system/house/AddBuilding.vue +++ b/src/views/system/house/AddBuilding.vue @@ -84,7 +84,7 @@ if (buildingId) { function getBuildingById() { console.log(houseStore.currentBuildingInfoList); houseStore.currentBuildingInfoList.forEach((item) => { - if (item.id === parseInt(buildingId)) { + if (item.id == buildingId) { form.value.buildingName = item.buildingName; form.value.buildToward = item.buildToward; form.value.buildingUse = item.buildingUse; @@ -104,7 +104,7 @@ const submitForm = () => { editBuildingApi({ ...form.value, villageId: currentVilageInfo.value.villageId, - id: parseInt(buildingId) + id: buildingId }) .then((res) => { ElMessage.success('修改成功'); diff --git a/src/views/system/house/AddHouse.vue b/src/views/system/house/AddHouse.vue index 641afed..f0b2bde 100644 --- a/src/views/system/house/AddHouse.vue +++ b/src/views/system/house/AddHouse.vue @@ -1,43 +1,43 @@