学生入住信息采集
This commit is contained in:
59
api/dms/studentDormInfo/index.js
Normal file
59
api/dms/studentDormInfo/index.js
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 查询宿舍学生关联列表
|
||||||
|
export function listStudent(query) {
|
||||||
|
return request({
|
||||||
|
url: '/dormitory/srs-dormitory-student/list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增宿舍学生关联
|
||||||
|
export function addStudent(data) {
|
||||||
|
return request({
|
||||||
|
url: '/dormitory/srs-dormitory-student/add',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取校区
|
||||||
|
export function listAllCampus() {
|
||||||
|
return request({
|
||||||
|
url: '/dormitory/dms-dormitory/listAllCampus',
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据校区id获取园区
|
||||||
|
export function listParkByCampus(id) {
|
||||||
|
return request({
|
||||||
|
url: '/dormitory/dms-dormitory/listParkByCampus/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据园区id获取楼栋
|
||||||
|
export function listBuildingByPark(id) {
|
||||||
|
return request({
|
||||||
|
url: '/dormitory/dms-dormitory/listBuildingByPark/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据楼栋id获取楼层
|
||||||
|
export function listFloorByBuilding(id) {
|
||||||
|
return request({
|
||||||
|
url: '/dormitory/dms-dormitory/listFloorByBuilding/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据楼层id获取宿舍号
|
||||||
|
export function listAllRoomByFloor(id) {
|
||||||
|
return request({
|
||||||
|
url: '/dormitory/dms-dormitory/listAllRoomByFloor/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ module.exports = {
|
|||||||
// baseUrl: 'http://zhxg.gxsdxy.cn/prod_api',
|
// baseUrl: 'http://zhxg.gxsdxy.cn/prod_api',
|
||||||
// baseUrl: 'http://172.16.96.111:8085',
|
// baseUrl: 'http://172.16.96.111:8085',
|
||||||
// baseUrl: 'http://192.168.211.22:8085',
|
// baseUrl: 'http://192.168.211.22:8085',
|
||||||
baseUrl: 'http://localhost:8088',
|
baseUrl: 'http://localhost:8085',
|
||||||
// 应用信息
|
// 应用信息
|
||||||
appInfo: {
|
appInfo: {
|
||||||
// 应用名称
|
// 应用名称
|
||||||
|
|||||||
19
pages.json
19
pages.json
@@ -209,8 +209,7 @@
|
|||||||
"navigationBarBackgroundColor": "#1890FF",
|
"navigationBarBackgroundColor": "#1890FF",
|
||||||
"navigationBarTextStyle": "white"
|
"navigationBarTextStyle": "white"
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"path": "pages/record/record",
|
"path": "pages/record/record",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "住宿记录",
|
"navigationBarTitleText": "住宿记录",
|
||||||
@@ -218,6 +217,22 @@
|
|||||||
"navigationBarBackgroundColor": "#1890FF",
|
"navigationBarBackgroundColor": "#1890FF",
|
||||||
"navigationBarTextStyle": "white"
|
"navigationBarTextStyle": "white"
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
"path": "pages/dormitory/studentDormInfo/index",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "学生入住信息收集",
|
||||||
|
"enablePullDownRefresh": false,
|
||||||
|
"navigationBarBackgroundColor": "#1890FF",
|
||||||
|
"navigationBarTextStyle": "white"
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
"path": "pages/dormitory/studentDormInfo/informationCollection",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "信息收集",
|
||||||
|
"enablePullDownRefresh": false,
|
||||||
|
"navigationBarBackgroundColor": "#1890FF",
|
||||||
|
"navigationBarTextStyle": "white"
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
"path": "pages/addapply/addapply",
|
"path": "pages/addapply/addapply",
|
||||||
"style": {
|
"style": {
|
||||||
|
|||||||
278
pages/dormitory/studentDormInfo/index.vue
Normal file
278
pages/dormitory/studentDormInfo/index.vue
Normal file
@@ -0,0 +1,278 @@
|
|||||||
|
<template>
|
||||||
|
<view class="page-container">
|
||||||
|
<!-- 添加信息收集按钮 -->
|
||||||
|
<view class="add" @click="addDormInfo">+</view>
|
||||||
|
|
||||||
|
<!-- 滚动容器(使用scroll-view确保事件生效) -->
|
||||||
|
<scroll-view class="scroll-container" scroll-y @scrolltolower="loadNextPage" refresher-enabled
|
||||||
|
@refresherrefresh="handleRefresh">
|
||||||
|
<!-- 入住收集列表 -->
|
||||||
|
<view class="dorm-list">
|
||||||
|
<view class="dorm-item" v-for="(item, index) in dormInfo"
|
||||||
|
:key="`${item.id}_${Math.ceil((index + 1) / queryParams.pageSize)}`" @click="handleItemClick(item)">
|
||||||
|
<view class="item-header">
|
||||||
|
<view class="name">姓名: {{ item.stuName }}</view>
|
||||||
|
<view class="tag" :class="item.isDormitoryHead === 1 ? 'head-tag' : ''">
|
||||||
|
{{ item.isDormitoryHead === 1 ? '宿舍长' : '' }}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="item-content">
|
||||||
|
<view>学号: {{ item.stuNo }}</view>
|
||||||
|
<view>班级: {{ item.className }}</view>
|
||||||
|
<view>院系: {{ item.deptName }}</view>
|
||||||
|
<view>宿舍: {{ item.parkName }} {{ item.buildingName }} {{ item.floorName }}楼{{ item.roomNo }}室
|
||||||
|
</view>
|
||||||
|
<view>入住时间: {{ item.checkinTime }}</view>
|
||||||
|
<view>状态: {{ item.inStatus === '1' ? '已入住' : '未入住' }}</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 加载状态 -->
|
||||||
|
<view v-if="isLoading" class="loading">加载中...</view>
|
||||||
|
<view v-if="!hasMore && dormInfo.length > 0" class="no-more">已加载全部数据</view>
|
||||||
|
<view v-if="dormInfo.length === 0 && !isLoading" class="no-data">暂无数据</view>
|
||||||
|
</scroll-view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
listStudent
|
||||||
|
} from "@/api/dms/studentDormInfo/index.js"
|
||||||
|
import {
|
||||||
|
getUserProfile
|
||||||
|
} from '@/api/system/user'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 5, // 每页5条,便于测试分页
|
||||||
|
dormitoryId: null,
|
||||||
|
bedId: null,
|
||||||
|
stuNo: null,
|
||||||
|
isDormitoryHead: null,
|
||||||
|
status: null,
|
||||||
|
checkinTime: null,
|
||||||
|
inStatus: null,
|
||||||
|
stuName: null,
|
||||||
|
},
|
||||||
|
dormInfo: [],
|
||||||
|
isLoading: false,
|
||||||
|
hasMore: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onShow() {
|
||||||
|
// 每次显示页面时重置数据并重新加载
|
||||||
|
this.resetData()
|
||||||
|
this.getUserProfile()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 重置分页数据(用于刷新或重新加载)
|
||||||
|
resetData() {
|
||||||
|
this.queryParams.pageNum = 1
|
||||||
|
this.dormInfo = []
|
||||||
|
this.hasMore = true
|
||||||
|
},
|
||||||
|
|
||||||
|
// 查询列表数据
|
||||||
|
async getList() {
|
||||||
|
if (this.isLoading || !this.hasMore) return
|
||||||
|
this.isLoading = true
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await listStudent(this.queryParams)
|
||||||
|
if (res.code === 200) {
|
||||||
|
const newData = res.rows || []
|
||||||
|
// 第一页覆盖数据,后续页追加
|
||||||
|
this.dormInfo = this.queryParams.pageNum === 1 ?
|
||||||
|
newData :
|
||||||
|
[...this.dormInfo, ...newData]
|
||||||
|
// 判断是否还有更多数据(当前页数据量等于页大小,说明可能有下一页)
|
||||||
|
this.hasMore = newData.length === this.queryParams.pageSize
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: '加载失败',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('加载数据出错:', err)
|
||||||
|
uni.showToast({
|
||||||
|
title: '网络错误',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
} finally {
|
||||||
|
this.isLoading = false
|
||||||
|
// 停止下拉刷新
|
||||||
|
uni.stopPullDownRefresh()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 加载下一页
|
||||||
|
loadNextPage() {
|
||||||
|
console.log('触发加载下一页')
|
||||||
|
if (this.hasMore) {
|
||||||
|
this.queryParams.pageNum++
|
||||||
|
this.getList()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 下拉刷新
|
||||||
|
handleRefresh() {
|
||||||
|
console.log('触发下拉刷新')
|
||||||
|
this.resetData()
|
||||||
|
this.getList()
|
||||||
|
},
|
||||||
|
|
||||||
|
// 获取用户信息
|
||||||
|
async getUserProfile() {
|
||||||
|
try {
|
||||||
|
const res = await getUserProfile()
|
||||||
|
console.log('当前用户信息:', res)
|
||||||
|
if (res.roleGroup == "学生") {
|
||||||
|
this.queryParams.stuName = res.data.nickName
|
||||||
|
}
|
||||||
|
this.getList()
|
||||||
|
} catch (err) {
|
||||||
|
console.error('获取用户信息失败:', err)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 跳转添加页面
|
||||||
|
addDormInfo() {
|
||||||
|
if (this.dormInfo.length > 0) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '请勿重复提交',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
return
|
||||||
|
}
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages/dormitory/studentDormInfo/informationCollection`
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
// 点击列表项
|
||||||
|
handleItemClick(item) {
|
||||||
|
console.log('点击学生信息:', item)
|
||||||
|
// 可添加跳转详情页逻辑
|
||||||
|
// uni.navigateTo({ url: `/pages/detail?id=${item.id}` })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.page-container {
|
||||||
|
position: relative;
|
||||||
|
height: 100vh;
|
||||||
|
background-color: #f5f7fa;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 滚动容器 */
|
||||||
|
.scroll-container {
|
||||||
|
height: 100%;
|
||||||
|
/* 必须设置高度才能滚动 */
|
||||||
|
width: 100%;
|
||||||
|
padding-bottom: 120rpx;
|
||||||
|
/* 预留底部按钮空间 */
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 添加按钮 */
|
||||||
|
.add {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 50rpx;
|
||||||
|
right: 50rpx;
|
||||||
|
width: 90rpx;
|
||||||
|
height: 90rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
background-color: #1890FF;
|
||||||
|
color: white;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 60rpx;
|
||||||
|
box-shadow: 0 4rpx 12rpx rgba(24, 144, 255, 0.3);
|
||||||
|
z-index: 99;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 列表容器 */
|
||||||
|
.dorm-list {
|
||||||
|
padding: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 列表项 */
|
||||||
|
.dorm-item {
|
||||||
|
background-color: #fff;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
padding: 28rpx;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
|
||||||
|
transition: transform 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dorm-item:active {
|
||||||
|
transform: scale(0.99);
|
||||||
|
/* 点击反馈 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 列表项头部 */
|
||||||
|
.item-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
padding-bottom: 16rpx;
|
||||||
|
border-bottom: 1px solid #f0f0f0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.name {
|
||||||
|
font-size: 34rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag {
|
||||||
|
font-size: 24rpx;
|
||||||
|
padding: 4rpx 16rpx;
|
||||||
|
border-radius: 20rpx;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.head-tag {
|
||||||
|
background-color: #28a745;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 列表项内容 */
|
||||||
|
.item-content {
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #666;
|
||||||
|
line-height: 1.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-content view {
|
||||||
|
margin-bottom: 14rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-content view:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 加载状态 */
|
||||||
|
.loading,
|
||||||
|
.no-more,
|
||||||
|
.no-data {
|
||||||
|
text-align: center;
|
||||||
|
padding: 30rpx 0;
|
||||||
|
color: #999;
|
||||||
|
font-size: 28rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-data {
|
||||||
|
padding: 100rpx 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
480
pages/dormitory/studentDormInfo/informationCollection.vue
Normal file
480
pages/dormitory/studentDormInfo/informationCollection.vue
Normal file
@@ -0,0 +1,480 @@
|
|||||||
|
<template>
|
||||||
|
<view class="form-container">
|
||||||
|
<view class="form-title">2025-2026学年学生宿舍入住收集表</view>
|
||||||
|
<view class="form-desc">涉及住宿费核算,请同学们按照实际入住情况填写。</view>
|
||||||
|
|
||||||
|
<!-- 1. 校区 -->
|
||||||
|
<view class="form-item">
|
||||||
|
<view class="item-label">
|
||||||
|
<text class="required">*</text>校区
|
||||||
|
</view>
|
||||||
|
<picker @change="handleCampusChange" :range="campusOptions" :range-key="'name'">
|
||||||
|
<view class="picker-input">{{ form.campusName || '请选择校区' }}</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 2. 园区 -->
|
||||||
|
<view class="form-item" v-if="form.campusName">
|
||||||
|
<view class="item-label">
|
||||||
|
<text class="required">*</text>园区
|
||||||
|
</view>
|
||||||
|
<picker @change="handleParkChange" :range="parkOptions" :range-key="'name'">
|
||||||
|
<view class="picker-input">{{ form.parkName || '请选择园区' }}</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 3. 楼栋 -->
|
||||||
|
<view class="form-item" v-if="form.parkName">
|
||||||
|
<view class="item-label">
|
||||||
|
<text class="required">*</text>楼栋
|
||||||
|
</view>
|
||||||
|
<picker @change="handleBuildingChange" :range="buildingOptions" :range-key="'name'">
|
||||||
|
<view class="picker-input">{{ form.buildingName || '请选择楼栋' }}</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 4. 层(下拉框) -->
|
||||||
|
<view class="form-item" v-if="form.buildingName">
|
||||||
|
<view class="item-label">
|
||||||
|
<text class="required">*</text>层
|
||||||
|
</view>
|
||||||
|
<picker @change="handleFloorChange" :range="floorOptions" :range-key="'floor'">
|
||||||
|
<view class="picker-input">{{ form.floorName || '请选择楼层' }}</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 5. 宿舍 -->
|
||||||
|
<view class="form-item" v-if="form.floorName">
|
||||||
|
<view class="item-label">
|
||||||
|
<text class="required">*</text>宿舍
|
||||||
|
</view>
|
||||||
|
<picker @change="handleDormChange" :range="dormOptions" :range-key="'displayText'">
|
||||||
|
<view class="picker-input">{{ form.roomNo || '请选择宿舍' }}</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 6. 学生学号 -->
|
||||||
|
<view class="form-item">
|
||||||
|
<view class="item-label">
|
||||||
|
<text class="required">*</text>学生学号
|
||||||
|
</view>
|
||||||
|
<input class="input" v-model="form.stuNo" placeholder="请输入学生学号" />
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 7. 是否为宿舍长 -->
|
||||||
|
<view class="form-item">
|
||||||
|
<view class="item-label">
|
||||||
|
<text class="required">*</text>是否为宿舍长
|
||||||
|
</view>
|
||||||
|
<picker @change="handleDormHeadChange" :range="dormHeadOptions">
|
||||||
|
<view class="picker-input">{{ form.isDormHead || '请选择' }}</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 8. 入住时间 -->
|
||||||
|
<view class="form-item">
|
||||||
|
<view class="item-label">
|
||||||
|
<text class="required">*</text>入住时间
|
||||||
|
</view>
|
||||||
|
<picker mode="date" @change="handleCheckinTimeChange">
|
||||||
|
<view class="picker-input">{{ form.checkinTime || '请选择入住时间' }}</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 9. 本人证件照 -->
|
||||||
|
<view class="form-item">
|
||||||
|
<view class="item-label">
|
||||||
|
<text class="required">*</text>本人证件照
|
||||||
|
</view>
|
||||||
|
<view class="item-desc">请上传本人证件照,以便宿管阿姨能认识大家,谢谢。</view>
|
||||||
|
<view class="upload-btn" @click="handleUpload">
|
||||||
|
<text class="upload-icon">+</text>
|
||||||
|
<text>上传图片</text>
|
||||||
|
</view>
|
||||||
|
<view class="upload-tip">当前设置:最多上传1张图片,单个图片10MB以内</view>
|
||||||
|
<view class="upload-preview" v-if="form.photo">
|
||||||
|
<image :src="form.photo" mode="aspectFill" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 提交按钮 -->
|
||||||
|
<button class="submit-btn" @click="handleSubmit" v-hasPermi="['dms:dormStu:add']">提交</button>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
listAllCampus,
|
||||||
|
listParkByCampus,
|
||||||
|
listBuildingByPark,
|
||||||
|
listFloorByBuilding,
|
||||||
|
listAllRoomByFloor,
|
||||||
|
addStudent
|
||||||
|
} from "@/api/dms/studentDormInfo/index.js"
|
||||||
|
import {
|
||||||
|
getUserProfile
|
||||||
|
} from '@/api/system/user'
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
user: [],
|
||||||
|
form: {
|
||||||
|
campusName: '',
|
||||||
|
parkName: '',
|
||||||
|
buildingName: '',
|
||||||
|
floorName: '',
|
||||||
|
roomNo: '',
|
||||||
|
stuNo: '',
|
||||||
|
isDormitoryHead: '',
|
||||||
|
isDormHead: '',
|
||||||
|
checkinTime: '',
|
||||||
|
photo: '',
|
||||||
|
teacherName: '',
|
||||||
|
className: '',
|
||||||
|
deptName: '',
|
||||||
|
stuName: '',
|
||||||
|
displayText: '',
|
||||||
|
isInStudentsleep: '是',
|
||||||
|
},
|
||||||
|
// 校区选项
|
||||||
|
campusOptions: [],
|
||||||
|
// 园区选项(按校区联动)
|
||||||
|
parkOptions: [],
|
||||||
|
// 楼栋选项(按园区联动)
|
||||||
|
buildingOptions: [],
|
||||||
|
// 楼层选项(下拉框)
|
||||||
|
floorOptions: [],
|
||||||
|
// 宿舍号选项(下拉框)
|
||||||
|
dormOptions: [],
|
||||||
|
// 宿舍长选项
|
||||||
|
dormHeadOptions: ['否', '是'],
|
||||||
|
// 当前选中项的id
|
||||||
|
selectedCampus: null, // 选中的校区({id, name})
|
||||||
|
selectedPark: null, // 选中的园区
|
||||||
|
selectedBuilding: null, // 选中的楼栋
|
||||||
|
selectedFloor: null, // 选中的楼层
|
||||||
|
selectedDorm: null, //选中的宿舍
|
||||||
|
};
|
||||||
|
},
|
||||||
|
onLoad() {
|
||||||
|
this.getUserProfile()
|
||||||
|
this.listAllCampus()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 获取用户信息
|
||||||
|
async getUserProfile() {
|
||||||
|
try {
|
||||||
|
const res = await getUserProfile()
|
||||||
|
this.user = res
|
||||||
|
this.form.stuNo =
|
||||||
|
console.log('当前用户信息:', res)
|
||||||
|
} catch (err) {
|
||||||
|
console.error('获取用户信息失败:', err)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 获取校区数据
|
||||||
|
async listAllCampus() {
|
||||||
|
let res = await listAllCampus()
|
||||||
|
if (res.code == 200) {
|
||||||
|
this.campusOptions = [...res.data]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 根据校区id获取园区
|
||||||
|
async listParkByCampus(id) {
|
||||||
|
let res = await listParkByCampus(id)
|
||||||
|
if (res.code == 200) {
|
||||||
|
this.parkOptions = [...res.data]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 根据园区id获取楼栋
|
||||||
|
async listBuildingByPark(id) {
|
||||||
|
let res = await listBuildingByPark(id)
|
||||||
|
if (res.code == 200) {
|
||||||
|
this.buildingOptions = [...res.data]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 根据楼栋id获取楼层
|
||||||
|
async listFloorByBuilding(id) {
|
||||||
|
let res = await listFloorByBuilding(id)
|
||||||
|
if (res.code == 200) {
|
||||||
|
this.floorOptions = [...res.data]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 根据楼层id获取宿舍号
|
||||||
|
async listAllRoomByFloor(id) {
|
||||||
|
let res = await listAllRoomByFloor(id)
|
||||||
|
if (res.code == 200) {
|
||||||
|
this.dormOptions = [...res.data]
|
||||||
|
// 遍历数据,为每个对象添加 displayText 属性
|
||||||
|
this.dormOptions = res.data.map(v => ({
|
||||||
|
...v, // 保留原对象所有属性
|
||||||
|
// 新增拼接后的显示文本属性
|
||||||
|
displayText: `${v.roomNo} -- ${v.gender} -- 床位 ${v.bedNum} -- 已住 ${v.occupancy}`,
|
||||||
|
isFull: v.occupancy >= v.bedNum // 新增:判断是否满人
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 校区选择变化
|
||||||
|
handleCampusChange(e) {
|
||||||
|
this.form.campusName = this.campusOptions[e.detail.value].name;
|
||||||
|
this.form.parkName = ''; // 重置园区
|
||||||
|
this.form.buildingName = ''; // 重置楼栋
|
||||||
|
this.form.floorName = ''; // 重置楼层
|
||||||
|
this.form.roomNo = ''; // 重置宿舍
|
||||||
|
// 获取选中的校区id
|
||||||
|
this.selectedCampus = this.campusOptions[e.detail.value].id;
|
||||||
|
// 获取对应校区下面的园区
|
||||||
|
this.listParkByCampus(this.selectedCampus)
|
||||||
|
},
|
||||||
|
// 园区选择变化
|
||||||
|
handleParkChange(e) {
|
||||||
|
this.form.parkName = this.parkOptions[e.detail.value].name;
|
||||||
|
this.form.buildingName = ''; // 重置楼栋
|
||||||
|
this.form.floorName = ''; // 重置楼层
|
||||||
|
this.form.roomNo = ''; // 重置宿舍
|
||||||
|
// 获取选中的园区的id
|
||||||
|
this.selectedPark = this.parkOptions[e.detail.value].id;
|
||||||
|
// 获取对应园区下面的楼栋
|
||||||
|
this.listBuildingByPark(this.selectedPark)
|
||||||
|
},
|
||||||
|
// 楼栋选择变化
|
||||||
|
handleBuildingChange(e) {
|
||||||
|
this.form.buildingName = this.buildingOptions[e.detail.value].name;
|
||||||
|
this.form.floorName = ''; // 重置楼层
|
||||||
|
this.form.roomNo = ''; // 重置宿舍
|
||||||
|
// 获取选中的楼栋的id
|
||||||
|
this.selectedBuilding = this.buildingOptions[e.detail.value].id;
|
||||||
|
// 获取选中的楼栋下面的楼层
|
||||||
|
this.listFloorByBuilding(this.selectedBuilding)
|
||||||
|
},
|
||||||
|
// 楼层选择变化(下拉框)
|
||||||
|
handleFloorChange(e) {
|
||||||
|
this.form.floorName = this.floorOptions[e.detail.value].floor;
|
||||||
|
this.form.roomNo = ''; // 重置宿舍
|
||||||
|
// 获取选中的楼层的id
|
||||||
|
this.selectedFloor = this.floorOptions[e.detail.value].id;
|
||||||
|
// 获取选中的楼层下面的宿舍号
|
||||||
|
this.listAllRoomByFloor(this.selectedFloor)
|
||||||
|
},
|
||||||
|
// 宿舍号选择变化(行拉框)
|
||||||
|
handleDormChange(e) {
|
||||||
|
const index = e.detail.value;
|
||||||
|
const selectedDorm = this.dormOptions[index]; // 获取选中的宿舍对象
|
||||||
|
|
||||||
|
// 判断是否满人
|
||||||
|
if (selectedDorm.isFull) {
|
||||||
|
// 满人时提示并重置选择
|
||||||
|
uni.showToast({
|
||||||
|
title: `宿舍 ${selectedDorm.roomNo} 已住满,无法选择`,
|
||||||
|
icon: 'none',
|
||||||
|
duration: 2000
|
||||||
|
});
|
||||||
|
// 重置宿舍选择(如果之前有选中值则保留,否则为空)
|
||||||
|
if (!this.form.roomNo) {
|
||||||
|
this.form.roomNo = '';
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 未满人时正常选中
|
||||||
|
this.form.roomNo = selectedDorm.roomNo; // 显示拼接文本
|
||||||
|
this.selectedDorm = selectedDorm.id; // 存储宿舍ID(用于提交)
|
||||||
|
},
|
||||||
|
// 宿舍长选择变化
|
||||||
|
handleDormHeadChange(e) {
|
||||||
|
this.form.isDormitoryHead = this.dormHeadOptions[e.detail.value] == '是' ? 1 : 0;
|
||||||
|
this.form.isDormHead = this.dormHeadOptions[e.detail.value]
|
||||||
|
},
|
||||||
|
// 入住时间选择变化
|
||||||
|
handleCheckinTimeChange(e) {
|
||||||
|
this.form.checkinTime = e.detail.value;
|
||||||
|
},
|
||||||
|
// 证件照上传
|
||||||
|
handleUpload() {
|
||||||
|
uni.chooseImage({
|
||||||
|
count: 1,
|
||||||
|
sizeType: ['compressed'],
|
||||||
|
sourceType: ['album', 'camera'],
|
||||||
|
success: (res) => {
|
||||||
|
this.form.photo = res.tempFilePaths[0];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 提交表单
|
||||||
|
async handleSubmit() {
|
||||||
|
console.log(this.form);
|
||||||
|
// 验证必填项
|
||||||
|
if (
|
||||||
|
!this.form.campusName || // 校区名称(字符串,空则false)
|
||||||
|
!this.form.parkName || // 园区名称(字符串,空则false)
|
||||||
|
!this.form.buildingName || // 楼栋名称(字符串,空则false)
|
||||||
|
(!this.form.floorName && this.form.floorName !== 0) || // 楼层(数值,排除0的误判)
|
||||||
|
(!this.form.roomNo && this.form.roomNo !== 0) || // 宿舍号(数值,排除0的误判)
|
||||||
|
!this.form.isDormHead || // 是否宿舍长(值为"是"/"否")
|
||||||
|
!this.form.checkinTime || // 入住时间(日期字符串,空则false)
|
||||||
|
!this.form.photo // 证件照(blob路径,空则false,若必填需加)
|
||||||
|
) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '带*号的为必填项,请填写完整',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 2000
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.form.dormitoryId = this.selectedDorm;
|
||||||
|
// 模拟提交
|
||||||
|
uni.showLoading({
|
||||||
|
title: '提交中...'
|
||||||
|
});
|
||||||
|
// 添加入住信息
|
||||||
|
let res = await addStudent(this.form);
|
||||||
|
if (res.code == 200) {
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showToast({
|
||||||
|
title: '提交成功',
|
||||||
|
icon: 'success'
|
||||||
|
});
|
||||||
|
setTimeout(() => {
|
||||||
|
// 重置表单
|
||||||
|
this.form = {
|
||||||
|
campusName: '',
|
||||||
|
parkName: '',
|
||||||
|
buildingName: '',
|
||||||
|
floorName: '',
|
||||||
|
roomNo: '',
|
||||||
|
stuNo: '',
|
||||||
|
isDormitoryHead: '',
|
||||||
|
checkinTime: '',
|
||||||
|
photo: ''
|
||||||
|
};
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages/dormitory/studentDormInfo/index`
|
||||||
|
})
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.form-container {
|
||||||
|
padding: 30rpx;
|
||||||
|
background-color: #fff;
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-title {
|
||||||
|
font-size: 36rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-desc {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #666;
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 40rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-item {
|
||||||
|
margin-bottom: 40rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-label {
|
||||||
|
font-size: 28rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #333;
|
||||||
|
margin-bottom: 16rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 红色*号样式
|
||||||
|
.required {
|
||||||
|
color: #ff4d4f;
|
||||||
|
margin-right: 6rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-desc {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #999;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下拉框样式
|
||||||
|
.picker-input {
|
||||||
|
width: 100%;
|
||||||
|
height: 80rpx;
|
||||||
|
border: 1px solid #eee;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0 20rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
font-size: 28rpx;
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 输入框样式
|
||||||
|
.input {
|
||||||
|
width: 100%;
|
||||||
|
height: 80rpx;
|
||||||
|
border: 1px solid #eee;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
padding: 0 20rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
font-size: 28rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 图片上传样式
|
||||||
|
.upload-btn {
|
||||||
|
width: 200rpx;
|
||||||
|
height: 80rpx;
|
||||||
|
border: 1px dashed #ccc;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 10rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #666;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.upload-icon {
|
||||||
|
font-size: 40rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.upload-tip {
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: #999;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.upload-preview {
|
||||||
|
width: 200rpx;
|
||||||
|
height: 200rpx;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.upload-preview image {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 提交按钮样式
|
||||||
|
.submit-btn {
|
||||||
|
width: 100%;
|
||||||
|
height: 90rpx;
|
||||||
|
background-color: #1890ff;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 32rpx;
|
||||||
|
border-radius: 45rpx;
|
||||||
|
margin-top: 60rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
BIN
static/images/workbench/studentDormInfo.png
Normal file
BIN
static/images/workbench/studentDormInfo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
Reference in New Issue
Block a user