From 69b73a93739af5629356c6ff33b1016378b0b847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=97=AD=E6=98=8E?= Date: Fri, 29 Aug 2025 23:02:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BF=83=E7=90=86=E5=92=A8=E8=AF=A2=E9=A2=84?= =?UTF-8?q?=E7=BA=A6=E7=A7=BB=E5=8A=A8=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ljkConsultationAppointmentServiceImpl.java | 18 +- mobile/src/api/xljk.js | 236 ++++ mobile/src/pages.json | 26 +- mobile/src/pages/index/index.vue | 24 +- .../src/pages/xljk/my-appointments/index.vue | 737 ++++++++++++ .../xljk/reservation/appointment-form.vue | 708 ++++++++++++ mobile/src/pages/xljk/reservation/index.vue | 1006 +++++++++++++++++ 7 files changed, 2752 insertions(+), 3 deletions(-) create mode 100644 mobile/src/api/xljk.js create mode 100644 mobile/src/pages/xljk/my-appointments/index.vue create mode 100644 mobile/src/pages/xljk/reservation/appointment-form.vue create mode 100644 mobile/src/pages/xljk/reservation/index.vue diff --git a/backend/ruoyi-modules/ruoyi-xljk/src/main/java/org/dromara/xljk/service/impl/XljkConsultationAppointmentServiceImpl.java b/backend/ruoyi-modules/ruoyi-xljk/src/main/java/org/dromara/xljk/service/impl/XljkConsultationAppointmentServiceImpl.java index 94af7357..98bb0546 100644 --- a/backend/ruoyi-modules/ruoyi-xljk/src/main/java/org/dromara/xljk/service/impl/XljkConsultationAppointmentServiceImpl.java +++ b/backend/ruoyi-modules/ruoyi-xljk/src/main/java/org/dromara/xljk/service/impl/XljkConsultationAppointmentServiceImpl.java @@ -431,7 +431,23 @@ public class XljkConsultationAppointmentServiceImpl implements IXljkConsultation slot.put("availableCount", totalDetailSlots - bookedCount); // 可用数量 slot.put("isExpired", isExpired); // 是否已过期 - // TODO: 添加咨询师姓名等信息 + // 查询咨询师姓名 + if (schedule.getCounselorId() != null) { + try { + String sql = "SELECT nick_name FROM sys_user WHERE user_id = ?"; + List> result = jdbcTemplate.queryForList(sql, schedule.getCounselorId()); + if (!result.isEmpty()) { + slot.put("counselorName", result.get(0).get("nick_name")); + } else { + slot.put("counselorName", null); + } + } catch (Exception e) { + log.warn("查询咨询师姓名失败, counselorId: {}, error: {}", schedule.getCounselorId(), e.getMessage()); + slot.put("counselorName", null); + } + } else { + slot.put("counselorName", null); + } availableSlots.add(slot); } diff --git a/mobile/src/api/xljk.js b/mobile/src/api/xljk.js new file mode 100644 index 00000000..926a3c1c --- /dev/null +++ b/mobile/src/api/xljk.js @@ -0,0 +1,236 @@ +import { request } from '@/common/request'; + +/** + * 心理健康咨询预约 API + * 移动端API接口 - 基于web端功能移植 + */ + +// ===== 预约时段管理 API ===== + +/** + * 获取可预约时段列表(用于日历视图) + * @param {string} startDate 开始日期 YYYY-MM-DD + * @param {string} endDate 结束日期 YYYY-MM-DD + */ +export const getAvailableTimeSlots = (startDate, endDate) => { + return request({ + url: '/xljk/consultation/appointment/available-slots', + method: 'GET', + params: { startDate, endDate } + }); +}; + +/** + * 获取可用的详细时段列表(30分钟一个时段) + * @param {string} date 日期 YYYY-MM-DD + * @param {string} timeSlot 时段 如 "09:00-12:00" + */ +export const getAvailableDetailSlots = (date, timeSlot) => { + return request({ + url: '/xljk/consultation/appointment/available-detail-slots', + method: 'GET', + params: { date, timeSlot } + }); +}; + +// ===== 预约记录管理 API ===== + +/** + * 学生提交预约 + * @param {object} data 预约数据 + */ +export const submitAppointment = (data) => { + return request({ + url: '/xljk/consultation/appointment/submit', + method: 'POST', + data + }); +}; + +/** + * 获取我的预约记录(学生用) + * @param {string|number} studentId 学生ID + * @param {boolean} forceRefresh 是否强制刷新 + */ +export const getMyAppointments = (studentId, forceRefresh = false) => { + let url = `/xljk/consultation/appointment/my-appointments/${studentId}`; + + // 强制添加时间戳参数,确保绕过浏览器缓存 + url += `?_t=${new Date().getTime()}`; + + // 如果需要额外强制刷新 + if (forceRefresh) { + url += `&force=true`; + } + + return request({ + url, + method: 'GET', + header: { + // 禁止所有缓存 + 'Cache-Control': 'no-cache, no-store, must-revalidate', + 'Pragma': 'no-cache', + 'Expires': '0' + } + }); +}; + +/** + * 查询预约记录详细信息 + * @param {string|number} id 预约记录ID + */ +export const getAppointmentDetail = (id) => { + return request({ + url: `/xljk/consultation/appointment/${id}`, + method: 'GET' + }); +}; + +/** + * 取消预约(更新状态为已取消,不删除记录) + * @param {string|number} id 预约记录ID + */ +export const cancelAppointment = (id) => { + return request({ + url: `/xljk/consultation/appointment`, + method: 'PUT', + data: { + id: id, + status: 2 // 已取消状态 + } + }); +}; + +/** + * 更新预约信息(通用方法) + * @param {object} data 更新数据,必须包含id字段 + */ +export const updateAppointment = (data) => { + return request({ + url: `/xljk/consultation/appointment`, + method: 'PUT', + data + }); +}; + +// ===== 选项数据 API ===== + +/** + * 获取咨询师选项 + */ +export const getCounselorOptions = () => { + return request({ + url: '/xljk/consultation/schedule/options/counselors', + method: 'GET' + }); +}; + +/** + * 获取学生信息(通过学号) + * @param {string} studentNo 学号 + */ +export const getStudentByNo = (studentNo) => { + return request({ + url: `/xljk/consultation/student/${studentNo}`, + method: 'GET' + }); +}; + +/** + * 获取院系选项 + */ +export const getCollegeOptions = () => { + return request({ + url: '/xljk/consultation/appointment/options/colleges', + method: 'GET' + }); +}; + +/** + * 获取专业选项 + * @param {string} collegeName 院系名称(可选) + */ +export const getMajorOptions = (collegeName) => { + return request({ + url: '/xljk/consultation/appointment/options/majors', + method: 'GET', + params: { collegeName } + }); +}; + +/** + * 获取班级选项 + * @param {string} collegeName 院系名称(可选) + * @param {string} majorName 专业名称(可选) + */ +export const getClassOptions = (collegeName, majorName) => { + return request({ + url: '/xljk/consultation/appointment/options/classes', + method: 'GET', + params: { collegeName, majorName } + }); +}; + +// ===== 移动端专用辅助方法 ===== + +/** + * 格式化日期为 YYYY-MM-DD + * @param {Date} date 日期对象 + */ +export const formatDate = (date) => { + 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}`; +}; + +/** + * 获取指定日期的周日期范围 + * @param {Date} date 指定日期 + * @returns {object} { startDate, endDate, weekDates } + */ +export const getWeekDateRange = (date = new Date()) => { + const currentDate = new Date(date); + const currentDay = currentDate.getDay(); // 0=Sunday, 1=Monday, ... + + // 计算本周一的日期 + const monday = new Date(currentDate); + monday.setDate(currentDate.getDate() - currentDay + (currentDay === 0 ? -6 : 1)); + + // 生成一周的日期数组 + const weekDates = []; + for (let i = 0; i < 7; i++) { + const weekDate = new Date(monday); + weekDate.setDate(monday.getDate() + i); + weekDates.push({ + date: formatDate(weekDate), + dayName: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'][i], + dayNumber: weekDate.getDate(), + isToday: formatDate(weekDate) === formatDate(new Date()) + }); + } + + return { + startDate: formatDate(monday), + endDate: formatDate(new Date(monday.getTime() + 6 * 24 * 60 * 60 * 1000)), + weekDates + }; +}; + +/** + * 检查预约限制 + * @param {string|number} studentId 学生ID + */ +export const checkAppointmentLimitation = async (studentId) => { + try { + // 这里可能需要导入noshow相关的API,暂时使用简单的实现 + return request({ + url: `/xljk/consultation/appointment/check-limitation/${studentId}`, + method: 'GET' + }); + } catch (error) { + console.error('检查预约限制失败', error); + // 检查失败不阻止预约 + return { code: 200, data: { limited: false } }; + } +}; \ No newline at end of file diff --git a/mobile/src/pages.json b/mobile/src/pages.json index c3960042..8db5e1ac 100644 --- a/mobile/src/pages.json +++ b/mobile/src/pages.json @@ -302,7 +302,31 @@ "navigationBarBackgroundColor": "#0051d9", "navigationBarTextStyle": "white" } - } + }, + { + "path": "pages/xljk/reservation/index", + "style": { + "navigationBarTitleText": "心理咨询预约", + "navigationBarBackgroundColor": "#0051d9", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/xljk/my-appointments/index", + "style": { + "navigationBarTitleText": "我的预约", + "navigationBarBackgroundColor": "#0051d9", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/xljk/reservation/appointment-form", + "style": { + "navigationBarTitleText": "预约咨询", + "navigationBarBackgroundColor": "#0051d9", + "navigationBarTextStyle": "white" + } + } ], "globalStyle": { "navigationBarTextStyle": "black", diff --git a/mobile/src/pages/index/index.vue b/mobile/src/pages/index/index.vue index 202e2d01..71c588cd 100644 --- a/mobile/src/pages/index/index.vue +++ b/mobile/src/pages/index/index.vue @@ -262,6 +262,20 @@ /> + + + + @@ -710,7 +724,8 @@ export default { this.hasPermi(['student:dormhygiene:listapp']) || this.hasPermi(['student:workstudy:list']) || this.hasPermi(['student:violation:listapp']) || - this.hasPermi(['student:assessment:applyapp']) + this.hasPermi(['student:assessment:applyapp']) || + this.hasPermi(['student:counsel:reservation']) ); }, @@ -966,6 +981,13 @@ export default { }); }, + // 跳转到心理咨询预约页面 + gotoPsychologicalReservation() { + uni.navigateTo({ + url: '/pages/xljk/reservation/index', + }); + }, + // 跳转到修改密码页面 gotoResetPassword() { uni.navigateTo({ diff --git a/mobile/src/pages/xljk/my-appointments/index.vue b/mobile/src/pages/xljk/my-appointments/index.vue new file mode 100644 index 00000000..efb6c804 --- /dev/null +++ b/mobile/src/pages/xljk/my-appointments/index.vue @@ -0,0 +1,737 @@ + + + + + \ No newline at end of file diff --git a/mobile/src/pages/xljk/reservation/appointment-form.vue b/mobile/src/pages/xljk/reservation/appointment-form.vue new file mode 100644 index 00000000..2667b2af --- /dev/null +++ b/mobile/src/pages/xljk/reservation/appointment-form.vue @@ -0,0 +1,708 @@ + + + + + \ No newline at end of file diff --git a/mobile/src/pages/xljk/reservation/index.vue b/mobile/src/pages/xljk/reservation/index.vue new file mode 100644 index 00000000..5310ec70 --- /dev/null +++ b/mobile/src/pages/xljk/reservation/index.vue @@ -0,0 +1,1006 @@ + + + + +