From e1b4415d1c1238ec124578f2aabdcbefef7917c0 Mon Sep 17 00:00:00 2001 From: wangzeyan <258785420@qq.com> Date: Sun, 25 May 2025 08:20:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/app/api/aaaaaaaaaaa.ts | 59 --- admin/src/app/api/venue.ts | 3 + .../src/app/views/aaaaaaaaaaa/aaaaaaaaaaa.vue | 196 -------- .../components/aaaaaaaaaaa-edit.vue | 176 ------- .../app/views/auth/components/edit-role.vue | 138 +++--- admin/src/app/views/auth/role.vue | 151 +++--- .../timetables/components/schedule-add.vue | 434 ++++++++++++++++++ admin/src/app/views/timetables/timetables.vue | 378 +-------------- admin/src/components/TencentMapPicker.vue | 3 +- .../app/adminapi/controller/venue/Venue.php | 75 +-- niucloud/app/adminapi/route/venue.php | 2 + .../app/service/admin/venue/VenueService.php | 56 ++- 12 files changed, 704 insertions(+), 967 deletions(-) delete mode 100644 admin/src/app/api/aaaaaaaaaaa.ts delete mode 100644 admin/src/app/views/aaaaaaaaaaa/aaaaaaaaaaa.vue delete mode 100644 admin/src/app/views/aaaaaaaaaaa/components/aaaaaaaaaaa-edit.vue create mode 100644 admin/src/app/views/timetables/components/schedule-add.vue diff --git a/admin/src/app/api/aaaaaaaaaaa.ts b/admin/src/app/api/aaaaaaaaaaa.ts deleted file mode 100644 index 7bdeb4be..00000000 --- a/admin/src/app/api/aaaaaaaaaaa.ts +++ /dev/null @@ -1,59 +0,0 @@ -import request from '@/utils/request' - -// USER_CODE_BEGIN -- aaaaaaaaaaa -/** - * 获取测试列表 - * @param params - * @returns - */ -export function getAaaaaaaaaaaList(params: Record) { - return request.get(`aaaaaaaaaaa/aaaaaaaaaaa`, { params }) -} - -/** - * 获取测试详情 - * @param id 测试id - * @returns - */ -export function getAaaaaaaaaaaInfo(id: number) { - return request.get(`aaaaaaaaaaa/aaaaaaaaaaa/${id}`) -} - -/** - * 添加测试 - * @param params - * @returns - */ -export function addAaaaaaaaaaa(params: Record) { - return request.post('aaaaaaaaaaa/aaaaaaaaaaa', params, { - showErrorMessage: true, - showSuccessMessage: true, - }) -} - -/** - * 编辑测试 - * @param id - * @param params - * @returns - */ -export function editAaaaaaaaaaa(params: Record) { - return request.put(`aaaaaaaaaaa/aaaaaaaaaaa/${params.id}`, params, { - showErrorMessage: true, - showSuccessMessage: true, - }) -} - -/** - * 删除测试 - * @param id - * @returns - */ -export function deleteAaaaaaaaaaa(id: number) { - return request.delete(`aaaaaaaaaaa/aaaaaaaaaaa/${id}`, { - showErrorMessage: true, - showSuccessMessage: true, - }) -} - -// USER_CODE_END -- aaaaaaaaaaa diff --git a/admin/src/app/api/venue.ts b/admin/src/app/api/venue.ts index 46f06c85..879f4f73 100644 --- a/admin/src/app/api/venue.ts +++ b/admin/src/app/api/venue.ts @@ -60,4 +60,7 @@ export function getWithCampusList(params: Record) { return request.get('venue/campus_all', { params }) } +export function getAllVenueList(params: Record){ + return request.get('venue/venue_all', { params }) +} // USER_CODE_END -- venue diff --git a/admin/src/app/views/aaaaaaaaaaa/aaaaaaaaaaa.vue b/admin/src/app/views/aaaaaaaaaaa/aaaaaaaaaaa.vue deleted file mode 100644 index 5ef33169..00000000 --- a/admin/src/app/views/aaaaaaaaaaa/aaaaaaaaaaa.vue +++ /dev/null @@ -1,196 +0,0 @@ - - - - - diff --git a/admin/src/app/views/aaaaaaaaaaa/components/aaaaaaaaaaa-edit.vue b/admin/src/app/views/aaaaaaaaaaa/components/aaaaaaaaaaa-edit.vue deleted file mode 100644 index 48f7095b..00000000 --- a/admin/src/app/views/aaaaaaaaaaa/components/aaaaaaaaaaa-edit.vue +++ /dev/null @@ -1,176 +0,0 @@ - - - - - - diff --git a/admin/src/app/views/auth/components/edit-role.vue b/admin/src/app/views/auth/components/edit-role.vue index ff85f573..325f7ed3 100644 --- a/admin/src/app/views/auth/components/edit-role.vue +++ b/admin/src/app/views/auth/components/edit-role.vue @@ -1,40 +1,39 @@ @@ -84,13 +84,13 @@ diff --git a/admin/src/app/views/timetables/components/schedule-add.vue b/admin/src/app/views/timetables/components/schedule-add.vue new file mode 100644 index 00000000..43607ddd --- /dev/null +++ b/admin/src/app/views/timetables/components/schedule-add.vue @@ -0,0 +1,434 @@ + + + + + \ No newline at end of file diff --git a/admin/src/app/views/timetables/timetables.vue b/admin/src/app/views/timetables/timetables.vue index 696d3502..8708989d 100644 --- a/admin/src/app/views/timetables/timetables.vue +++ b/admin/src/app/views/timetables/timetables.vue @@ -101,132 +101,12 @@

- - - - - - - - - - - - - - - - - - - - - - - - - - - {{ availableCapacity }} - - - - - 班级 - 学员 - 试课 - - - - - - - {{ item.class_name }} - - - - - - -
- - - {{ item.name }} - - -
-
- - - - - - - - - - -
- -
+ + @@ -235,48 +115,14 @@ import { ref, onMounted, computed } from 'vue' import { getTimetables } from '@/app/api/course_schedule' import { getWithCampusList } from '@/app/api/venue' -import { getVenueList } from '@/app/api/venue' -import { getClassroomList, getWithPersonnelList } from '@/app/api/classroom' -import { addCourseSchedule } from '@/app/api/course_schedule' -import { ElMessage } from 'element-plus' +import ScheduleAdd from './components/schedule-add.vue' // 校区列表 const campusList = ref([]) const selectedCampus = ref('') -// 添加课程相关数据 +// 添加课程弹窗 const addDialogVisible = ref(false) -const addFormRef = ref(null) -const venueList = ref([]) -const classList = ref([]) -const studentList = ref([]) -const coachList = ref([]) -const timeSlotOptions = ref(['9:00-10:00', '10:00-11:00', '11:00-12:00', '14:00-15:00', '15:00-16:00', '16:00-17:00']) -const availableCapacity = ref(0) -const studentSearchKeyword = ref('') -const filteredStudentList = ref([]) - -const addForm = ref({ - campus_id: '', - venue_id: '', - course_date: '', - time_slot: '', - course_type: 'class', - class_ids: [], - student_ids: [], - course_name: '', - coach_id: '' -}) - -const addFormRules = { - campus_id: [{ required: true, message: '请选择校区', trigger: 'change' }], - venue_id: [{ required: true, message: '请选择场地', trigger: 'change' }], - course_date: [{ required: true, message: '请选择上课日期', trigger: 'change' }], - time_slot: [{ required: true, message: '请选择上课时段', trigger: 'change' }], - course_type: [{ required: true, message: '请选择上课类型', trigger: 'change' }], - coach_id: [{ required: true, message: '请选择上课教练', trigger: 'change' }], - course_name: [{ required: true, message: '请输入课程名称', trigger: 'blur' }] -} // 周日期选择 const weekDate = ref(new Date()) @@ -425,209 +271,10 @@ const handleCellClick = (row, column, cell, event) => { } } -// 添加课程相关事件 -const handleAddCampusChange = async () => { - // 更新场地列表 - try { - const response = await getVenueList({ campus_id: addForm.value.campus_id }) - if (response.data && response.data.list) { - venueList.value = response.data.list - } - } catch (error) { - console.error('获取场地列表失败:', error) - } - - // 更新班级列表 - try { - const response = await getClassroomList({ campus_id: addForm.value.campus_id }) - if (response.data && response.data.list) { - classList.value = response.data.list - } - } catch (error) { - console.error('获取班级列表失败:', error) - } - - // 重置相关字段 - addForm.value.venue_id = '' - addForm.value.class_ids = [] - availableCapacity.value = 0 -} - -const calculateAvailableCapacity = async () => { - if (!addForm.value.venue_id || !addForm.value.time_slot) { - availableCapacity.value = 0 - return - } - - try { - // 获取场地容量 - const venueInfo = venueList.value.find(item => item.id === addForm.value.venue_id) - if (venueInfo) { - // 设置默认容量 - availableCapacity.value = venueInfo.capacity || 0 - - // 获取该时段已安排的课程占用情况 - if (addForm.value.course_date) { - const params = { - venue_id: addForm.value.venue_id, - course_date: addForm.value.course_date, - time_slot: addForm.value.time_slot - } - - const response = await getTimetables(params) - if (response.data && response.data.length > 0) { - // 查找对应场地和时间的课程 - const matchingDay = response.data.find(day => - day.date.includes(addForm.value.course_date) - ) - - if (matchingDay) { - const matchingTimeSlot = matchingDay.timeSlots.find(slot => - slot.timeRange === addForm.value.time_slot - ) - - if (matchingTimeSlot && matchingTimeSlot.course) { - // 更新可用容量 - availableCapacity.value = matchingTimeSlot.course.hasnumber - } - } - } - } - } - } catch (error) { - console.error('计算可用容量失败:', error) - } -} - -const handleCourseTypeChange = () => { - // 清空相关字段 - addForm.value.class_ids = [] - addForm.value.student_ids = [] - addForm.value.course_name = '' - - // 如果选择的是班级类型,加载学员列表 - if (addForm.value.course_type === 'student' || addForm.value.course_type === 'trial') { - loadStudentList() - } -} - -const handleClassChange = () => { - // 当选择班级时,设置课程名称为班级名称 - if (addForm.value.class_ids.length > 0) { - const selectedClass = classList.value.find(item => item.id === addForm.value.class_ids[0]) - if (selectedClass) { - addForm.value.course_name = selectedClass.class_name - } - } -} - -// 加载学员列表 -const loadStudentList = async () => { - try { - // 这里应该调用获取学员列表的接口 - // 由于没有看到明确的接口,暂时使用模拟数据 - // const response = await fetch('/student_courses/student_all') - // const data = await response.json() - // if (data.data) { - // studentList.value = data.data - // filteredStudentList.value = [...studentList.value] - // } - - // 模拟数据 - studentList.value = [ - { id: 1, name: '学员1' }, - { id: 2, name: '学员2' }, - { id: 3, name: '学员3' } - ] - filteredStudentList.value = [...studentList.value] - } catch (error) { - console.error('获取学员列表失败:', error) - } -} - -// 加载教练列表 -const loadCoachList = async () => { - try { - // 使用classroom的人员列表接口 - const response = await getWithPersonnelList({}) - if (response.data) { - coachList.value = response.data - } else { - // 模拟数据 - coachList.value = [ - { id: 1, name: '教练1' }, - { id: 2, name: '教练2' }, - { id: 3, name: '教练3' } - ] - } - } catch (error) { - console.error('获取教练列表失败:', error) - // 模拟数据 - coachList.value = [ - { id: 1, name: '教练1' }, - { id: 2, name: '教练2' }, - { id: 3, name: '教练3' } - ] - } -} - -const searchStudents = () => { - if (!studentSearchKeyword.value) { - filteredStudentList.value = [...studentList.value] - return - } - - filteredStudentList.value = studentList.value.filter(student => - student.name.includes(studentSearchKeyword.value) - ) -} - -const submitAddForm = () => { - addFormRef.value.validate(async (valid) => { - if (!valid) return - - try { - const params = { - campus_id: addForm.value.campus_id, - venue_id: addForm.value.venue_id, - course_date: addForm.value.course_date, - time_slot: addForm.value.time_slot, - course_id: 0, // 这里可能需要根据实际情况创建课程 - coach_id: addForm.value.coach_id, - participants: addForm.value.course_type, - available_capacity: availableCapacity.value, - status: 'active', - } - - // 根据不同类型设置学员信息 - if (addForm.value.course_type === 'class') { - params.class_ids = addForm.value.class_ids - // 获取班级包含的学员 - const classStudents = [] - // 这里需要根据实际接口调整 - params.student_ids = classStudents - } else { - params.student_ids = addForm.value.student_ids - } - - const response = await addCourseSchedule(params) - if (response.code === 0) { - ElMessage.success('添加课程成功') - addDialogVisible.value = false - fetchData() // 刷新课程表 - } - } catch (error) { - console.error('添加课程失败:', error) - ElMessage.error('添加课程失败') - } - }) -} - // 页面加载时获取数据 onMounted(() => { fetchCampusList() fetchData() - loadCoachList() }) @@ -671,13 +318,4 @@ onMounted(() => { .week-picker { width: 180px; } - -.student-checkbox-list { - max-height: 200px; - overflow-y: auto; - border: 1px solid #EBEEF5; - border-radius: 4px; - padding: 10px; - margin-top: 8px; -} diff --git a/admin/src/components/TencentMapPicker.vue b/admin/src/components/TencentMapPicker.vue index 3a9654f8..8272f0ad 100644 --- a/admin/src/components/TencentMapPicker.vue +++ b/admin/src/components/TencentMapPicker.vue @@ -315,8 +315,7 @@ const cleanupMap = () => { const loadMapSDK = (): Promise => { return new Promise((resolve, reject) => { - mapKey.value = 'AKTBZ-OGICT-E5NXQ-LGEGK-H5AJ5-M2BOX' - + mapKey.value = import.meta.env.VITE_MAP_KEY mapScript = document.createElement('script') mapScript.type = 'text/javascript' mapScript.src = `https://map.qq.com/api/gljs?libraries=tools ,service&v=1.exp&key=${mapKey.value}` diff --git a/niucloud/app/adminapi/controller/venue/Venue.php b/niucloud/app/adminapi/controller/venue/Venue.php index c697b7c8..4df1484d 100644 --- a/niucloud/app/adminapi/controller/venue/Venue.php +++ b/niucloud/app/adminapi/controller/venue/Venue.php @@ -22,19 +22,20 @@ use app\service\admin\venue\VenueService; */ class Venue extends BaseAdminController { - /** - * 获取场地列表 - * @return \think\Response - */ - public function lists(){ + /** + * 获取场地列表 + * @return \think\Response + */ + public function lists() + { $data = $this->request->params([ - ["campus_id",""], - ["venue_name",""], - ["capacity",""], - ["availability_status",""], - ["time_range_type",""], - ["created_at",""], - ["updated_at",""] + ["campus_id", ""], + ["venue_name", ""], + ["capacity", ""], + ["availability_status", ""], + ["time_range_type", ""], + ["created_at", ""], + ["updated_at", ""] ]); return success((new VenueService())->getPage($data)); } @@ -44,7 +45,8 @@ class Venue extends BaseAdminController * @param int $id * @return \think\Response */ - public function info(int $id){ + public function info(int $id) + { return success((new VenueService())->getInfo($id)); } @@ -52,14 +54,15 @@ class Venue extends BaseAdminController * 添加场地 * @return \think\Response */ - public function add(){ + public function add() + { $data = $this->request->params([ - ["campus_id",0], - ["venue_name",""], - ["capacity",0], - ["availability_status",0], - ["time_range_type",""], - ["fixed_time_ranges",[]], + ["campus_id", 0], + ["venue_name", ""], + ["capacity", 0], + ["availability_status", 0], + ["time_range_type", ""], + ["fixed_time_ranges", []], ]); $this->validate($data, 'app\validate\venue\Venue.add'); @@ -72,14 +75,15 @@ class Venue extends BaseAdminController * @param $id 场地id * @return \think\Response */ - public function edit(int $id){ + public function edit(int $id) + { $data = $this->request->params([ - ["campus_id",0], - ["venue_name",""], - ["capacity",0], - ["availability_status",0], - ["time_range_type",""], - ["fixed_time_ranges",[]], + ["campus_id", 0], + ["venue_name", ""], + ["capacity", 0], + ["availability_status", 0], + ["time_range_type", ""], + ["fixed_time_ranges", []], ]); $this->validate($data, 'app\validate\venue\Venue.edit'); @@ -92,14 +96,23 @@ class Venue extends BaseAdminController * @param $id 场地id * @return \think\Response */ - public function del(int $id){ + public function del(int $id) + { (new VenueService())->del($id); return success('DELETE_SUCCESS'); } - - public function getCampusAll(){ - return success(( new VenueService())->getCampusAll()); + + public function getCampusAll() + { + return success((new VenueService())->getCampusAll()); } + public function getVenueAll() + { + $data = $this->request->params([ + ["campus_id", 0], + ]); + return success((new VenueService())->getVenueAll($data['campus_id'])); + } } diff --git a/niucloud/app/adminapi/route/venue.php b/niucloud/app/adminapi/route/venue.php index 6234ac7e..a0dda4d3 100644 --- a/niucloud/app/adminapi/route/venue.php +++ b/niucloud/app/adminapi/route/venue.php @@ -34,6 +34,8 @@ Route::group('venue', function () { Route::get('campus_all','venue.Venue/getCampusAll'); + Route::get('venue_all','venue.Venue/getVenueAll'); + })->middleware([ AdminCheckToken::class, AdminCheckRole::class, diff --git a/niucloud/app/service/admin/venue/VenueService.php b/niucloud/app/service/admin/venue/VenueService.php index 7817271f..5e692f35 100644 --- a/niucloud/app/service/admin/venue/VenueService.php +++ b/niucloud/app/service/admin/venue/VenueService.php @@ -106,11 +106,65 @@ class VenueService extends BaseAdminService } + /** + * 获取校区列表 + * @return array + */ public function getCampusAll() { $campusModel = new Campus(); - return $campusModel->select()->toArray(); + return $campusModel->select() + ->where('campus_status', '=', 1) + ->toArray(); + } + + /** + * 获取校区下的场地列表 + * @param $campus_id + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function getVenueAll($campus_id) + { + return $this->model->where('availability_status', '=', 1) + ->where('campus_id', $campus_id) + ->select() + ->toArray(); } + /** + * 获取场地那天的可预约时间 + */ + public function getVenueTime($venue_id, $date) + { + $venue_info = $this->model->where('id', '=', $venue_id)->find(); + $venue_info['time_range'] = []; + //可用时间范围 + if ($venue_info['time_range_type'] === 'range') { + $time_range_start = $venue_info['time_range_start']; + $time_range_end = $venue_info['time_range_end']; + for ($i = $time_range_start; $i <= $time_range_end; $i++) { + $venue_info['time_range'][] = $i; + } + } + // 固定使用时间 + if ($venue_info['time_range_type'] === 'fixed') { + $venue_info['time_range'] = json_decode($venue_info['fixed_time_ranges'], true); + for ($i = 0; $i < count($venue_info['time_range']); $i++) { + $venue_info['time_range'][$i]['start'] = strtotime($date . ' ' . $venue_info['time_range'][$i]['start_time']); + $venue_info['time_range'][$i]['end'] = strtotime($date . ' ' . $venue_info['time_range'][$i]['end_time']); + } + } + // 全天可用从早上8点开始到晚上22点结束 + if ($venue_info['time_range_type'] === 'all') { + for ($i = 8; $i <= 22; $i++) { + $venue_info['time_range'][] = $i; + } + } + + return $venue_info; + } }