From 8bf726a745516f0a7368a65ff68723599fd2bb43 Mon Sep 17 00:00:00 2001 From: zhaichao Date: Sun, 23 Aug 2026 20:24:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E8=A1=A8=E8=B0=83=E6=95=B4=E7=94=B3?= =?UTF-8?q?=E8=AF=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/teachBusiness/semester.js | 8 ++++ .../views/teachBusiness/timetable/index.vue | 33 +++++++++++++++-- .../teachBusiness/timetableAdjust/index.vue | 37 +++++++++++++++---- 3 files changed, 67 insertions(+), 11 deletions(-) diff --git a/frontend/src/api/teachBusiness/semester.js b/frontend/src/api/teachBusiness/semester.js index 79f4cb87..d4e68169 100644 --- a/frontend/src/api/teachBusiness/semester.js +++ b/frontend/src/api/teachBusiness/semester.js @@ -9,6 +9,14 @@ export function listSemester(query) { }) } +// 查询所有学期列表(年度下拉数据源,返回全部学期含 nd/dqxq,按年度倒序) +export function listAllSemester() { + return request({ + url: '/semester/all', + method: 'get' + }) +} + // 根据主键查询学期 export function getSemester(nd) { return request({ diff --git a/frontend/src/views/teachBusiness/timetable/index.vue b/frontend/src/views/teachBusiness/timetable/index.vue index 5a825183..38347f3d 100644 --- a/frontend/src/views/teachBusiness/timetable/index.vue +++ b/frontend/src/views/teachBusiness/timetable/index.vue @@ -244,6 +244,7 @@ import { listStudentTeamTask } from '@/api/teachBusiness/studentTeamTask' import { listTeam } from '@/api/studentRecords/team' import { listKb } from '@/api/teachOffice/kb' import { listTeacher } from '@/api/teachOffice/teacher' +import { listAllSemester } from '@/api/teachBusiness/semester' // 节次 -> 节次区间映射 const JC_SECTION = { @@ -270,7 +271,6 @@ function getMonday(d) { export default { name: 'Timetable', data() { - const currentYear = new Date().getFullYear() return { activeTab: 'today', // 今日 @@ -292,12 +292,14 @@ export default { // 班次 teamOptions: [], shiftXydbh: '', - shiftNd: currentYear, + shiftNd: undefined, shiftList: [], shiftLoading: false, shiftTotal: 0, shiftQuery: { pageNum: 1, pageSize: 20 }, - yearOptions: [currentYear - 1, currentYear, currentYear + 1], + // 年度下拉数据来自 /semester/all(真实后端数据) + yearOptions: [], + defaultNd: undefined, // 名称映射(真实接口数据,用于班次 tab 课程/教员编号转名称) kbMap: {}, teacherMap: {} @@ -322,10 +324,11 @@ export default { shiftTitle() { const team = this.teamOptions.find(t => t.xydbh === this.shiftXydbh) const name = (team && team.xydmc) || '' - return this.shiftNd + '年' + name + '课程表' + return (this.shiftNd ? this.shiftNd + '年' : '') + name + '课程表' } }, created() { + this.loadYearOptions() this.getTodayList() this.getWeekList() this.getPracticeList() @@ -334,6 +337,28 @@ export default { this.loadTeacherMap() }, methods: { + /* ---------- 年度下拉(数据来自 /semester/all) ---------- */ + loadYearOptions() { + return listAllSemester().then(response => { + const list = response.data || [] + // 去重并按年度倒序 + const map = {} + list.forEach(item => { + if (item.nd !== null && item.nd !== undefined && item.nd !== '') map[item.nd] = item + }) + const arr = Object.keys(map).sort((a, b) => String(b).localeCompare(String(a))) + this.yearOptions = arr + // 默认年度:优先当前学期(dqxq=true),否则取最新年度 + const current = list.find(item => item.dqxq === true) + this.defaultNd = (current && current.nd) || arr[0] + if (!this.shiftNd) this.shiftNd = this.defaultNd + return arr + }).catch(() => { + this.yearOptions = [] + this.defaultNd = undefined + return [] + }) + }, weekDayName(d) { return WEEK_DAY_NAMES[d.getDay()] }, diff --git a/frontend/src/views/teachBusiness/timetableAdjust/index.vue b/frontend/src/views/teachBusiness/timetableAdjust/index.vue index c438bdb9..f3dc6b78 100644 --- a/frontend/src/views/teachBusiness/timetableAdjust/index.vue +++ b/frontend/src/views/teachBusiness/timetableAdjust/index.vue @@ -336,6 +336,7 @@ import { receiveByAuthority, cancelScheduleAdjust } from '@/api/teachBusiness/courseRunning' +import { listAllSemester } from '@/api/teachBusiness/semester' // 节次 -> 节次区间映射 const JC_SECTION = { @@ -359,22 +360,22 @@ const RECEIVE_STATUS = { export default { name: 'TimetableAdjust', data() { - const currentYear = new Date().getFullYear() const curUserName = (this.$store.state.user && this.$store.state.user.name) || '' return { - currentYear: currentYear, curUserName: curUserName, loading: false, tableData: [], total: 0, queryParams: { - nd: currentYear, + nd: undefined, sqjybh: undefined, jyspzzt: undefined, pageNum: 1, pageSize: 20 }, - yearOptions: [currentYear - 1, currentYear, currentYear + 1], + // 年度下拉数据来自 /semester/all(真实后端数据) + yearOptions: [], + defaultNd: undefined, jcOptions: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], auditStatusOptions: [ { label: '未审批', value: 0 }, @@ -416,9 +417,31 @@ export default { } }, created() { - this.loadList() + this.loadYearOptions().then(() => this.loadList()) }, methods: { + /* ---------- 年度下拉(数据来自 /semester/all) ---------- */ + loadYearOptions() { + return listAllSemester().then(response => { + const list = response.data || [] + // 去重并按年度倒序 + const map = {} + list.forEach(item => { + if (item.nd !== null && item.nd !== undefined && item.nd !== '') map[item.nd] = item + }) + const arr = Object.keys(map).sort((a, b) => String(b).localeCompare(String(a))) + this.yearOptions = arr + // 默认年度:优先当前学期(dqxq=true),否则取最新年度 + const current = list.find(item => item.dqxq === true) + this.defaultNd = (current && current.nd) || arr[0] + if (!this.queryParams.nd) this.queryParams.nd = this.defaultNd + return arr + }).catch(() => { + this.yearOptions = [] + this.defaultNd = undefined + return [] + }) + }, /* ---------- 通用格式化 ---------- */ fmtDateTime(v) { if (!v) return '-' @@ -470,7 +493,7 @@ export default { }, resetQuery() { this.queryParams = { - nd: this.currentYear, + nd: this.defaultNd, sqjybh: undefined, jyspzzt: undefined, pageNum: 1, @@ -495,7 +518,7 @@ export default { /* ---------- 新增申请 ---------- */ openAdd() { this.addForm = { - nd: this.currentYear, + nd: this.defaultNd || this.yearOptions[0], sskcbbh: '', sy: '', rq: '',