|
@@ -0,0 +1,250 @@
|
|
|
+import { defineComponent, onMounted, ref } from 'vue'
|
|
|
+import styles from './index.module.less'
|
|
|
+import CircleProgress from './component/CircleProgress'
|
|
|
+import iconBackup from './image/icon-backup.png'
|
|
|
+import iconEnsemble from './image/icon-ensemble.png'
|
|
|
+
|
|
|
+import * as echarts from 'echarts'
|
|
|
+import { postMessage } from '@/helpers/native-message'
|
|
|
+
|
|
|
+type EChartsOption = echarts.EChartsOption
|
|
|
+
|
|
|
+export default defineComponent({
|
|
|
+ name: 'subject-echarts',
|
|
|
+ setup() {
|
|
|
+ const colors = [
|
|
|
+ {
|
|
|
+ color: '#FF8057',
|
|
|
+ borderColor: 'rgba(255,128,87,0.5)',
|
|
|
+ text: '达标率'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ color: '#2FC58D',
|
|
|
+ borderColor: 'rgba(47,197,141,0.5)',
|
|
|
+ text: '达标'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ color: '#4A99FF',
|
|
|
+ borderColor: 'rgba(74,153,255,0.5)',
|
|
|
+ text: '未达标'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ color: '#9884BA',
|
|
|
+ borderColor: 'rgba(152,132,186,0.5)',
|
|
|
+ text: '非会员'
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ const myChart = ref<echarts.ECharts>()
|
|
|
+ const handleInit = () => {
|
|
|
+ var chartDom = document.getElementById('subjectEcharts')!
|
|
|
+ myChart.value = echarts.init(chartDom, undefined, {
|
|
|
+ renderer: 'svg'
|
|
|
+ })
|
|
|
+ var option: EChartsOption
|
|
|
+
|
|
|
+ option = {
|
|
|
+ tooltip: {
|
|
|
+ trigger: 'axis',
|
|
|
+ },
|
|
|
+ dataset: {
|
|
|
+ source: [['Email']]
|
|
|
+ },
|
|
|
+ grid: {
|
|
|
+ left: '3%',
|
|
|
+ right: '3%',
|
|
|
+ bottom: '3%',
|
|
|
+ containLabel: true
|
|
|
+ },
|
|
|
+ xAxis: {
|
|
|
+ type: 'category',
|
|
|
+ boundaryGap: false,
|
|
|
+ data: ['长笛', '单簧管', '萨克斯', '小号', '圆号', '上低音号', '打击乐'],
|
|
|
+ axisPointer:{
|
|
|
+ type: 'shadow'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ yAxis: [
|
|
|
+ {
|
|
|
+ type: 'value',
|
|
|
+ position: 'left',
|
|
|
+ alignTicks: true,
|
|
|
+ axisLine: {
|
|
|
+ show: true,
|
|
|
+ lineStyle: {
|
|
|
+ color: colors[2].color
|
|
|
+ }
|
|
|
+ },
|
|
|
+ axisLabel: {
|
|
|
+ formatter: '{value}'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'value',
|
|
|
+ position: 'right',
|
|
|
+ alignTicks: true,
|
|
|
+ axisLine: {
|
|
|
+ show: true,
|
|
|
+ lineStyle: {
|
|
|
+ color: colors[0].color
|
|
|
+ }
|
|
|
+ },
|
|
|
+ axisLabel: {
|
|
|
+ formatter: '{value} %'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ name: '达标率',
|
|
|
+ type: 'line',
|
|
|
+ data: [120, 132, 101, 134, 90, 230, 210]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '达标',
|
|
|
+ type: 'line',
|
|
|
+ data: [150, 232, 201, 154, 190, 330, 410]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '未达标',
|
|
|
+ type: 'line',
|
|
|
+ data: [320, 332, 301, 334, 390, 330, 320]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '非会员',
|
|
|
+ type: 'line',
|
|
|
+ yAxisIndex: 1,
|
|
|
+ data: [2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+
|
|
|
+ option && myChart.value.setOption(option)
|
|
|
+ console.log('🚀 ~ myChart:', myChart.value)
|
|
|
+ }
|
|
|
+ const getThisWeek = async () => {
|
|
|
+ postMessage(
|
|
|
+ {
|
|
|
+ api: 'setAccomanyEcharts'
|
|
|
+ },
|
|
|
+ (evt) => {
|
|
|
+ console.log(evt?.content)
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
+ const action = () => {
|
|
|
+ // myChart.value?.dispatchAction({
|
|
|
+ // type: 'showTip',
|
|
|
+ // name: '单簧管'
|
|
|
+ // })
|
|
|
+ myChart.value?.dispatchAction({
|
|
|
+ type:'downplay',
|
|
|
+ seriesIndex:[0,1],//两个图标同时展示
|
|
|
+ dataIndex:0
|
|
|
+ })
|
|
|
+ }
|
|
|
+ onMounted(() => {
|
|
|
+ getThisWeek()
|
|
|
+ handleInit()
|
|
|
+ })
|
|
|
+ return () => (
|
|
|
+ <div class={styles.subjectEcharts}>
|
|
|
+ <div class={[styles.container, styles.ensemble]}>
|
|
|
+ <div class={styles.head}>
|
|
|
+ <div class={styles.headLeft}>
|
|
|
+ <img class={styles.icon} src={iconEnsemble} />
|
|
|
+ <div>总体情况</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class={styles.content}>
|
|
|
+ <CircleProgress value={80} size={80} color="#FF8057" strokeWidth={6} duration={3000} />
|
|
|
+ <div class={styles.items}>
|
|
|
+ <div class={styles.item}>
|
|
|
+ <div class={styles.itemNum}>
|
|
|
+ <span class={styles.rect}></span>
|
|
|
+ <span style={{ color: '#FF8057' }}>348</span>
|
|
|
+ </div>
|
|
|
+ <div class={styles.itemTitle}>达标人数</div>
|
|
|
+ </div>
|
|
|
+ <div class={[styles.item, styles.line]}>
|
|
|
+ <div class={styles.itemNum}>
|
|
|
+ <span class={styles.rect} style={{ background: '#FFE7DF' }}></span>
|
|
|
+ <span>348</span>
|
|
|
+ </div>
|
|
|
+ <div class={styles.itemTitle}>未达标人数</div>
|
|
|
+ </div>
|
|
|
+ <div class={styles.item}>
|
|
|
+ <div class={styles.itemNum}>
|
|
|
+ <span>348</span>
|
|
|
+ </div>
|
|
|
+ <div class={styles.itemTitle}>非会员人数</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class={[styles.container, styles.ensemble]}>
|
|
|
+ <div class={styles.head}>
|
|
|
+ <div class={styles.headLeft}>
|
|
|
+ <img class={styles.icon} src={iconBackup} />
|
|
|
+ <div>声部情况</div>
|
|
|
+ </div>
|
|
|
+ <div class={styles.headRight}>
|
|
|
+ {colors.map((c) => (
|
|
|
+ <div
|
|
|
+ style={{ color: c.color, borderColor: c.borderColor }}
|
|
|
+ onClick={() => {
|
|
|
+ console.log(myChart.value)
|
|
|
+ action()
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {c.text}
|
|
|
+ </div>
|
|
|
+ ))}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div id="subjectEcharts" class={styles.echartsMain}></div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class={[styles.container, styles.subjectWrap]}>
|
|
|
+ {new Array(8).fill(1).map((item: any, index: number) => (
|
|
|
+ <div class={[styles.listItem, index == 3 ? styles.listItemActive : '']}>
|
|
|
+ <div class={styles.dot}></div>
|
|
|
+ <div class={styles.itemLeft}>
|
|
|
+ <div class={styles.subjectName}>长笛</div>
|
|
|
+ <div class={styles.subjectType}>声部</div>
|
|
|
+ </div>
|
|
|
+ <div class={styles.listitems}>
|
|
|
+ <div class={styles.item}>
|
|
|
+ <div class={styles.itemNum}>
|
|
|
+ <span style={{ color: colors[0].color }}>348</span>
|
|
|
+ </div>
|
|
|
+ <div class={styles.itemTitle}>达标率</div>
|
|
|
+ </div>
|
|
|
+ <div class={styles.item}>
|
|
|
+ <div class={styles.itemNum}>
|
|
|
+ <span style={{ color: colors[1].color }}>348</span>
|
|
|
+ </div>
|
|
|
+ <div class={styles.itemTitle}>达标人数</div>
|
|
|
+ </div>
|
|
|
+ <div class={styles.item}>
|
|
|
+ <div class={styles.itemNum}>
|
|
|
+ <span style={{ color: colors[2].color }}>348</span>
|
|
|
+ </div>
|
|
|
+ <div class={styles.itemTitle}>未达标人数</div>
|
|
|
+ </div>
|
|
|
+ <div class={styles.item}>
|
|
|
+ <div class={styles.itemNum}>
|
|
|
+ <span style={{ color: colors[3].color }}>348</span>
|
|
|
+ </div>
|
|
|
+ <div class={styles.itemTitle}>非会员人数</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ ))}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
+})
|