提交宿舍房间设置的前端界面
This commit is contained in:
1 parent
7ce20647f0
commit
12b4b58647
28 files changed
+1623
-17
No files matched your search
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,260 @@
|
||||
import request from '@/utils/request';
|
||||
import { DormQuery, RoomForm, BedForm, DormTreeNode, RoomInfo, BedInfo } from './types';
|
||||
|
||||
// API前缀
|
||||
const baseUrl = '/xsssfjgl';
|
||||
|
||||
/**
|
||||
* 获取宿舍树形结构
|
||||
*/
|
||||
export function getDormTree() {
|
||||
return request({
|
||||
url: baseUrl + '/tree',
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取房间列表
|
||||
* @param query 查询条件
|
||||
* @returns 房间列表
|
||||
*/
|
||||
export function listRooms(query: DormQuery) {
|
||||
return request({
|
||||
url: baseUrl + '/room/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取房间详情
|
||||
* @param roomId 房间ID
|
||||
* @returns 房间详情
|
||||
*/
|
||||
export function getRoom(roomId: string | number) {
|
||||
return request({
|
||||
url: baseUrl + '/room/' + roomId,
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增房间
|
||||
* @param data 房间信息
|
||||
* @returns 结果
|
||||
*/
|
||||
export function addRoom(data: RoomForm) {
|
||||
return request({
|
||||
url: baseUrl + '/room',
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改房间
|
||||
* @param data 房间信息
|
||||
* @returns 结果
|
||||
*/
|
||||
export function updateRoom(data: RoomForm) {
|
||||
return request({
|
||||
url: baseUrl + '/room',
|
||||
method: 'put',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除房间
|
||||
* @param roomIds 房间ID字符串
|
||||
* @returns 结果
|
||||
*/
|
||||
export function delRoom(roomIds: string | number) {
|
||||
return request({
|
||||
url: baseUrl + '/room/' + roomIds,
|
||||
method: 'delete'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取床位列表
|
||||
* @param roomId 房间ID
|
||||
* @returns 床位列表
|
||||
*/
|
||||
export function listBeds(roomId: string | number) {
|
||||
return request({
|
||||
url: baseUrl + '/bed/list',
|
||||
method: 'get',
|
||||
params: { roomId }
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增床位
|
||||
* @param data 床位信息
|
||||
* @returns 结果
|
||||
*/
|
||||
export function addBed(data: BedForm) {
|
||||
return request({
|
||||
url: baseUrl + '/bed',
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改床位
|
||||
* @param data 床位信息
|
||||
* @returns 结果
|
||||
*/
|
||||
export function updateBed(data: BedForm) {
|
||||
return request({
|
||||
url: baseUrl + '/bed',
|
||||
method: 'put',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除床位
|
||||
* @param bedIds 床位ID字符串
|
||||
* @returns 结果
|
||||
*/
|
||||
export function delBed(bedIds: string | number) {
|
||||
return request({
|
||||
url: baseUrl + '/bed/' + bedIds,
|
||||
method: 'delete'
|
||||
});
|
||||
}
|
||||
|
||||
// 模拟数据 - 在API接口完成前使用
|
||||
// 生成宿舍树形结构的模拟数据
|
||||
export function getMockDormTree(): { data: DormTreeNode[] } {
|
||||
const mockData: DormTreeNode[] = [
|
||||
{
|
||||
id: 1,
|
||||
label: '东校区',
|
||||
type: 'campus',
|
||||
disabled: true,
|
||||
children: [
|
||||
{
|
||||
id: 11,
|
||||
label: '东区宿舍',
|
||||
type: 'area',
|
||||
disabled: true,
|
||||
children: [
|
||||
{
|
||||
id: 111,
|
||||
label: '东区1号楼',
|
||||
type: 'building',
|
||||
buildingFloors: 6
|
||||
},
|
||||
{
|
||||
id: 112,
|
||||
label: '东区2号楼',
|
||||
type: 'building',
|
||||
buildingFloors: 8
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
label: '西校区',
|
||||
type: 'campus',
|
||||
disabled: true,
|
||||
children: [
|
||||
{
|
||||
id: 21,
|
||||
label: '西区宿舍',
|
||||
type: 'area',
|
||||
disabled: true,
|
||||
children: [
|
||||
{
|
||||
id: 211,
|
||||
label: '西区1号楼',
|
||||
type: 'building',
|
||||
buildingFloors: 7
|
||||
},
|
||||
{
|
||||
id: 212,
|
||||
label: '西区2号楼',
|
||||
type: 'building',
|
||||
buildingFloors: 5
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
return { data: mockData };
|
||||
}
|
||||
|
||||
// 生成房间数据的模拟数据
|
||||
export function getMockRooms(buildingId: string | number, floorNumber?: number): { rows: RoomInfo[], total: number } {
|
||||
const rooms: RoomInfo[] = [];
|
||||
|
||||
// 根据buildingId判断楼层数
|
||||
let floors = 6;
|
||||
if (buildingId === 112) floors = 8;
|
||||
else if (buildingId === 211) floors = 7;
|
||||
else if (buildingId === 212) floors = 5;
|
||||
|
||||
// 如果指定了楼层,只生成该楼层的数据
|
||||
const startFloor = floorNumber || 1;
|
||||
const endFloor = floorNumber || floors;
|
||||
|
||||
for (let floor = startFloor; floor <= endFloor; floor++) {
|
||||
for (let i = 1; i <= 10; i++) {
|
||||
const roomNumber = `${floor}${i.toString().padStart(2, '0')}`;
|
||||
rooms.push({
|
||||
roomId: `${buildingId}${roomNumber}`,
|
||||
roomName: roomNumber,
|
||||
floorNumber: floor,
|
||||
buildingId: buildingId,
|
||||
capacity: 4,
|
||||
used: Math.floor(Math.random() * 5),
|
||||
roomType: '标准间',
|
||||
status: Math.random() > 0.9 ? '1' : '0',
|
||||
remark: '',
|
||||
createBy: 'admin',
|
||||
createTime: '2023-01-01 00:00:00',
|
||||
updateBy: 'admin',
|
||||
updateTime: '2023-01-01 00:00:00'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
rows: rooms.filter(room => !floorNumber || room.floorNumber === floorNumber),
|
||||
total: rooms.length
|
||||
};
|
||||
}
|
||||
|
||||
// 生成床位数据的模拟数据
|
||||
export function getMockBeds(roomId: string | number): { data: BedInfo[] } {
|
||||
const beds: BedInfo[] = [];
|
||||
const capacity = 4;
|
||||
|
||||
for (let i = 1; i <= capacity; i++) {
|
||||
const status = Math.random() > 0.6 ? '1' : '0';
|
||||
beds.push({
|
||||
bedId: `${roomId}-${i}`,
|
||||
bedName: `${i}号床`,
|
||||
roomId: roomId,
|
||||
status: status,
|
||||
studentId: status === '1' ? 10000 + Math.floor(Math.random() * 5000) : undefined,
|
||||
studentName: status === '1' ? `学生${Math.floor(Math.random() * 1000)}` : undefined,
|
||||
remark: '',
|
||||
createBy: 'admin',
|
||||
createTime: '2023-01-01 00:00:00',
|
||||
updateBy: 'admin',
|
||||
updateTime: '2023-01-01 00:00:00'
|
||||
});
|
||||
}
|
||||
|
||||
return { data: beds };
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
// 基础字段类型
|
||||
export interface BaseEntity {
|
||||
createBy: number | string;
|
||||
createTime: string;
|
||||
updateBy: number | string;
|
||||
updateTime: string;
|
||||
}
|
||||
|
||||
// 分页查询参数
|
||||
export interface PageQuery {
|
||||
pageNum: number;
|
||||
pageSize: number;
|
||||
}
|
||||
|
||||
// 树形数据节点类型
|
||||
export interface DormTreeNode {
|
||||
id: string | number;
|
||||
label: string;
|
||||
children?: DormTreeNode[];
|
||||
type: 'campus' | 'area' | 'building'; // 节点类型:校区、宿舍区、宿舍楼
|
||||
disabled?: boolean; // 是否禁用选择
|
||||
buildingFloors?: number; // 宿舍楼层数
|
||||
}
|
||||
|
||||
// 房间信息
|
||||
export interface RoomInfo extends BaseEntity {
|
||||
roomId: string | number;
|
||||
roomName: string;
|
||||
floorNumber: number;
|
||||
buildingId: string | number;
|
||||
capacity: number;
|
||||
used: number;
|
||||
roomType: string;
|
||||
status: string; // 0-正常 1-维修中 2-停用
|
||||
remark: string;
|
||||
}
|
||||
|
||||
// 床位信息
|
||||
export interface BedInfo extends BaseEntity {
|
||||
bedId: string | number;
|
||||
bedName: string;
|
||||
roomId: string | number;
|
||||
status: string; // 0-空闲 1-已分配 2-维修中
|
||||
studentId?: string | number;
|
||||
studentName?: string;
|
||||
remark: string;
|
||||
}
|
||||
|
||||
// 查询参数
|
||||
export interface DormQuery extends PageQuery {
|
||||
buildingId?: string | number;
|
||||
roomName?: string;
|
||||
floorNumber?: number;
|
||||
status?: string;
|
||||
}
|
||||
|
||||
// 房间表单
|
||||
export interface RoomForm {
|
||||
roomId?: string | number;
|
||||
roomName: string;
|
||||
floorNumber: number;
|
||||
buildingId: string | number;
|
||||
capacity: number;
|
||||
roomType: string;
|
||||
status: string;
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
// 床位表单
|
||||
export interface BedForm {
|
||||
bedId?: string | number;
|
||||
bedName: string;
|
||||
roomId: string | number;
|
||||
status: string;
|
||||
remark?: string;
|
||||
}
|
||||
File renamed without changes.
Reference in new issue
Block a user