diff --git a/src/api/base/jcApi.ts b/src/api/base/jcApi.ts new file mode 100644 index 0000000..6a9e339 --- /dev/null +++ b/src/api/base/jcApi.ts @@ -0,0 +1,276 @@ +import { get, post } from '@/utils/request' + +/** + * 获取就餐标准列表 + */ +export const getJcBzListApi = async (params: any) => { + return await get('/api/jcBz/getJcBzList', params) +} + +/** + * 获取就餐清单列表 + */ +export const getJcQdListApi = async (params: any) => { + return await get('/api/jcQd/findPage', params) +} + +/** + * 获取就餐点名分页 + */ +export const getJcDmPageApi = async (params: any) => { + return await get('/api/jcDm/findPage', params) +} + +/** + * 根据学生ID查询就餐清单状态 + */ +export const getStudentJcStatusApi = async (xsId: string) => { + return await get('/api/jcQd/findPage', { + xsId, + pageNum: 1, + pageSize: 100 + }) +} + +/** + * 提交就餐点名 + */ +export const submitJcDmApi = async (data: any) => { + return await post('/api/jcDm/save', data) +} + +/** + * 提交陪餐教师信息 + */ +export const submitJcPtApi = async (data: any) => { + return await post('/api/jcPt/save', data) +} + +/** + * 获取就餐点名记录 + */ +export const getJcDmListApi = async (params: any) => { + return await get('/api/jcDm/findPage', params) +} + +/** + * 获取陪餐教师记录 + */ +export const getJcPtListApi = async (params: any) => { + return await get('/api/jcPt/findPage', params) +} + +/** + * 【教师端专用】根据班级ID获取学生点名数据 + * 返回两组学生数据:已缴费和未缴费/未报名 + */ +export const getClassStudentDmDataApi = async (bjId: string, njId: string) => { + try { + const response = await get('/mobile/js/jc/getClassStudentDmData', { bjId, njId }) + return response + } catch (error) { + console.error('获取班级学生点名数据失败:', error) + throw error + } +} + +/** + * 【教师端专用】提交就餐点名数据 + * 包含:点名教师ID、点名时间、学生列表、陪餐教师列表等 + */ +export const submitJcDmDataApi = async (dmData: any) => { + try { + const response = await post('/mobile/js/jc/tjDmData', dmData) + return response + } catch (error) { + console.error('提交就餐点名数据失败:', error) + throw error + } +} + +/** + * 【教师端专用】获取就餐点名详情 + */ +export const getJcDmDetailApi = async (dmId: string) => { + try { + const response = await get('/mobile/js/jc/getDmDetail', { dmId }) + return response + } catch (error) { + console.error('获取就餐点名详情失败:', error) + throw error + } +} + +/** + * 【优化版本】根据班级ID获取学生就餐状态 - 使用批量查询避免循环 + */ +export const getClassStudentJcStatusBatchApi = async (bjId: string, njId: string) => { + try { + // 1. 批量查询班级学生列表 + const studentsRes = await get('/api/xs/findPage', { + bjId, + njId, + pageNum: 1, + pageSize: 1000 + }) + + if (!studentsRes.result || !studentsRes.result.rows || studentsRes.result.rows.length === 0) { + return [] + } + + const students = studentsRes.result.rows + const studentIds = students.map((s: any) => s.id) + + // 2. 批量查询所有学生的就餐清单状态 + const jcQdRes = await get('/api/jcQd/findBatchByXsIds', { + xsIds: studentIds.join(','), + pageNum: 1, + pageSize: 1000 + }) + + // 3. 将就餐清单转换为Map,便于快速查找 + const jcQdMap = new Map() + if (jcQdRes.result && jcQdRes.result.rows) { + jcQdRes.result.rows.forEach((qd: any) => { + jcQdMap.set(qd.xsId, qd) + }) + } + + // 4. 构建学生状态列表 + const studentStatusList = students.map((student: any) => { + const jcQdInfo = jcQdMap.get(student.id) + const hasJcQd = !!jcQdInfo + const jfZt = jcQdInfo?.jfZt || null + + // 根据缴费状态和就餐清单情况设置默认状态 + let defaultStatus = 'A' // 默认正常状态 + if (!hasJcQd) { + defaultStatus = 'E' // 未报名 + } else if (jfZt !== 'B') { + defaultStatus = 'D' // 未缴费 + } + + return { + ...student, + hasJcQd, + jcQdInfo, + jfZt, + jcZt: defaultStatus, + studentType: hasJcQd && jfZt === 'B' ? 'paid' : 'unpaid' + } + }) + + return studentStatusList + } catch (error) { + console.error('批量查询学生就餐状态失败:', error) + throw error + } +} + +/** + * 【原版本】根据班级ID获取学生就餐状态 - 保留作为备用 + * @deprecated 建议使用 getClassStudentDmDataApi 替代 + */ +export const getClassStudentJcStatusApi = async (bjId: string, njId: string) => { + // 先获取班级学生列表 + const studentsRes = await get('/api/xs/findPage', { + bjId, + njId, + pageNum: 1, + pageSize: 1000 + }) + + if (!studentsRes.result || !studentsRes.result.rows) { + return [] + } + + const students = studentsRes.result.rows + const studentStatusList = [] + + // 为每个学生查询就餐清单状态 + for (const student of students) { + try { + const jcQdRes = await get('/api/jcQd/findPage', { + xsId: student.id, + pageNum: 1, + pageSize: 10 + }) + + let hasJcQd = false + let jcQdInfo = null + let jfZt = null // 缴费状态 + + if (jcQdRes.result && jcQdRes.result.rows && jcQdRes.result.rows.length > 0) { + jcQdInfo = jcQdRes.result.rows[0] + hasJcQd = true + jfZt = jcQdInfo.jfZt || null + } + + // 根据缴费状态和就餐清单情况设置默认状态 + let defaultStatus = 'A' // 默认正常状态 + if (!hasJcQd) { + defaultStatus = 'E' // 未报名 + } else if (jfZt !== 'B') { + defaultStatus = 'D' // 未缴费 + } + + studentStatusList.push({ + ...student, + hasJcQd, + jcQdInfo, + jfZt, + jcZt: defaultStatus, // 默认就餐状态 + // 添加学生类型标识,便于前端分类显示 + studentType: hasJcQd && jfZt === 'B' ? 'paid' : 'unpaid' + }) + } catch (error) { + console.error(`查询学生 ${student.xm} 就餐状态失败:`, error) + studentStatusList.push({ + ...student, + hasJcQd: false, + jcQdInfo: null, + jfZt: null, + jcZt: 'E', // 查询失败时默认为未报名 + studentType: 'unpaid' + }) + } + } + + return studentStatusList +} + +/** + * 批量提交学生就餐点名记录 + */ +export const submitBatchJcDmApi = async (dmList: any[]) => { + const promises = dmList.map(dm => submitJcDmApi(dm)) + return await Promise.all(promises) +} + +/** + * 批量提交学生就餐点名记录 - 优化版本 + */ +export const submitBatchJcDmOptimizedApi = async (dmList: any[]) => { + return await post('/api/jcDm/saveBatch', dmList) +} + +/** + * 根据班级ID获取学生就餐状态统计信息 + */ +export const getClassStudentJcStatusStatsApi = async (bjId: string, njId: string) => { + return await get('/api/jcQd/getClassStats', { bjId, njId }) +} + +/** + * 根据点名批次ID获取点名记录 + */ +export const getJcDmByBatchIdApi = async (dmPcId: string) => { + return await get('/api/jcDm/findByBatchId', { dmPcId }) +} + +/** + * 根据班级和日期获取点名记录 + */ +export const getJcDmByClassAndDateApi = async (bjId: string, njId: string, dmDate: string) => { + return await get('/api/jcDm/findByClassAndDate', { bjId, njId, dmDate }) +} diff --git a/src/pages.json b/src/pages.json index 13e0a0c..dafddf7 100644 --- a/src/pages.json +++ b/src/pages.json @@ -565,6 +565,18 @@ "navigationBarTextStyle": "black", "backgroundColor": "#f4f5f7" } + }, + { + "path": "pages/view/routine/jc/index", + "style": { + "navigationBarTitleText": "就餐点名" + } + }, + { + "path": "pages/view/routine/jc/detail", + "style": { + "navigationBarTitleText": "就餐点名详情" + } } ], "globalStyle": { diff --git a/src/pages/base/service/index.vue b/src/pages/base/service/index.vue index 0b1f6aa..ed1c4d1 100644 --- a/src/pages/base/service/index.vue +++ b/src/pages/base/service/index.vue @@ -64,9 +64,9 @@ -