移动端V1.0

This commit is contained in:
2025-07-16 15:34:34 +08:00
commit 194b0750fd
1083 changed files with 178295 additions and 0 deletions

View File

@@ -0,0 +1,262 @@
<template>
<view class="detail">
<!-- 轮播图区域 -->
<view style="margin: 40rpx;">
<uni-swiper-dot :info="swiperlist" :current="current" :dots-styles="dotStyles" field="content" mode="round">
<swiper interval="2000" autoplay class="swiper-box" @change="change">
<swiper-item v-for="(item, index) in list.roomImgs" :key="index">
<view class="swiper-item">
<image mode="aspectFill" :src="basePath+item"></image>
</view>
</swiper-item>
</swiper>
</uni-swiper-dot>
</view>
<!-- 房间信息区域 -->
<view class="content">
<view class="title">
<view class="title-a">
<text>{{list.roomName}}</text>
<view v-for="(tab,index) in rolelist" :key="index" v-if="list.status==tab.dictValue"
:class="[list.status==0?'open-up':'',list.status==1?'shutdown':'',list.status==2?'maintenance':'']">
{{tab.dictLabel}}
</view>
</view>
<view class="title-b">
<uni-icons color="#FFBB12" type="staff-filled" size="24"></uni-icons>
<text>{{list.roomCapacity}}/</text>
</view>
</view>
<view class="introduction">
<text>{{list.roomInfo}}</text>
</view>
</view>
<!-- 时间选择区域 -->
<view class="time-zone">
<view class="time-header">
<text>开放时间</text>
<text><text style="color: red;">*</text>请选择日期进行预约</text>
</view>
<!-- 日历组件 -->
<uni-calendar
:insert="true"
:lunar="true"
:start-date="startDate"
:end-date="endDate"
:selected="selectedDates"
@change="onCalendarChange"
/>
<view class="usage-matters">
<text>使用事项</text>
<text>{{list.roomMatter}}</text>
</view>
</view>
</view>
</template>
<script>
import { getRoom } from '@/api/OneStopCommunity/room.js';
import { getDicts } from '@/api/system/dict/data.js';
import { baseUrl } from "@/config.js";
export default {
data() {
return {
basePath: baseUrl,
swiperlist: [],
list: [],
current: 0,
dotStyles: {
width: 12,
backgroundColor: 'rgba(255, 255, 255, 0.4)',
border: '1px rgba(255, 255, 255, 0.4) solid',
color: '#fff',
selectedBackgroundColor: '#1890FF',
selectedBorder: '1px #1890FF solid'
},
id: "",
rolelist: [],
startDate: this.getTodayDate(),
endDate: this.getFourteenDaysLaterDate(),
selectedDates: []
};
},
onLoad(option) {
this.id = option.id;
Promise.all([
this.getRoomdetail(),
this.getstate()
]).catch(error => {
console.error('初始化失败:', error);
uni.showToast({ title: '数据加载失败', icon: 'none' });
});
},
methods: {
change(e) {
this.current = e.detail.current;
},
async getRoomdetail() {
try {
const res = await getRoom(this.id);
if (res.code === 200) {
this.list = res.data;
this.list.roomImgs = this.list.roomImgs ? this.list.roomImgs.split(",") : [];
this.swiperlist = this.list.roomImgs.map(img => this.basePath + img);
}
} catch (error) {
throw error;
}
},
async getstate() {
try {
const res = await getDicts('rt_fu_room_status');
this.rolelist = res.data;
} catch (error) {
throw error;
}
},
getTodayDate() {
const today = new Date();
return `${today.getFullYear()}-${String(today.getMonth()+1).padStart(2,'0')}-${String(today.getDate()).padStart(2,'0')}`;
},
getFourteenDaysLaterDate() {
const date = new Date();
date.setDate(date.getDate() + 14);
return `${date.getFullYear()}-${String(date.getMonth()+1).padStart(2,'0')}-${String(date.getDate()).padStart(2,'0')}`;
},
onCalendarChange(e) {
uni.navigateTo({
url: `./reservation?rtTime=${e.fulldate}&list=${JSON.stringify(this.list)}`
});
}
}
};
</script>
<style lang="scss" scoped>
.detail {
background-color: rgba(244, 244, 244, 0.6);
padding-bottom: 40rpx;
.swiper-box {
width: 100%;
height: 600rpx;
border-radius: 16rpx;
overflow: hidden;
.swiper-item {
height: 600rpx;
image {
width: 100%;
height: 100%;
border-radius: 16rpx;
}
}
}
.content {
margin: 0 40rpx;
.title {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20rpx;
.title-a {
display: flex;
align-items: center;
text {
font-size: 40rpx;
font-weight: 600;
font-family: PingFang SC;
}
.open-up, .shutdown, .maintenance {
margin-left: 20rpx;
font-size: 20rpx;
padding: 4rpx 12rpx;
border-radius: 8rpx;
}
.open-up {
background-color: #E7FAF0;
border: 1px solid #D0F5E0;
color: #71E2A3;
}
.shutdown {
background-color: #FFEDED;
border: 1px solid #FF9292;
color: #FF9292;
}
.maintenance {
background-color: #eeeeee;
border: 1px solid #cfcfcf;
color: #818181;
}
}
.title-b {
display: flex;
align-items: center;
font-size: 28rpx;
color: #666;
uni-icons {
margin-right: 8rpx;
}
}
}
.introduction {
font-size: 28rpx;
color: #555;
line-height: 1.6;
}
}
.time-zone {
background-color: #fff;
border-radius: 40rpx 40rpx 0 0;
padding: 40rpx;
margin-top: 40rpx;
.time-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 30rpx;
text:first-child {
font-size: 36rpx;
font-weight: 550;
}
text:last-child {
font-size: 24rpx;
color: #999;
}
}
.usage-matters {
margin-top: 40rpx;
font-size: 28rpx;
color: #666;
text:first-child {
font-weight: bold;
margin-right: 10rpx;
}
}
}
}
</style>

View File

@@ -0,0 +1,495 @@
<template>
<view class="functionhouse">
<scroll-view class="nav-scroll" scroll-x="true">
<view class="navs">
<text @tap="tabChange(item,index)" :class="[tabIndex==index?'active':'']" v-for="(item,index) in tabs"
:key="index">{{item}}</text>
</view>
<view class="notices">
<uni-notice-bar @click="toggle()" show-icon scrollable :text="noticeText" color="#202020"
background-color="white" />
</view>
<view class="search">
<uni-search-bar cancel-text="搜索" placeholder="请输入房间名" @clear="clear" @cancel="search" @confirm="search"
show-action v-model="queryParams.roomName">
</uni-search-bar>
</view>
</scroll-view>
<view style="padding-bottom: 300rpx;"></view>
<scroll-view class="scroll-views" scroll-y="true" @scrolltolower="scrolltolower">
<view class="list">
<view v-for="(item,index) in list" :key="index" class="item" @tap="toDetailPage(item)">
<image :src="basePath+item.roomImgs"></image>
<!-- <image v-else></image> -->
<view class="box">
<view class="title">
<text>{{item.roomName}}</text>
<view v-for="(tab,index) in rolelist" :key="index" v-if="item.roomStatus==tab.dictValue"
:class="[item.roomStatus==1?'open-up':'',item.roomStatus==0?'shutdown':'',item.roomStatus==2?'maintenance':'']"
style="">{{tab.dictLabel}}</view>
</view>
<view>
<text class="introduction">{{item.roomInfo}}</text>
</view>
<view class="bottom">
<view style="display: flex;">
<view>
<uni-icons color="#FFBB12" type="staff-filled" size="21"></uni-icons>
</view>
<view>
<text>{{item.roomCapacity}}/</text>
</view>
</view>
<view>
<text>
详情
</text>
<uni-icons color="#272636" type="forward" size="16"></uni-icons>
</view>
</view>
</view>
</view>
</view>
<view class="empty" v-if="list.length==0&&topLoading==false">
<image src="@/static/empty.png" mode="widthFix"></image>
暂时没有数据
</view>
<view class="loading-more-top" v-if="topLoading">
<uni-load-more style="padding-top: 90px;" status="loading" />
</view>
<view class="loading-more" v-if="loading">
<uni-load-more status="loading" />
</view>
<view class="no-more" v-if="!loading&&list.length!=0">
到底啦~~
</view>
</scroll-view>
<uni-popup ref="popup">
<view class="container">
<view class="title">
<text>
学生社区简介
</text>
</view>
<view class="introduction">
<text class="introduction-1">
一站式学生社区欢迎你~~
</text>
<view class="introduction-a">
<view>
<text>联系电话0771-2033319</text>
</view>
<view>
<text>QQ2848561721</text>
</view>
</view>
</view>
</view>
</uni-popup>
</view>
</template>
<script>
import {
listRoom
} from '@/api/OneStopCommunity/room.js';
import {
getDicts
} from '@/api/system/dict/data.js';
import {
baseUrl
} from "@/config.js";
export default {
data() {
return {
basePath: baseUrl,
topLoading: true,
loading: false,
tabs: ["全部", "开放中", "关闭中"],
tabIndex: 0,
noticeText: "一站式社区欢迎你 ",
queryParams: {
pageNum: 1,
pageSize: 10,
roomStatus: ""
},
list: [
],
rolelist: [],
imgsrc: ""
}
},
methods: {
cancel(res) {
this.queryParams.roomName = ""
this.getlist()
},
clear(res) {
this.queryParams.roomName = ""
this.search() // 直接调用统一的搜索方法 知无涯
},
search() {
// 重置为第一页并清空当前列表 知无涯
this.queryParams.pageNum = 1
this.list = [] // 清空现有数据 知无涯
this.topLoading = true // 显示顶部加载状态 知无涯
this.getlist()
},
toggle() {
// open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
this.$refs.popup.open("center")
},
tabChange(item, index) {
this.tabIndex = index;
switch (item) {
case "全部":
this.queryParams.roomStatus = ""
this.getlist()
break;
case "开放中":
this.queryParams.roomStatus = 1
this.getlist()
break;
case "关闭中":
this.queryParams.roomStatus = 0
this.getlist()
break;
default:
}
},
//详情
toDetailPage(item) {
console.log(item)
uni.navigateTo({
url: `./detail?id=${item.roomId}`
})
},
scrolltolower() {
if (!this.loading && this.queryParams.pageNum < this.totalPages) {
this.queryParams.pageNum++
this.loading = true
this.getlist()
}
},
async getlist() {
let res = await listRoom(this.queryParams)
if (res.code == 200) {
// 处理图片数据 知无涯
const arr = res.rows.map(item => {
return {
...item,
roomImgs: item.roomImgs ? item.roomImgs.split(",")[0] : null
}
})
// 统一处理数据追加逻辑 知无涯
this.list = this.queryParams.pageNum === 1 ?
arr : [...this.list, ...arr]
this.totalPages = Math.ceil(res.total / this.queryParams.pageSize)
this.loading = false
this.topLoading = false
}
},
async getstate() {
let res = await getDicts('rt_fu_room_status')
this.rolelist = res.data
console.log(res.data)
},
},
onShow() {
this.getlist()
this.getstate()
},
}
</script>
<style lang="scss" scoped>
.functionhouse {
background-color: #F5F5F7;
.search {
width: 100%;
background-color: white;
// position: fixed;
z-index: 10;
// top: 80rpx;
// background-color: #F5F5F7;
/deep/ .uni-searchbar__box {
// .uni-searchbar__box
// background-color: white !important;
}
}
.nav-scroll {
position: fixed;
white-space: nowrap;
width: 100%;
background-color: white;
z-index: 2;
.navs {
padding: 26rpx 47rpx;
text {
font-size: 28rpx;
margin-right: 55rpx;
color: #202020;
opacity: 0.5;
&.active {
opacity: 1;
font-weight: bold;
border-bottom: 5px solid #1890FF;
padding-bottom: 2px;
}
}
}
.notices {
border-top: 1px solid #ECF1F7;
/deep/ .uni-icons {
color: #1890FF !important;
}
.uni-noticebar {
margin-bottom: 0;
}
}
scroll-view {
position: fixed;
z-index: 2;
}
}
.scroll-views {
height: calc(100vh - 10px);
.list {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-content: flex-start;
padding: 0rpx 24rpx;
.item {
width: 48%;
// width: 324rpx;
// height: 480rpx;
background-color: white;
border-radius: 20rpx;
&:nth-child(n+3) {
// background-color: #202020 !important;
margin-top: 20rpx;
}
.box {
padding: 20rpx 20rpx;
.introduction {
word-break: break-all;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
text-overflow: ellipsis;
font-size: 26rpx;
word-spacing: 4rpx;
letter-spacing: 4rpx;
color: #202020;
opacity: .5;
margin-top: 20rpx;
}
.bottom {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 28rpx;
margin-top: 34rpx;
}
}
image {
border-radius: 20rpx 20rpx 0rpx 0rpx;
width: 100%;
height: 300rpx;
}
.title {
display: flex;
justify-content: space-between;
text {
font-family: PingFang SC;
font-size: 32rpx;
font-weight: 700;
}
}
}
}
.no-more {
text-align: center;
color: gray;
padding-bottom: 10px;
padding-top: 20rpx;
}
.empty {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 200rpx;
color: #9E9E9E;
font-size: 36rpx;
image {
width: 250rpx;
margin-bottom: 50rpx;
}
}
}
.container {
width: 60vw;
height: 400rpx;
border-radius: 20rpx;
background-color: white;
padding: 20rpx 30rpx;
.title {
text-align: center;
font-size: 40rpx;
font-weight: 700;
}
.introduction {
margin-top: 40rpx;
padding-top: 20rpx;
font-size: 35rpx;
font-family: PingFang SC;
font-weight: 500;
height: 300rpx;
border-top: 1px solid silver;
.introduction-1 {
word-break: break-all;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
}
.introduction-a {
margin-top: 40rpx;
font-size: 28rpx;
color: #787878;
&>view {
margin-bottom: 20rpx;
}
}
}
}
/* 搜索框外层容器样式 知无涯 */
.search {
width: 100%; // 宽度100%撑满父容器
background-color: white; // 白色背景
padding: 10rpx 24rpx; // 内边距上下10rpx左右24rpx
display: flex; // 启用flex布局
align-items: center; // 子元素垂直居中
/* 深度选择器(穿透组件样式) */
/deep/ .uni-searchbar {
flex: 1; // 占据剩余空间
display: flex; // 启用flex布局
align-items: center; // 子元素垂直居中
/* 搜索输入框样式 */
&__box {
flex: 1; // 占据剩余空间
display: flex; // 启用flex布局
align-items: center; // 子元素垂直居中
background-color: white !important; // 强制白色背景
border: 1px solid #1890FF !important; // 蓝色边框
border-radius: 30rpx; // 30rpx圆角
height: 60rpx; // 固定高度60rpx
}
/* 占位符文本样式 */
&__text-placeholder {
color: #999 !important; // 浅灰色文字
}
/* 搜索按钮样式 */
&__cancel {
background-color: #1890FF !important; // 蓝色背景
color: white !important; // 白色文字
border-radius: 20rpx; // 30rpx圆角
height: 60rpx; // 高度与输入框保持一致
line-height: 60rpx; // 行高=高度实现垂直居中
font-size: 28rpx; // 文字大小
margin-left: 5rpx; // 与输入框的间距
min-width: 75rpx; // 最小宽度(避免文字过短时变形)
/* 按钮点击态效果 */
&:active {
background-color: #1070CC !important; // 点击时变为深蓝色
}
}
}
}
.open-up {
width: 80rpx;
height: 32rpx;
background-color: #E7FAF0;
border: 1px #D0F5E0 solid;
color: #71E2A3;
font-size: 20rpx;
margin-top: 4rpx;
text-align: center;
}
.shutdown {
width: 80rpx;
height: 35rpx;
line-height: 35rpx;
background-color: #FFEDED;
border: 1px #FF9292 solid;
color: #FF9292;
font-size: 20rpx;
margin-top: 4rpx;
text-align: center;
}
.maintenance {
width: 80rpx;
height: 35rpx;
line-height: 35rpx;
background-color: #eeeeee;
border: 1px #cfcfcf solid;
color: #818181;
font-size: 20rpx;
margin-top: 4rpx;
text-align: center;
}
}
</style>

View File

@@ -0,0 +1,211 @@
<template>
<u-popup :show="pickShow" mode="bottom" :round="10" closeOnClickOverlay @close="onCancel">
<view class="multiple-pick-content">
<view class="top">
<view class="cancel" @tap="onCancel">取消</view>
<view class="confirm" @tap="onConfirm">确认</view>
</view>
<view class="list-container">
<view class="item-container">
<view class="item" :class="{'selected': isSelected(item), 'disabled': isDisabled(item)}"
v-for="(item, index) in list" :key="index" @tap="onClick(item, index)">
<view>
{{ keyName ? item[keyName] : item }}
</view>
<u-icon v-if="isSelected(item)" name="checkmark" :color="isDisabled(item) ? '#959595' : '#2979ff'"
size="18"></u-icon>
</view>
</view>
</view>
</view>
</u-popup>
</template>
<script>
export default {
name: "multiplePick",
components: {UIcon, UPopup},
data() {
return {
pickShow: false,
selecteds: []
};
},
props: {
/**
* 开启单选
*/
single: Boolean,
/**
* 可选最多项
*/
max: Number,
/**
* 超出最大项提示
*/
maxMessage: String,
/**
* 数据集合
*/
list: Array,
/**
* 默认选择
*/
defaults: Array,
/**
* 主键名,如果没有,则识别为字符串数组
*/
keyName: String,
/**
* 禁用属性名前提是有keyName
*/
disabledKey: String,
/**
* 禁用值前提是有disabledKey
*/
disabledValue: String
},
watch: {
defaults: {
handler(n) {
// 不能直接赋值否则selecteds变化时会改变默认值
this.selecteds = n.slice(0, n.length);
},
immediate: true
}
},
methods: {
/**
* 当前项是否禁用
*/
isDisabled(item) {
return this.keyName && this.disabledKey && this.disabledValue && item[this.disabledKey] === this.disabledValue;
},
/**
* 当前项是否选中
*/
isSelected(item) {
return this.selecteds.includes(this.keyName ? item[this.keyName] : item);
},
/**
* 打开选择器
*/
show() {
this.pickShow = true;
},
/**
* 关闭选择器
*/
close() {
this.pickShow = false;
},
/**
* 数据项点击监听
*/
onClick(item, index) {
if (this.isDisabled(item)) {
// 如果是禁用的,不执行
return;
}
// 获取当前项值
const value = this.keyName ? item[this.keyName] : item;
if (this.single) {
// 开启单选
this.selecteds = [];
this.selecteds.push(value);
} else {
// 获取当前项在已选中的集合中的位置
const i = this.selecteds.indexOf(value);
// 存在则删除,不存在则添加
if (i !== -1) {
this.selecteds.splice(i, 1);
} else {
if (this.max && this.selecteds.length >= this.max) {
// 如果有最大值且已选超过最大值
if (this.maxMessage) {
// 有提示提示内容
uni.showToast({
icon: 'none',
title: this.maxMessage
});
return;
}
// 否则删掉最旧的数据
this.selecteds.shift();
}
this.selecteds.push(value);
}
}
},
/**
* 确认按钮事件
*/
onConfirm() {
this.$emit('confirm', this.selecteds);
},
/**
* 取消按钮事件
*/
onCancel() {
// 重新赋值选中的集合
this.selecteds = this.defaults.slice(0, this.defaults.length);
this.pickShow = false;
this.$emit('cancel');
}
}
}
</script>
<style lang="scss" scoped>
.multiple-pick-content {
padding: 20px;
box-sizing: border-box;
min-height: 200px;
max-height: 50vh;
.top {
padding: 0 0 10px 0;
width: 100%;
display: flex;
justify-content: space-between;
line-height: 32px;
.cancel {
color: #f43d18;
}
.confirm {
color: #0066ff;
}
}
.list-container {
padding: 10px 0px 40px 0px;
box-sizing: border-box;
max-height: calc(50vh - 42px);
height: 100%;
overflow-y: auto;
}
.item-container {
width: 100%;
.item {
padding: 10px 0;
box-sizing: border-box;
width: 100%;
display: flex;
justify-content: space-between;
&.selected {
color: #2979ff !important;
}
&.disabled {
color: #959595 !important;
}
}
}
}
</style>

View File

@@ -0,0 +1,511 @@
<template>
<view class="reservation">
<view class="form-container">
<form>
<view class="form-item">
<label>功能房</label>
<input type="text" v-model="list.roomName" disabled placeholder-class="input-placeholder" />
</view>
<view class="form-item">
<label>主题</label>
<input type="text" v-model="formData.rtTheme" placeholder="请输入活动主题" placeholder-class="input-placeholder" />
</view>
<view class="form-item">
<label>申请人</label>
<input type="text" v-model="formData.rtCreatRole" placeholder="请输入申请人姓名" placeholder-class="input-placeholder" />
</view>
<view class="form-item">
<label>使用部门/学院</label>
<picker mode="selector" :range="deptXZJGList" @change="handleDeptChange">
<view class="picker">
{{ formData.rtDepar || '请选择' }}
</view>
</picker>
</view>
<view class="form-item">
<label>参与人数</label>
<input type="number" v-model="formData.rtPeople" :placeholder="'最多可容纳'+list.roomCapacity+'人'" placeholder-class="input-placeholder" />
</view>
<view class="form-item">
<label>预约用途</label>
<picker range-key="dictLabel" :value="rangeIndex" :range="Reserveduse" @change="classChange">
<view class="uni-input">
<text v-if="Reserveduse.length" class="val">{{Reserveduse[rangeIndex].dictLabel}}</text>
<text v-else class="placeholder">请选择预约用途</text>
<uni-icons type="down" size="16" color="#202020"></uni-icons>
</view>
</picker>
</view>
<view class="form-item">
<label>人员类型</label>
<view class="trigger" @click="showDrawer = true">
<view class="uni-input">
<text v-if="selectedRoles.length">{{ selectedRoles.join(", ") }}</text>
<text v-else class="placeholder">请选择人员类型</text>
<uni-icons type="down" size="16" color="#202020"></uni-icons>
</view>
</view>
</view>
</form>
</view>
<view class="time-selection">
<view class="time-header">
<text>选择时间段</text>
<text><text style="color: red;">*</text>请选择可用时间段</text>
</view>
<view class="time-slots">
<view v-for="(item,index) in slotslist" :key="index" class="slot-item">
<button @click="selectTimeSlot(item,index)"
:disabled="item.isOccupy==1"
:class="{
'active': timeindex===index,
'disabled': item.isOccupy==1,
'warning': formData.rtPeople > list.roomCapacity
}">
{{item.openingHours}}
</button>
</view>
</view>
<view class="usage-matters">
<text>使用事项</text>
<text>{{list.roomMatter}}</text>
</view>
<button type="primary"
:disabled="isSubmitting || !isFormValid"
class="submit-btn"
@tap="onSubmit">
{{isSubmitting ? '提交中...' : '提交预约'}}
</button>
</view>
<!-- 人员类型选择抽屉 -->
<view v-if="showDrawer" class="drawer-overlay" @click="showDrawer = false"></view>
<view v-if="showDrawer" class="drawer">
<view class="drawer-header">
<text>选择人员类型</text>
<text class="drawer-close" @click="showDrawer = false">完成</text>
</view>
<view class="drawer-body">
<uni-data-checkbox
:multiple="true"
v-model="selectedRoles"
mode="tag"
:map="{text:'dictLabel',value:'dictValue'}"
:localdata="rolelist">
</uni-data-checkbox>
</view>
</view>
</view>
</template>
<script>
import {
selectRtFuReservationTime,
addRoomReservation,
getXZJGDept
} from '@/api/OneStopCommunity/room.js';
import { getDicts } from '@/api/system/dict/data.js';
export default {
data() {
return {
showDrawer: false,
selectedRoles: [],
isSubmitting: false,
timeindex: null,
formData: {
rtTheme: "",
rtCreatRole: "",
rtDepar: "",
rtPeople: "",
},
rangeIndex: 0,
roomNo: "",
rtTime: "",
list: {},
slotslist: [],
Reserveduse: [],
rolelist: [],
deptXZJGList: []
};
},
computed: {
isFormValid() {
return (
this.formData.rtTheme &&
this.formData.rtCreatRole &&
this.formData.rtDepar &&
this.formData.rtPeople > 0 &&
this.formData.rtPeople <= this.list.roomCapacity &&
this.Reserveduse.length > 0 &&
this.selectedRoles.length > 0 &&
this.timeindex !== null
);
}
},
methods: {
handleDeptChange(e) {
this.formData.rtDepar = this.deptXZJGList[e.detail.value];
},
classChange(e) {
this.rangeIndex = e.detail.value;
},
selectTimeSlot(item, index) {
this.timeindex = index;
},
async getXZJGDeptList() {
try {
const res = await getXZJGDept();
//二级学院排列位置调整
let depts = res.data;
let quList = depts.slice(14,25)
depts.splice(14,11);
depts.splice(0, 0, ...quList);
this.deptXZJGList = depts;
//this.deptXZJGList = res.data;
} catch (error) {
console.error('获取部门列表失败:', error);
uni.showToast({ title: '获取部门列表失败', icon: 'none' });
}
},
async getlist() {
try {
const res = await selectRtFuReservationTime({
roomNo: this.list.roomNo,
rtTime: this.rtTime
});
this.slotslist = res.data || [];
} catch (error) {
console.error('获取时间段失败:', error);
uni.showToast({ title: '获取可用时间段失败', icon: 'none' });
}
},
async getReserved() {
try {
const res = await getDicts('routine_rtfureservations_rt_purpose');
this.Reserveduse = res.data;
} catch (error) {
console.error('获取预约用途失败:', error);
}
},
async getrole() {
try {
const res = await getDicts('routine_rtfureservation_rt_role');
this.rolelist = res.data;
} catch (error) {
console.error('获取人员类型失败:', error);
}
},
validateForm() {
if (!this.formData.rtTheme) {
uni.showToast({ title: '请输入活动主题', icon: 'none' });
return false;
}
if (!this.formData.rtCreatRole) {
uni.showToast({ title: '请输入申请人姓名', icon: 'none' });
return false;
}
if (!this.formData.rtDepar) {
uni.showToast({ title: '请选择使用部门/学院', icon: 'none' });
return false;
}
if (!this.formData.rtPeople || this.formData.rtPeople <= 0) {
uni.showToast({ title: '请输入有效的参与人数', icon: 'none' });
return false;
}
if (this.formData.rtPeople > this.list.roomCapacity) {
uni.showToast({
title: `人数超过限制(最多${this.list.roomCapacity}人)`,
icon: 'none'
});
return false;
}
if (!this.Reserveduse.length || !this.Reserveduse[this.rangeIndex]) {
uni.showToast({ title: '请选择预约用途', icon: 'none' });
return false;
}
if (this.selectedRoles.length === 0) {
uni.showToast({ title: '请选择人员类型', icon: 'none' });
return false;
}
if (this.timeindex === null) {
uni.showToast({ title: '请选择预约时间段', icon: 'none' });
return false;
}
return true;
},
async onSubmit() {
if (this.isSubmitting) return;
if (!this.validateForm()) return;
this.isSubmitting = true;
try {
const form = {
...this.formData,
rtPurpose: this.Reserveduse[this.rangeIndex].dictLabel,
rtRole: this.selectedRoles.join(","),
roomNo: this.list.roomNo,
roomName: this.list.roomName,
rtNo: this.slotslist[this.timeindex].rtNo,
rtTime: this.rtTime,
rtTimePeriod: this.slotslist[this.timeindex].openingHours
};
console.log('提交数据:', form);
const res = await addRoomReservation(form);
if (res.code === 200) {
uni.showToast({ title: '预约成功' });
setTimeout(() => {
uni.redirectTo({ url: "../appointment/index" });
}, 1500);
} else {
uni.showToast({ title: res.msg || '预约失败', icon: 'none' });
}
} catch (error) {
console.error('预约提交失败:', error);
uni.showToast({ title: '预约提交失败', icon: 'none' });
} finally {
this.isSubmitting = false;
}
}
},
onLoad(option) {
this.rtTime = option.rtTime;
this.list = JSON.parse(option.list);
this.formData.roomName = this.list.roomName;
Promise.all([
this.getlist(),
this.getReserved(),
this.getrole(),
this.getXZJGDeptList()
]).catch(error => {
console.error('初始化失败:', error);
});
}
};
</script>
<style lang="scss" scoped>
.reservation {
background-color: #f4f4f4;
min-height: 100vh;
padding-bottom: 40rpx;
.form-container {
padding: 40rpx;
background-color: #fff;
margin-bottom: 20rpx;
.form-item {
margin-bottom: 30rpx;
padding: 20rpx;
background-color: #fff;
border-radius: 12rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
label {
display: block;
margin-bottom: 20rpx;
font-size: 28rpx;
color: #333;
font-weight: 500;
}
input, .picker {
height: 80rpx;
line-height: 80rpx;
padding: 0 20rpx;
border: 1rpx solid #e1e1e1;
border-radius: 10rpx;
font-size: 28rpx;
color: #333;
}
.uni-input {
display: flex;
align-items: center;
justify-content: space-between;
.val {
flex: 1;
}
.placeholder {
color: #b6b6b6;
}
}
.trigger {
.uni-input {
height: 80rpx;
line-height: 80rpx;
padding: 0 20rpx;
border: 1rpx solid #e1e1e1;
border-radius: 10rpx;
}
}
}
}
.time-selection {
background-color: #fff;
padding: 40rpx;
border-radius: 20rpx 20rpx 0 0;
.time-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 30rpx;
text:first-child {
font-size: 32rpx;
font-weight: 550;
}
text:last-child {
font-size: 24rpx;
color: #999;
}
}
.time-slots {
display: flex;
flex-wrap: wrap;
margin: 0 -10rpx;
.slot-item {
width: 33.33%;
padding: 10rpx;
box-sizing: border-box;
button {
height: 80rpx;
line-height: 80rpx;
font-size: 26rpx;
border-radius: 10rpx;
background-color: #f9fbfc;
color: #1890FF;
border: 1rpx solid #1890FF;
&.active {
background-color: #1890FF;
color: #fff;
}
&.disabled {
background-color: #f5f5f5;
color: #c1c1c1;
border-color: #e1e1e1;
}
&.warning {
border-color: #ff9900;
color: #ff9900;
}
}
}
}
.usage-matters {
margin-top: 40rpx;
font-size: 26rpx;
color: #666;
line-height: 1.6;
text:first-child {
font-weight: bold;
margin-right: 10rpx;
}
}
.submit-btn {
margin-top: 50rpx;
height: 90rpx;
line-height: 90rpx;
font-size: 32rpx;
border-radius: 45rpx;
background-color: #1890FF;
&[disabled] {
background-color: #c1ccdf;
}
}
}
.drawer-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
z-index: 998;
}
.drawer {
position: fixed;
left: 0;
right: 0;
bottom: 0;
background-color: #fff;
border-radius: 20rpx 20rpx 0 0;
padding: 30rpx;
z-index: 999;
box-shadow: 0 -5rpx 20rpx rgba(0, 0, 0, 0.1);
.drawer-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 30rpx;
padding-bottom: 20rpx;
border-bottom: 1rpx solid #eee;
text:first-child {
font-size: 32rpx;
font-weight: bold;
}
.drawer-close {
color: #1890FF;
font-size: 28rpx;
}
}
.drawer-body {
max-height: 60vh;
overflow-y: auto;
padding-bottom: 40rpx;
}
}
}
.input-placeholder {
color: #b6b6b6;
font-size: 28rpx;
}
</style>