Verified Commit 6d4736c8 authored by jxtxzzw's avatar jxtxzzw

增加更多维度表示课程信息

Signed-off-by: jxtxzzw's avatarjxtxzzw <jxtxzzw@126.com>
parent 286c25b6
Pipeline #276 passed with stages
in 35 minutes and 58 seconds
......@@ -5,14 +5,18 @@
"university": "Carnegie Mellon University",
"score": null,
"max_score": null,
"grade_point": 4,
"max_grade_point": 4,
"grade": "A"
},
{
"id": "2",
"course": "计算机组成原理",
"university": "华东师范大学",
"score": 3.9,
"max_score": 4.0,
"score": 90,
"max_score": 100,
"grade_point": null,
"max_grade_point": null,
"grade": null
},
{
......@@ -21,6 +25,8 @@
"university": "另一所学校",
"score": 80,
"max_score": 100,
"grade_point": 3.88,
"max_grade_point": 4,
"grade": "A-"
}
]
<template>
<div>
<span v-for="c in course" :key="c.id" style="margin-right: 20px">
<Badge :text="getShowText(c.score, c.max_score, c.grade)" type="success">
<Tag type="dot" color="primary">{{
`${c.course} (${c.university})`
}}</Tag>
</Badge>
</span>
</div>
</template>
<script>
import { course } from 'assets/reader'
export default {
......@@ -20,16 +8,85 @@ export default {
}
},
methods: {
getShowText(score, maxScore, grade) {
let text = ''
if (score != null && score > 0) {
text += ` ${score}/${maxScore} `
renderForEach(h, c) {
let verticalOffset = 0
const tag = h(
'Tag',
{
attrs: {
type: 'dot',
color: 'primary',
},
},
`${c.course} (${c.university})`
)
let scoreWrapper = tag
if (c.score != null) {
scoreWrapper = h(
'Badge',
{
attrs: {
text: `${c.score}/${c.max_score}`,
type: 'primary',
offset: [verticalOffset, 50],
},
},
[tag]
)
verticalOffset -= 20
}
if (grade != null) {
text += ` ${grade} `
let gradePointWrapper = scoreWrapper
if (c.grade_point != null) {
gradePointWrapper = h(
'Badge',
{
attrs: {
text: `${c.grade_point}/${c.max_grade_point}`,
type: 'info',
offset: [verticalOffset, 50],
},
},
[scoreWrapper]
)
}
return text
let gradeWrapper = gradePointWrapper
if (c.grade != null) {
gradeWrapper = h(
'Badge',
{
attrs: {
text: c.grade,
type: 'success',
},
},
[gradePointWrapper]
)
}
return h(
'span',
{
style: {
marginRight: '40px',
marginTop: '40px',
},
},
[gradeWrapper]
)
},
},
render(h) {
const list = []
for (const c of this.course) {
list.push(this.renderForEach(h, c))
}
return h('div', [
h('div', {
style: {
height: '20px',
},
}),
h('div', list),
])
},
}
</script>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment