From c5c8ba96dcc47e473de663e3ce58468d4296d938 Mon Sep 17 00:00:00 2001 From: e <2432808546@qq.com> Date: Thu, 25 Nov 2021 18:35:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/achievement/vir/index.vue | 6 +- src/pages/match/manage/matchDetail.vue | 144 ++++++++++++++++------- src/pages/match/manage/matchProgress.vue | 84 ++++++------- src/pages/project/list/index.vue | 17 ++- 4 files changed, 162 insertions(+), 89 deletions(-) diff --git a/src/pages/achievement/vir/index.vue b/src/pages/achievement/vir/index.vue index e746cd1..34eec66 100644 --- a/src/pages/achievement/vir/index.vue +++ b/src/pages/achievement/vir/index.vue @@ -101,7 +101,7 @@ export default { }, getData() { this.$post(`${this.api.getPracticeDetail}?pageNum=${this.page}&pageSize=${this.pageSize}&projectId=${this.projectId}&keyword=${this.keyword}`).then(res => { - this.multipleSelection = res.page.records; + // this.multipleSelection = res.page.records; this.listData = res.page.records; this.total = res.page.total; let avgScore = +res.avgScore @@ -124,9 +124,9 @@ export default { let ids = this.multipleSelection.map(item => { return item.reportId; }); - location.href = `${this.api.exportPracticeInfo}?ids=${ids.toString()}`; + location.href = `${this.api.exportPracticeInfo}?projectId=${this.projectId}&ids=${ids.toString()}`; } else { - location.href = `${this.api.exportPracticeInfo}?ids=`; + location.href = `${this.api.exportPracticeInfo}?projectId=${this.projectId}`; } }, handleDelete(row) { diff --git a/src/pages/match/manage/matchDetail.vue b/src/pages/match/manage/matchDetail.vue index b055d78..549c6c6 100644 --- a/src/pages/match/manage/matchDetail.vue +++ b/src/pages/match/manage/matchDetail.vue @@ -132,7 +132,8 @@ export default { playTime: "", playStartTime: "", playEndTime: "", - description: "" + description: "", + touchTime:0, }; }, components: { @@ -140,6 +141,7 @@ export default { }, watch: { signupTime: function(val) { + this.touchTime = this.touchTime+1 if (val) { this.signUpStartTime = val[0]; this.signUpEndTime = val[1]; @@ -149,6 +151,7 @@ export default { } }, playTime: function(val) { + this.touchTime = this.touchTime+1 if (val) { this.playStartTime = val[0]; this.playEndTime = val[1]; @@ -167,9 +170,9 @@ export default { "setMatchId" ]), save(status) { + this.touchTime = 0 this.sponsor = this.sponsorList.filter(d => d).join(); this.undertaker = this.undertakerList.filter(d => d).join(); - if (!this.name) return util.warningMsg("请填写竞赛名称"); if (status == 0) { if (!this.sponsor) return util.warningMsg("请填写主办方"); @@ -183,7 +186,6 @@ export default { if (!this.playStartTime && status == 0) return util.warningMsg("请选择竞赛时间"); if (playStartTime && playStartTime < signUpEndTime) return util.warningMsg("竞赛时间不能早于报名结束时间"); if (!this.description && status == 0) return util.warningMsg("请填写竞赛详情"); - let data = { id: this.id, coverUrl: this.coverUrl, @@ -203,51 +205,48 @@ export default { this.$put(this.api.editContest, data).then(res => { util.successMsg("修改成功"); this.$router.back(); - }) - .catch(err => { - }); + }).catch(err => { + }); } else { this.$post(this.api.addContest, data).then(res => { util.successMsg("创建成功"); this.$router.back(); - }) - .catch(err => { - }); + }).catch(err => { + }); } }, getData() { - this.$get(this.api.getContest + "/" + this.id) - .then(res => { - let data = res.contest; - this.coverUrl = data.coverUrl; - this.carouselUrl = data.carouselUrl; - this.description = data.description; - this.name = data.name; - this.playEndTime = data.playEndTime; - this.playStartTime = data.playStartTime; - this.publishStatus = data.publishStatus; - this.signUpEndTime = data.signUpEndTime; - this.signUpStartTime = data.signUpStartTime; - this.sponsor = data.sponsor; - this.undertaker = data.undertaker; - - this.signupTime = [data.signUpStartTime, data.signUpEndTime]; - this.playTime = [data.playStartTime, data.playEndTime]; - this.sponsorList = data.sponsor.split(","); - this.undertakerList = data.undertaker.split(","); - }) - .catch(err => { - - }); + this.$get(this.api.getContest + "/" + this.id).then(res => { + let data = res.contest; + this.coverUrl = data.coverUrl; + this.carouselUrl = data.carouselUrl; + this.description = data.description; + this.name = data.name; + this.playEndTime = data.playEndTime; + this.playStartTime = data.playStartTime; + this.publishStatus = data.publishStatus; + this.signUpEndTime = data.signUpEndTime; + this.signUpStartTime = data.signUpStartTime; + this.sponsor = data.sponsor; + this.undertaker = data.undertaker; + this.signupTime = [data.signUpStartTime, data.signUpEndTime]; + this.playTime = [data.playStartTime, data.playEndTime]; + this.sponsorList = data.sponsor.split(","); + this.undertakerList = data.undertaker.split(","); + }).catch(err => { + }); }, commitId() { + this.touchTime = this.touchTime+1 this.setMatchId(this.id); // this.$store.commit("setMatchId", { matchId: this.id }); }, handleExceed(files, fileList) { + this.touchTime = this.touchTime+1 util.warningMsg(`当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!`); }, uploadSuccess(res, file, fileList) { + this.touchTime = this.touchTime+1 if (this.coverUrl) { let fileName = this.coverUrl.replace("https://liuwanr.oss-cn-shenzhen.aliyuncs.com/", ""); this.$del(`${this.api.fileDeletion}?keys=${fileName}`).then(res => { @@ -257,6 +256,7 @@ export default { this.coverUrl = res.data.filesResult.fileUrl; }, uploadLgSuccess(res, file, fileList) { + this.touchTime = this.touchTime+1 if (this.carouselUrl) { let fileName = this.carouselUrl.replace("https://liuwanr.oss-cn-shenzhen.aliyuncs.com/", ""); this.$del(`${this.api.fileDeletion}?keys=${fileName}`).then(res => { @@ -266,6 +266,7 @@ export default { this.carouselUrl = res.data.filesResult.fileUrl; }, uploadError(err, file, fileList) { + this.touchTime = this.touchTime+1 this.$message({ message: "上传出错,请重试!", type: "error", @@ -273,9 +274,11 @@ export default { }); }, beforeRemove(file, fileList) { + this.touchTime = this.touchTime+1 return this.$confirm(`确定移除 ${file.name}?`); }, handleRemove(file, fileList) { + this.touchTime = this.touchTime+1 let fileName = this.coverUrl.replace("https://liuwanr.oss-cn-shenzhen.aliyuncs.com/", ""); this.$del(`${this.api.fileDeletion}?keys=${fileName}`).then(res => { this.coverUrl = ""; @@ -283,6 +286,7 @@ export default { }); }, handleLgRemove(file, fileList) { + this.touchTime = this.touchTime+1 let fileName = this.carouselUrl.replace("https://liuwanr.oss-cn-shenzhen.aliyuncs.com/", ""); this.$del(`${this.api.fileDeletion}?keys=${fileName}`).then(res => { this.carouselUrl = ""; @@ -290,6 +294,7 @@ export default { }); }, uploadSure() { + this.touchTime = this.touchTime+1 this.BatchUpload = false; this.pageNo = 1; this.keyword = ""; @@ -298,27 +303,86 @@ export default { goback() { this.$confirm("确定返回?未更新的信息将不会保存。", "提示", { type: "warning" - }) - .then(() => { - this.$router.push("/match"); - }) - .catch(() => { - }); + }).then(() => { + this.$router.push("/match"); + }).catch(() => { + }); }, addSponsor() { + this.touchTime = this.touchTime+1 this.sponsorList.push(""); }, delSponsor(index) { + this.touchTime = this.touchTime+1 this.sponsorList.splice(index, 1); }, addOrganizer() { + this.touchTime = this.touchTime+1 this.undertakerList.push(""); }, delOrganizer(index) { + this.touchTime = this.touchTime+1 this.undertakerList.splice(index, 1); } - - } + }, + beforeDestroy() { + if (this.touchTime>0){ + this.$confirm('暂未保存,是否保存本次编辑?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + this.sponsor = this.sponsorList.filter(d => d).join(); + this.undertaker = this.undertakerList.filter(d => d).join(); + if (!this.name) return util.warningMsg("请填写竞赛名称"); + if (status == 0) { + if (!this.sponsor) return util.warningMsg("请填写主办方"); + if (!this.signUpStartTime) return util.warningMsg("请选择报名时间"); + } + let now = new Date().getTime(); + let signUpStartTime = new Date(this.signUpStartTime).getTime(); + let signUpEndTime = new Date(this.signUpEndTime).getTime(); + let playStartTime = new Date(this.playStartTime).getTime(); + // if(signUpStartTime && now > signUpStartTime) return this.$$message.warning('报名时间不能早于当前时间') + if (!this.playStartTime && status == 0) return util.warningMsg("请选择竞赛时间"); + if (playStartTime && playStartTime < signUpEndTime) return util.warningMsg("竞赛时间不能早于报名结束时间"); + if (!this.description && status == 0) return util.warningMsg("请填写竞赛详情"); + let data = { + id: this.id, + coverUrl: this.coverUrl, + carouselUrl: this.carouselUrl, + description: this.description, + founderId: 1, + name: this.name, + playEndTime: this.playEndTime, + playStartTime: this.playStartTime, + publishStatus: status ? this.publishStatus : 0, + signUpEndTime: this.signUpEndTime, + signUpStartTime: this.signUpStartTime, + sponsor: this.sponsor, + undertaker: this.undertaker + }; + if (this.id) { + this.$put(this.api.editContest, data).then(res => { + util.successMsg("修改成功"); + this.$router.back(); + }).catch(err => { + }); + } else { + this.$post(this.api.addContest, data).then(res => { + util.successMsg("创建成功"); + this.$router.back(); + }).catch(err => { + }); + } + }).catch(() => { + this.$message({ + type: 'info', + message: '已取消保存' + }); + }); + } + }, }; diff --git a/src/pages/match/manage/matchProgress.vue b/src/pages/match/manage/matchProgress.vue index ebae30b..5741310 100644 --- a/src/pages/match/manage/matchProgress.vue +++ b/src/pages/match/manage/matchProgress.vue @@ -63,7 +63,8 @@ export default { multipleSelection: [], pageNo: 1, pageSize: 10, - totals: 0 + totals: 0, + touchTime:0, }; }, mounted() { @@ -81,12 +82,14 @@ export default { if (data.title.length) { if (row.id) { this.$put(this.api.editContestProgress, data).then(res => { + this.touchTime = this.touchTime-1 util.successMsg("修改成功"); this.getData(); }).catch(res => { }); } else { this.$post(this.api.addContestProgress, data).then(res => { + this.touchTime = this.touchTime-1 util.successMsg("创建成功"); this.getData(); }).catch(res => { @@ -110,18 +113,18 @@ export default { handleDelete(row) { this.$confirm("此删除操作不可逆,是否确认删除选中项?", "提示", { type: "warning" - }) - .then(() => { - this.$del(`${this.api.deleteContestProgress}/${row.id}`).then(res => { - util.successMsg("删除成功"); - this.getData(); - }).catch(res => { - }); - }) - .catch(() => { + }).then(() => { + this.touchTime = this.touchTime+1 + this.$del(`${this.api.deleteContestProgress}/${row.id}`).then(res => { + util.successMsg("删除成功"); + this.getData(); + }).catch(res => { }); + }).catch(() => { + }); }, addData() { + this.touchTime = this.touchTime+1 if (this.listData.length) { if (this.listData[this.listData.length - 1].id) { this.listData.push({ @@ -147,45 +150,46 @@ export default { }, }, beforeDestroy() { - this.$confirm('暂未保存,是否保存本次编辑?', '提示', { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: 'warning' - }).then(() => { - let num = 0; - for(var i=0;i { + if (this.touchTime>0){ + this.$confirm('暂未保存,是否保存本次编辑?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + let num = 0; + for(var i=0;i { - }).catch(res => { - }); + }).catch(res => { + }); + }else{ + num = num+1 + } }else{ num = num+1 } + } + if (num >0){ + this.$message({ + type: 'error', + message: '保存失败,有未填项目' + }); }else{ - num = num+1 + this.$message({ + type: 'success', + message: '保存成功!' + }); } - } - if (num >0){ - this.$message({ - type: 'error', - message: '保存失败,有未填项目' - }); - }else{ + }).catch(() => { this.$message({ - type: 'success', - message: '保存成功!' + type: 'info', + message: '已取消保存' }); - } - - }).catch(() => { - this.$message({ - type: 'info', - message: '已取消保存' }); - }); + } }, }; diff --git a/src/pages/project/list/index.vue b/src/pages/project/list/index.vue index 8dcf2fa..8adc55c 100644 --- a/src/pages/project/list/index.vue +++ b/src/pages/project/list/index.vue @@ -86,8 +86,8 @@