diff --git a/src/api/index.js b/src/api/index.js index 3c94b83..94dd309 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -268,6 +268,7 @@ export default { allExperimentalResultsAreDerived: `${host}competition/competition/performance/allExperimentalResultsAreDerived`, derivedRanking: `${host}competition/competition/rank/derivedRanking`, individualDerivedRanking: `${host}competition/competition/rank/individualDerivedRanking`, + gradeDownloadExcel: `${host}competition/competition/performance/downloadExcel`, gradeImport: `https://www.occupationlab.com/template/赛事成绩导入模板.xlsx`, rankImportTeam: `https://www.occupationlab.com/template/赛事排名导入模板(团队赛).xlsx`, rankImportPerson: `https://www.occupationlab.com/template/赛事排名导入模板(个人赛).xlsx`, diff --git a/src/pages/match/add/step1.vue b/src/pages/match/add/step1.vue index 022019b..9f5a8a8 100644 --- a/src/pages/match/add/step1.vue +++ b/src/pages/match/add/step1.vue @@ -146,11 +146,13 @@
指定区域、院校 - 选择院校 - {{ rangeName }} +
{ }) }, manage (row) { - this.$router.push(`/match/manage?id=${row.id}&releaseType=${row.releaseType}&name=${row.competitionName}`) + this.$router.push(`/match/manage?id=${row.id}&name=${row.competitionName}`) }, changeType () { diff --git a/src/pages/match/manage/index.vue b/src/pages/match/manage/index.vue index a9a5a90..e914073 100644 --- a/src/pages/match/manage/index.vue +++ b/src/pages/match/manage/index.vue @@ -52,7 +52,6 @@ export default { data () { return { name: this.$route.query.name, - releaseType: +this.$route.query.releaseType, active: this.$route.query.tab || '', tabs: { tab1: "大赛详情", @@ -102,7 +101,7 @@ export default { // } // }, methods: { - initTabs () { + async initTabs () { const { btns } = this const tab1 = btns.includes('/match/list:管理:大赛详情') const tab2 = btns.includes('/match/list:管理:大赛成绩管理') @@ -110,8 +109,10 @@ export default { const tab4 = btns.includes('/match/list:管理:公告通知') const tab5 = btns.includes('/match/list:管理:报名人员') + const res = await this.$post(`${this.api.getCompetition}?competitionId=${this.$route.query.id}`) + tab1 || this.$delete(this.tabs, 'tab1') - if (!tab2 || !this.releaseType) this.$delete(this.tabs, 'tab2') + if (!tab2 || !res.competition.releaseType) this.$delete(this.tabs, 'tab2') tab3 || this.$delete(this.tabs, 'tab3') tab4 || this.$delete(this.tabs, 'tab4') tab5 || this.$delete(this.tabs, 'tab5') diff --git a/src/pages/match/manage/matchArchList.vue b/src/pages/match/manage/matchArchList.vue index 2bc3d66..63ab888 100644 --- a/src/pages/match/manage/matchArchList.vue +++ b/src/pages/match/manage/matchArchList.vue @@ -9,259 +9,276 @@ - -
-
-
-

已参加/应参加人数

-

{{ isNaN(statData.totalNumber) ? '' : statData.attendance + '/' + statData.totalNumber }}

-
-
-

实验平均分

-

{{ avgScore }}

+
+ +
+
+
+

已参加/应参加人数

+

{{ isNaN(statData.totalNumber) ? '' : statData.attendance + '/' + statData.totalNumber }}

+
+
+

实验平均分

+

{{ avgScore }}

+
+
-
-
- - - - + -
-
- -
-
- 上传成绩 - 批量删除 - 导出 -
-
- {{ loading ? '正在导出' : '批量导出' }} + + -
- - - + + + +
-
- 模板下载 -
- +
+ 模板下载 +
+ - 上传文件 - - 部分数据导入失败,查看失败原因 + 上传文件 +
+ +
- - 取 消 - 确 定 + 停止导入
@@ -299,14 +316,17 @@ export default { importVisible: false, uploadList: [], uploadFaild: false, - exportCode: '', + uploading: false, + faildData: null, headers: { token: util.local.get(Setting.tokenKey) }, statData: {}, tabs: ['成绩列表', '文件列表'], active: 0, - loading: false + loading: false, + exporting: false, + exporting1: false, }; }, watch: { @@ -321,51 +341,52 @@ export default { this.getData() }, methods: { - getData () { + async getData () { + this.loading = true // 文件列表 if (this.active) { - this.$post(this.api.cCompetitionStageFileList, { + const { data } = await this.$post(this.api.cCompetitionStageFileList, { pageNum: this.page1, pageSize: this.pageSize, competitionId: this.id, stageId: this.stageId, keyWord: this.keyword, - }).then(({ data }) => { - data.records.forEach(e => { - e.loading = false - e.fileType = '其他' - if (util.isVideo(e.fileFormat)) { - e.fileType = '视频' - } else if (util.isAudio(e.fileFormat)) { - e.fileType = '音频' - } else if (util.isImg(e.fileFormat)) { - e.fileType = '图片' - } else if (util.isDoc(e.fileFormat)) { - e.fileType = '文档' - } else if (util.isCompress(e.fileFormat)) { - e.fileType = '压缩包' - } else if (e.fileType === 'pdf') { - e.fileType = 'pdf' - } - }) - this.list1 = data.records - this.total1 = data.total - }).catch(res => { }) + }) + data.records.forEach(e => { + e.loading = false + e.fileType = '其他' + if (util.isVideo(e.fileFormat)) { + e.fileType = '视频' + } else if (util.isAudio(e.fileFormat)) { + e.fileType = '音频' + } else if (util.isImg(e.fileFormat)) { + e.fileType = '图片' + } else if (util.isDoc(e.fileFormat)) { + e.fileType = '文档' + } else if (util.isCompress(e.fileFormat)) { + e.fileType = '压缩包' + } else if (e.fileType === 'pdf') { + e.fileType = 'pdf' + } + }) + this.list1 = data.records + this.total1 = data.total + this.loading = false } else { // 成绩列表 - this.$post(this.api.stageGradeManagementList, { + const { data, page } = await this.$post(this.api.stageGradeManagementList, { pageNum: this.page, pageSize: this.pageSize, competitionId: this.id, keyWord: this.keyword, stageId: this.stageId, isNakadai: 1 - }).then(({ data, page }) => { - this.total = page.total - this.list = page.records - this.statData = data - this.avgScore = (+data.avgScore).toFixed(2) - this.getChart() - }).catch(res => { }) + }) + this.total = page.total + this.list = page.records + this.statData = data + this.avgScore = (+data.avgScore).toFixed(2) + this.getChart() + this.loading = false } }, initData () { @@ -377,50 +398,42 @@ export default { this.$router.push(`/match/report?reportId=${row.reportId}`) }, // 导出(有勾选:就导勾选中的;没有勾选:就导全部) - exportData () { - // 有选择数据,则导出已选择的,否则导出全部 - if (this.multipleSelection.length) { - axios.post(this.api.exportExperimentalResultsInBatch, this.multipleSelection, { - headers: this.headers, - responseType: 'blob' - }).then((res) => { + async exportData () { + if (this.list.length) { + this.exporting = true + // 有选择数据,则导出已选择的,否则导出全部 + if (this.multipleSelection.length) { + const res = await axios.post(this.api.exportExperimentalResultsInBatch, this.multipleSelection, { + headers: this.headers, + responseType: 'blob' + }) util.downloadFileDirect(`赛事成绩.xls`, new Blob([res.data])) - }).catch(res => { }) - } else if (this.list.length) { - axios.post(this.api.allExperimentalResultsAreDerived, { - pageNum: 1, - pageSize: 10000, - competitionId: this.id, - isNakadai: 1, - stageId: this.stageId, - }, { - headers: this.headers, - responseType: 'blob' - }).then((res) => { + this.exporting = false + } else { + const res = await axios.post(this.api.allExperimentalResultsAreDerived, { + pageNum: 1, + pageSize: 10000, + competitionId: this.id, + isNakadai: 1, + stageId: this.stageId, + }, { + headers: this.headers, + responseType: 'blob' + }) util.downloadFileDirect(`赛事成绩.xls`, new Blob([res.data])) - }).catch(res => { }) + this.exporting = false + } } - - // let { list } = this - // if (this.multipleSelection.length) { - // list = this.multipleSelection - // } - // axios.post(this.api.exportExperimentalResultsInBatch, list, { - // headers: this.headers, - // responseType: 'blob' - // }).then((res) => { - // util.downloadFileDirect(`赛事成绩.xls`, new Blob([res.data])) - // }).catch(res => { }) }, // 导出(有勾选:就导勾选中的;没有勾选:就导全部) exportData1 () { - this.loading = true + this.exporting1 = true let list = this.list1 if (this.multipleSelection1.length) { list = this.multipleSelection1 } Zip('批量导出', list, () => { - this.loading = false + this.exporting1 = false }) }, handleDelete (row) { // 删除 @@ -443,21 +456,22 @@ export default { if (this.multipleSelection.length) { this.$confirm("该项目下的所有成绩报告将会删除,是否继续?", "提示", { type: "warning" - }).then(() => { + }).then(async () => { let ids = this.multipleSelection.map(item => { return this.method == 2 ? item.scoreId : item.reportId }); - this.$post(this.api.batchDeleteContestGrade, { - ids, - competitionId: this.id, - stageId: this.stageId - }).then(res => { + ids = ids.filter(e => e) + if (ids.length) { + await this.$post(this.api.batchDeleteContestGrade, { + ids, + competitionId: this.id, + stageId: this.stageId + }) this.multipleSelection = []; this.$refs.table.clearSelection(); util.successMsg("删除成功"); this.getData(); - }).catch(res => { - }); + } }).catch(() => { }); } else { @@ -517,7 +531,12 @@ export default { }, // 模板下载 download () { - location.href = this.api.gradeImport + axios.get(`${this.api.gradeDownloadExcel}?competitionId=${this.id}&stageId=${this.stageId}`, { + headers: this.headers, + responseType: 'blob' + }).then((res) => { + util.downloadFileDirect('赛事成绩导入模板.xlsx', new Blob([res.data])) + }).catch(res => { }) }, // 上传文件 handleExceed (files, fileList) { @@ -527,23 +546,27 @@ export default { }, // 下载失败文件 showFaild () { - axios.get(`${this.api.performanceExportFailure}?exportCode=${this.exportCode}`, { + axios.get(`${this.api.performanceExportFailure}?exportCode=${this.faildData.exportCode}&competitionType=${this.faildData.competitionType}`, { headers: this.headers, responseType: 'blob' }).then((res) => { util.downloadFileDirect(`批量导入成绩管理失败数据导出.xls`, new Blob([res.data])) }).catch(res => { }) }, - uploadSuccess (res, file, fileList) { + uploadSuccess (res) { + this.uploading = false this.uploadFaild = false if (res.status === 200) { - if (res.data.exportCode) { - this.exportCode = res.data.exportCode + const { data } = res + if (data.exportCode) { + this.faildData = data this.uploadFaild = true - util.errorMsg(`本次上传有${res.data.failureNum}个错误信息录入`) + } else { + util.successMsg(data.tip, 3000) + this.importVisible = false } } else { - res.message ? util.errorMsg(res.message) : util.errorMsg("上传失败,请检查数据") + util.errorMsg(res.message || '上传失败,请检查数据') } }, uploadError (err, file, fileList) { @@ -553,6 +576,9 @@ export default { center: true }) }, + beforeUpload (file) { + this.uploading = true + }, beforeRemove (file, fileList) { return this.$confirm(`确定移除 ${file.name}?`) }, @@ -560,9 +586,12 @@ export default { this.uploadList = fileList this.uploadFaild = false }, - uploadSure () { + cancelUpload () { + this.uploading = false + this.$refs.upload.abort() + this.keyword = '' + this.initData() this.importVisible = false - this.getData() }, // tab回调 @@ -658,4 +687,11 @@ export default { height: 300px; } } +/deep/.import-file { + .el-progress__text, + .el-progress, + .el-upload-list__item-status-label { + display: none !important; + } +} \ No newline at end of file diff --git a/src/pages/match/manage/matchInfo.vue b/src/pages/match/manage/matchInfo.vue index bac3def..3094bc6 100644 --- a/src/pages/match/manage/matchInfo.vue +++ b/src/pages/match/manage/matchInfo.vue @@ -288,7 +288,7 @@