除了上传文件外 报名和提交功能完成

This commit is contained in:
unknown 2022-06-28 18:16:37 +08:00
parent a0604a6834
commit c97d51aac9
4 changed files with 219 additions and 36 deletions

View File

@ -490,7 +490,7 @@ export default {
var startTime = parseInt(this.$moment(this.applyTime[0]).format("X")) var startTime = parseInt(this.$moment(this.applyTime[0]).format("X"))
var endTime = parseInt(this.$moment(this.applyTime[1]).format("X")) var endTime = parseInt(this.$moment(this.applyTime[1]).format("X"))
var nowTime = parseInt(this.$moment().format("X")) var nowTime = parseInt(this.$moment().format("X"))
this.applyFilterUrl = res.data.applyTableUrl
if (startTime <= nowTime && nowTime <= endTime){ if (startTime <= nowTime && nowTime <= endTime){
pageUtils.openPage(this.$router,"/" + this.$route.params.compId +"/apply"); pageUtils.openPage(this.$router,"/" + this.$route.params.compId +"/apply");
}else { }else {

View File

@ -5,18 +5,18 @@
<div class="content"> <div class="content">
<div class="card"> <div class="card">
<el-upload <el-upload
drag drag
name="importSubmitFile" name="importSubmitFile"
:limit="1" :limit="1"
:on-exceed="handleExceed" :on-exceed="handleExceed"
:action="uploadActionUrl" :action="uploadActionUrl"
accept=".zip,.rar" accept=".zip,.rar"
:before-upload="onBeforeUpload" :before-upload="onBeforeUpload"
:on-progress="onUpload" :on-progress="onUpload"
:on-success="(res)=>{importSuccess(res)}" :on-success="(res)=>{importSuccess(res)}"
:before-remove="beforeRemove" :before-remove="beforeRemove"
:file-list="fileList" :file-list="fileList"
class="import-submit-file" class="import-submit-file"
> >
<i class="el-icon-upload"></i> <i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div> <div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
@ -35,28 +35,38 @@
</template> </template>
<script> <script>
import {Message} from "element-ui";
import pageUtils from "@/utils/pageUtils";
export default { export default {
name: "Submit", name: "Submit",
data(){ data() {
return { return {
fileList: [
],
downloadActionUrl: "", downloadActionUrl: "",
applyTime: [],
submitTime: [],
onlineScript: false,
onlineInter: '',
}; };
}, },
methods:{ methods: {
// //
handleExceed(){ handleExceed() {
this.$message.warning("限制上传一个文件"); this.$message.warning("限制上传一个文件");
}, },
// //
onBeforeUpload(file){ onBeforeUpload(file) {
const isIMAGE = file.type === "rar"||"zip"; const isIMAGE = file.type === "rar" || "zip";
const isLt1M = file.size / 1024 / 1024 < 1; const isLt1M = file.size / 1024 / 1024 < 1;
if (!isIMAGE) { if (!isIMAGE) {
this.$message.error("上传文件只能是rar/zip压缩包格式!"); this.$message.error("上传文件只能是rar/zip压缩包格式!");
@ -66,41 +76,179 @@ export default {
} }
// false // false
return isIMAGE && isLt1M; return isIMAGE && isLt1M;
}, },
// //
onUpload(){ onUpload() {
this.loading_text = "拼命导入中...请稍等"; this.loading_text = "拼命导入中...请稍等";
this.loading = true; this.loading = true;
}, },
// //
importSuccess(res){ importSuccess(res) {
if(res.code == "0"){ if (res.code == "0") {
if(res.data == 0){ if (res.data == 0) {
this.$message({ this.$message({
showClose: true, showClose: true,
message: '上传报名表成功', message: '上传报名表成功',
type: 'success', type: 'success',
}); });
} }
}else{ } else {
this.$message({ this.$message({
showClose: true, showClose: true,
message: '上传报名表失败' + res.message, message: '上传报名表失败' + res.message,
type: 'error' type: 'error'
}); });
} }
}, },
//
userStateCheck() {
/**
* 1. 有信息 拿到token userId 去获取用户信息
* 2. 无信息 提示用户登录
*/
let token = localStorage.getItem("systemToken");
let userId = localStorage.getItem("userId");
if (userId != null && token != null && userId !== '' && token !== '') {
//
var user = {
userId,
}
this.$api.getUserDataByUserId(user).then((res) => {
console.log(res);
if (res.status == 0) {
//
this.initPage()
} else {
Message.warning("请登录后操作");
pageUtils.openPage(this.$router, "/" + this.$route.params.compId + "/login");
}
}).catch(function (res) {
console.log(res);
})
} else {
Message.warning("请登录后操作");
pageUtils.openPage(this.$router, "/" + this.$route.params.compId + "/login");
}
},
checkTime() {
var compId = this.$route.params.compId;
var compInfo = {
compId,
}
this.$api.getComp(compInfo).then((res) => {
if (res.status === 0) {
// 线
if (res.data.online === true) {
//线
this.applyTime[0] = res.data.applyStartTime
this.applyTime[1] = res.data.applyEndTime
this.submitTime[0] = res.data.submitStartTime
this.submitTime[1] = res.data.submitEndTime
var startTime = parseInt(this.$moment(this.submitTime[0]).format("X"))
var endTime = parseInt(this.$moment(this.submitTime[1]).format("X"))
var nowTime = parseInt(this.$moment().format("X"))
this.applyFilterUrl = res.data.applyTableUrl
if (startTime <= nowTime && nowTime <= endTime) {
//
} else {
Message.warning("未在报名时间段")
this.$router.go(-1)
this.getPath()
}
} else {
// 线404
Message.warning("该竞赛还未上线");
//TODO:
this.$router.push({
path: '/404'
});
}
} else {
// 404
Message.warning("不存在该竞赛");
this.$router.push({
path: '/404'
});
}
})
},
initPage() {
/**
* 1.判断登录状态
* 2.判断时间
* 3.判断用户报名记录
* 4.提交记录
*/
//
this.checkTime();
// 线
var submitCust = {
compId: this.$route.params.compId
}
this.$api.getSubmitCust(submitCust).then((res) => {
if (res.status == 0) {
//
this.onlineScript = res.data.onlineScript
this.onlineInter = res.date.onlineInter
} else {
Message.error("获取比赛信息失败")
}
})
var applyInfo = {
compId: this.$route.params.compId,
userId: localStorage.getItem("userId")
}
this.$api.getApplyForPerson(applyInfo).then((res) => {
if (res.status == 0) {
//
var teamId = res.data.applyInfo.teamId
var submitInfo = {
compId: this.$route.params.compId,
teamId
}
this.$api.getSubmitInfo(submitInfo).then((res) => {
if (res.status == 0) {
//
this.fileList.push({
name: res.data.file.split("/")[3],
url: res.data.file
}
)
} else if (res.status == 10) {
//
} else {
Message.error("权限不足或其他错误")
}
})
} else if (res.status == 10) {
//
Message.error("当前用户未报名")
this.$router.go(-1)
} else {
Message.error("权限不足或其他错误")
}
})
},
}, },
mounted() {
mounted(){ this.userStateCheck()
}, },
}; };
</script> </script>
@ -108,12 +256,13 @@ export default {
<style scoped> <style scoped>
.card { .card {
width: 72vw; width: 72vw;
height: 22vw; height: 22vw;
background-color: white; background-color: white;
box-shadow: 0px 4px 10px 0 rgba(0,0,0,0.15); box-shadow: 0px 4px 10px 0 rgba(0, 0, 0, 0.15);
position: relative; position: relative;
} }
.import-submit-file { .import-submit-file {
position: absolute; position: absolute;
top: 50%; top: 50%;

View File

@ -246,6 +246,31 @@ export const getDivisionAndKind = (data) => {
}) })
}; };
export const getSubmitCust = (data) => {
return axios({
headers:{
"Authorization": localStorage.getItem("systemToken")
},
url: '/submit/getSubmitCustByCompId',
method: 'post',
data
})
};
export const getSubmitInfo = (data) => {
return axios({
headers:{
"Authorization": localStorage.getItem("systemToken")
},
url: '/submit/getSubmitInfoForPerson',
method: 'post',
data
})
};
// 默认全部倒出 // 默认全部倒出
// 根据需要进行 // 根据需要进行
export default { export default {
@ -271,5 +296,7 @@ export default {
getApplyForPerson, getApplyForPerson,
delMemberByMemNum, delMemberByMemNum,
updateApplyInfo, updateApplyInfo,
getDivisionAndKind getDivisionAndKind,
getSubmitCust,
getSubmitInfo
} }

View File

@ -19,6 +19,13 @@ module.exports = {
pathRewrite: { pathRewrite: {
'^/api': '' '^/api': ''
} }
},
'/script':{
target: 'http://localhost:8888',
changeOrigin: true,
pathRewrite: {
'^/script': ''
}
} }
}, },
// 此处开启 https // 此处开启 https