diff --git a/src/libs/util.js b/src/libs/util.js index f51044f..20412b1 100644 --- a/src/libs/util.js +++ b/src/libs/util.js @@ -7,12 +7,13 @@ import api from "@/api"; import Setting from "@/setting"; let logout = false; -const roleList = { - "1": "超级管理员", - "13": "管理员", - "14": "老师", - "4": "学生" -}; +// 文件后缀集合 +const exts = { + video: 'mp4,3gp,mov,m4v,avi,dat,mkv,flv,vob,rmvb,rm,qlv', + audio: 'mp3,aac,ape,flac,wav,wma,amr,mid', + img: 'jpg,jpeg,png,gif,svg,psd', + doc: 'doc,docx,txt,xls,xlsx,csv,xml,ppt,pptx' +} const util = { cookies, local: _local, @@ -72,24 +73,29 @@ const util = { }, // 传入文件后缀判断是否是视频 isVideo(ext) { - if ("mp4,3gp,mov,m4v,avi,dat,mkv,flv,vob,rmvb,rm,qlv".includes(ext)) return true; + if (exts.video.includes(ext)) return true; return false; }, // 传入文件后缀判断是否是音频 isAudio(ext) { - if ("mp3,aac,ape,flac,wav,wma,amr,mid".includes(ext)) return true; + if (exts.audio.includes(ext)) return true; return false; }, // 传入文件后缀判断是否是图片 isImg(ext) { - if ("jpg,jpeg,png,gif,svg,psd".includes(ext)) return true; + if (exts.img.includes(ext)) return true; return false; }, // 传入文件后缀判断是否是pdf以外的文档 isDoc(ext) { - if (!util.isVideo(ext) && !util.isAudio(ext) && !util.isImg(ext) && ext != "pdf") return true; + if (exts.doc.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 => { @@ -160,10 +166,6 @@ const util = { Message.closeAll(); return Message.error({ message, showClose: true, offset: (document.documentElement.clientHeight - 40) / 2, duration }); }, - // 传入roleId,返回角色名称 - getRoleName(roleId) { - return roleList[roleId] || "未知状态"; - }, // 登录互踢 getToken() { if (process.env.NODE_ENV != "production") { diff --git a/src/pages/match/add/index.vue b/src/pages/match/add/index.vue index 34c3349..f9b39c0 100644 --- a/src/pages/match/add/index.vue +++ b/src/pages/match/add/index.vue @@ -1,11 +1,12 @@ - + - + + 点击上传 @@ -132,19 +134,20 @@ - 保存 + 保存 发布 预览 - + + @@ -152,27 +155,6 @@ 确 定 - - - - - {{ form.name }} - 最近编辑时间:{{ form.updateTime }} - - - 竞赛信息 - - - 附件下载 - - - {{ item.fileName }} - 下载 - - - - - @@ -189,9 +171,8 @@ export default { headers: { token: util.local.get(Setting.tokenKey) }, - fileName: '', form: { - id: '', + id: this.$route.query.id, platformSource: 1, // 平台来源(0:中台,1:职站) isOpen: 0, // 职站是否开启(0开启 1未开启 默认0) name: '', @@ -209,19 +190,21 @@ export default { playEndTime: '', description: '', }, + fileName: '', signupTime: '', playTime: '', sponsorList: [""], undertakerList: [""], + fileList: [], pickerOptions: { disabledDate: time => { return time.getTime() < new Date().getTime() - 86400000; } }, - provinceList: this.$store.state.provinceList, rangeVisible: false, + casVisible: true, range: [], - ranges: [], + rangeInit: [], rangeName: '', // 选择区域懒加载 props: { @@ -231,6 +214,7 @@ export default { lazyLoad (node, resolve) { const { level, value } = node // 省份 + console.log('lazy', node, that.range) if (!level) { that.$get(that.api.queryProvince).then(({ list }) => { const data = [] @@ -281,7 +265,6 @@ export default { }, submiting: false, updateTime: 0, - previewVisible: false }; }, components: { @@ -317,9 +300,57 @@ export default { } }, mounted() { - + this.getData() }, methods: { + getData() { + const { id } = this.form + id && this.$post(`${this.api.getContest}?contestId=${id}`).then(({ contest }) => { + this.signupTime = [contest.signUpStartTime, contest.signUpEndTime] + this.playTime = [contest.playStartTime, contest.playEndTime] + this.sponsorList = contest.sponsor.split(",") + this.undertakerList = contest.undertaker.split(",") + // 附件 + const fileList = contest.contestAnnexList + if (fileList) { + const files = [] + fileList.map(e => { + files.push({ + name: e.fileName, + url: e.filePath + }) + }) + this.fileList = files + } else { + contest.contestAnnexList = [] + } + + // 选择范围 + const ranges = contest.contestRangeList + if (ranges) { + const range = [] + ranges.map(e => { + const item = [+e.provinceId] + e.cityId && item.push(+e.cityId) + e.schoolId && item.push(+e.schoolId) + range.push(item) + }) + this.range = range + console.log("🚀 ~ file: matchDetail.vue ~ line 327 ~ this.$post ~ this.range", this.range) + } + + // 选择范围name + const rangeName = contest.contestRangeRespList + if (rangeName) { + const range = [] + rangeName.map(e => { + range.push(e.type ? (e.cityName || e.provinceName) : e.schoolName) + }) + this.rangeName = range.join(',') + } + this.form = contest + }).catch(err => {}) + }, // 选择范围 showRange() { this.rangeVisible = true @@ -404,11 +435,10 @@ export default { }).catch(res => {}) }, handleAnnexRemove(file, fileList) { - file.url && this.$del(`${this.api.fileDeletion}?keys=${file.url}`).then(res => {}).catch(res => {}) - }, - // 预览 - preview() { - this.previewVisible = true + const { url, name } = file + url && this.$del(`${this.api.fileDeletion}?keys=${url}`).then(res => {}).catch(res => {}) + const id = this.form.contestAnnexList.find(e => e.fileName === name).id + id && this.$post(`${this.api.deleteAnnex}?id=${id}`).then(res => {}).catch(res => {}) }, // 预览附件 previewFile(item) { @@ -421,7 +451,7 @@ export default { util.downloadFile(item.fileName, item.filePath) }, // 提交 - save(status) { + save(status, frame) { if (this.submiting) return false; const { form } = this form.sponsor = this.sponsorList.filter(d => d).join(); @@ -443,12 +473,13 @@ export default { this.submiting = true form.publishStatus = status - form.isOpen = status ? 0 : 1 // 保存则禁用,发布则启用 + form.ztOpen = status ? 0 : 1 // 保存则禁用,发布则启用 if (this.form.id) { - this.$put(this.api.editContest, form).then(res => { + this.$post(this.api.editContest, form).then(res => { + this.updateTime = 1 this.submiting = false; util.successMsg("修改成功"); - this.$router.back(); + frame || this.$router.push(`/match?page=${this.$store.state.matchPage}`) // frame为1则表示是父页面调的,不作返回操作 }) .catch(err => { this.submiting = false; @@ -457,17 +488,23 @@ export default { this.$post(this.api.addContest, form).then(res => { this.submiting = false; util.successMsg("创建成功"); - this.$router.back(); + frame || this.$router.push(`/match?page=${this.$store.state.matchPage}`) // frame为1则表示是父页面调的,不作返回操作 }) .catch(err => { this.submiting = false; }); } }, + // 预览 + preview() { + util.local.set('match', this.form) + window.open(this.$router.resolve('preview').href) + }, back() { const updateTime = this.updateTime + const { id } = this.form // 更改了信息才需要提示 - if (updateTime) { + if ((id && updateTime > 1) || (!id && updateTime)) { this.$confirm(`编辑的内容未保存,是否保存?`, '提示', { type: 'warning' }).then(() => { @@ -630,7 +667,29 @@ $upload-lg-height: 150px; font-weight: bold; } } +/deep/.preview-dia { + .el-dialog__body { + padding: 0 0 20px; + background-color: #F3F6FA; + } +} .match { + .banner{ + width: 100%; + height: 350px; + color: #fff; + background-size: 100% 350px; + background-repeat: no-repeat; + box-sizing: border-box; + } + .match-inner { + width: 1000px; + min-height: calc(100vh - 465px); + padding: 30px 40px 20px; + margin: 40px auto 0; + background-color: #fff; + box-sizing: border-box; + } .l-title{ display: flex; align-items: center; diff --git a/src/pages/match/manage/index.vue b/src/pages/match/manage/index.vue index be5e5a3..43ef596 100644 --- a/src/pages/match/manage/index.vue +++ b/src/pages/match/manage/index.vue @@ -24,7 +24,7 @@ - - \ No newline at end of file diff --git a/src/pages/match/preview/index.vue b/src/pages/match/preview/index.vue new file mode 100644 index 0000000..a1dd067 --- /dev/null +++ b/src/pages/match/preview/index.vue @@ -0,0 +1,127 @@ + + + + + + {{ form.name }} + 最近编辑时间:{{ form.updateTime }} + + + 竞赛信息 + + + 附件下载 + + + {{ item.fileName }} + {{ item.fileName }} + 下载 + + + + + + + + + + \ No newline at end of file diff --git a/src/router/index.js b/src/router/index.js index 8e6c47c..97f3b80 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -245,12 +245,15 @@ function getPermission() { } const notice = permissionRouters.findIndex(e => e.name === 'match') if (notice !== -1) { - permissionRouters[notice].children.push({ - name: `noticeDetail`, - path: `/match/noticeDetail`, - component: () => import("@/pages/match/manage/noticeDetail"), - meta: { title: "通知公告" } - }) + const match = [ + { + name: `noticeDetail`, + path: `/match/noticeDetail`, + component: () => import("@/pages/match/manage/noticeDetail"), + meta: { title: "通知公告" } + } + ] + permissionRouters[notice].children.push(...match) } // 把处理完成的路由,add到router里 // 记录一下路由的名称,用于nav diff --git a/src/router/routes.js b/src/router/routes.js index e484fa7..583e096 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -49,6 +49,12 @@ const frameOut = [ path: "/redirect", name: "redirect", component: () => import("@/pages/account/redirect") + }, + { + name: `matchPreview`, + path: `/match/preview`, + component: () => import("@/pages/match/preview"), + meta: { title: "赛事预览" } } ]; diff --git a/src/setting.js b/src/setting.js index bd19c57..962ae4c 100644 --- a/src/setting.js +++ b/src/setting.js @@ -23,7 +23,7 @@ if (isPro) { jumpPath = "http://192.168.31.125:8087/"; bankPath = `http://192.168.31.125:8093` host = "http://121.37.12.51/"; // 中台测试服 - // host = "http://192.168.31.151:9000/"; // 榕 + host = "http://192.168.31.151:9000/"; // 榕 // host = 'http://192.168.31.137:9000/'; // 赓 }