修改宿管的BUG
This commit is contained in:
1 parent
86ceebef18
commit
66a7fd7068
4 files changed
+88
-50
No files matched your search
+2
-1
@@ -60,7 +60,8 @@ public class XgDormAreaServiceImpl implements IXgDormAreaService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public TableDataInfo<XgDormAreaVo> queryPageList(XgDormAreaBo bo, PageQuery pageQuery) {
|
public TableDataInfo<XgDormAreaVo> queryPageList(XgDormAreaBo bo, PageQuery pageQuery) {
|
||||||
Page<XgDormAreaVo> result = baseMapper.selectPageWithCampusName(pageQuery.build(), bo);
|
// 禁用默认的全局排序列(create_time),避免在 join 查询中出现未加表别名的列导致歧义
|
||||||
|
Page<XgDormAreaVo> result = baseMapper.selectPageWithCampusName(pageQuery.disableDefaultOrder().build(), bo);
|
||||||
return TableDataInfo.build(result);
|
return TableDataInfo.build(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ import {
|
|||||||
} from '@/api/xg/xgss/sslxx/dormBuilding';
|
} from '@/api/xg/xgss/sslxx/dormBuilding';
|
||||||
import { DormBuildingVO, DormBuildingQuery, DormBuildingForm } from '@/api/xg/xgss/sslxx/dormBuilding/types';
|
import { DormBuildingVO, DormBuildingQuery, DormBuildingForm } from '@/api/xg/xgss/sslxx/dormBuilding/types';
|
||||||
import { DormCampusVO } from '@/api/xg/xgss/xqxx/dormCampus/types';
|
import { DormCampusVO } from '@/api/xg/xgss/xqxx/dormCampus/types';
|
||||||
import { getCurrentInstance, ComponentInternalInstance, ref, reactive, toRefs, onMounted } from 'vue';
|
import { getCurrentInstance, ComponentInternalInstance, ref, reactive, toRefs, onMounted, watch } from 'vue';
|
||||||
import { ElForm, ElMessageBox, ElMessage } from 'element-plus';
|
import { ElForm, ElMessageBox, ElMessage } from 'element-plus';
|
||||||
|
|
||||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||||
@@ -178,8 +178,10 @@ const initFormData: DormBuildingForm = {
|
|||||||
buildingCode: undefined,
|
buildingCode: undefined,
|
||||||
buildingName: undefined,
|
buildingName: undefined,
|
||||||
campusId: undefined,
|
campusId: undefined,
|
||||||
|
areaId: '2015638219126755329',
|
||||||
buildingType: undefined,
|
buildingType: undefined,
|
||||||
buildingDescription: undefined,
|
buildingDescription: undefined,
|
||||||
|
remark: undefined,
|
||||||
sortOrder: undefined,
|
sortOrder: undefined,
|
||||||
floors: 6 // 添加默认值为6
|
floors: 6 // 添加默认值为6
|
||||||
};
|
};
|
||||||
@@ -220,6 +222,30 @@ const loadCampusOptions = async () => {
|
|||||||
campusList.value = res.rows || [];
|
campusList.value = res.rows || [];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 默认宿舍区映射(按校区名称判断)
|
||||||
|
const AREA_DEFAULTS: Record<string, string> = {
|
||||||
|
'临安校区': '2015638219126755329',
|
||||||
|
'西溪校区': '2015639946668298241'
|
||||||
|
};
|
||||||
|
|
||||||
|
const deriveAreaIdFromCampusId = (campusId?: string | number) => {
|
||||||
|
const defaultArea = AREA_DEFAULTS['临安校区'];
|
||||||
|
if (!campusId) return defaultArea;
|
||||||
|
const campus = campusList.value.find((c: any) => String(c.id) === String(campusId));
|
||||||
|
if (!campus || !campus.campusName) return defaultArea;
|
||||||
|
if (campus.campusName.includes('临安')) return AREA_DEFAULTS['临安校区'];
|
||||||
|
if (campus.campusName.includes('西溪')) return AREA_DEFAULTS['西溪校区'];
|
||||||
|
return defaultArea;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 当选择校区变化时,自动设置 areaId
|
||||||
|
watch(
|
||||||
|
() => form.value.campusId,
|
||||||
|
(newCampusId) => {
|
||||||
|
(form.value as any).areaId = deriveAreaIdFromCampusId(newCampusId);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
const handleQuery = () => {
|
const handleQuery = () => {
|
||||||
queryParams.value.pageNum = 1;
|
queryParams.value.pageNum = 1;
|
||||||
@@ -252,6 +278,10 @@ const handleUpdate = async (row?: DormBuildingVO) => {
|
|||||||
const _id = row?.id || ids.value[0];
|
const _id = row?.id || ids.value[0];
|
||||||
const res = await getDormBuilding(_id);
|
const res = await getDormBuilding(_id);
|
||||||
Object.assign(form.value, res.data);
|
Object.assign(form.value, res.data);
|
||||||
|
// If areaId is missing from returned data, default it based on campus
|
||||||
|
if (!(form.value as any).areaId) {
|
||||||
|
(form.value as any).areaId = deriveAreaIdFromCampusId(form.value.campusId);
|
||||||
|
}
|
||||||
dialog.visible = true;
|
dialog.visible = true;
|
||||||
dialog.title = '修改宿舍楼信息';
|
dialog.title = '修改宿舍楼信息';
|
||||||
};
|
};
|
||||||
@@ -261,6 +291,10 @@ const submitForm = () => {
|
|||||||
dormBuildingFormRef.value?.validate(async (valid: boolean) => {
|
dormBuildingFormRef.value?.validate(async (valid: boolean) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
buttonLoading.value = true;
|
buttonLoading.value = true;
|
||||||
|
// Ensure areaId defaults based on selected campus before submitting
|
||||||
|
if (!(form.value as any).areaId) {
|
||||||
|
(form.value as any).areaId = deriveAreaIdFromCampusId(form.value.campusId);
|
||||||
|
}
|
||||||
if (form.value.id) {
|
if (form.value.id) {
|
||||||
await updateDormBuilding(form.value)
|
await updateDormBuilding(form.value)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@@ -303,6 +337,8 @@ const handleDelete = async (row?: DormBuildingVO) => {
|
|||||||
/** 重置操作表单 */
|
/** 重置操作表单 */
|
||||||
const reset = () => {
|
const reset = () => {
|
||||||
form.value = { ...initFormData };
|
form.value = { ...initFormData };
|
||||||
|
// default areaId for new forms/reset based on current campus selection (or 临安)
|
||||||
|
(form.value as any).areaId = deriveAreaIdFromCampusId(form.value.campusId);
|
||||||
dormBuildingFormRef.value?.resetFields();
|
dormBuildingFormRef.value?.resetFields();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -110,61 +110,62 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 房间数据展示 -->
|
<!-- 房间数据展示:总是根据楼层渲染(即使该层暂无房间也会显示,方便添加房间) -->
|
||||||
<div v-else-if="roomList.length > 0" class="room-display">
|
<div v-else class="room-display">
|
||||||
<div v-for="floor in floorList" :key="floor" class="mb-4">
|
<div v-if="floorList.length === 0" class="empty-state">
|
||||||
<el-divider>
|
<el-empty description="该宿舍楼未设置楼层信息" />
|
||||||
<el-tag type="success" effect="dark" class="mr-2">{{ floor }}层</el-tag>
|
</div>
|
||||||
<el-button type="primary" icon="Plus" size="small" @click="handleAddAllRoom(floor)">自动添加房间</el-button>
|
|
||||||
<el-button type="primary" icon="Plus" size="small" @click="handleAddRoom(floor)">添加房间</el-button>
|
|
||||||
</el-divider>
|
|
||||||
|
|
||||||
<div class="room-container">
|
<div v-else>
|
||||||
<el-empty v-if="getRoomsByFloor(floor).length === 0" description="暂无房间数据" />
|
<div v-for="floor in floorList" :key="floor" class="mb-4">
|
||||||
<div v-else class="room-grid">
|
<el-divider>
|
||||||
<el-card
|
<el-tag type="success" effect="dark" class="mr-2">{{ floor }}层</el-tag>
|
||||||
v-for="room in getRoomsByFloor(floor)"
|
<el-button type="primary" icon="Plus" size="small" @click="handleAddAllRoom(floor)">自动添加房间</el-button>
|
||||||
:key="room.id"
|
<el-button type="primary" icon="Plus" size="small" @click="handleAddRoom(floor)">添加房间</el-button>
|
||||||
class="room-card"
|
</el-divider>
|
||||||
:class="{ 'room-disabled': room.roomStatus !== '0' }"
|
|
||||||
>
|
<div class="room-container">
|
||||||
<template #header>
|
<el-empty v-if="getRoomsByFloor(floor).length === 0" description="暂无房间数据" />
|
||||||
<div class="flex items-center justify-between">
|
<div v-else class="room-grid">
|
||||||
<span class="font-bold">{{ room.roomName }}</span>
|
<el-card
|
||||||
<div>
|
v-for="room in getRoomsByFloor(floor)"
|
||||||
<el-tag v-if="room.roomStatus === '0'" type="success" size="small">正常</el-tag>
|
:key="room.id"
|
||||||
<el-tag v-else-if="room.roomStatus === '1'" type="warning" size="small">维修中</el-tag>
|
class="room-card"
|
||||||
<el-tag v-else type="danger" size="small">停用</el-tag>
|
:class="{ 'room-disabled': room.roomStatus !== '0' }"
|
||||||
|
>
|
||||||
|
<template #header>
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<span class="font-bold">{{ room.roomName }}</span>
|
||||||
|
<div>
|
||||||
|
<el-tag v-if="room.roomStatus === '0'" type="success" size="small">正常</el-tag>
|
||||||
|
<el-tag v-else-if="room.roomStatus === '1'" type="warning" size="small">维修中</el-tag>
|
||||||
|
<el-tag v-else type="danger" size="small">停用</el-tag>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<div class="room-info">
|
||||||
|
<div class="mb-2">
|
||||||
|
<span class="text-gray-500">类型:</span
|
||||||
|
>{{ room.roomType === '1' ? '标准间' : room.roomType === '2' ? '单人间' : '套间' }}
|
||||||
|
</div>
|
||||||
|
<div class="mb-2"><span class="text-gray-500">床位:</span>{{ room.currentBeds || 0 }}/{{ room.actualBeds }}</div>
|
||||||
|
<div class="mb-2"><span class="text-gray-500">排序:</span>{{ room.sort || 0 }}</div>
|
||||||
|
<div class="flex justify-between mt-4">
|
||||||
|
<div>
|
||||||
|
<el-button type="primary" size="small" @click="handleManageBeds(room)">床位管理</el-button>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<el-button type="primary" link size="small" icon="Edit" @click="handleEditRoom(room)" />
|
||||||
|
<el-button type="danger" link size="small" icon="Delete" @click="handleDeleteRoom(room)" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</el-card>
|
||||||
<div class="room-info">
|
</div>
|
||||||
<div class="mb-2">
|
|
||||||
<span class="text-gray-500">类型:</span
|
|
||||||
>{{ room.roomType === '1' ? '标准间' : room.roomType === '2' ? '单人间' : '套间' }}
|
|
||||||
</div>
|
|
||||||
<div class="mb-2"><span class="text-gray-500">床位:</span>{{ room.currentBeds || 0 }}/{{ room.actualBeds }}</div>
|
|
||||||
<div class="mb-2"><span class="text-gray-500">排序:</span>{{ room.sort || 0 }}</div>
|
|
||||||
<div class="flex justify-between mt-4">
|
|
||||||
<div>
|
|
||||||
<el-button type="primary" size="small" @click="handleManageBeds(room)">床位管理</el-button>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<el-button type="primary" link size="small" icon="Edit" @click="handleEditRoom(room)" />
|
|
||||||
<el-button type="danger" link size="small" icon="Delete" @click="handleDeleteRoom(room)" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</el-card>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 空状态展示 -->
|
|
||||||
<div v-else class="empty-state">
|
|
||||||
<el-empty description="请先选择左侧宿舍楼查看房间信息" />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Binary file not shown.
Reference in new issue
Block a user