zlwu 9 місяців тому
батько
коміт
66a7fd7068

+ 2 - 1
backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/service/impl/XgDormAreaServiceImpl.java

@@ -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);
     }
 

+ 37 - 1
web/src/views/xg/xgss/sslxx/dormBuilding/index.vue

@@ -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();
 };
 

+ 48 - 47
web/src/views/xg/xgss/xsssfjgl/index.vue

@@ -110,61 +110,62 @@
                 </div>
               </div>
 
-              <!-- 房间数据展示 -->
-              <div v-else-if="roomList.length > 0" class="room-display">
-                <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>
-                    <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">
-                    <el-empty v-if="getRoomsByFloor(floor).length === 0" description="暂无房间数据" />
-                    <div v-else class="room-grid">
-                      <el-card
-                        v-for="room in getRoomsByFloor(floor)"
-                        :key="room.id"
-                        class="room-card"
-                        :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 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>
+                      <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">
+                      <el-empty v-if="getRoomsByFloor(floor).length === 0" description="暂无房间数据" />
+                      <div v-else class="room-grid">
+                        <el-card
+                          v-for="room in getRoomsByFloor(floor)"
+                          :key="room.id"
+                          class="room-card"
+                          :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>
-                          </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>
+                          </template>
+                          <div class="room-info">
+                            <div class="mb-2">
+                              <span class="text-gray-500">类型:</span
+                              >{{ room.roomType === '1' ? '标准间' : room.roomType === '2' ? '单人间' : '套间' }}
                             </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 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>
-                      </el-card>
+                        </el-card>
+                      </div>
                     </div>
                   </div>
                 </div>
               </div>
-
-              <!-- 空状态展示 -->
-              <div v-else class="empty-state">
-                <el-empty description="请先选择左侧宿舍楼查看房间信息" />
-              </div>
             </div>
           </el-card>
         </template>

BIN
副本统一身份认证接入指南.docx