修改宿管的BUG
This commit is contained in:
1 parent
86ceebef18
commit
66a7fd7068
4 files changed
+46
-8
No files matched your search
+2
-1
@@ -60,7 +60,8 @@ public class XgDormAreaServiceImpl implements IXgDormAreaService {
|
||||
*/
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ import {
|
||||
} from '@/api/xg/xgss/sslxx/dormBuilding';
|
||||
import { DormBuildingVO, DormBuildingQuery, DormBuildingForm } from '@/api/xg/xgss/sslxx/dormBuilding/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';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
@@ -178,8 +178,10 @@ const initFormData: DormBuildingForm = {
|
||||
buildingCode: undefined,
|
||||
buildingName: undefined,
|
||||
campusId: undefined,
|
||||
areaId: '2015638219126755329',
|
||||
buildingType: undefined,
|
||||
buildingDescription: undefined,
|
||||
remark: undefined,
|
||||
sortOrder: undefined,
|
||||
floors: 6 // 添加默认值为6
|
||||
};
|
||||
@@ -220,6 +222,30 @@ const loadCampusOptions = async () => {
|
||||
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 = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
@@ -252,6 +278,10 @@ const handleUpdate = async (row?: DormBuildingVO) => {
|
||||
const _id = row?.id || ids.value[0];
|
||||
const res = await getDormBuilding(_id);
|
||||
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.title = '修改宿舍楼信息';
|
||||
};
|
||||
@@ -261,6 +291,10 @@ const submitForm = () => {
|
||||
dormBuildingFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
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) {
|
||||
await updateDormBuilding(form.value)
|
||||
.then(() => {
|
||||
@@ -303,6 +337,8 @@ const handleDelete = async (row?: DormBuildingVO) => {
|
||||
/** 重置操作表单 */
|
||||
const reset = () => {
|
||||
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();
|
||||
};
|
||||
|
||||
|
||||
@@ -110,8 +110,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 房间数据展示 -->
|
||||
<div v-else-if="roomList.length > 0" class="room-display">
|
||||
<!-- 房间数据展示:总是根据楼层渲染(即使该层暂无房间也会显示,方便添加房间) -->
|
||||
<div v-else class="room-display">
|
||||
<div v-if="floorList.length === 0" class="empty-state">
|
||||
<el-empty description="该宿舍楼未设置楼层信息" />
|
||||
</div>
|
||||
|
||||
<div v-else>
|
||||
<div v-for="floor in floorList" :key="floor" class="mb-4">
|
||||
<el-divider>
|
||||
<el-tag type="success" effect="dark" class="mr-2">{{ floor }}层</el-tag>
|
||||
@@ -160,10 +165,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 空状态展示 -->
|
||||
<div v-else class="empty-state">
|
||||
<el-empty description="请先选择左侧宿舍楼查看房间信息" />
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
Binary file not shown.
Reference in new issue
Block a user