Commit 8507e761 by peijy

pyj 7.17 个人工作-录播室预约-空闲情况

parent c67f398d
...@@ -3,8 +3,10 @@ ...@@ -3,8 +3,10 @@
<!-- 搜索条件表单 --> <!-- 搜索条件表单 -->
<el-form :model="queryParams" ref="queryParams" size="small" :inline="true" v-show="showSearch"> <el-form :model="queryParams" ref="queryParams" size="small" :inline="true" v-show="showSearch">
<el-form-item label="日期" prop="startTime"> <el-form-item label="日期" prop="startTime">
<el-date-picker size="small" v-model="queryParams.startTime" type="date" placeholder="开始日期" value-format="yyyy-MM-dd" <el-date-picker size="small" v-model="queryParams.startTime" type="date" placeholder="开始日期"
format="yyyy-MM-dd" @change="changeDate" :picker-options="pickerOptions"> value-format="yyyy-MM-dd"
format="yyyy-MM-dd" @change="changeDate" :picker-options="pickerOptions"
style="margin-right:10px">
</el-date-picker> </el-date-picker>
<el-date-picker size="small" type="date" v-model="endTime" disabled> <el-date-picker size="small" type="date" v-model="endTime" disabled>
...@@ -13,37 +15,44 @@ ...@@ -13,37 +15,44 @@
</el-form-item> </el-form-item>
<el-form-item prop="studioName"> <el-form-item prop="studioName" :rules="[{ required: true, message: '请选择录播室', trigger: 'change,blur' }]">
<el-select v-model="queryParams.studioName" placeholder="录播室"> <el-select v-model="queryParams.studioId" placeholder="录播室" >
<el-option v-for="item in options" :key="item.studioName" :label="item.studioId" :value="item.studioName"> <el-option v-for="item in options" :key="item.id" :label="item.studioName" :value="item.id">
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-button type="primary" icon="el-icon-search" @click="fetchData">搜索</el-button> <el-button size="mini" type="primary" icon="el-icon-search" @click="fetchData">搜索</el-button>
<!-- <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button> --> <!-- <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button> -->
<!-- :disabled="isReservationDisabled" --> <!-- :disabled="isReservationDisabled" -->
<el-button @click="reserve">预约</el-button> <el-button size="mini" @click="reserve">预约</el-button>
</el-form> </el-form>
<p style="margin: 0 0 0 30px;font-size: 14px">
说明:(1)录播室每天开放上午四节、下午四节、晚上三节。共计每天11节。(2)请提前一天进行预约。(3)预约不可跨天,跨天请进行多次预约</p>
<!-- 录播室占用情况表格 --> <!-- 录播室占用情况表格 -->
<table> <table style="margin-left: 30px">
<thead> <thead>
<tr> <tr>
<th></th> <th></th>
<!-- 表格日期--> <!-- 表格日期-->
<th v-for="day in days" :key="day">{{ day }}</th> <th v-for="day in days" :key="day">{{ day }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr v-for="(timeSlot, index) in timeSlots" :key="index"> <tr v-for="(timeSlot, index) in timeSlots" :key="index">
<td>{{ timeSlot }}</td> <td>{{ timeSlot }}</td>
<!-- <td v-for="(day, dayIndex) in days" :key="dayIndex" :class="{-->
<!-- occupied: isOccupied(day, index),-->
<!-- selected: isSelected(day, index),-->
<!-- }" @mousedown="handleMouseDown(day, index)" @mouseup="handleMouseUp(day, index)"-->
<!-- @mouseenter="handleMouseEnter(day, index)" @click="handleCellClick(day, index)">-->
<!-- {{ isOccupied(day, index) ? "占用" : "" }}-->
<!-- </td>-->
<td v-for="(day, dayIndex) in days" :key="dayIndex" :class="{ <td v-for="(day, dayIndex) in days" :key="dayIndex" :class="{
occupied: isOccupied(day, index), occupied: isOccupied(day, index),
selected: isSelected(day, index), selected: isSelected(day, index),
}" @mousedown="handleMouseDown(day, index)" @mouseup="handleMouseUp(day, index)" }" @click="handleCellClick(day, index)">
@mouseenter="handleMouseEnter(day, index)" @click="handleCellClick(day, index)">
{{ isOccupied(day, index) ? "占用" : "" }} {{ isOccupied(day, index) ? "占用" : "" }}
</td> </td>
</tr> </tr>
...@@ -51,8 +60,13 @@ ...@@ -51,8 +60,13 @@
</table> </table>
<!-- 预约录播室成功的弹窗 --> <!-- 预约录播室成功的弹窗 -->
<el-dialog :visible.sync="successDialogVisible" title="预约节次"> <el-dialog :visible.sync="successDialogVisible" title="预约">
<p>是否确定预约此节次?</p> <el-form ref="form" :model="form" label-width="80px">
<el-form-item label="录播内容">
<el-input type="textarea" v-model="form.studioContent"></el-input>
</el-form-item>
</el-form>
<!-- <p>是否确定预约此节次?</p>-->
<div slot="footer"> <div slot="footer">
<el-button @click="successDialogVisible = false">取消</el-button> <el-button @click="successDialogVisible = false">取消</el-button>
<el-button :plain="true" type="primary" @click="confirmBooking">确定</el-button> <el-button :plain="true" type="primary" @click="confirmBooking">确定</el-button>
...@@ -78,20 +92,24 @@ export default { ...@@ -78,20 +92,24 @@ export default {
//包含今天 //包含今天
// return time.getTime() < Date.now() - 8.64e7; // return time.getTime() < Date.now() - 8.64e7;
//不含今天 //不含今天
return time.getTime() < Date.now() ; return time.getTime() < Date.now();
} }
}, },
time:'', time: '',
studioUseData: [], // 存储录播室占用情况数据 studioUseData: [], // 存储录播室占用情况数据
showSearch: true, // 是否显示搜索条件 showSearch: true, // 是否显示搜索条件
successDialogVisible: false, // 预约录播室成功的弹窗是否可见 successDialogVisible: false, // 预约录播室成功的弹窗是否可见
//弹框表单
form: {
studioContent: ''
},
days: [], // 存储日期的数组 days: [], // 存储日期的数组
timeSlots: [], // 存储时间段的数组 timeSlots: [], // 存储时间段的数组
selectedTimeSlots: [], // 存储已选时间段的数组 selectedTimeSlots: [], // 存储已选时间段的数组
isMouseDown: false, // 鼠标按下标志位 isMouseDown: false, // 鼠标按下标志位
startSelection: null, // 选中的开始时间段 startSelection: null, // 选中的开始时间段
endSelection: null, // 选中的结束时间段 endSelection: null, // 选中的结束时间段
options:"", options: "",
bookingForm: { bookingForm: {
startTime: "", // 录播开始时间 startTime: "", // 录播开始时间
timeSlots: "", // 预约的时间段 timeSlots: "", // 预约的时间段
...@@ -100,52 +118,92 @@ export default { ...@@ -100,52 +118,92 @@ export default {
studioId: "", // 录播室名称 studioId: "", // 录播室名称
startTime: "", // 查询的开始时间 startTime: "", // 查询的开始时间
}, },
//表格占用数据
occupiedData: [],
//弹框标记符
remark: false,
rooms: [], //录播室下拉列表存储 rooms: [], //录播室下拉列表存储
endTime:'' endTime: ''
}; };
}, },
created() { created() {
this.queryParams.startTime = moment(new Date()).add(1,'days').format("YYYY-MM-DD"); this.queryParams.startTime = moment(new Date()).add(1, 'days').format("YYYY-MM-DD");
this.endTime = moment(this.queryParams.startTime).add(9,'days') this.endTime = moment(this.queryParams.startTime).add(9, 'days')
// 初始化日期和时间段 // 初始化日期和时间段
this.initDays(); this.initDays();
this.initTimeSlots(); this.initTimeSlots();
// 获取录播室下拉框列表 // 获取录播室下拉框列表
this.getRoomList(); this.getRoomList();
// this.fetchStudioUseData(); this.fetchStudioUseData();
// this.fetchData(); // this.fetchData();
}, },
methods: { methods: {
changeDate(){ changeDate() {
this.endTime = moment(this.queryParams.startTime).add(9,'days') this.endTime = moment(this.queryParams.startTime).add(9, 'days')
}, },
fetchStudioUseData() { fetchStudioUseData() {
// 调用接口获取录播室占用情况数据 // 调用接口获取录播室占用情况数据
const params = { // console.log(123654, params);
startTime: this.queryParams.startTime, getstudioUse(this.queryParams).then((res) => {
studioId: this.queryParams.studioId,
};
console.log(123654, params);
getstudioUse({params}).then((res) => {
this.studioUseData = res.rows; this.studioUseData = res.rows;
console.log(123, this.studioUseData); console.log(123, this.studioUseData);
}); });
}, },
//表格占用显示
isOccupied(day, index) { isOccupied(day, index) {
// 判断指定的时间段是否被占用 // 判断指定的时间段是否被占用
const occupiedData = this.studioUseData.find((item) => { const occupiedData = this.studioUseData.find((item) => {
return item.day === day && item.index === index; // console.log('Array.from(item.useJc)',item.useJc.split(','))
// console.log('Array.from(item.useJc)',index + 1)
return item.useDate === day && item.useJc.split(',').includes((index+1).toString());
}); });
return occupiedData ? occupiedData.useUserId : false; return occupiedData ? occupiedData.useUserId : false;
}, },
//表格点击选中
isSelected(day, index) {
if (this.isOccupied(day, index)) {
return false
} else {
// 检查时间段是否已选中
return this.selectedTimeSlots.some((selectedSlot) => {
// console.log('selectedSlot',selectedSlot)
return selectedSlot.day === day && selectedSlot.index === index;
});
}
},
//表格点击事件
handleCellClick(day, index) { handleCellClick(day, index) {
// 处理单元格点击事件 console.log('day',day)
if (!this.isOccupied(day, index)) { console.log('index',index+1)
// 单元格为空闲状态,进行预约操作 //占用点击不生效
// this.reserve();//加上此代码,点击表格立马弹出预约窗口 if (this.isOccupied(day, index) && this.selectedTimeSlots.length == 0) {
this.remark = false
return
} else if (this.selectedTimeSlots.length == 0) {
// 处理单元格点击事件,点击第一个
this.selectedTimeSlots.push({day, index})
this.remark = true
//没有选同一天
} else if (this.selectedTimeSlots[0].day != day) {
this.remark = true
this.$modal.alertWarning("预约不可跨天");
return;
} else {
this.remark = true
//筛选出符合条件的对象
const selectObj = this.selectedTimeSlots.find((item) => {
console.log('find', item.day == day && item.index == index)
return item.day == day && item.index == index
})
console.log('selectObj', selectObj)
if (selectObj != undefined) {
this.remark = true
this.selectedTimeSlots = this.selectedTimeSlots.filter(item => item.index != index)
this.selectedTimeSlots.length == 0 ? this.remark = false : this.selectedTimeSlots
} else {
this.selectedTimeSlots.push({day, index})
}
} }
}, },
// ----------------------------------------------------- // -----------------------------------------------------
...@@ -153,6 +211,7 @@ export default { ...@@ -153,6 +211,7 @@ export default {
getRoomList() { getRoomList() {
getAppointmentList({}).then((res) => { getAppointmentList({}).then((res) => {
this.options = res.rows; this.options = res.rows;
console.log('res',res)
}); });
}, },
...@@ -179,23 +238,22 @@ export default { ...@@ -179,23 +238,22 @@ export default {
// startDate.setDate(startDate.getDate() + 1); // startDate.setDate(startDate.getDate() + 1);
// console.log('startDate',startDate) // console.log('startDate',startDate)
for (let i = 0; i < 10; i++) { for (let i = 0; i < 10; i++) {
const formattedDate = moment(this.queryParams.startTime).add(i,'days').format("YYYY-MM-DD"); const formattedDate = moment(this.queryParams.startTime).add(i, 'days').format("YYYY-MM-DD");
console.log('formattedDate',formattedDate) console.log('formattedDate', formattedDate)
// const currentDate = new Date(startDate); // const currentDate = new Date(startDate);
// currentDate.setDate(currentDate.getDate() + i); // currentDate.setDate(currentDate.getDate() + i);
// const formattedDate = this.formatDate(currentDate); // const formattedDate = this.formatDate(currentDate);
this.days.push(formattedDate); this.days.push(formattedDate);
} }
},
formatDate(date) {
// 格式化日期为'YYYY-MM-DD'的形式
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()).padStart(2, "0");
return `${year}-${month}-${day}`;
}, },
// formatDate(date) {
// // 格式化日期为'YYYY-MM-DD'的形式
// const year = date.getFullYear();
// const month = String(date.getMonth() + 1).padStart(2, "0");
// const day = String(date.getDate()).padStart(2, "0");
// return `${year}-${month}-${day}`;
// },
// isOccupied(day, index) { // isOccupied(day, index) {
// // 判断指定的时间段是否被占用 // // 判断指定的时间段是否被占用
// // 这里假设你有一个函数可以根据日期和时间段查询录播室的占用情况 // // 这里假设你有一个函数可以根据日期和时间段查询录播室的占用情况
...@@ -205,13 +263,13 @@ export default { ...@@ -205,13 +263,13 @@ export default {
handleMouseDown(day, index) { handleMouseDown(day, index) {
// 处理鼠标按下事件 // 处理鼠标按下事件
this.isMouseDown = true; this.isMouseDown = true;
this.startSelection = { day, index }; this.startSelection = {day, index};
this.endSelection = { day, index }; this.endSelection = {day, index};
}, },
handleMouseUp(day, index) { handleMouseUp(day, index) {
// 处理鼠标松开事件 // 处理鼠标松开事件
this.isMouseDown = false; this.isMouseDown = false;
this.endSelection = { day, index }; this.endSelection = {day, index};
// 根据按下的键盘按键进行选择操作 // 根据按下的键盘按键进行选择操作
if (event.ctrlKey) { if (event.ctrlKey) {
...@@ -229,10 +287,11 @@ export default { ...@@ -229,10 +287,11 @@ export default {
handleMouseEnter(day, index) { handleMouseEnter(day, index) {
// 处理鼠标进入单元格事件(用于 Shift 键多选) // 处理鼠标进入单元格事件(用于 Shift 键多选)
if (this.isMouseDown && event.shiftKey) { if (this.isMouseDown && event.shiftKey) {
this.endSelection = { day, index }; this.endSelection = {day, index};
this.selectMultipleSlots(); this.selectMultipleSlots();
} }
}, },
//多选事件
selectMultipleSlots() { selectMultipleSlots() {
// 选择多个时间段(同一天内) // 选择多个时间段(同一天内)
const startDay = this.startSelection.day; const startDay = this.startSelection.day;
...@@ -240,7 +299,6 @@ export default { ...@@ -240,7 +299,6 @@ export default {
const startIndex = this.startSelection.index; const startIndex = this.startSelection.index;
const endIndex = this.endSelection.index; const endIndex = this.endSelection.index;
const selectedTimeSlots = []; const selectedTimeSlots = [];
// 遍历日期范围内的时间段,选择符合条件的时间段 // 遍历日期范围内的时间段,选择符合条件的时间段
for ( for (
let dayIndex = this.days.indexOf(startDay); let dayIndex = this.days.indexOf(startDay);
...@@ -248,98 +306,134 @@ export default { ...@@ -248,98 +306,134 @@ export default {
dayIndex++ dayIndex++
) { ) {
const day = this.days[dayIndex]; const day = this.days[dayIndex];
// 对于同一天内的时间段,根据索引范围进行选择 // 对于同一天内的时间段,根据索引范围进行选择
if ( if (
dayIndex === this.days.indexOf(startDay) && dayIndex === this.days.indexOf(startDay) &&
dayIndex === this.days.indexOf(endDay) dayIndex === this.days.indexOf(endDay)
) { ) {
for (let index = startIndex; index <= endIndex; index++) { for (let index = startIndex; index <= endIndex; index++) {
selectedTimeSlots.push({ day, index }); selectedTimeSlots.push({day, index});
} }
} else if (dayIndex === this.days.indexOf(startDay)) { } else if (dayIndex === this.days.indexOf(startDay)) {
// 对于起始日期,选择从起始索引到最后一个时间段 // 对于起始日期,选择从起始索引到最后一个时间段
for (let index = startIndex; index < this.timeSlots.length; index++) { for (let index = startIndex; index < this.timeSlots.length; index++) {
selectedTimeSlots.push({ day, index }); selectedTimeSlots.push({day, index});
} }
} else if (dayIndex === this.days.indexOf(endDay)) { } else if (dayIndex === this.days.indexOf(endDay)) {
// 对于结束日期,选择从第一个时间段到结束索引 // 对于结束日期,选择从第一个时间段到结束索引
for (let index = 0; index <= endIndex; index++) { for (let index = 0; index <= endIndex; index++) {
selectedTimeSlots.push({ day, index }); selectedTimeSlots.push({day, index});
} }
} else { } else {
// 其他日期完全选择 // 其他日期完全选择
for (let index = 0; index < this.timeSlots.length; index++) { for (let index = 0; index < this.timeSlots.length; index++) {
selectedTimeSlots.push({ day, index }); selectedTimeSlots.push({day, index});
} }
} }
} }
this.selectedTimeSlots = selectedTimeSlots; this.selectedTimeSlots = selectedTimeSlots;
}, },
isSelected(day, index) {
// 检查时间段是否已选中
return this.selectedTimeSlots.some((selectedSlot) => {
return selectedSlot.day === day && selectedSlot.index === index;
});
},
fetchData() { fetchData() {
this.days = []; this.this.studioUseData = []
// 查询按钮的点击事件处理程序 this.fetchStudioUseData()
this.initDays() // this.days = [];
getstudioUse({ // // 查询按钮的点击事件处理程序
startTime: this.queryParams.startTime, // this.initDays()
studioId: this.queryParams.studioId, // getstudioUse({
}) // startTime: this.queryParams.startTime,
.then((res) => { // studioId: this.queryParams.studioId,
this.studioUseData = res; // })
}) // .then((res) => {
.then((response) => { // this.studioUseData = res;
// console.log(response); // })
if (response.code == 200) { // .then((response) => {
this.studioUseData = response.rows; // // console.log(response);
console.log(222, response.rows); // if (response.code == 200) {
} // this.studioUseData = response.rows;
}); // console.log(222, response.rows);
// 在这里,你可以发送请求获取录播室占用情况等数据 // }
console.log("查询成功"); // });
// // 在这里,你可以发送请求获取录播室占用情况等数据
// console.log("查询成功");
}, },
reserve() { //弹窗
// 预约按钮的点击事件处理程序 reserve(day, index) {
// 在这里,你可以处理预约操作,例如弹出对话框来录入录播内容并进行预约操作 if (this.remark) {
if (this.selectedTimeSlots.length > 0) { if(this.queryParams.studioId == ''){
this.successDialogVisible = false;
this.$modal.alertWarning("请选择录播室");
}else{
this.successDialogVisible = true; this.successDialogVisible = true;
} }
} else{
console.log(this.remark)
this.successDialogVisible = false;
}
// }
// 预约按钮的点击事件处理程序
// 在这里,你可以处理预约操作,例如弹出对话框来录入录播内容并进行预约操作
// if (this.selectedTimeSlots.length > 0) {
// this.successDialogVisible = true;
// }
}, },
confirmBooking() { confirmBooking() {
// 弹窗确定按钮的点击事件处理程序 // 弹窗确定按钮的点击事件处理程序
// 在这里,你可以处理预约操作,例如发送请求进行录播室预约操作 // 在这里,你可以处理预约操作,例如发送请求进行录播室预约操作
// 预约成功后,你可以根据已选时间段的数据来更新录播室的占用情况 // 预约成功后,你可以根据已选时间段的数据来更新录播室的占用情况
this.successDialogVisible = false; this.successDialogVisible = false;
console.log('queryParams.studioName',this.queryParams)
// 更新录播室占用情况 console.log('this.selectedTimeSlots',this.selectedTimeSlots)
for (const selectedSlot of this.selectedTimeSlots) { console.log('form.studioContent',this.form.studioContent)
const day = selectedSlot.day; const jc = this.selectedTimeSlots.map(item => {
const index = selectedSlot.index; return item.index+1
// 在这里,你可以根据录播室ID、日期和时间段进行更新录播室占用情况的操作 })
// 调用接口或更新数据来标记录播室在指定的日期和时间段被占用 const stringJC = jc.toString()
console.log(`录播室在 ${day}${this.timeSlots[index]} 被预约成功`); console.log('stringJC',stringJC)
const params = {
//录播室id
studioId:this.queryParams.studioId,
//预约时间
appointmentTime:this.selectedTimeSlots[0].day,
//预约节次
appointmentJc:stringJC,
//录播内容
studioContent:this.form.studioContent
} }
addIdle(params).then(res => {
// 清除已选时间段 console.log('res',res)
this.selectedTimeSlots = []; if(res.code == 200){
this.$message({ this.$message({
message: "预约成功", message: "预约成功",
type: "success", type: "success",
}); });
this.fetchStudioUseData()
console.log("确定"); }
}, })
// 更新录播室占用情况
// for (const selectedSlot of this.selectedTimeSlots) {
// const day = selectedSlot.day;
// const index = selectedSlot.index;
// // 在这里,你可以根据录播室ID、日期和时间段进行更新录播室占用情况的操作
// // 调用接口或更新数据来标记录播室在指定的日期和时间段被占用
// console.log(`录播室在 ${day} 的 ${this.timeSlots[index]} 被预约成功`);
// }
//
// // 清除已选时间段
// this.selectedTimeSlots = [];
//
// this.$message({
// message: "预约成功",
// type: "success",
// });
//
// console.log("确定");
// },
// isReservationDisabled() { // isReservationDisabled() {
// // 预约按钮是否禁用 // // 预约按钮是否禁用
// return this.selectedTimeSlots.length === 0; // return this.selectedTimeSlots.length === 0;
// }, },
}, },
}; };
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment