Skip to content

Commit

Permalink
disable submit button after submitting
Browse files Browse the repository at this point in the history
  • Loading branch information
zema1 committed Sep 7, 2018
1 parent 1224375 commit 97a6729
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 31 deletions.
9 changes: 6 additions & 3 deletions src/pages/oj/views/problem/Problem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@
</div>
</template>
<Button type="warning" icon="edit" :loading="submitting" @click="submitCode"
:disabled="problemSubmitDisabled"
:disabled="problemSubmitDisabled || submitted"
class="fl-right">
<span v-if="!submitting">Submit</span>
<span v-else>Submitting</span>
<span v-if="submitting">Submitting</span>
<span v-else-if="submitted">Submitted</span>
<span v-else>Submit</span>
</Button>
</Col>
</Row>
Expand Down Expand Up @@ -228,6 +229,7 @@
language: 'C++',
theme: 'solarized',
submissionId: '',
submitted: false,
result: {
result: 9
},
Expand Down Expand Up @@ -405,6 +407,7 @@
const submitFunc = (data, detailsVisible) => {
this.statusVisible = true
api.submitCode(data).then(res => {
this.submitted = true
this.submissionId = res.data.data && res.data.data.submission_id
// 定时检查状态
this.submitting = false
Expand Down
54 changes: 27 additions & 27 deletions src/pages/oj/views/submission/SubmissionDetails.vue
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
<template>
<Row type="flex" justify="space-around">
<Col :span="20" id="status">
<Alert :type="status.type" showIcon>
<span class="title">{{status.statusName}}</span>
<div slot="desc" class="content">
<template v-if="isCE">
<pre>{{submission.statistic_info.err_info}}</pre>
</template>
<template v-else>
<span>Time: {{submission.statistic_info.time_cost | submissionTime}}</span>
<span>Memory: {{submission.statistic_info.memory_cost | submissionMemory}}</span>
<span>Lang: {{submission.language}}</span>
<span>Author: {{submission.username}}</span>
</template>
</div>
</Alert>
<Alert :type="status.type" showIcon>
<span class="title">{{status.statusName}}</span>
<div slot="desc" class="content">
<template v-if="isCE">
<pre>{{submission.statistic_info.err_info}}</pre>
</template>
<template v-else>
<span>Time: {{submission.statistic_info.time_cost | submissionTime}}</span>
<span>Memory: {{submission.statistic_info.memory_cost | submissionMemory}}</span>
<span>Lang: {{submission.language}}</span>
<span>Author: {{submission.username}}</span>
</template>
</div>
</Alert>
</Col>

<!--后台返info就显示出来, 权限控制放后台 -->
<Col v-if="submission.info && !isCE" :span="20">
<Table stripe :loading="loading" :disabled-hover="true" :columns="columns" :data="submission.info.data"></Table>
<Table stripe :loading="loading" :disabled-hover="true" :columns="columns" :data="submission.info.data"></Table>
</Col>

<Col :span="20">
<Highlight :code="submission.code" :language="submission.language" :border-color="status.color"></Highlight>
<Highlight :code="submission.code" :language="submission.language" :border-color="status.color"></Highlight>
</Col>
<Col v-if="submission.can_unshare" :span="20">
<div id="share-btn">
<Button v-if="submission.shared"
type="warning" size="large" @click="shareSubmission(false)">
UnShare
</Button>
<Button v-else
type="primary" size="large" @click="shareSubmission(true)">
Share
</Button>
</div>
<div id="share-btn">
<Button v-if="submission.shared"
type="warning" size="large" @click="shareSubmission(false)">
UnShare
</Button>
<Button v-else
type="primary" size="large" @click="shareSubmission(true)">
Share
</Button>
</div>
</Col>
</Row>

</template>

<script>
import api from '@oj/api'
import { JUDGE_STATUS } from '@/utils/constants'
import {JUDGE_STATUS} from '@/utils/constants'
import utils from '@/utils/utils'
import Highlight from '@/pages/oj/components/Highlight'
Expand Down
2 changes: 1 addition & 1 deletion src/utils/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function utcToLocal (utcDt, format = 'YYYY-M-D HH:mm:ss') {
return moment.utc(utcDt).local().format(format)
}

// get duration from startTime to endTime, return like 3 days, 2 hours, one yead ..
// get duration from startTime to endTime, return like 3 days, 2 hours, one year ..
function duration (startTime, endTime) {
let start = moment(startTime)
let end = moment(endTime)
Expand Down

0 comments on commit 97a6729

Please sign in to comment.