contest rank 管理员可以查看real_name了

This commit is contained in:
zema1 2017-11-29 13:45:41 +08:00
parent 8905d208e9
commit 0de46da7a4
8 changed files with 91 additions and 62 deletions

View File

@ -12,8 +12,11 @@ const state = {
contest_type: CONTEST_TYPE.PUBLIC
},
contestProblems: [],
showMenu: true,
showChart: true
itemVisible: {
menu: true,
chart: true,
realName: false
}
}
const getters = {
@ -95,11 +98,8 @@ const mutations = {
[types.CHANGE_CONTEST] (state, payload) {
state.contest = payload.contest
},
[types.CHANGE_CONTEST_MENU_VISIBLE] (state, payload) {
state.showMenu = payload.visible
},
[types.CHANGE_CONTEST_CHART_VISIBLE] (state, payload) {
state.showChart = payload.visible
[types.CHANGE_CONTEST_ITEM_VISIBLE] (state, payload) {
state.itemVisible = {...state.itemVisible, ...payload}
},
[types.CHANGE_CONTEST_PROBLEMS] (state, payload) {
state.contestProblems = payload.contestProblems
@ -113,9 +113,12 @@ const mutations = {
[types.CLEAR_CONTEST] (state) {
state.contest = {created_by: {}}
state.contestProblems = []
state.showMenu = true
state.showChart = true
state.access = false
state.itemVisible = {
menu: true,
chart: true,
realName: false
}
},
[types.NOW] (state, payload) {
state.now = payload.now

View File

@ -18,8 +18,7 @@ export default keyMirror({
'NOW_ADD_1S': null,
'CHANGE_CONTEST': null,
'CHANGE_CONTEST_PROBLEMS': null,
'CHANGE_CONTEST_MENU_VISIBLE': null,
'CHANGE_CONTEST_CHART_VISIBLE': null,
'CHANGE_CONTEST_ITEM_VISIBLE': null,
'CHANGE_CONTEST_RANK_LIMIT': null,
'CONTEST_ACCESS': null,
'CLEAR_CONTEST': null

View File

@ -151,7 +151,7 @@
},
computed: {
...mapState({
showMenu: state => state.contest.showMenu,
showMenu: state => state.contest.itemVisible.menu,
contest: state => state.contest.contest,
contest_table: state => [state.contest.contest],
now: state => state.contest.now

View File

@ -12,14 +12,18 @@
<span>Chart</span>
<i-switch v-model="showChart"></i-switch>
</p>
<p style="margin-top: 10px">
<p v-if="isAdmin">
<span>RealName</span>
<i-switch v-model="showRealName"></i-switch>
</p>
<p>
<span>Auto Refresh(10s)</span>
<i-switch :disabled="refreshDisabled" @on-change="handleAutoRefresh"></i-switch>
</p>
</div>
</Poptip>
</div>
<div v-if="showChart" class="echarts">
<div v-show="showChart" class="echarts">
<ECharts :options="options" ref="chart" auto-resize></ECharts>
</div>
<Table ref="tableRank" class="auto-resize" :columns="columns" :data="dataRank" disabled-hover></Table>
@ -37,7 +41,6 @@
import Pagination from '@oj/components/Pagination'
import ContestRankMixin from './contestRankMixin'
import api from '@oj/api'
import time from '@/utils/time'
import utils from '@/utils/utils'
@ -187,22 +190,6 @@
},
methods: {
...mapActions(['getContestProblems']),
getContestRankData (page = 1, refresh = false) {
let offset = (page - 1) * this.limit
if (this.showChart && !refresh) {
this.$refs.chart.showLoading({maskColor: 'rgba(250, 250, 250, 0.8)'})
}
api.getContestRank(offset, this.limit, this.$route.params.contestID).then(res => {
if (this.showChart && !refresh) {
this.$refs.chart.hideLoading()
}
this.total = res.data.data.total
if (page === 1) {
this.applyToChart(res.data.data.results.slice(0, 10))
}
this.applyToTable(res.data.data.results)
})
},
addChartCategory (contestProblems) {
let category = []
for (let i = 0; i <= contestProblems.length; ++i) {
@ -321,8 +308,14 @@
}
#switches {
span {
margin-left: 5px;
p {
margin-top: 5px;
&:first-child {
margin-top: 0;
}
span {
margin-left: 8px;
}
}
}
</style>

View File

@ -32,7 +32,7 @@
}
},
beforeRouteLeave (to, from, next) {
this.$store.commit(types.CHANGE_CONTEST_MENU_VISIBLE, {visible: true})
this.$store.commit(types.CHANGE_CONTEST_ITEM_VISIBLE, {menu: true})
next()
}
}

View File

@ -12,14 +12,18 @@
<span>Chart</span>
<i-switch v-model="showChart"></i-switch>
</p>
<p style="margin-top: 10px">
<p v-if="isAdmin">
<span>RealName</span>
<i-switch v-model="showRealName"></i-switch>
</p>
<p>
<span>Auto Refresh(10s)</span>
<i-switch :disabled="refreshDisabled" @on-change="handleAutoRefresh"></i-switch>
</p>
</div>
</Poptip>
</div>
<div v-if="showChart" class="echarts">
<div v-show="showChart" class="echarts">
<ECharts :options="options" ref="chart" auto-resize></ECharts>
</div>
<Table ref="tableRank" class="auto-resize" :columns="columns" :data="dataRank" disabled-hover></Table>
@ -37,7 +41,6 @@
import Pagination from '@oj/components/Pagination'
import ContestRankMixin from './contestRankMixin'
import utils from '@/utils/utils'
import api from '@oj/api'
export default {
name: 'acm-contest-rank',
@ -168,22 +171,6 @@
},
methods: {
...mapActions(['getContestProblems']),
getContestRankData (page = 1, refresh = false) {
let offset = (page - 1) * this.limit
if (this.showChart && !refresh) {
this.$refs.chart.showLoading({maskColor: 'rgba(250, 250, 250, 0.8)'})
}
api.getContestRank(offset, this.limit, this.$route.params.contestID).then(res => {
if (this.showChart && !refresh) {
this.$refs.chart.hideLoading()
}
this.total = res.data.data.total
if (page === 1) {
this.applyToChart(res.data.data.results.slice(0, 10))
}
this.applyToTable(res.data.data.results)
})
},
applyToChart (rankData) {
let [usernames, scores] = [[], []]
rankData.forEach(ele => {
@ -250,8 +237,14 @@
}
#switches {
span {
margin-left: 5px;
p {
margin-top: 5px;
&:first-child {
margin-top: 0;
}
span {
margin-left: 8px;
}
}
}
</style>

View File

@ -1,5 +1,6 @@
import api from '@oj/api'
import ScreenFull from '@admin/components/ScreenFull.vue'
import { mapState } from 'vuex'
import { mapState, mapGetters } from 'vuex'
import { types } from '@oj/store/index'
import { CONTEST_STATUS } from '@/utils/constants'
@ -8,6 +9,22 @@ export default {
ScreenFull
},
methods: {
getContestRankData (page = 1, refresh = false) {
let offset = (page - 1) * this.limit
if (this.showChart && !refresh) {
this.$refs.chart.showLoading({maskColor: 'rgba(250, 250, 250, 0.8)'})
}
api.getContestRank(offset, this.limit, this.$route.params.contestID).then(res => {
if (this.showChart && !refresh) {
this.$refs.chart.hideLoading()
}
this.total = res.data.data.total
if (page === 1) {
this.applyToChart(res.data.data.results.slice(0, 10))
}
this.applyToTable(res.data.data.results)
})
},
handleAutoRefresh (status) {
if (status === true) {
this.refreshFunc = setInterval(() => {
@ -20,24 +37,25 @@ export default {
}
},
computed: {
...mapGetters(['isAdmin']),
...mapState({
'contest': state => state.contest.contest,
'contestProblems': state => state.contest.contestProblems
}),
showChart: {
get () {
return this.$store.state.contest.showChart
return this.$store.state.contest.itemVisible.chart
},
set (value) {
this.$store.commit(types.CHANGE_CONTEST_CHART_VISIBLE, {visible: value})
this.$store.commit(types.CHANGE_CONTEST_ITEM_VISIBLE, {chart: value})
}
},
showMenu: {
get () {
return this.$store.state.contest.showMenu
return this.$store.state.contest.itemVisible.menu
},
set (value) {
this.$store.commit(types.CHANGE_CONTEST_MENU_VISIBLE, {visible: value})
this.$store.commit(types.CHANGE_CONTEST_ITEM_VISIBLE, {menu: value})
this.$nextTick(() => {
if (this.showChart) {
this.$refs.chart.resize()
@ -46,8 +64,25 @@ export default {
})
}
},
refreshDisabled () {
return this.contest.status === CONTEST_STATUS.ENDED
showRealName: {
get () {
return this.$store.state.contest.itemVisible.realName
},
set (value) {
this.$store.commit(types.CHANGE_CONTEST_ITEM_VISIBLE, {realName: value})
if (value) {
this.columns.splice(2, 0, {
title: 'RealName',
align: 'center',
width: '150px',
render: (h, {row}) => {
return h('span', row.user.real_name)
}
})
} else {
this.columns.splice(2, 1)
}
}
},
limit: {
get () {
@ -56,6 +91,9 @@ export default {
set (value) {
this.$store.commit(types.CHANGE_CONTEST_RANK_LIMIT, {rankLimit: value})
}
},
refreshDisabled () {
return this.contest.status === CONTEST_STATUS.ENDED
}
},
beforeDestroy () {

View File

@ -321,6 +321,9 @@
},
'rejudgeColumnVisible' () {
this.adjustRejudgeColumn()
},
'isAuthenticated' () {
this.init()
}
}
}