From 2a84e9b92fc03734e51f14c596a8c6a60bb90bde Mon Sep 17 00:00:00 2001
From: lion <120344285@qq.com>
Date: Thu, 21 Aug 2025 18:04:32 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/calendar/components/addCalendar.vue | 67 +-
src/views/config/classFiles.vue | 106 +-
src/views/config/components/addTeacher.vue | 35 +-
src/views/config/teacher.vue | 38 +-
src/views/course/components/addClass.vue | 1811 ++++++++---------
src/views/course/components/editClass.vue | 133 +-
src/views/email/index.vue | 486 ++---
src/views/student/index.vue | 53 +-
src/views/student/schoolmate.vue | 35 +-
9 files changed, 1440 insertions(+), 1324 deletions(-)
diff --git a/src/views/calendar/components/addCalendar.vue b/src/views/calendar/components/addCalendar.vue
index 08909d0..9987434 100644
--- a/src/views/calendar/components/addCalendar.vue
+++ b/src/views/calendar/components/addCalendar.vue
@@ -15,7 +15,7 @@
*是否发布:
+ >是否对外展示:
具体说明:
-
+ @change="onModuleChange"
+ @create="onCreateModule"
+ >
+
+
+
@@ -331,6 +344,18 @@ export default {
course_content_options: [],
course_options: [],
canSelect: false,
+ module_options: [
+ { id: 1, value: '第一模块' },
+ { id: 2, value: '第二模块' },
+ { id: 3, value: '第三模块' },
+ { id: 4, value: '第四模块' },
+ { id: 5, value: '第五模块' },
+ { id: 6, value: '第六模块' },
+ { id: 7, value: '第七模块' },
+ { id: 8, value: '第八模块' },
+ { id: 9, value: '第九模块' },
+ { id: 10, value: '第十模块' }
+ ],
form: {
is_publish:1,
type: "",
@@ -483,6 +508,40 @@ export default {
});
}
},
+ onModuleChange(value) {
+ // 当选择模块时,自动拼接到标题后面
+ if (value && this.form.title) {
+ // 先去除标题中可能存在的模块值
+ let cleanTitle = this.form.title;
+ this.module_options.forEach(module => {
+ if (cleanTitle.includes(' | ' + module.value)) {
+ cleanTitle = cleanTitle.replace(' | ' + module.value, '');
+ }
+ });
+ // 拼接新的模块值
+ this.form.title = cleanTitle + ' | ' + value;
+ }
+ },
+ onCreateModule(value) {
+ // 当创建新模块时,添加到选项列表并选中
+ const newModule = {
+ id: this.module_options.length + 1,
+ value: value
+ };
+ this.module_options.push(newModule);
+ this.form.introduce = value;
+ // 先去除标题中可能存在的模块值,再拼接新的模块值
+ if (this.form.title) {
+ let cleanTitle = this.form.title;
+ this.module_options.forEach(module => {
+ if (cleanTitle.includes(' | ' + module.value)) {
+ cleanTitle = cleanTitle.replace(' | ' + module.value, '');
+ }
+ });
+ // 拼接新的模块值
+ this.form.title = cleanTitle + ' | ' + value;
+ }
+ },
submit() {
if (this.id) {
this.form.id = this.id;
diff --git a/src/views/config/classFiles.vue b/src/views/config/classFiles.vue
index 2af20e7..cec6975 100644
--- a/src/views/config/classFiles.vue
+++ b/src/views/config/classFiles.vue
@@ -6,11 +6,17 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
查询
@@ -28,10 +34,10 @@
-
-
+
@@ -59,27 +65,36 @@
-
-
-
+
+
+
+
+
课程名称:{{ subjectObj.name }}
+
+ 开课日期:{{ subjectObj.start_date }}至{{ subjectObj.end_date }}
+
+
+ 课程体系:{{
+ subjectObj.type_detail ? subjectObj.type_detail.name : ""
+ }}
+
+
+
+
+ 班主任:{{ subjectObj.teacherList ? subjectObj.teacherList : "" }}
+
+
+ 课表状态:{{
+ subjectObj.course_content_status === 1 ? "已发布" : "未发布"
+ }}
+
+
+
+
+ 添加课程
+
+
+ 导入
+
+
+
+ 发布课表
+
+
+ 取消发布课表
+
+
+ 短信通知
+
+
+
+ 下载并打印课表
+
+
+ 批量修改地址
+
+
+
+
+
+
+
+
+
+
+ {{ scope.row.teacher ? scope.row.teacher.name : "" }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ file.original_name }}
+
+
+
+ 暂无课件
+
+
+
+
+ 编辑
+ 上传课件
+
+ 删除
+
+
+
+
+
+
+ 取消
+
+
+
+
+
+
+
+
+
+
+
课程信息
+
日期:{{ selectedCourse.date }}
+
时间:{{ selectedCourse.period }}
+
+
主题:{{ selectedCourse.theme }}
+
+ 老师:{{ selectedCourse.teacher ? selectedCourse.teacher.name : "" }}
+
+
+
+
+
课件上传
+
+
+
+ 将文件拖到此处,或点击上传
+
+
+ 支持 PDF、Word、PPT、Excel、压缩包、图片等格式,单个文件不超过50MB
+
+
+
+
+
+
已上传文件
+
+ {{ file.name }}
+ {{ formatFileSize(file.size) }}
+ 删除
+
+
+
+
+
+
+
+
+
+
+
+
已选择 {{ selectedRows.length }} 个课程
+
将统一修改以下课程的地址信息:
+
+ -
+ {{ row.date }} {{ row.period }} - {{ row.theme }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/course/components/editClass.vue b/src/views/course/components/editClass.vue
index d5ce39b..26a4acb 100644
--- a/src/views/course/components/editClass.vue
+++ b/src/views/course/components/editClass.vue
@@ -42,11 +42,22 @@
授课老师:
-
+ 新增授课老师
+
+
+
+
+
@@ -60,36 +71,40 @@
-
+
- 上课地点:
+ 课程方向:
-
+
+
+
+
-
+
-
+
+
@@ -161,9 +177,16 @@
import {
save as saveTeacher
} from "@/api/info/teachers.js"
+ import { index as teacherIndex } from "@/api/info/teachers.js";
+ import addTeacher from '@/views/config/components/addTeacher.vue'
+ import {
+ getparameteritem
+} from "@/api/system/dictionary.js"
export default {
mixins: [myMixins],
- components: {},
+ components: {
+ addTeacher
+ },
data() {
return {
isShow: false,
@@ -174,19 +197,22 @@
mapparams: {
zoom: 11
},
+ direction_options:[],
mapform: [],
form: {
date: '',
// timeRange: [],
period:'',
teacher_id: "",
+ teacher_introduce: '', // 授课老师简介
theme: '',
+ direction: '', // 课程方向
address: '',
address_detail: '',
latitude: '',
longitude: '',
course_id: '', // 添加课程ID字段
- direction: '', // 课程方向
+
remark: '', // 备注
// introduce: '',
files: [], // 现有课件列表
@@ -205,22 +231,61 @@
removedFileIds: [], // 已删除的文件ID列表
}
},
- created() {},
+ created() {
+ this.getAllPara()
+ },
methods: {
+ getAllPara() {
+ getparameteritem('course_direction').then(res => {
+ console.log("res", res)
+ this.direction_options = res.detail
+ })
+ },
setTeachers(e) {
this.teacher_options = e
},
+ async getTeachers() {
+ try {
+ const res = await teacherIndex({
+ page: 1,
+ page_size: 999,
+ });
+ this.teacher_options = res.data;
+ } catch (error) {
+ console.error('获取授课老师列表失败:', error);
+ this.$message.error('获取授课老师列表失败');
+ }
+ },
changeTeacher(e) {
if (e) {
this.teacher_options.map(item => {
if (e === item.id) {
this.form.teacher_id = item.id
+ // 自动填充授课老师简介
+ this.form.teacher_introduce = item.introduce || ''
// this.form.introduce = item.introduce
}
})
}
console.log("e", e)
},
+ addTeacher() {
+ this.$refs.addTeacher.isShow = true
+ },
+ refreshTeacherList() {
+ // 刷新授课老师列表,这里需要调用父组件的方法来重新获取授课老师列表
+ this.getTeachers().then(() => {
+ // 获取最新的授课老师列表后,自动选中新增的授课老师
+ if (this.teacher_options && this.teacher_options.length > 0) {
+ // 获取最新添加的授课老师(假设最新添加的授课老师在数组的最后)
+ const latestTeacher = this.teacher_options[0];
+ if (latestTeacher) {
+ this.form.teacher_id = latestTeacher.id;
+ // this.$message.success(`已自动选中新增的授课老师:${latestTeacher.name}`);
+ }
+ }
+ });
+ },
changeTime(e) {
console.log("eeee", e)
if (e) {
@@ -251,6 +316,16 @@
return
}
+ // 检查授课老师简介是否发生变化,如果变化了则同时更新授课老师信息
+ let needUpdateTeacher = false
+ if (this.form.teacher_id && this.form.teacher_introduce !== undefined) {
+ // 找到当前选中的授课老师
+ const selectedTeacher = this.teacher_options.find(item => item.id === this.form.teacher_id)
+ if (selectedTeacher && selectedTeacher.introduce !== this.form.teacher_introduce) {
+ needUpdateTeacher = true
+ }
+ }
+
// 处理课件文件ID
const existingFileIds = this.form.files.map(file => file.id);
const newFileIds = this.newFileList.map(file => {
@@ -269,21 +344,34 @@
console.log('提交数据:', submitData) // 添加日志查看提交的数据
- save(submitData).then(res => {
+ // 先保存课表信息
+ save(submitData).then(async (res) => {
this.$message({
type: 'success',
message: this.type === 'add' ? '新增课表成功' : '编辑课表成功'
})
- // saveTeacher({
- // id: this.form.teacher_id
- // }).then(res => {
-
- // })
+
+ // 如果授课老师简介发生变化,则同时更新授课老师信息
+ if (needUpdateTeacher) {
+ try {
+ await saveTeacher({
+ id: this.form.teacher_id,
+ introduce: this.form.teacher_introduce
+ })
+ this.$message.success('授课老师简介更新成功')
+ } catch (error) {
+ console.error('更新授课老师简介失败:', error)
+ this.$message.warning('课表保存成功,但授课老师简介更新失败')
+ }
+ }
+
this.isShow = false
this.$emit('refresh')
// this.active = 1
+ }).catch(error => {
+ console.error('保存课表失败:', error)
+ this.$message.error('保存课表失败')
})
-
},
getDetail() {
show({
@@ -292,6 +380,8 @@
}).then(res => {
this.form = this.base.requestToForm(res, this.form)
this.form.files = res.files ? res.files : []
+ // 获取授课老师简介
+ this.form.teacher_introduce = res.teacher ? res.teacher.introduce || '' : ''
// this.form.timeRange = [this.form.start_time ? this.form.start_time : '', this.form.end_time ? this.form
// .end_time : ''
// ]
@@ -352,6 +442,8 @@
watch: {
isShow(newVal) {
if (newVal) {
+ // 每次打开对话框时获取最新的授课老师列表
+ this.getTeachers()
// 只有编辑时才获取详情
if (this.type === 'editor') {
this.getDetail()
@@ -366,6 +458,7 @@
// timeRange: [],
period:'',
teacher_id: "",
+ teacher_introduce: '', // 重置授课老师简介
theme: '',
address: '',
address_detail: '',
diff --git a/src/views/email/index.vue b/src/views/email/index.vue
index b61679b..c26b4ac 100644
--- a/src/views/email/index.vue
+++ b/src/views/email/index.vue
@@ -649,9 +649,12 @@
clearable
@keyup.enter="searchStudents">
-
-
+
+
+
+
+
-
+
+
+
+
+
+
+ {{item.course.year?item.course.year:''}}{{item.course.type_detail?item.course.type_detail.name+' | ':''}}{{item.course.name}}
+
+
+
+ {{state.value}}
+
+
+
+
+
+
+
+
@@ -718,10 +744,12 @@
import { saveEmailTemplate, getEmailTemplateList, deleteEmailTemplate } from '@/api/email/index'
import { uploadEmailRecord } from '@/api/email/index'
import { saveEmailRecord, getEmailRecordList, sendEmail } from '@/api/email/index'
-import { index as getCourseList } from '@/api/course/index'
+
+import { indexStudy } from '@/api/student/index.js'
export default {
name: 'EmailManagement',
+ mixins: [require('@/mixin/selectMixin.js').default],
data() {
return {
activeTab: 'templates',
@@ -774,8 +802,9 @@ export default {
// 系统数据导出相关
systemStudentSearch: '',
- selectedCourseType: '', // 选中的课程
- courseTypesList: [], // 课程列表
+ selectedCourse: '', // 选中的具体课程
+ courseList: [], // 具体课程列表
+ selectedStatus: '', // 审核状态筛选
selectedSystemStudents: [], // 当前页的选择
allSelectedStudents: [], // 总的选择对象数组,保存所有分页中的选择
studentsLoading: false,
@@ -1439,8 +1468,9 @@ export default {
this.selectedSystemStudents = [] // 清空当前页选择
this.allSelectedStudents = [] // 清空总选择数组
this.systemStudentSearch = '' // 清空搜索关键词
- this.selectedCourseType = '' // 清空课程选择
- this.loadCourseTypes() // 加载课程列表
+ this.selectedCourse = '' // 清空具体课程选择
+ this.courseList = [] // 清空课程列表
+ this.loadCourses() // 加载课程列表
this.loadStudents() // 加载数据
},
@@ -1487,13 +1517,34 @@ export default {
// 准备Excel数据
const excelData = [
- ['姓名', '邮箱', '课程名称', '公司'],
- ...uniqueSelections.map(student => [
- student.name,
- student.email,
- student.courseName || '',
- student.company || ''
- ])
+ ['姓名', '邮箱', '课程名称', '公司', '职务'],
+ ...uniqueSelections.map(student => {
+ // 构建课程名称和状态字符串
+ let courseInfo = ''
+ if (student.course_signs && student.course_signs.length > 0) {
+ const courseStrings = student.course_signs.map(item => {
+ if (item.course) {
+ const courseName = `${item.course.year || ''}${item.course.type_detail ? item.course.type_detail.name + ' | ' : ''}${item.course.name}`
+ // 查找对应的审核状态
+ const statusItem = this.apply_status_list.find(state => state.id === item.status)
+ const statusText = statusItem ? statusItem.value : '未知状态'
+ return `${courseName} (${statusText})`
+ }
+ return ''
+ }).filter(text => text) // 过滤空字符串
+ courseInfo = courseStrings.join('\n')
+ } else {
+ courseInfo = student.courseName || ''
+ }
+
+ return [
+ student.name,
+ student.email,
+ courseInfo,
+ student.company || '',
+ student.company_position || ''
+ ]
+ })
]
// 创建工作簿
@@ -1505,7 +1556,8 @@ export default {
{ wch: 15 }, // 姓名
{ wch: 25 }, // 邮箱
{ wch: 20 }, // 课程名称
- { wch: 20 } // 公司
+ { wch: 20 }, // 公司
+ { wch: 12 } // 职务
]
worksheet['!cols'] = colWidths
@@ -1581,244 +1633,200 @@ export default {
this.$message.success(`已在控制台打印 ${uniqueSelections.length} 条数据(去重后,包含所有分页选择)`)
},
- // 加载课程列表
- loadCourseTypes() {
- getCourseList({
- page: 1,
- page_size: 999,
- sort_name: 'id',
- sort_type: 'ASC'
- }).then(res => {
- this.courseTypesList = res.data
- }).catch(error => {
- console.error('加载课程列表失败:', error)
- })
- },
+
// 课程选择变化处理
- handleCourseTypeChange(courseId) {
- if (courseId) {
- // 找到选中的课程
- const selectedCourse = this.courseTypesList.find(course => course.id === courseId)
- if (selectedCourse) {
- // 将课程名称赋值给搜索框
- this.systemStudentSearch = selectedCourse.name
- // 清空当前页选择
- this.selectedSystemStudents = []
- // 重置分页到第一页
- this.currentPage = 1
- // 调用loadStudents进行搜索
- this.loadStudents()
- }
- } else {
- // 清空课程选择时,清空搜索框
- this.systemStudentSearch = ''
- // 清空当前页选择
- this.selectedSystemStudents = []
- // 重置分页到第一页
- this.currentPage = 1
- // 重新加载学员数据
- this.loadStudents()
- }
+ handleCourseChange() {
+ // 切换具体课程时,重置分页并刷新
+ this.selectedSystemStudents = []
+ this.currentPage = 1
+ this.loadStudents()
},
// 加载学员数据
loadStudents() {
this.studentsLoading = true
- // 调用API获取学员数据
- import('@/api/student/index').then(({ index }) => {
- // 构建查询参数
- const params = {
- has_course: 1,
- page: this.currentPage,
- page_size: this.pageSize
- }
-
- // 添加关键词搜索参数
- if (this.systemStudentSearch && this.systemStudentSearch.trim()) {
- params.keyword = this.systemStudentSearch.trim()
- }
+ // 构建与学员列表一致的查询参数
+ const params = {
+ page: this.currentPage,
+ page_size: this.pageSize
+ }
+ if (this.systemStudentSearch && this.systemStudentSearch.trim()) {
+ params.keyword = this.systemStudentSearch.trim()
+ }
+ if (this.selectedCourse) {
+ params.course_id = this.selectedCourse
+ }
+ if (this.selectedStatus !== '' && this.selectedStatus !== null) {
+ params.status = this.selectedStatus
+ }
+
+ indexStudy(params).then(res => {
+ // 保存当前的选择状态
+ const currentSelection = [...this.selectedSystemStudents]
+ console.log('保存当前选择状态:', currentSelection.length)
+ console.log('当前总选择数组:', this.allSelectedStudents)
- // 添加课程筛选参数
- if (this.selectedCourseType) {
- params.course_id = this.selectedCourseType
+ // 将当前页选择添加到总选择数组,并去重
+ if (currentSelection.length > 0) {
+ currentSelection.forEach(student => {
+ // 检查是否已存在相同ID的学员
+ const isDuplicate = this.allSelectedStudents.some(existing => Number(existing.id) === Number(student.id))
+ if (!isDuplicate) {
+ this.allSelectedStudents.push(student)
+ console.log(`✅ 新增学员到总选择: ${student.name} (ID: ${student.id})`)
+ } else {
+ console.log(`❌ 跳过重复学员: ${student.name} (ID: ${student.id})`)
+ }
+ })
}
- index(params, false).then(res => {
- // 保存当前的选择状态
- const currentSelection = [...this.selectedSystemStudents]
- console.log('保存当前选择状态:', currentSelection.length)
- console.log('当前总选择数组:', this.allSelectedStudents)
-
- // 将当前页选择添加到总选择数组,并去重
- if (currentSelection.length > 0) {
- currentSelection.forEach(student => {
- // 检查是否已存在相同ID的学员
- const isDuplicate = this.allSelectedStudents.some(existing => Number(existing.id) === Number(student.id))
- if (!isDuplicate) {
- this.allSelectedStudents.push(student)
- console.log(`✅ 新增学员到总选择: ${student.name} (ID: ${student.id})`)
- } else {
- console.log(`❌ 跳过重复学员: ${student.name} (ID: ${student.id})`)
- }
+ console.log('去重后的总选择数组:', this.allSelectedStudents)
+ // 处理API返回的数据(与学员列表一致的结构)
+ const listData = res.list && Array.isArray(res.list.data) ? res.list.data : []
+ if (Array.isArray(listData)) {
+ // 处理API返回的数据,确保包含必要的字段
+ console.log('开始处理学员数据,数量:', listData.length)
+ this.students = listData.map(student => {
+ // 获取最新的课程信息
+ let courseName = ''
+ let courseStartDate = ''
+ let courseEndDate = ''
+
+ if (student.course_signs && student.course_signs.length > 0) {
+ // 按时间排序,获取最新的一条课程记录
+ const sortedSigns = student.course_signs.sort((a, b) => {
+ const dateA = new Date(a.created_at || a.createdAt || a.sign_date || 0)
+ const dateB = new Date(b.created_at || b.createdAt || b.sign_date || 0)
+ return dateB - dateA // 降序排列,最新的在前
+ })
+ const latestSign = sortedSigns[0]
+
+ // 从course对象中获取课程信息
+ if (latestSign.course && latestSign.course.name) {
+ courseName = latestSign.course.name
+ courseStartDate = latestSign.course.start_date || ''
+ courseEndDate = latestSign.course.end_date || ''
+ } else {
+ // 备用方案:从sign记录本身获取
+ courseName = latestSign.course_name || latestSign.course || latestSign.courseName || ''
+ }
+ } else {
+ // 如果没有course_signs,使用备用字段
+ courseName = student.course_name || student.course || ''
+ }
+
+ return {
+ id: student.id,
+ name: student.name || student.real_name || '',
+ email: student.email || '-',
+ company: student.company_name || student.work_unit || '',
+ phone: student.phone || student.mobile || '',
+ department: student.department || '',
+ courseName: courseName,
+ courseStartDate: courseStartDate,
+ courseEndDate: courseEndDate,
+ course_signs: student.course_signs || [],
+ company_position: student.company_position || ''
+ }
+ })
+
+ // 更新分页信息(来自 res.list)
+ if (res.list) {
+ this.totalStudents = res.list.total || 0
+ this.currentPage = res.list.current_page || 1
+ this.pageSize = res.list.per_page || this.pageSize
+ }
+ console.log('数据处理完成,this.students长度:', this.students.length)
+ console.log('分页信息更新:', {
+ total: this.totalStudents,
+ currentPage: this.currentPage,
+ pageSize: this.pageSize
})
- }
-
- console.log('去重后的总选择数组:', this.allSelectedStudents)
- // 处理API返回的数据
- console.log('API响应数据:', res) // 调试信息
- console.log('res.data类型:', typeof res.data, '长度:', res.data ? res.data.length : 'undefined')
- if (res.data) {
- // 处理API返回的数据,确保包含必要的字段
- console.log('开始处理学员数据,数量:', res.data.length)
- this.students = res.data.map(student => {
- // 获取最新的课程信息
- let courseName = ''
- let courseStartDate = ''
- let courseEndDate = ''
-
- if (student.course_signs && student.course_signs.length > 0) {
- // 按时间排序,获取最新的一条课程记录
- const sortedSigns = student.course_signs.sort((a, b) => {
- const dateA = new Date(a.created_at || a.createdAt || a.sign_date || 0)
- const dateB = new Date(b.created_at || b.createdAt || b.sign_date || 0)
- return dateB - dateA // 降序排列,最新的在前
- })
- const latestSign = sortedSigns[0]
-
- // 从course对象中获取课程信息
- if (latestSign.course && latestSign.course.name) {
- courseName = latestSign.course.name
- courseStartDate = latestSign.course.start_date || ''
- courseEndDate = latestSign.course.end_date || ''
- } else {
- // 备用方案:从sign记录本身获取
- courseName = latestSign.course_name || latestSign.course || latestSign.courseName || ''
- }
- } else {
- // 如果没有course_signs,使用备用字段
- courseName = student.course_name || student.course || ''
- }
-
- return {
- id: student.id,
- name: student.name || student.real_name || '',
- email: student.email || '-',
- company: student.company_name || student.work_unit || '',
- phone: student.phone || student.mobile || '',
- department: student.department || '',
- courseName: courseName,
- courseStartDate: courseStartDate,
- courseEndDate: courseEndDate
- }
- })
+
+ // 恢复选择状态
+ this.$nextTick(() => {
+ this.selectedSystemStudents = currentSelection
+ console.log('已恢复选择状态,数量:', this.selectedSystemStudents.length)
- // 更新分页信息
- this.totalStudents = res.total || 0
- this.currentPage = res.current_page || 1
- this.pageSize = res.per_page || 20
- console.log('数据处理完成,this.students长度:', this.students.length)
- console.log('分页信息更新:', {
- total: this.totalStudents,
- currentPage: this.currentPage,
- pageSize: this.pageSize
- })
+ // 恢复表格的视觉勾选状态
+ console.log('开始恢复表格勾选状态...')
+ console.log('当前页学员数据:', this.students.map(s => ({ id: s.id, name: s.name })))
+ console.log('当前页选择:', currentSelection.map(s => ({ id: s.id, name: s.name })))
+ console.log('总选择数组:', this.allSelectedStudents.map(s => ({ id: s.id, name: s.name })))
- // 恢复选择状态
- this.$nextTick(() => {
- this.selectedSystemStudents = currentSelection
- console.log('已恢复选择状态,数量:', this.selectedSystemStudents.length)
-
- // 恢复表格的视觉勾选状态
- console.log('开始恢复表格勾选状态...')
- console.log('当前页学员数据:', this.students.map(s => ({ id: s.id, name: s.name })))
- console.log('当前页选择:', currentSelection.map(s => ({ id: s.id, name: s.name })))
- console.log('总选择数组:', this.allSelectedStudents.map(s => ({ id: s.id, name: s.name })))
-
- // 恢复当前页的选择状态
- if (currentSelection.length > 0) {
- currentSelection.forEach(selectedStudent => {
- // 在当前页数据中查找对应的学员
- const studentInCurrentPage = this.students.find(student => Number(student.id) === Number(selectedStudent.id))
- if (studentInCurrentPage) {
- // 使用 Element UI 的方法设置勾选状态
- this.$refs.systemStudentTable.toggleRowSelection(studentInCurrentPage, true)
- console.log(`✅ 已勾选学员: ${studentInCurrentPage.name} (ID: ${studentInCurrentPage.id})`)
- } else {
- console.log(`❌ 未找到学员: ${selectedStudent.name} (ID: ${selectedStudent.id})`)
- }
- })
- }
-
- // 恢复总选择数组中在当前页显示的选择状态
- this.students.forEach(student => {
- const isInAllSelected = this.allSelectedStudents.some(selected => Number(selected.id) === Number(student.id))
- const isInCurrentSelection = currentSelection.some(selected => Number(selected.id) === Number(student.id))
-
- if (isInAllSelected && !isInCurrentSelection) {
- // 这个学员在总选择数组中,但不在当前页选择中,需要勾选
- this.$refs.systemStudentTable.toggleRowSelection(student, true)
- console.log(`✅ 从总选择恢复勾选: ${student.name} (ID: ${student.id})`)
+ // 恢复当前页的选择状态
+ if (currentSelection.length > 0) {
+ currentSelection.forEach(selectedStudent => {
+ // 在当前页数据中查找对应的学员
+ const studentInCurrentPage = this.students.find(student => Number(student.id) === Number(selectedStudent.id))
+ if (studentInCurrentPage) {
+ // 使用 Element UI 的方法设置勾选状态
+ this.$refs.systemStudentTable.toggleRowSelection(studentInCurrentPage, true)
+ console.log(`✅ 已勾选学员: ${studentInCurrentPage.name} (ID: ${studentInCurrentPage.id})`)
+ } else {
+ console.log(`❌ 未找到学员: ${selectedStudent.name} (ID: ${selectedStudent.id})`)
}
})
+ }
+
+ // 恢复总选择数组中在当前页显示的选择状态
+ this.students.forEach(student => {
+ const isInAllSelected = this.allSelectedStudents.some(selected => Number(selected.id) === Number(student.id))
+ const isInCurrentSelection = currentSelection.some(selected => Number(selected.id) === Number(student.id))
- console.log('表格勾选状态恢复完成')
+ if (isInAllSelected && !isInCurrentSelection) {
+ // 这个学员在总选择数组中,但不在当前页选择中,需要勾选
+ this.$refs.systemStudentTable.toggleRowSelection(student, true)
+ console.log(`✅ 从总选择恢复勾选: ${student.name} (ID: ${student.id})`)
+ }
})
- } else {
- this.students = []
- // 即使没有数据,也要保持分页信息
- if (res.total !== undefined) {
- this.totalStudents = res.total
- }
- if (res.current_page !== undefined) {
- this.currentPage = res.current_page
- }
- if (res.per_page !== undefined) {
- this.pageSize = res.per_page
- }
- // 只有在真正没有数据时才显示警告
- if (res.data && res.data.length === 0) {
- this.$message.warning('当前页暂无学员数据')
- }
+
+ console.log('表格勾选状态恢复完成')
+ })
+ } else {
+ this.students = []
+ if (res.list) {
+ if (res.list.total !== undefined) this.totalStudents = res.list.total
+ if (res.list.current_page !== undefined) this.currentPage = res.list.current_page
+ if (res.list.per_page !== undefined) this.pageSize = res.list.per_page
}
- }).catch(error => {
- console.error('加载学员数据失败:', error)
- this.$message.error('加载学员数据失败')
- // 加载失败时使用空数组
- this.students = []
- }).finally(() => {
- this.studentsLoading = false
+ if (Array.isArray(listData) && listData.length === 0) {
+ this.$message.warning('当前页暂无学员数据')
+ }
+ }
+ }).catch(error => {
+ console.error('加载学员数据失败:', error)
+ this.$message.error('加载学员数据失败')
+ // 加载失败时使用空数组
+ this.students = []
+ }).finally(() => {
+ this.studentsLoading = false
+
+ // 恢复之前的选择状态
+ this.$nextTick(() => {
+ console.log('在finally中恢复选择状态...')
+ console.log('当前页学员:', this.students.map(s => ({ id: s.id, name: s.name })))
+ console.log('当前页选择:', this.selectedSystemStudents.map(s => ({ id: s.id, name: s.name })))
+ console.log('总选择数组:', this.allSelectedStudents.map(s => ({ id: s.id, name: s.name })))
- // 恢复之前的选择状态
- this.$nextTick(() => {
- console.log('在finally中恢复选择状态...')
- console.log('当前页学员:', this.students.map(s => ({ id: s.id, name: s.name })))
- console.log('当前页选择:', this.selectedSystemStudents.map(s => ({ id: s.id, name: s.name })))
- console.log('总选择数组:', this.allSelectedStudents.map(s => ({ id: s.id, name: s.name })))
+ // 恢复所有应该勾选的学员(包括当前页选择和总选择数组中的)
+ this.students.forEach(student => {
+ const isInCurrentSelection = this.selectedSystemStudents.some(selected => Number(selected.id) === Number(student.id))
+ const isInAllSelected = this.allSelectedStudents.some(selected => Number(selected.id) === Number(student.id))
- // 恢复所有应该勾选的学员(包括当前页选择和总选择数组中的)
- this.students.forEach(student => {
- const isInCurrentSelection = this.selectedSystemStudents.some(selected => Number(selected.id) === Number(student.id))
- const isInAllSelected = this.allSelectedStudents.some(selected => Number(selected.id) === Number(student.id))
-
- if (isInCurrentSelection || isInAllSelected) {
- // 使用 Element UI 的表格方法设置选择状态
- this.$refs.systemStudentTable.toggleRowSelection(student, true)
- if (isInCurrentSelection) {
- console.log(`✅ 在finally中恢复当前页勾选: ${student.name} (ID: ${student.id})`)
- } else {
- console.log(`✅ 在finally中恢复总选择勾选: ${student.name} (ID: ${student.id})`)
- }
+ if (isInCurrentSelection || isInAllSelected) {
+ // 使用 Element UI 的表格方法设置选择状态
+ this.$refs.systemStudentTable.toggleRowSelection(student, true)
+ if (isInCurrentSelection) {
+ console.log(`✅ 在finally中恢复当前页勾选: ${student.name} (ID: ${student.id})`)
+ } else {
+ console.log(`✅ 在finally中恢复总选择勾选: ${student.name} (ID: ${student.id})`)
}
- })
- console.log('finally中已恢复选择状态')
+ }
})
+ console.log('finally中已恢复选择状态')
})
- }).catch(error => {
- console.error('导入API模块失败:', error)
- this.$message.error('系统模块加载失败')
- this.students = []
- this.studentsLoading = false
})
},
@@ -1828,6 +1836,7 @@ export default {
this.currentPage = 1 // 重置分页到第一页
this.selectedSystemStudents = [] // 清空当前页选择
this.allSelectedStudents = [] // 清空总选择数组
+ this.selectedCourse = '' // 清空具体课程选择
this.loadStudents() // 执行搜索
},
@@ -1861,6 +1870,21 @@ export default {
document.body.removeChild(link)
this.$message.success(`已导出 ${this.recipients.length} 个收件人数据`)
+ },
+
+ // 加载具体课程列表
+ loadCourses() {
+ // 直接加载所有课程列表
+ import('@/api/course/index').then(({ index }) => {
+ index({
+ page: 1,
+ page_size: 999
+ }).then(res => {
+ this.courseList = res.data || []
+ }).catch(error => {
+ console.error('加载课程列表失败:', error)
+ })
+ })
}
}
}
diff --git a/src/views/student/index.vue b/src/views/student/index.vue
index d3150a1..55a6429 100644
--- a/src/views/student/index.vue
+++ b/src/views/student/index.vue
@@ -85,12 +85,6 @@
-
-
-
-
-
-
@@ -161,7 +155,7 @@
重置
导入
批量设置校友库
- 批量取消校友库/加入黑名单
+ 批量取消校友库
@@ -231,14 +225,14 @@
-
+
@@ -335,7 +329,6 @@
company_industry: '',
is_vip: '',
is_schoolmate: '',
- is_black: '',
courses_end_date: '',
education: '',
type: '',
@@ -423,11 +416,6 @@
label: '是否校友库学员',
align: 'center',
width: 120,
- }, {
- prop: 'is_black',
- label: '是否黑名单',
- align: 'center',
- width: 120,
},{
prop: 'is_vip',
label: '学员身份',
@@ -524,7 +512,6 @@
this.select.is_vip = ''
this.select.courses_end_date = ''
this.select.is_schoolmate = ''
- this.select.is_black = ''
this.select.education = ''
this.select.type = ''
this.select.status = ''
@@ -557,7 +544,6 @@
is_vip: this.select.is_vip,
courses_end_date: this.select.courses_end_date,
is_schoolmate: this.select.is_schoolmate,
- is_black: this.select.is_black,
education: this.select.education,
type: this.select.type,
status: this.select.status,
@@ -589,7 +575,7 @@
updateSchoolmates(vip) {
if (this.seleSchoolmates.length > 0) {
if (vip == 0) {
- // 批量取消校友库 - 询问是否加入黑名单
+ // 批量取消校友库
this.$confirm(
`确定要将选中的 ${this.seleSchoolmates.length} 名学员从校友库移除吗?`,
'提示',
@@ -599,24 +585,10 @@
type: 'warning'
}
).then(() => {
- // 第一个确认框选择确定后,弹出第二个确认框询问是否加入黑名单
- this.$confirm(
- '是否将这些学员加入黑名单?',
- '黑名单确认',
- {
- confirmButtonText: '是',
- cancelButtonText: '否',
- type: 'warning'
- }
- ).then(() => {
- // 选择是,加入黑名单
- this.submitUpdateSchoolmates(vip, 1);
- }).catch(() => {
- // 选择否,不加入黑名单
- this.submitUpdateSchoolmates(vip, 0);
- });
+ // 直接取消校友库,不加入黑名单
+ this.submitUpdateSchoolmates(vip);
}).catch(() => {
- // 第一个确认框选择取消,不执行任何操作
+ // 用户取消操作
console.log('用户取消了操作');
});
} else {
@@ -640,7 +612,7 @@
).then(() => {
// 选择是,剔除黑名单学员后提交
if (otherUsers.length > 0) {
- this.submitUpdateSchoolmates(vip, 0, otherUsers);
+ this.submitUpdateSchoolmates(vip, otherUsers);
} else {
this.$Message.warning('没有可设置为校友的学员');
}
@@ -659,7 +631,7 @@
type: 'warning'
}
).then(() => {
- this.submitUpdateSchoolmates(vip, 0);
+ this.submitUpdateSchoolmates(vip);
}).catch(() => {
console.log('用户取消了操作');
});
@@ -671,7 +643,7 @@
}
},
// 提交更新校友库状态
- submitUpdateSchoolmates(vip, isBlack, users = null) {
+ submitUpdateSchoolmates(vip, users = null) {
// 如果传入了users参数,使用传入的用户列表,否则使用默认的seleSchoolmates
const targetUsers = users || this.seleSchoolmates;
@@ -683,9 +655,8 @@
updateSchoolmate({
is_schoolmate: vip,
ids: ids.join(','),
- is_black: isBlack
+ is_black: 0 // 固定设置为非黑名单
}).then(res => {
- const blackStatus = isBlack === 1 ? '并加入黑名单' : '但不加入黑名单';
const userCount = targetUsers.length;
const operation = vip === 1 ? '加入校友库' : '从校友库移除';
@@ -693,7 +664,7 @@
// 如果有黑名单学员被剔除,显示特殊提示
this.$Message.success(`批量${operation}成功,共处理 ${userCount} 名学员`)
} else {
- this.$Message.success(`批量${operation}成功,${blackStatus}`)
+ this.$Message.success(`批量${operation}成功`)
}
this.getList()
diff --git a/src/views/student/schoolmate.vue b/src/views/student/schoolmate.vue
index 2452678..32cf54a 100644
--- a/src/views/student/schoolmate.vue
+++ b/src/views/student/schoolmate.vue
@@ -153,7 +153,7 @@
查询
重置
- 批量取消校友库/加入黑名单
+ 批量取消校友库
@@ -553,7 +553,7 @@
updateSchoolmates(vip) {
if (this.seleSchoolmates.length > 0) {
if (vip == 0) {
- // 批量取消校友库 - 询问是否加入黑名单
+ // 批量取消校友库
this.$confirm(
`确定要将选中的 ${this.seleSchoolmates.length} 名学员从校友库移除吗?`,
'提示',
@@ -563,24 +563,10 @@
type: 'warning'
}
).then(() => {
- // 第一个确认框选择确定后,弹出第二个确认框询问是否加入黑名单
- this.$confirm(
- '是否将这些学员加入黑名单?',
- '黑名单确认',
- {
- confirmButtonText: '是',
- cancelButtonText: '否',
- type: 'warning'
- }
- ).then(() => {
- // 选择是,加入黑名单
- this.submitUpdateSchoolmates(vip, 1);
- }).catch(() => {
- // 选择否,不加入黑名单
- this.submitUpdateSchoolmates(vip, 0);
- });
+ // 直接取消校友库,不加入黑名单
+ this.submitUpdateSchoolmates(vip, 0);
}).catch(() => {
- // 第一个确认框选择取消,不执行任何操作
+ // 用户取消操作
console.log('用户取消了操作');
});
} else {
@@ -604,7 +590,7 @@
).then(() => {
// 选择是,剔除黑名单学员后提交
if (otherUsers.length > 0) {
- this.submitUpdateSchoolmates(vip, 0, otherUsers);
+ this.submitUpdateSchoolmates(vip, otherUsers);
} else {
this.$Message.warning('没有可设置为校友的学员');
}
@@ -623,7 +609,7 @@
type: 'warning'
}
).then(() => {
- this.submitUpdateSchoolmates(vip, 0);
+ this.submitUpdateSchoolmates(vip);
}).catch(() => {
console.log('用户取消了操作');
});
@@ -635,7 +621,7 @@
}
},
// 提交更新校友库状态
- submitUpdateSchoolmates(vip, isBlack, users = null) {
+ submitUpdateSchoolmates(vip, users = null) {
// 如果传入了users参数,使用传入的用户列表,否则使用默认的seleSchoolmates
const targetUsers = users || this.seleSchoolmates;
@@ -647,9 +633,8 @@
updateSchoolmate({
is_schoolmate: vip,
ids: ids.join(','),
- is_black: isBlack
+ is_black: 0 // 固定设置为非黑名单
}).then(res => {
- const blackStatus = isBlack === 1 ? '并加入黑名单' : '但不加入黑名单';
const userCount = targetUsers.length;
const operation = vip === 1 ? '加入校友库' : '从校友库移除';
@@ -657,7 +642,7 @@
// 如果有黑名单学员被剔除,显示特殊提示
this.$Message.success(`批量${operation}成功,共处理 ${userCount} 名学员(已剔除黑名单学员)`)
} else {
- this.$Message.success(`批量${operation}成功,${blackStatus}`)
+ this.$Message.success(`批量${operation}成功`)
}
this.getList()