赛事修复

dev_2022-06-14
yujialong 2 years ago
parent bd2985541b
commit 12b3c6e314
  1. 30
      src/libs/util.js
  2. 145
      src/pages/match/add/index.vue
  3. 4
      src/pages/match/manage/index.vue
  4. 665
      src/pages/match/manage/matchDetail.vue
  5. 127
      src/pages/match/preview/index.vue
  6. 7
      src/router/index.js
  7. 6
      src/router/routes.js
  8. 2
      src/setting.js

@ -7,12 +7,13 @@ import api from "@/api";
import Setting from "@/setting"; import Setting from "@/setting";
let logout = false; let logout = false;
const roleList = { // 文件后缀集合
"1": "超级管理员", const exts = {
"13": "管理员", video: 'mp4,3gp,mov,m4v,avi,dat,mkv,flv,vob,rmvb,rm,qlv',
"14": "老师", audio: 'mp3,aac,ape,flac,wav,wma,amr,mid',
"4": "学生" img: 'jpg,jpeg,png,gif,svg,psd',
}; doc: 'doc,docx,txt,xls,xlsx,csv,xml,ppt,pptx'
}
const util = { const util = {
cookies, cookies,
local: _local, local: _local,
@ -72,24 +73,29 @@ const util = {
}, },
// 传入文件后缀判断是否是视频 // 传入文件后缀判断是否是视频
isVideo(ext) { 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; return false;
}, },
// 传入文件后缀判断是否是音频 // 传入文件后缀判断是否是音频
isAudio(ext) { isAudio(ext) {
if ("mp3,aac,ape,flac,wav,wma,amr,mid".includes(ext)) return true; if (exts.audio.includes(ext)) return true;
return false; return false;
}, },
// 传入文件后缀判断是否是图片 // 传入文件后缀判断是否是图片
isImg(ext) { isImg(ext) {
if ("jpg,jpeg,png,gif,svg,psd".includes(ext)) return true; if (exts.img.includes(ext)) return true;
return false; return false;
}, },
// 传入文件后缀判断是否是pdf以外的文档 // 传入文件后缀判断是否是pdf以外的文档
isDoc(ext) { 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; return false;
}, },
// 判断是否能够预览
canPreview(ext) {
if (!util.isVideo(ext) && !util.isAudio(ext) && !util.isImg(ext) && !util.isDoc(ext)) return false
return true
},
// 循环去除html标签 // 循环去除html标签
removeHtmlTag(list, attr) { removeHtmlTag(list, attr) {
list.map(n => { list.map(n => {
@ -160,10 +166,6 @@ const util = {
Message.closeAll(); Message.closeAll();
return Message.error({ message, showClose: true, offset: (document.documentElement.clientHeight - 40) / 2, duration }); return Message.error({ message, showClose: true, offset: (document.documentElement.clientHeight - 40) / 2, duration });
}, },
// 传入roleId,返回角色名称
getRoleName(roleId) {
return roleList[roleId] || "未知状态";
},
// 登录互踢 // 登录互踢
getToken() { getToken() {
if (process.env.NODE_ENV != "production") { if (process.env.NODE_ENV != "production") {

@ -1,11 +1,12 @@
<template> <template>
<div> <div>
<el-card shadow="hover" class="m-b-20"> <el-card v-if="!form.id" shadow="hover" class="m-b-20">
<div class="flex-between"> <div class="flex-between">
<el-page-header @back="back" :content="'创建赛事'"></el-page-header> <el-page-header @back="back" :content="'创建赛事'"></el-page-header>
</div> </div>
</el-card> </el-card>
<el-card shadow="hover" class="m-b-20"> <div class="page">
<div class="page-content">
<el-form label-width="170px" label-suffix=":" size="small"> <el-form label-width="170px" label-suffix=":" size="small">
<el-form-item label="竞赛封面(选填)"> <el-form-item label="竞赛封面(选填)">
<el-upload <el-upload
@ -123,6 +124,7 @@
:on-exceed="handleExceedAnnex" :on-exceed="handleExceedAnnex"
:action="this.api.fileupload" :action="this.api.fileupload"
:headers="headers" :headers="headers"
:file-list="fileList"
name="file" name="file"
> >
<el-button size="small" type="primary">点击上传</el-button> <el-button size="small" type="primary">点击上传</el-button>
@ -132,19 +134,20 @@
</el-upload> </el-upload>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button @click="save(0)">保存</el-button> <el-button v-if="!form.id" @click="save(0)">保存</el-button>
<el-button type="primary" @click="save(1)">发布</el-button> <el-button type="primary" @click="save(1)">发布</el-button>
<el-button type="danger" @click="preview">预览</el-button> <el-button type="danger" @click="preview">预览</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-card> </div>
</div>
<el-dialog title="请勾选院校" :visible.sync="rangeVisible" width="580px" custom-class="range-dia" :close-on-click-modal="false"> <el-dialog title="请勾选院校" :visible.sync="rangeVisible" width="580px" custom-class="range-dia" :close-on-click-modal="false">
<el-cascader <el-cascader
ref="range" ref="range"
v-model="range" v-model="range"
:options="ranges"
:props="props" :props="props"
:show-all-levels="false"
clearable clearable
filterable></el-cascader> filterable></el-cascader>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
@ -152,27 +155,6 @@
<el-button size="small" type="primary" @click="rangeSubmit"> </el-button> <el-button size="small" type="primary" @click="rangeSubmit"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
<el-dialog title="预览" :visible.sync="previewVisible" width="1080px" custom-class="preview-dia" :close-on-click-modal="false">
<div class="match">
<div class="info">
<h6 class="title">{{ form.name }}</h6>
<div class="meta">最近编辑时间{{ form.updateTime }}</div>
</div>
<div class="l-title" id="part1"><img src="@/assets/img/label.png" alt=""> 竞赛信息</div>
<div v-if="form.description" class="texts ql-editor" v-html="form.description"></div>
<template v-if="form.contestAnnexList">
<h6 class="p-title">附件下载</h6>
<ul class="files">
<li v-for="(item, i) in form.contestAnnexList" :key="i">
<el-link class="file-name" type="primary" @click="previewFile(item)">{{ item.fileName }}</el-link>
<el-link type="primary" :underline="false" @click="download(item)">下载</el-link>
</li>
</ul>
</template>
</div>
</el-dialog>
</div> </div>
</template> </template>
@ -189,9 +171,8 @@ export default {
headers: { headers: {
token: util.local.get(Setting.tokenKey) token: util.local.get(Setting.tokenKey)
}, },
fileName: '',
form: { form: {
id: '', id: this.$route.query.id,
platformSource: 1, // (0:1) platformSource: 1, // (0:1)
isOpen: 0, // (0 1 0) isOpen: 0, // (0 1 0)
name: '', name: '',
@ -209,19 +190,21 @@ export default {
playEndTime: '', playEndTime: '',
description: '', description: '',
}, },
fileName: '',
signupTime: '', signupTime: '',
playTime: '', playTime: '',
sponsorList: [""], sponsorList: [""],
undertakerList: [""], undertakerList: [""],
fileList: [],
pickerOptions: { pickerOptions: {
disabledDate: time => { disabledDate: time => {
return time.getTime() < new Date().getTime() - 86400000; return time.getTime() < new Date().getTime() - 86400000;
} }
}, },
provinceList: this.$store.state.provinceList,
rangeVisible: false, rangeVisible: false,
casVisible: true,
range: [], range: [],
ranges: [], rangeInit: [],
rangeName: '', rangeName: '',
// //
props: { props: {
@ -231,6 +214,7 @@ export default {
lazyLoad (node, resolve) { lazyLoad (node, resolve) {
const { level, value } = node const { level, value } = node
// //
console.log('lazy', node, that.range)
if (!level) { if (!level) {
that.$get(that.api.queryProvince).then(({ list }) => { that.$get(that.api.queryProvince).then(({ list }) => {
const data = [] const data = []
@ -281,7 +265,6 @@ export default {
}, },
submiting: false, submiting: false,
updateTime: 0, updateTime: 0,
previewVisible: false
}; };
}, },
components: { components: {
@ -317,9 +300,57 @@ export default {
} }
}, },
mounted() { mounted() {
this.getData()
}, },
methods: { 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() { showRange() {
this.rangeVisible = true this.rangeVisible = true
@ -404,11 +435,10 @@ export default {
}).catch(res => {}) }).catch(res => {})
}, },
handleAnnexRemove(file, fileList) { handleAnnexRemove(file, fileList) {
file.url && this.$del(`${this.api.fileDeletion}?keys=${file.url}`).then(res => {}).catch(res => {}) 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
preview() { id && this.$post(`${this.api.deleteAnnex}?id=${id}`).then(res => {}).catch(res => {})
this.previewVisible = true
}, },
// //
previewFile(item) { previewFile(item) {
@ -421,7 +451,7 @@ export default {
util.downloadFile(item.fileName, item.filePath) util.downloadFile(item.fileName, item.filePath)
}, },
// //
save(status) { save(status, frame) {
if (this.submiting) return false; if (this.submiting) return false;
const { form } = this const { form } = this
form.sponsor = this.sponsorList.filter(d => d).join(); form.sponsor = this.sponsorList.filter(d => d).join();
@ -443,12 +473,13 @@ export default {
this.submiting = true this.submiting = true
form.publishStatus = status form.publishStatus = status
form.isOpen = status ? 0 : 1 // form.ztOpen = status ? 0 : 1 //
if (this.form.id) { 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; this.submiting = false;
util.successMsg("修改成功"); util.successMsg("修改成功");
this.$router.back(); frame || this.$router.push(`/match?page=${this.$store.state.matchPage}`) // frame1
}) })
.catch(err => { .catch(err => {
this.submiting = false; this.submiting = false;
@ -457,17 +488,23 @@ export default {
this.$post(this.api.addContest, form).then(res => { this.$post(this.api.addContest, form).then(res => {
this.submiting = false; this.submiting = false;
util.successMsg("创建成功"); util.successMsg("创建成功");
this.$router.back(); frame || this.$router.push(`/match?page=${this.$store.state.matchPage}`) // frame1
}) })
.catch(err => { .catch(err => {
this.submiting = false; this.submiting = false;
}); });
} }
}, },
//
preview() {
util.local.set('match', this.form)
window.open(this.$router.resolve('preview').href)
},
back() { back() {
const updateTime = this.updateTime const updateTime = this.updateTime
const { id } = this.form
// //
if (updateTime) { if ((id && updateTime > 1) || (!id && updateTime)) {
this.$confirm(`编辑的内容未保存,是否保存?`, '提示', { this.$confirm(`编辑的内容未保存,是否保存?`, '提示', {
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
@ -630,7 +667,29 @@ $upload-lg-height: 150px;
font-weight: bold; font-weight: bold;
} }
} }
/deep/.preview-dia {
.el-dialog__body {
padding: 0 0 20px;
background-color: #F3F6FA;
}
}
.match { .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{ .l-title{
display: flex; display: flex;
align-items: center; align-items: center;

@ -24,7 +24,7 @@
</template> </template>
<script> <script>
import MatchDetail from "./matchDetail"; import MatchDetail from "../add";
import MatchProgress from "./matchProgress"; import MatchProgress from "./matchProgress";
import notice from "./notice"; import notice from "./notice";
import MatchSignup from "./matchSignup"; import MatchSignup from "./matchSignup";
@ -67,7 +67,7 @@ export default {
this.$confirm(`编辑的内容未保存,是否保存并且发布?`, '提示', { this.$confirm(`编辑的内容未保存,是否保存并且发布?`, '提示', {
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
detail.save(1) detail.save(1, 1)
this.backOrTab(i) this.backOrTab(i)
}).catch(() => { }).catch(() => {
this.backOrTab(i) this.backOrTab(i)

@ -1,665 +0,0 @@
<template>
<!-- 大赛详情 -->
<div style="padding: 24px">
<div class="page-content">
<el-form label-width="170px" label-suffix=":" size="small">
<el-form-item label="竞赛封面(选填)">
<el-upload
class="avatar-uploader"
accept=".jpg,.png,.jpeg,.gif"
:on-remove="handleRemove"
:on-error="uploadError"
:on-success="uploadSuccess"
:before-remove="beforeRemove"
:limit="1"
:on-exceed="handleExceed"
:action="this.api.fileupload"
:headers="headers"
name="file"
>
<img v-if="form.coverUrl" :src="form.coverUrl" class="avatar">
<div class="uploader-default" v-else>
<i class="el-icon-plus"></i>
<p>上传封面</p>
</div>
<div slot="tip" class="el-upload__tip">
<p>展示宽度为220高度140JPG/PNG/GIF3MB以内</p>
</div>
</el-upload>
</el-form-item>
<el-form-item label="竞赛封面长图(选填)">
<el-upload
class="avatar-uploader avatar-uploader-lg"
accept=".jpg,.png,.jpeg,.gif"
:on-remove="handleLgRemove"
:on-error="uploadError"
:on-success="uploadLgSuccess"
:before-remove="beforeRemove"
:limit="1"
:on-exceed="handleExceed"
:action="this.api.fileupload"
:headers="headers"
name="file"
>
<img v-if="form.carouselUrl" :src="form.carouselUrl" class="avatar-lg">
<div class="uploader-default" v-else>
<i class="el-icon-plus"></i>
<p>上传封面</p>
</div>
<div slot="tip" class="el-upload__tip">
<p>展示宽度为1920高度300JPG/PNG/GIF3MB以内</p>
</div>
</el-upload>
</el-form-item>
<el-form-item label="比赛范围">
<div>
<el-radio v-model="form.competitionScope" :label="0">本校内</el-radio>
</div>
<div>
<el-radio v-model="form.competitionScope" :label="1">全平台</el-radio>
</div>
<div>
<el-radio v-model="form.competitionScope" :label="2">指定区域院校</el-radio>
<el-button v-if="form.competitionScope === 2" type="primary" size="mini" @click="showRange">选择院校</el-button>
<span style="margin-left: 20px">{{ rangeName }}</span>
</div>
</el-form-item>
<el-form-item label="竞赛名称">
<div class="d-inline-block">
<el-input placeholder="请输入竞赛名称" v-model="form.name" clearable></el-input>
</div>
</el-form-item>
<el-form-item label="主办方">
<div class="inline-input">
<div class="input-wrap" v-for="(item,index) in sponsorList" :key="index">
<el-input placeholder="主办方名称" v-model="sponsorList[index]"></el-input>
<i v-if="sponsorList.length > 1" class="remove" @click="delSponsor(index)"></i>
<button v-if="index == 0" class="add-btn" @click="addSponsor">
<i class="el-icon-plus"></i>
<span>添加</span>
</button>
</div>
</div>
</el-form-item>
<el-form-item label="承办方(选填)">
<div class="inline-input">
<div class="input-wrap" v-for="(item,index) in undertakerList" :key="index">
<el-input placeholder="承办方名称" v-model="undertakerList[index]"></el-input>
<i v-if="undertakerList.length > 1" class="remove" @click="delOrganizer(index)"></i>
<button v-if="index == 0" class="add-btn" @click="addOrganizer">
<i class="el-icon-plus"></i>
<span>添加</span>
</button>
</div>
</div>
<button v-if="!undertakerList.length" class="add-btn" @click="addOrganizer">
<i class="el-icon-plus"></i>
<span>添加</span>
</button>
</el-form-item>
<el-form-item label="报名时间">
<el-date-picker v-model="signupTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetimerange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
</el-form-item>
<el-form-item label="竞赛时间">
<el-date-picker v-model="playTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetimerange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
</el-form-item>
<el-form-item label="竞赛详情">
<quill :border="true" v-model="form.description" :height="400" />
</el-form-item>
<el-form-item label="附件">
<el-upload
:on-remove="handleAnnexRemove"
:on-error="uploadError"
:before-upload="beforeUpload"
:on-success="uploadAnnexSuccess"
:limit="5"
:on-exceed="handleExceedAnnex"
:action="this.api.fileupload"
:headers="headers"
:file-list="fileList"
name="file"
>
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">
<p>支持扩展名.rar .zip .doc .docx .pdf .jpg...</p>
</div>
</el-upload>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="save(1)">发布</el-button>
<el-button @click="$router.back()">取消</el-button>
</el-form-item>
</el-form>
</div>
<el-dialog title="请勾选院校" :visible.sync="rangeVisible" width="580px" custom-class="range-dia" :close-on-click-modal="false">
<el-cascader
ref="range"
v-model="range"
:options="ranges"
:props="props"
clearable
filterable></el-cascader>
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="rangeVisible = false"> </el-button>
<el-button size="small" type="primary" @click="rangeSubmit"> </el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import util from "@/libs/util";
import quill from "@/components/quill";
import Setting from "@/setting";
export default {
name: "add",
data() {
const that = this
return {
headers: {
token: util.local.get(Setting.tokenKey)
},
form: {
id: this.$route.query.id,
platformSource: 1, // (0:1)
isOpen: 0, // (0 1 0)
name: '',
sponsor: '',
undertaker: '',
competitionScope: 0, // (0: 1: 2:)
contestRangeList: [], //
contestAnnexList: [], //
fileName: '',
coverUrl: '',
carouselUrl: '',
publishStatus: 0,
signUpStartTime: '',
signUpEndTime: '',
playStartTime: '',
playEndTime: '',
description: '',
},
signupTime: '',
playTime: '',
sponsorList: [""],
undertakerList: [""],
fileList: [],
pickerOptions: {
disabledDate: time => {
return time.getTime() < new Date().getTime() - 86400000;
}
},
provinceList: this.$store.state.provinceList,
rangeVisible: false,
range: [],
ranges: [],
rangeName: '',
//
props: {
multiple: true,
checkStrictly: true,
lazy: true,
lazyLoad (node, resolve) {
const { level, value } = node
//
console.log('lazy', node)
if (!level) {
that.$get(that.api.queryProvince).then(({ list }) => {
const data = []
list.map(e => {
data.push({
value: e.provinceId,
label: e.provinceName
})
})
resolve(data)
}).catch(res => {})
} else if (level === 1) {
//
that.$get(that.api.queryCity, {
provinceId: value
}).then(({ list }) => {
const data = []
list.map(e => {
data.push({
provinceId: value,
value: e.cityId,
label: e.cityName
})
})
resolve(data)
}).catch(res => {})
} else if (level === 2) {
//
that.$get(that.api.getSchoolsByProvince, {
provinceId: node.data.provinceId,
cityId: value,
schoolName: ''
}).then(({ list }) => {
const data = []
list.map(e => {
data.push({
value: e.schoolId,
label: e.schoolName,
leaf: true
})
})
resolve(data)
}).catch(res => {})
} else {
resolve([])
}
}
},
submiting: false,
updateTime: 0
};
},
components: {
quill
},
watch: {
// ,
form: {
handler(){
this.updateTime++
},
deep:true
},
signupTime: function(val) {
const { form } = this
if (val) {
form.signUpStartTime = val[0];
form.signUpEndTime = val[1];
} else {
form.signUpStartTime = ''
form.signUpEndTime = ''
}
},
playTime: function(val) {
const { form } = this
if (val) {
form.playStartTime = val[0]
form.playEndTime = val[1]
} else {
form.playStartTime = ''
form.playEndTime = ''
}
}
},
mounted() {
this.getData()
},
methods: {
getData() {
this.$post(`${this.api.getContest}?contestId=${this.form.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
}
// 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
// name
this.$nextTick(() => {
this.updateTime = 1
// const checked = this.$refs.range.getCheckedNodes()
// console.log(444, contest, checked)
// const name = []
// checked.map(e => {
// name.push(e.label)
// })
// this.rangeName = name.join('')
})
}).catch(err => {})
},
//
showRange() {
this.rangeVisible = true
console.log(33, this.form.contestRangeList)
},
//
rangeSubmit() {
// id
const data = []
this.range.map(e => {
data.push({
contestId: this.form.id || '',
provinceId: e[0] || '',
cityId: e[1] || '',
schoolId: e[2] || '',
type: e.length > 2 ? 0 : 1
})
})
this.form.contestRangeList = data
// name
const checked = this.$refs.range.getCheckedNodes()
const name = []
checked.map(e => {
name.push(e.label)
})
this.rangeName = name.join('、')
this.rangeVisible = false
},
handleExceed(files, fileList) {
util.warningMsg(`当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!`);
},
handleExceedAnnex(files, fileList) {
util.warningMsg(`当前限制选择 5 个文件,如需更换,请删除一个文件再重新选择!`);
},
uploadSuccess(res) {
const { coverUrl } = this.form
coverUrl && this.$del(`${this.api.fileDeletion}?keys=${coverUrl}`).then(res => {}).catch(res => {})
this.form.coverUrl = res.data.filesResult.fileUrl
},
uploadLgSuccess(res) {
const { carouselUrl } = this.form
carouselUrl && this.$del(`${this.api.fileDeletion}?keys=${carouselUrl}`).then(res => {}).catch(res => {})
this.form.carouselUrl = res.data.filesResult.fileUrl
},
//
uploadAnnexSuccess(res) {
const file = res.data.filesResult
const { id } = this.form
const data = {
contestId: id || '',
fileName: this.fileName,
filePath: file.fileUrl
}
this.form.contestAnnexList.push(data)
//
id && this.$post(this.api.saveAnnex, data).then(res => {}).catch(res => {})
console.log(44, this.form)
},
//
beforeUpload(file) {
const isLt2M = file.size / 1024 / 1024 < 10
if (!isLt2M) util.warningMsg('请上传小于10MB的附件!')
if (isLt2M) {
this.fileName = file.name
return true
} else {
return false
}
},
uploadError(err, file, fileList) {
this.$message({
message: "上传出错,请重试!",
type: "error",
center: true
})
},
beforeRemove(file, fileList) {
return this.$confirm(`确定移除 ${file.name}`);
},
handleRemove(file, fileList) {
this.$del(`${this.api.fileDeletion}?keys=${this.form.coverUrl}`).then(res => {
this.form.coverUrl = ''
}).catch(res => {})
},
handleLgRemove(file, fileList) {
this.$del(`${this.api.fileDeletion}?keys=${this.form.carouselUrl}`).then(res => {
this.form.carouselUrl = ''
}).catch(res => {})
},
handleAnnexRemove(file, fileList) {
this.$del(`${this.api.fileDeletion}?keys=${file.url}`).then(res => {}).catch(res => {})
const id = this.form.contestAnnexList.find(e => e.fileName === file.name).id
this.$post(`${this.api.deleteAnnex}?id=${id}`).then(res => {}).catch(res => {})
},
//
save(status) {
if (this.submiting) return false;
const { form } = this
form.sponsor = this.sponsorList.filter(d => d).join();
form.undertaker = this.undertakerList.filter(d => d).join();
if (form.competitionScope == 2 && !form.contestRangeList.length) return util.warningMsg('请选择区域、院校')
if (!form.name) return util.warningMsg("请填写竞赛名称");
if (status == 1) {
if (!form.sponsor) return util.warningMsg("请填写主办方");
if (!form.signUpStartTime) return util.warningMsg("请选择报名时间");
}
let now = new Date().getTime();
let signUpStartTime = new Date(form.signUpStartTime).getTime();
let signUpEndTime = new Date(form.signUpEndTime).getTime();
let playStartTime = new Date(form.playStartTime).getTime();
// if (signUpStartTime && now > signUpStartTime) return util.warningMsg("");
if (!form.playStartTime && status == 1) return util.warningMsg("请选择竞赛时间");
if (playStartTime && playStartTime < signUpEndTime) return util.warningMsg("竞赛时间不能早于报名结束时间");
if (!form.description && status == 1) return util.warningMsg("请填写竞赛详情");
this.submiting = true
form.publishStatus = status
form.isOpen = 0 //
if (this.form.id) {
delete form.contestAnnexList
this.$post(this.api.editContest, form).then(res => {
this.updateTime = 1
this.submiting = false;
util.successMsg("修改成功");
this.$router.back();
})
.catch(err => {
this.submiting = false;
});
} else {
this.$post(this.api.addContest, form).then(res => {
this.submiting = false;
util.successMsg("创建成功");
this.$router.back();
})
.catch(err => {
this.submiting = false;
});
}
},
//
preview() {
},
back() {
const updateTime = this.updateTime
//
if (updateTime > 1) {
this.$confirm(`编辑的内容未保存,是否保存?`, '提示', {
type: 'warning'
}).then(() => {
this.save(1)
}).catch(() => {
this.backPage()
})
} else {
this.backPage()
}
},
backPage(){
this.$router.back()
},
addSponsor() {
this.sponsorList.push("");
},
delSponsor(index) {
this.sponsorList.splice(index, 1);
},
addOrganizer() {
this.undertakerList.push("");
},
delOrganizer(index) {
this.undertakerList.splice(index, 1);
}
}
};
</script>
<style scoped lang="scss">
$upload-width: 220px;
$upload-height: 140px;
$upload-lg-height: 150px;
/deep/ .avatar-uploader {
.el-upload {
position: relative;
width: $upload-width;
height: $upload-height;
border: 1px dashed #d9d9d9;
border-radius: 6px;
cursor: pointer;
overflow: hidden;
&:hover {
border-color: #cb221c;
}
.uploader-default {
display: flex;
height: $upload-height;
flex-direction: column;
justify-content: center;
text-align: center;
background: rgba(0, 0, 0, 0.04);
i {
font-size: 20px;
font-weight: bold;
color: #8c939d;
}
p {
margin-top: 10px;
font-size: 14px;
color: rgba(0, 0, 0, 0.65);
line-height: 1;
}
}
}
&.avatar-uploader-lg {
.el-upload {
width: 100%;
max-width: 960px;
height: $upload-lg-height;
.uploader-default {
height: $upload-lg-height;
}
}
}
.avatar {
display: block;
width: $upload-width;
height: $upload-height;
}
.avatar-lg {
display: block;
width: 100%;
height: $upload-lg-height;
}
.el-upload__tip {
margin-top: 0;
p {
font-size: 14px;
color: rgba(0, 0, 0, 0.45);
line-height: 1;
&:first-child {
margin-bottom: 5px;
}
}
}
}
/deep/ .d-inline-block {
width: 216px;
.el-select, .el-input {
width: 100%;
}
}
.inline-input {
.input-wrap {
display: flex;
align-items: center;
margin-bottom: 10px;
.el-input {
display: inline-block;
width: 216px;
margin-right: 8px;
}
.remove {
width: 16px;
height: 16px;
background: url("../../../assets/img/close.png") 0 0/cover no-repeat;
cursor: pointer;
}
}
.add-btn {
margin-left: 32px;
}
}
.add-btn {
display: flex;
justify-content: center;
align-items: center;
width: 216px;
line-height: 32px;
font-size: 14px;
color: rgba(0, 0, 0, 0.65);
background-color: transparent;
border: 1px dashed rgba(0, 0, 0, 0.15);
border-radius: 4px;
cursor: pointer;
i {
margin-right: 8px;
font-size: 14px;
font-weight: bold;
}
}
</style>

@ -0,0 +1,127 @@
<template>
<div class="match">
<div class="banner" :style="{backgroundImage: 'url(' + (form.carouselUrl || 'https://huoran.oss-cn-shenzhen.aliyuncs.com/20220613/png/1536269450851409920.png') + ')'}"></div>
<div class="match-inner">
<div class="info">
<h6 class="title">{{ form.name }}</h6>
<div class="meta">最近编辑时间{{ form.updateTime }}</div>
</div>
<div class="l-title" id="part1"><img src="@/assets/img/label.png" alt=""> 竞赛信息</div>
<div v-if="form.description" class="texts ql-editor" v-html="form.description"></div>
<template v-if="form.contestAnnexList">
<h6 class="p-title">附件下载</h6>
<ul class="files">
<li v-for="(item, i) in form.contestAnnexList" :key="i">
<el-link v-if="item.canPreview" class="m-r-10" type="primary" @click="previewFile(item)">{{ item.fileName }}</el-link>
<span v-else class="file-name">{{ item.fileName }}</span>
<el-link type="primary" :underline="false" @click="download(item)">下载</el-link>
</li>
</ul>
</template>
</div>
</div>
</template>
<script>
import util from "@/libs/util";
export default {
name: "match",
data() {
return {
form: util.local.get('match')
};
},
mounted() {
this.handleAnnex()
},
methods: {
//
handleAnnex() {
const list = this.form.contestAnnexList
if (list) {
list.map(e => {
const { filePath } = e
e.canPreview = util.canPreview(filePath.substr(filePath.lastIndexOf('.') + 1)) //
})
this.$forceUpdate()
}
},
//
previewFile(item) {
const { filePath } = item
const suffix = filePath.substr(filePath.lastIndexOf('.') + 1)
window.open((util.isDoc(suffix) || suffix === 'pdf' ? 'https://view.officeapps.live.com/op/view.aspx?src=' : '') + item.filePath)
},
//
download(item) {
util.downloadFile(item.fileName, item.filePath)
},
}
};
</script>
<style lang="scss" scoped>
.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;
margin-bottom: 12px;
font-size: 18px;
color: #333;
img{
margin-right: 5px;
}
}
.title{
width: 67%;
margin: 0 auto;
font-size: 28px;
text-align: center;
color: #0B1D30;
}
.info .meta{
padding: 16px 0;
font-size: 12px;
color: #999;
text-align: center;
}
.texts {
margin-bottom: 30px;
font-size: 14px;
line-height: 1.6;
text-indent: 2em;
overflow: hidden;
/deep/img{
max-width: 100%;
}
}
.files {
li {
display: flex;
align-items: center;
margin: 10px 0;
}
.file-name {
margin-right: 10px;
font-size: 12px;
}
}
}
</style>

@ -245,12 +245,15 @@ function getPermission() {
} }
const notice = permissionRouters.findIndex(e => e.name === 'match') const notice = permissionRouters.findIndex(e => e.name === 'match')
if (notice !== -1) { if (notice !== -1) {
permissionRouters[notice].children.push({ const match = [
{
name: `noticeDetail`, name: `noticeDetail`,
path: `/match/noticeDetail`, path: `/match/noticeDetail`,
component: () => import("@/pages/match/manage/noticeDetail"), component: () => import("@/pages/match/manage/noticeDetail"),
meta: { title: "通知公告" } meta: { title: "通知公告" }
}) }
]
permissionRouters[notice].children.push(...match)
} }
// 把处理完成的路由,add到router里 // 把处理完成的路由,add到router里
// 记录一下路由的名称,用于nav // 记录一下路由的名称,用于nav

@ -49,6 +49,12 @@ const frameOut = [
path: "/redirect", path: "/redirect",
name: "redirect", name: "redirect",
component: () => import("@/pages/account/redirect") component: () => import("@/pages/account/redirect")
},
{
name: `matchPreview`,
path: `/match/preview`,
component: () => import("@/pages/match/preview"),
meta: { title: "赛事预览" }
} }
]; ];

@ -23,7 +23,7 @@ if (isPro) {
jumpPath = "http://192.168.31.125:8087/"; jumpPath = "http://192.168.31.125:8087/";
bankPath = `http://192.168.31.125:8093` bankPath = `http://192.168.31.125:8093`
host = "http://121.37.12.51/"; // 中台测试服 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/'; // 赓 // host = 'http://192.168.31.137:9000/'; // 赓
} }

Loading…
Cancel
Save