From f87e02b06be8d5256a5d3473ed19eb5464bd1e91 Mon Sep 17 00:00:00 2001 From: liweijie Date: Tue, 22 Sep 2026 16:46:56 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=89=E4=BF=AE=E8=AF=BE=E5=92=8C=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E7=A7=91=E7=9B=AE=EF=BC=8C=E4=B8=8A=E4=BC=A0=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4=EF=BC=8C=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E6=8C=89=E9=92=AE=E9=80=89=E6=8B=A9=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/teachOffice/elective.js | 13 +++ .../src/views/teachOffice/elective/index.vue | 93 +++++++++++++---- .../src/views/teachOffice/subject/index.vue | 99 +++++++++++-------- 3 files changed, 144 insertions(+), 61 deletions(-) diff --git a/frontend/src/api/teachOffice/elective.js b/frontend/src/api/teachOffice/elective.js index 05fd5664..0b039c45 100644 --- a/frontend/src/api/teachOffice/elective.js +++ b/frontend/src/api/teachOffice/elective.js @@ -46,6 +46,19 @@ export function batchStopElective(bhList) { }) } +/** 导入选修课 Excel POST /jys/elective/import(multipart,字段名 file) */ +export function importElective(file) { + const formData = new FormData() + formData.append('file', file) + return request({ + url: '/jys/elective/import', + method: 'post', + data: formData, + headers: { 'Content-Type': 'multipart/form-data' }, + timeout: 60000 + }) +} + // 下载选修班列表(Excel) export function exportElectiveList(query) { return request({ diff --git a/frontend/src/views/teachOffice/elective/index.vue b/frontend/src/views/teachOffice/elective/index.vue index 9feeeb0d..481c1e86 100644 --- a/frontend/src/views/teachOffice/elective/index.vue +++ b/frontend/src/views/teachOffice/elective/index.vue @@ -74,10 +74,7 @@ 下载选修班列表 学员名单Word 学员名单Excel - 选择文件 - {{ fileName }} - - 上传数据 + 数据导入 @@ -233,6 +230,29 @@ 确定 + + + +
+
+ 选择文件 + {{ fileName }} + +
+
请选择填写完成的选修课数据模板文件上传
+
+
+ 取消 + 上传数据 +
+
@@ -240,6 +260,7 @@ import { listElective, addElective, + importElective, batchOpenElective, batchCancelOpenElective, batchStopElective, @@ -278,6 +299,8 @@ export default { selectedRows: [], // ==================== 文件上传 ==================== + importVisible: false, + importing: false, selectedFile: null, // ==================== 新建选修课弹窗 ==================== @@ -436,6 +459,13 @@ export default { }, // ==================== 文件上传 ==================== + handleOpenImport() { + this.selectedFile = null + this.importVisible = true + this.$nextTick(() => { + if (this.$refs.fileInputRef) this.$refs.fileInputRef.value = '' + }) + }, handleSelectFile() { this.$refs.fileInputRef && this.$refs.fileInputRef.click() }, @@ -447,7 +477,14 @@ export default { this.$message.warning('请先选择文件') return } - this.$message.warning('后端暂未提供该接口') + this.importing = true + importElective(this.selectedFile).then(res => { + this.$message.success((res && res.msg) || '导入成功') + this.importVisible = false + this.loadList() + }).catch(() => {}).finally(() => { + this.importing = false + }) }, // ==================== 表格多选 ==================== @@ -628,19 +665,6 @@ export default { .el-button + .el-button { margin-left: 0; } - - .file-name { - max-width: 180px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - font-size: 12px; - color: #999; - - &.has-file { - color: #303133; - } - } } } @@ -663,4 +687,37 @@ export default { margin-top: 16px; } } + +// ==================== 数据导入弹窗 ==================== +.import-dialog { + .import-body { + display: flex; + flex-direction: column; + gap: 14px; + } + + .import-file-row { + display: flex; + align-items: center; + gap: 12px; + + .file-name { + max-width: 240px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + font-size: 12px; + color: #999; + + &.has-file { + color: #303133; + } + } + } + + .import-tip { + font-size: 12px; + color: #909399; + } +} diff --git a/frontend/src/views/teachOffice/subject/index.vue b/frontend/src/views/teachOffice/subject/index.vue index fb0684ed..44f4316f 100644 --- a/frontend/src/views/teachOffice/subject/index.vue +++ b/frontend/src/views/teachOffice/subject/index.vue @@ -52,27 +52,6 @@ - - -
-
-

数据导入

-

选择填写完成的课程科目模板并上传

-
-
-
-
- 选择文件 - {{ fileName }} - -
-
- 覆盖已存在课程科目 - 上传数据 -
-
-
-
@@ -81,6 +60,7 @@ 新建课程科目 删除所选 【课程科目数据文件模板】下载 + 数据导入
+ + + +
+
+ 选择文件 + {{ fileName }} + +
+ 覆盖已存在课程科目 +
+ 下载课程科目数据文件模板 +
+
+
+ 取消 + 上传数据 +
+
@@ -333,6 +339,7 @@ export default { selectedRows: [], // ==================== 文件上传 ==================== + importVisible: false, selectedFile: null, coverExist: false, @@ -508,6 +515,14 @@ export default { }, // ==================== 文件上传(后端暂未提供) ==================== + handleOpenImport() { + this.selectedFile = null + this.coverExist = false + this.importVisible = true + this.$nextTick(() => { + if (this.$refs.fileInputRef) this.$refs.fileInputRef.value = '' + }) + }, handleSelectFile() { this.$refs.fileInputRef && this.$refs.fileInputRef.click() }, @@ -518,6 +533,10 @@ export default { }, handleUpload() { + if (!this.selectedFile) { + this.$message.warning('请先选择文件') + return + } this.$message.warning('后端暂未提供该接口') }, @@ -627,37 +646,31 @@ export default { } -// ==================== 4. 文件上传区域 ==================== -.upload-card { - margin-bottom: 16px; +// ==================== 4. 数据导入弹窗 ==================== +.import-dialog { + .import-body { + display: flex; + flex-direction: column; + gap: 14px; + } - .upload-row { + .import-file-row { display: flex; align-items: center; - justify-content: space-between; - flex-wrap: wrap; gap: 12px; - .upload-left { - display: flex; - align-items: center; - gap: 12px; + .file-name { + font-size: 12px; + color: #999; - .file-name { - font-size: 12px; - color: #999; - - &.has-file { - color: #303133; - } + &.has-file { + color: #303133; } } + } - .upload-right { - display: flex; - align-items: center; - gap: 12px; - } + .import-tip { + margin-top: -4px; } }