提交 5939ac45 authored 作者: matian's avatar matian

Merge remote-tracking branch 'origin/vite' into vite

......@@ -14,6 +14,7 @@
v-if="isSetScoreRange"
@close="isSetScoreRange = false"
@scoreRangeChange="scoreRangeChange"
:recordScoreRange="recordScoreRange"
></set-score-range>
</div>
</template>
......@@ -26,6 +27,7 @@ export default {
data() {
return {
data: [],
recordScoreRange: [],
isSetScoreRange: false,
option: {
tooltip: {
......@@ -71,13 +73,16 @@ export default {
}
},
mounted() {
this.scoreRangeChange([{ a: 0, b: 100 }])
this.scoreRangeChange()
},
methods: {
scoreRangeChange(data) {
scoreRangeChange(data = {}) {
const { datas = [{ a: 0, b: 100 }], tags = [0, 100] } = data
const arr = [0, 10, 11, 12, 13, 20, 22, 24, 50, 50, 50, 21, 54, 100]
const colors = ['#6F85CC', '#96C080', '#EAC370', '#D96685', '#B170CE']
this.option.series[0].data = data.reduce((prev, cur, index) => {
this.recordScoreRange = tags
// 组装echart数据
this.option.series[0].data = datas.reduce((prev, cur, index) => {
let count = 0
arr.forEach(i => {
if (i >= (i === 0 ? cur.a : cur.a + 1) && i <= cur.b) count++
......@@ -85,8 +90,10 @@ export default {
prev.push({ value: count, name: `${cur.a}-${cur.b}`, itemStyle: colors[index] })
return prev
}, [])
// 渲染echart
const myChart = echarts.init(document.getElementById('score'))
myChart.setOption(this.option)
// 关闭弹窗
this.isSetScoreRange = false
}
}
......
......@@ -10,7 +10,7 @@
<div class="btn" @click="addTag">添加</div>
</div>
<div class="range-box">
<template v-for="(item, index) in tagCount">
<template v-for="(item, index) in tags">
<div class="li-item"
:key="index"
v-if="item != 0 && item != 100"
......@@ -35,15 +35,19 @@
<script>
export default {
props: {
recordScoreRange: { type: Array, default: () => [] }
},
data() {
return {
tagInput: '',
tagCount: [0, 100]
tags: [0, 100]
}
},
mounted() {
},
created() {
this.tags = [...this.recordScoreRange]
},
methods: {
// 添加标签
addTag() {
......@@ -53,28 +57,29 @@ export default {
this.$message('请填写正确分数段')
return false
}
if (this.tagCount.length === 9) {
if (this.tags.length === 9) {
this.$message('最多可添加8个')
return false
}
if (!this.tagCount.includes(value)) {
this.tagCount.push(value)
this.tagCount.sort((a, b) => a - b)
if (!this.tags.includes(value)) {
this.tags.push(value)
this.tags.sort((a, b) => a - b)
this.tagInput = ''
}
console.log(this.recordScoreRange, '===123')
},
// 删除标签
removeTag(index) {
this.tagCount.splice(index, 1)
this.tags.splice(index, 1)
},
// 确认选择
confirmTag() {
const data = this.tagCount.reduce((prev, cur) => {
const data = this.tags.reduce((prev, cur) => {
const findPrev = prev[prev.length - 1]
if (cur !== 0) prev.push({ a: findPrev ? findPrev.b : 0, b: cur })
return prev
}, [])
this.$emit('scoreRangeChange', data)
this.$emit('scoreRangeChange', { datas: data, tags: this.tags })
}
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论