forked from luocaodan/teach
-
Notifications
You must be signed in to change notification settings - Fork 2
/
teacher_navbar.vue
156 lines (150 loc) · 5.07 KB
/
teacher_navbar.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<template>
<div class="navbar clearFloat">
<el-menu
:default-active="activeIndex"
mode="horizontal"
@select="handleSelect">
<el-menu-item index="1">
班级
</el-menu-item>
<el-submenu index="6">
<template slot="title">班级管理</template>
<el-menu-item index="6-1">
批量添加学生账户
</el-menu-item>
<el-submenu index="6-4">
<template slot="title">教学进度管理</template>
<el-menu-item v-for="classroomId in classroomIdList" :index="'6-4-' + classroomId">
{{classroomNameList[classroomIdList.indexOf(classroomId)]}}
</el-menu-item>
</el-submenu>
<el-menu-item index="6-2">
学生学习情况监视
</el-menu-item>
<el-menu-item index="6-3">
学生成绩管理
</el-menu-item>
</el-submenu>
<el-submenu index="7">
<template slot="title">系统管理</template>
<el-menu-item index="7-1">
评测节点管理
</el-menu-item>
<el-menu-item index="7-2">
系统运行状态监视
</el-menu-item>
<el-menu-item index="7-3">
系统设置
</el-menu-item>
</el-submenu>
<el-submenu index="5" v-if="admin === 'admin'">
<template slot="title">组织</template>
<el-menu-item index="5-1">
新建组织
</el-menu-item>
<el-menu-item index="5-2">
管理组织
</el-menu-item>
</el-submenu>
<el-submenu index="3">
<template slot="title">
广播
<el-badge is-dot v-if="broadcast_num > 0" class="mark" />
</template>
<el-menu-item index="3-1">
发送广播
</el-menu-item>
<el-menu-item index="3-2">
收到的广播
<el-badge v-if="broadcast_num > 0" class="mark" :value=broadcast_num />
</el-menu-item>
</el-submenu>
<el-submenu index="8">
<template slot="title">博客</template>
<el-menu-item v-for="classroomId in classroomIdList" :index="'8-' + classroomId">
{{classroomNameList[classroomIdList.indexOf(classroomId)]}}
</el-menu-item>
</el-submenu>
<el-menu-item index="2">
GitLab
<i class="el-icon-link"></i>
</el-menu-item>
<el-menu-item index="4" style="float: right">
注销平台
</el-menu-item>
</el-menu>
</div>
</template>
<script>
import axios from 'axios/index';
export default {
props: ['admin', 'broadcast_num'],
data() {
return {
activeIndex: '1',
gitlabHost: '',
classroomIdList: [],
classroomNameList: []
}
},
mounted() {
this.gitlabHost = document.getElementById('navbar').dataset.gitlabhost;
// console.log(document.getElementById('navbar').dataset);
// console.log(document.getElementById('navbar').dataset.classroomid);
// console.log(document.getElementById('navbar').dataset.classroomname);
this.classroomIdList = JSON.parse(
document.getElementById('navbar').dataset.classroomid);
this.classroomNameList = JSON.parse(
document.getElementById('navbar').dataset.classroomname);
setInterval(this.getLatestBroadcast, 2000);
},
methods: {
handleSelect(key) {
if (key === '1') {
window.location.href = '/classrooms';
} else if (key === '2') {
window.location.href = this.gitlabHost;
} else if (key.startsWith('3-')) {
if (key === '3-1') {
window.location.href = '/broadcasts/new';
} else if (key === '3-2') {
window.location.href = '/broadcasts';
}
} else if (key === '4') {
window.location.href = '/logout';
} else if (key.startsWith('5-')) {
if (key === '5-1') {
window.location.assign('/organizations/new');
} else if (key === '5-2') {
window.location.assign('/organizations');
}
} else if (key.startsWith('6-')) {
if (key === '6-1') {
window.location.assign('/members/new');
} else if (key.startsWith('6-4-')) {
let classroomIdTmp = key.split("6-4-")[1];
window.location.assign(`/classrooms/${classroomIdTmp}/teaching_progress_index`);
}
} else if (key.startsWith('7-')) {
if (key === '7-1') {
window.location.assign('/runners');
}
} else if (key.startsWith('8-')){
let classroomIdTmp = key.split("8-")[1];
window.location.assign(`/classrooms/${classroomIdTmp}/blogs`);
}
},
getLatestBroadcast() {
axios.get('/broadcasts/get_latest_broadcast').then((response) => {
if (response.data['broadcast_num'] > this.broadcast_num) {
this.broadcast_num = response.data['broadcast_num']
this.$notify({
title: '新广播',
message: response.data['latest_broadcast']['content']
})
}
});
}
}
}
</script>