liuxiaolong
2019-05-06 2ab7a76a38fbf8fa107bf6371f5410ba54e1d394
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
157
158
159
160
161
162
163
<template>
  <b-card no-body class="p-4 border-0" style="height: 100%;">
    <h5 class="mb-0">
      当日签到
    </h5>
    <div style="height:80%"><vue-echart :options="pieOptions" :theme="polarTheme" :auto-resize="true"></vue-echart></div>
    <!-- <vue-echart :options="pieOptions" :theme="polarTheme" :auto-resize="true"></vue-echart> -->
    <!-- <vue-echart :options="barOptions" :auto-resize="true"></vue-echart> -->
    <div><div style="float:left">迟到 5人:</div><b-progress variant="success" :value="5/8*100" style="margin-top:5px" height="0.75rem" /></div>
    <div><div style="float:left">早退 3人:</div><b-progress variant="info" :value="3/8*100" style="margin-top:5px" height="0.75rem" /></div>
  </b-card>
</template>
<style>
.echarts {
  height: 100% !important;
  width: 100% !important;
}
</style>
<script>
import ECharts from 'vue-echarts/components/ECharts.vue'
import 'echarts/lib/chart/pie'
import 'echarts/theme/shine'
import { getTeacherSignCountData } from '@/server/home.js'
 
export default {
  name: 'HomePieChart',
  props: {},
  data() {
    return {
      userInfo: this.$store.getters.basicUserInfo,
      /* 图表 */
      // pieOptions: pieOption,
      polarTheme: 'shine',
      mapList: [],
      tabMap: '',
      /* 地图组件使用 */
      mapInfo: null,
      deviceArr: [],
      deviceInfo: null,
      mapDeviceType: [],
      pieOptions: {
        tooltip: {
          trigger: 'item',
          formatter: '{a} <br/>{b}: {c} ({d}%)'
        },
        title: {},
        legend: {
        },
        series: [
          {
            name: '签到统计',
            type: 'pie',
            radius: ['50%', '80%'],
            center: ['50%', '55%'],
            avoidLabelOverlap: false,
            label: {
              normal: {
                show: false,
                position: 'center'
              },
              emphasis: {
                show: false,
                textStyle: {
                  fontSize: '15',
                  fontWeight: 'bold'
                }
              }
            },
            labelLine: {
              normal: {
                show: false
              }
            },
            data: [
            ]
          }
        ]
      }
 
    }
  },
  methods: {
    /* 查询图表数据 */
    async getTeacherSignCountData() {
      let res = await getTeacherSignCountData({
        orgId: this.userInfo.orgId,
        type: 'teacher',
        signDate: this.$moment().format('YYYY-MM-DD')
      })
      if (
        res &&
        !isNaN(parseInt(res.unsigned)) &&
        !isNaN(parseInt(res.signed))
      ) {
        const countNum = parseInt(res.unsigned) + parseInt(res.signed)
        this.pieOptions.series[0].data = [
          { value: 50, name: '未签到', countNum },
          { value: 12, name: '已签到', countNum }
        ]
      }
      this.pieOptions.title = {
        text: '总/62',
        top: '48%',
        left: '44%',
        textStyle: {fontSize: '14'}
      }
 
      this.pieOptions.legend = {
        bottom: 10,
        top: '0px',
        data: [{name: '未签到', icon: 'circle'}, {name: '已签到', icon: 'circle'}]
      }
    }
  },
  created() {
    this.getTeacherSignCountData()
  },
  components: {
    'vue-echart': ECharts
  }
}
</script>
 
<style lang="scss" scoped>
.btn-content {
  display: flex;
  justify-content: flex-end;
}
.alarm-box {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 9;
  .badge-default {
    background: #ccc;
  }
}
div,
ul,
li,
img,
span,
a,
p {
  /* 抑制选中 */
  -moz-user-select: none;
  -webkit-user-select: none;
  user-select: none;
}
.mapDeviceType-box {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 9;
  background: rgba(255, 255, 255, 0.8);
}
.mapDeviceType-box .mapDeviceType-item {
  /* .icon{} */
  .content {
    line-height: 20px;
  }
}
</style>