From 5faaded9766f5cafd1634bf936cfd6c60262d926 Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Tue, 28 May 2024 10:59:42 +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/api/index.js | 1 + src/libs/util.js | 402 ++++++++++++------------ src/pages/match/add/step3.vue | 35 ++- src/pages/match/manage/abnormalTeam.vue | 2 +- src/pages/match/manage/matchSignup.vue | 113 +++++-- 5 files changed, 305 insertions(+), 248 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index a3850ed..39339bc 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -176,6 +176,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/libs/util.js b/src/libs/util.js index 3ddbe9b..42f5be1 100644 --- a/src/libs/util.js +++ b/src/libs/util.js @@ -16,210 +16,210 @@ const exts = { compress: 'zip,rar,7z,tar,gz,bz2', } const util = { - cookies, - local: _local, - session: _session, - // 传入身份证获取生日 - 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-"); - //通过正则表达式来指定输出格式为:1990-01-01 - } - return birthday; - }, - // new Date('2020-11-12 00:00:00') 在IE下失效,因此把-替换成/ - dateCompatible(date) { - return date.replace(/\-/g, "/"); - }, - // 日期时间前面补零 - formateTime(num) { - return num < 10 ? `0${num}` : num; - }, - //返回格式化时间,传参例如:"yyyy-MM-dd hh:mm:ss" - 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)); - } - 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; - }, - // 移除数组中指定值 - removeByValue(arr, val) { - for (var i = 0; i < arr.length; i++) { - if (arr[i] == val) { - arr.splice(i, 1); - break; - } - } - }, - // 传入文件后缀判断是否是视频 - isVideo(ext) { - if (exts.video.includes(ext)) return true; - return false; - }, - // 传入文件后缀判断是否是音频 - isAudio(ext) { - if (exts.audio.includes(ext)) return true; - return false; - }, - // 传入文件后缀判断是否是图片 - isImg(ext) { - if (exts.img.includes(ext)) return true; - return false; - }, - // 传入文件后缀判断是否是pdf以外的文档 - isDoc(ext) { - if (exts.doc.includes(ext)) return true; - return false; - }, - // 传入文件后缀判断是否是压缩包 - isCompress(ext) { - if (exts.compress.includes(ext)) return true; - return false; - }, - // 判断是否能够预览 - canPreview(ext) { - if (!util.isVideo(ext) && !util.isAudio(ext) && !util.isImg(ext) && !util.isDoc(ext)) return false - return true - }, - // 循环去除html标签 - removeHtmlTag(list, attr) { - list.map(n => { - n[attr] = n[attr].replace(/<\/?.+?>/gi, ""); - }); - return list; - }, - // 传入文件名获取文件后缀 - getFileExt(fileName) { - return fileName.substring(fileName.lastIndexOf(".") + 1); - }, - // 传入文件名和路径,下载图片视频,支持跨域,a标签加download不支持跨域 - 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.send(); - }, - // 传入文件名和数据,下载文件 - 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); - } - }, - // 传入字符串,返回去除[]后的字符串,因为通过get请求带入方括号的话会有问题 - encodeStr(str) { - if (str.includes("[") || str.includes("]")) { - let newStr = ""; - for (let i of str) { - if (i == "[" || i == "]") { - newStr += encodeURI(i); - } else { - newStr += i; - } - } - return newStr; - } - return str; - }, - // 成功提示 - successMsg(message, duration = 3000) { - Message.closeAll(); - return Message.success({ message, showClose: true, offset: (document.documentElement.clientHeight - 40) / 2, duration }); - }, - // 警告提示 - warningMsg(message, duration = 3000) { - Message.closeAll(); - return Message.warning({ message, showClose: true, offset: (document.documentElement.clientHeight - 40) / 2, duration }); - }, - // 错误提示 - errorMsg(message, duration = 3000) { - Message.closeAll(); - return Message.error({ message, showClose: true, offset: (document.documentElement.clientHeight - 40) / 2, duration }); - }, - debounce(fn, delay) { // 防抖 - let timeout = null; - return function() { - const context = this; - const args = arguments; - clearTimeout(timeout); - timeout = setTimeout(() => { - fn.apply(context, args); - }, delay); - }; - }, - 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 - ); - }); + cookies, + local: _local, + session: _session, + // 传入身份证获取生日 + 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-"); + //通过正则表达式来指定输出格式为:1990-01-01 + } + return birthday; + }, + // new Date('2020-11-12 00:00:00') 在IE下失效,因此把-替换成/ + dateCompatible (date) { + return date.replace(/\-/g, "/"); + }, + // 日期时间前面补零 + formateTime (num) { + return num < 10 ? `0${num}` : num; + }, + //返回格式化时间,传参例如:"yyyy-MM-dd hh:mm:ss" + 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)); + } + 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; + }, + // 移除数组中指定值 + removeByValue (arr, val) { + for (var i = 0; i < arr.length; i++) { + if (arr[i] == val) { + arr.splice(i, 1); + break; + } + } + }, + // 传入文件后缀判断是否是视频 + isVideo (ext) { + if (exts.video.includes(ext)) return true; + return false; + }, + // 传入文件后缀判断是否是音频 + isAudio (ext) { + if (exts.audio.includes(ext)) return true; + return false; + }, + // 传入文件后缀判断是否是图片 + isImg (ext) { + if (exts.img.includes(ext)) return true; + return false; + }, + // 传入文件后缀判断是否是pdf以外的文档 + isDoc (ext) { + if (exts.doc.includes(ext)) return true; + return false; + }, + // 传入文件后缀判断是否是压缩包 + isCompress (ext) { + if (exts.compress.includes(ext)) return true; + return false; + }, + // 判断是否能够预览 + canPreview (ext) { + if (!util.isVideo(ext) && !util.isAudio(ext) && !util.isImg(ext) && !util.isDoc(ext)) return false + return true + }, + // 循环去除html标签 + removeHtmlTag (list, attr) { + list.map(n => { + n[attr] = n[attr].replace(/<\/?.+?>/gi, ""); + }); + return list; + }, + // 传入文件名获取文件后缀 + getFileExt (fileName) { + return fileName.substring(fileName.lastIndexOf(".") + 1); + }, + // 传入文件名和路径,下载图片视频,支持跨域,a标签加download不支持跨域 + 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.send(); + }, + // 传入文件名和数据,下载文件 + 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); + } + }, + // 传入字符串,返回去除[]后的字符串,因为通过get请求带入方括号的话会有问题 + encodeStr (str) { + if (str.includes("[") || str.includes("]")) { + let newStr = ""; + for (let i of str) { + if (i == "[" || i == "]") { + newStr += encodeURI(i); } else { - result = {}; - Object.keys(obj).forEach(key => { - result[key] = - typeof obj[key] === "object" && !(obj[key] instanceof Date) - ? util.deepCopy(obj[key]) - : obj[key]; - }); + newStr += i; + } + } + return newStr; + } + return str; + }, + // 成功提示 + successMsg (message, duration = 3000) { + Message.closeAll(); + return Message.success({ message, showClose: true, offset: (document.documentElement.clientHeight - 40) / 2, duration }); + }, + // 警告提示 + warningMsg (message, duration = 3000) { + Message.closeAll(); + return Message.warning({ message, showClose: true, offset: (document.documentElement.clientHeight - 40) / 2, duration }); + }, + // 错误提示 + errorMsg (message, duration = 3000) { + Message.closeAll(); + return Message.error({ message, showClose: true, offset: (document.documentElement.clientHeight - 40) / 2, duration }); + }, + debounce (fn, delay) { // 防抖 + let timeout = null; + return function () { + const context = this; + const args = arguments; + clearTimeout(timeout); + timeout = setTimeout(() => { + fn.apply(context, args); + }, delay); + }; + }, + 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; + }, + // 获取当前时间 + getNow () { + return new Promise(async (resolve, reject) => { + const { data } = await axios.get(Setting.apiBaseURL + api.getCurrentTime, { + headers: { + token: _local.get(Setting.tokenKey) } - return result; - }, - // 获取当前时间 - getNow () { - return new Promise(async (resolve, reject) => { - const { data } = await axios.get(Setting.apiBaseURL + api.getCurrentTime, { - headers: { - token: _local.get(Setting.tokenKey) - } - }) - resolve(new Date(data.currentTime)) }) - }, + resolve(new Date(data.currentTime)) + }) + }, }; export default util; \ No newline at end of file diff --git a/src/pages/match/add/step3.vue b/src/pages/match/add/step3.vue index 2d9d79d..bbc37f7 100644 --- a/src/pages/match/add/step3.vue +++ b/src/pages/match/add/step3.vue @@ -310,29 +310,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/pages/match/manage/abnormalTeam.vue b/src/pages/match/manage/abnormalTeam.vue index f331dbb..de1875e 100644 --- a/src/pages/match/manage/abnormalTeam.vue +++ b/src/pages/match/manage/abnormalTeam.vue @@ -59,7 +59,7 @@异常
+