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

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

View File

@ -35,28 +35,38 @@
</template>
<script>
import {Message} from "element-ui";
import pageUtils from "@/utils/pageUtils";
export default {
name: "Submit",
data(){
data() {
return {
fileList: [
],
downloadActionUrl: "",
applyTime: [],
submitTime: [],
onlineScript: false,
onlineInter: '',
};
},
methods:{
methods: {
//
handleExceed(){
handleExceed() {
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;
if (!isIMAGE) {
this.$message.error("上传文件只能是rar/zip压缩包格式!");
@ -70,23 +80,23 @@ export default {
},
//
onUpload(){
onUpload() {
this.loading_text = "拼命导入中...请稍等";
this.loading = true;
},
//
importSuccess(res){
importSuccess(res) {
if(res.code == "0"){
if(res.data == 0){
if (res.code == "0") {
if (res.data == 0) {
this.$message({
showClose: true,
message: '上传报名表成功',
type: 'success',
});
}
}else{
} else {
this.$message({
showClose: true,
message: '上传报名表失败' + res.message,
@ -97,10 +107,148 @@ export default {
},
//
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) {
//线
mounted(){
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() {
this.userStateCheck()
},
};
</script>
@ -111,9 +259,10 @@ export default {
width: 72vw;
height: 22vw;
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;
}
.import-submit-file {
position: absolute;
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 {
@ -271,5 +296,7 @@ export default {
getApplyForPerson,
delMemberByMemNum,
updateApplyInfo,
getDivisionAndKind
getDivisionAndKind,
getSubmitCust,
getSubmitInfo
}

View File

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