From 6599d982a4f19b55a86821756092ad95d2bc706f Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Tue, 28 May 2024 11:00:00 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=9B=E4=BA=8B=E5=88=86=E9=85=8D=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libs/util.js | 156 ++++---- src/utils/api.js | 2 + src/utils/util.js | 82 ++-- src/views/match/add/step3.vue | 35 +- src/views/match/manage/abnormalTeam.vue | 2 +- src/views/match/manage/matchSignup.vue | 479 +++++++++--------------- 6 files changed, 338 insertions(+), 418 deletions(-) diff --git a/src/libs/util.js b/src/libs/util.js index 7d39ce1..082ef00 100644 --- a/src/libs/util.js +++ b/src/libs/util.js @@ -1,6 +1,9 @@ import cookies from './util.cookies' -import {_local,_session} from './util.db' +import { _local, _session } from './util.db' import { Message } from 'element-ui' +import Setting from '@/setting' +import axios from 'axios' +import api from '@/utils/api' // 文件后缀集合 const exts = { @@ -15,115 +18,115 @@ const util = { local: _local, session: _session, // 传入身份证获取生日 - getBirth(idCard) { + getBirth (idCard) { var birthday = ""; - if(idCard != null && idCard != ""){ - if(idCard.length == 15){ - birthday = "19"+idCard.slice(6,12); - } else if(idCard.length == 18){ - birthday = idCard.slice(6,14); - } - birthday = birthday.replace(/(.{4})(.{2})/,"$1-$2-"); + if (idCard != null && idCard != "") { + if (idCard.length == 15) { + birthday = "19" + idCard.slice(6, 12); + } else if (idCard.length == 18) { + birthday = idCard.slice(6, 14); + } + birthday = birthday.replace(/(.{4})(.{2})/, "$1-$2-"); //通过正则表达式来指定输出格式为:1990-01-01 - } + } return birthday; }, // new Date('2020-11-12 00:00:00') 在IE下失效,因此把-替换成/ - dateCompatible(date) { + dateCompatible (date) { return date.replace(/\-/g, '/') }, // 日期时间前面补零 - formateTime(num) { + formateTime (num) { return num < 10 ? `0${num}` : num }, //返回格式化时间,传参例如:"yyyy-MM-dd hh:mm:ss" - formatDate(fmt,date) { + formatDate (fmt, date) { var date = date ? date : new Date() - var o = { - "M+" : date.getMonth()+1, //月份 - "d+" : date.getDate(), //日 - "h+" : date.getHours(), //小时 - "m+" : date.getMinutes(), //分 - "s+" : date.getSeconds(), //秒 - "q+" : Math.floor((date.getMonth()+3)/3), //季度 - "S" : date.getMilliseconds() //毫秒 - }; - if(/(y+)/.test(fmt)) { - fmt=fmt.replace(RegExp.$1, (date.getFullYear()+"").substr(4 - RegExp.$1.length)); + var o = { + "M+": date.getMonth() + 1, //月份 + "d+": date.getDate(), //日 + "h+": date.getHours(), //小时 + "m+": date.getMinutes(), //分 + "s+": date.getSeconds(), //秒 + "q+": Math.floor((date.getMonth() + 3) / 3), //季度 + "S": date.getMilliseconds() //毫秒 + }; + if (/(y+)/.test(fmt)) { + fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length)); } - for(var k in o) { - if(new RegExp("("+ k +")").test(fmt)){ - fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length))); - } + for (var k in o) { + if (new RegExp("(" + k + ")").test(fmt)) { + fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); + } } - return fmt; + return fmt; }, // 移除数组中指定值 - removeByValue(arr, val) { - for(var i=0; i { - n[attr] = n[attr].replace(/<\/?.+?>/gi,'') + n[attr] = n[attr].replace(/<\/?.+?>/gi, '') }) return list }, // 传入文件名获取文件后缀 - getFileExt(fileName) { + getFileExt (fileName) { return fileName.substring(fileName.lastIndexOf('.') + 1) }, // 传入文件名和路径,下载图片视频,支持跨域,a标签加download不支持跨域 - downloadFile(fileName, url) { + downloadFile (fileName, url) { var x = new XMLHttpRequest() x.open("GET", url, true) x.responseType = 'blob' - x.onload=function(e) { - var url = window.URL.createObjectURL(x.response) - var a = document.createElement('a') - a.href = url - a.download = fileName - a.click() + x.onload = function (e) { + var url = window.URL.createObjectURL(x.response) + var a = document.createElement('a') + a.href = url + a.download = fileName + a.click() } x.send() }, // 传入文件名和数据,下载文件 - downloadFileDirect(fileName,data) { + downloadFileDirect (fileName, data) { if ('download' in document.createElement('a')) { // 非IE下载 const elink = document.createElement('a') elink.download = fileName @@ -138,26 +141,37 @@ const util = { } }, // 成功提示 - successMsg(message,duration = 1500) { - return Message.success({message,showClose: true,offset: (document.documentElement.clientHeight - 40) / 2,duration}) + successMsg (message, duration = 1500) { + return Message.success({ message, showClose: true, offset: (document.documentElement.clientHeight - 40) / 2, duration }) }, // 警告提示 - warningMsg(message,duration = 1500) { - return Message.warning({message,showClose: true,offset: (document.documentElement.clientHeight - 40) / 2,duration}) + warningMsg (message, duration = 1500) { + return Message.warning({ message, showClose: true, offset: (document.documentElement.clientHeight - 40) / 2, duration }) }, // 错误提示 - errorMsg(message,duration = 1500) { - return Message.error({message,showClose: true,offset: (document.documentElement.clientHeight - 40) / 2,duration}) + errorMsg (message, duration = 1500) { + return Message.error({ message, showClose: true, offset: (document.documentElement.clientHeight - 40) / 2, duration }) }, // 判断是否是移动端 - isMobile() { - if(window.navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)) return true + isMobile () { + if (window.navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)) return true return false }, // 前置加0 - preZero(num) { + preZero (num) { return num > 9 ? num : `0${num}` }, + // 获取当前时间 + getNow () { + return new Promise(async (resolve, reject) => { + const { data } = await axios.get(Setting.apiBaseURL + api.getCurrentTime, { + headers: { + token: sessionStorage.getItem('token') + } + }) + resolve(new Date(data.currentTime)) + }) + }, } export default util \ No newline at end of file diff --git a/src/utils/api.js b/src/utils/api.js index 9eef8dc..1c4630d 100644 --- a/src/utils/api.js +++ b/src/utils/api.js @@ -12,6 +12,7 @@ export default { deleteProfile: `users/users/userInfo/deleteProfile`, refreshPageNotification: `nakadai/message/refreshPageNotification`, heartbeatDetection: `nakadai/message/heartbeatDetection`, + getCurrentTime: `competition/competition/management/getCurrentTime`, // 阿里云文件/视频管理 getPlayAuth: `${uploadURL}oss/manage/getPlayAuth`, // 获取播放凭证 @@ -335,6 +336,7 @@ export default { automaticAllocation: `competition/competition/automaticAllocation/automaticAllocation`, checkTeamStatus: `competition/teamAbnormalInformation/checkTeamStatus`, queryAbnormalTeam: `competition/teamAbnormalInformation/queryAbnormalTeam`, + viewEventAllocationInformation: `competition/competitionAutomaticAllocationRecord/viewEventAllocationInformation`, // 赛事内容 addCompetitionContent: `competition/competition/content/addCompetitionContent`, diff --git a/src/utils/util.js b/src/utils/util.js index 97025c4..fdeb86f 100644 --- a/src/utils/util.js +++ b/src/utils/util.js @@ -1,45 +1,45 @@ const util = { - deepCopy(obj) { // 深拷贝 - if (obj == null) { - return null; - } - if (typeof obj !== "object") return obj; - let result; - if (Array.isArray(obj)) { - result = []; - obj.forEach(item => { - result.push( - typeof item === "object" && !(item instanceof Date) - ? util.deepCopy(item) - : item - ); - }); - } else { - result = {}; - Object.keys(obj).forEach(key => { - result[key] = - typeof obj[key] === "object" && !(obj[key] instanceof Date) - ? util.deepCopy(obj[key]) - : obj[key]; - }); - } - return result; - }, - // 传入文件名和数据,下载文件 - downloadFileDirect(fileName,data) { - if ('download' in document.createElement('a')) { // 非IE下载 - const elink = document.createElement('a') - elink.download = fileName - elink.style.display = 'none' - elink.href = URL.createObjectURL(data) - document.body.appendChild(elink) - elink.click() - URL.revokeObjectURL(elink.href) // 释放URL 对象 - document.body.removeChild(elink) - } else { // IE10+下载 - navigator.msSaveBlob(data, fileName) - } - }, + deepCopy (obj) { // 深拷贝 + if (obj == null) { + return null; + } + if (typeof obj !== "object") return obj; + let result; + if (Array.isArray(obj)) { + result = []; + obj.forEach(item => { + result.push( + typeof item === "object" && !(item instanceof Date) + ? util.deepCopy(item) + : item + ); + }); + } else { + result = {}; + Object.keys(obj).forEach(key => { + result[key] = + typeof obj[key] === "object" && !(obj[key] instanceof Date) + ? util.deepCopy(obj[key]) + : obj[key]; + }); + } + return result; + }, + // 传入文件名和数据,下载文件 + downloadFileDirect (fileName, data) { + if ('download' in document.createElement('a')) { // 非IE下载 + const elink = document.createElement('a') + elink.download = fileName + elink.style.display = 'none' + elink.href = URL.createObjectURL(data) + document.body.appendChild(elink) + elink.click() + URL.revokeObjectURL(elink.href) // 释放URL 对象 + document.body.removeChild(elink) + } else { // IE10+下载 + navigator.msSaveBlob(data, fileName) + } + }, }; export default util; \ No newline at end of file diff --git a/src/views/match/add/step3.vue b/src/views/match/add/step3.vue index 3e599ce..a0a2d8c 100644 --- a/src/views/match/add/step3.vue +++ b/src/views/match/add/step3.vue @@ -318,29 +318,40 @@ export default { }, // 自动分配人员弹框 async autoAllocationConfirm (next) { + // 编辑 if (this.form[0].contentId) { - // 编辑的时候查询是否需要弹框选择重新分配 - const res = await this.$post(`${this.api.editWhetherPopUpsAppear}?competitionId=${this.id}`) - if (res.popupState) { - this.$confirm('报名的团队将按照新设置的规则进行自动分配阶段参赛人员,当前已分配的阶段参赛人员是否需要保留?', '提示', { - cancelButtonText: '已分配的保留', - confirmButtonText: '全部重新分配', + // 报名结束时间>当前时间 + if (new Date(this.$parent.$refs.step1.form.signUpEndTime) > Date.now()) { + this.$confirm('

团队赛发布成功,是否要重新自动分配阶段参赛人员?

(点击“是”将会在报名结束后给报名的团队自动分配阶段参赛人员

', '提示', { + confirmButtonText: '是', + cancelButtonText: '否', type: 'success', closeOnClickModal: false, showClose: false, + dangerouslyUseHTMLString: true, }).then(async () => { - await this.$post(`${this.api.automaticAllocation}?competitionId=${this.id}`) - this.$emit('next', next) + this.automaticAllocation(1, next) }).catch(() => { + this.automaticAllocation(0, next) + }) + } else { + this.$confirm('

团队赛发布成功,是否要重新自动分配阶段参赛人员?

(点击“是”将会立即给报名的团队自动分配阶段参赛人员

', '提示', { + confirmButtonText: '是', + cancelButtonText: '否', + type: 'success', + closeOnClickModal: false, + showClose: false, + dangerouslyUseHTMLString: true, + }).then(async () => { + await this.$post(`${this.api.automaticAllocation}?competitionId=${this.id}`) // 立马分配 this.$emit('next', next) - // this.automaticAllocation(0, next) + }).catch(() => { + this.automaticAllocation(0, next) }); - } else { - this.$emit('next', next) } } else { // 新增 - this.$confirm('

团队赛已发布,是否要自动分配阶段人员?

(点击“是”将会在报名结束后给报名的团队自动分配阶段参赛人员

', '提示', { + this.$confirm('

团队赛发布成功,是否要自动分配阶段参赛人员?

(点击“是”将会在报名结束后给报名的团队自动分配阶段参赛人员

', '提示', { confirmButtonText: '是', cancelButtonText: '否', type: 'success', diff --git a/src/views/match/manage/abnormalTeam.vue b/src/views/match/manage/abnormalTeam.vue index d8e1b38..5f4bb2a 100644 --- a/src/views/match/manage/abnormalTeam.vue +++ b/src/views/match/manage/abnormalTeam.vue @@ -60,7 +60,7 @@ diff --git a/src/views/match/manage/matchSignup.vue b/src/views/match/manage/matchSignup.vue index 4159fef..760b7a5 100644 --- a/src/views/match/manage/matchSignup.vue +++ b/src/views/match/manage/matchSignup.vue @@ -1,331 +1,181 @@