Blame view

src/components/berth/index.vue 5.69 KB
22fb20b3   songchongxian   城市停车运营监控
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
  <template>
    <div class="app-berthBox">
      <div class="theme-card">
        <div class="title"><span>泊位</span></div>
        <div class="content">
          <div class="topBox eleVerHorCenter-flex">
            <span class="eleText">总计</span>
            <div class="eleMarginLeft" v-html="berthTotal"></div>
          </div>
          <div class="bottomBox eleVerHorCenter-flex">
            <div class="bottomBoxLeft"> <div class="berthPie"></div> </div>
            <div class="bottomBoxRight">
              <table class="havefreeTb">
                <tr><td> <div class="free">{{ free }}</div></td><td>  <div class="freeText">空余</div></td></tr>
                <tr><td> <div class="have">{{ have }}</div></td><td>  <div class="haveText">占有</div></td></tr>
              </table>
            </div>
          </div>
        </div>
      </div>
    </div>
  </template>
  
  <script>
    import common from '../../api/common';
    import echarts from 'echarts'
    export default {
      name: "berth",
      data() {
        return {
          demo:'234567',//示例
          berthTotal:"",//泊位总数
          free:12345,//空余
          have:23456,//占有
          //color: this.$store.state.color,
          pieChart: {},
          name: '饼图',
          pieChartOption:{
            seriesData:[
              {name:"占有",value:6000},
              {name:"空余",value:4000}
            ]
          }
        }
      },
      mounted() {
be7e8a78   liuqimichale   泊位
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
        this.axios.post('urban/intelligence/berth/queryBerthStatisticByOrgIds',{
          orgIds: [10003,10005]
        }).then((response)=>{
          let  data = response.data.data
          console.log(data)
          this.berthTotal = common.formatNumToStr(data.allBerthNum)
          this.free = data.freeBerthNum
          this.have = data.isOccupyBertnNum
  
          this.pieChartOption.seriesData[0].value = data.isOccupyBertnNum
          this.pieChartOption.seriesData[1].value = data.freeBerthNum
          let pieChartOption = this.pieChartOption
          //占有率
          this.pieChart=this.createPie(pieChartOption);
          window.addEventListener('resize', function() {
            this.pieChart.resize()
          }.bind(this));
be7e8a78   liuqimichale   泊位
64
65
66
        }).catch((response)=>{
          console.log(response);
        })
22fb20b3   songchongxian   城市停车运营监控
67
68
        //this.createLine();
        //总收入
be7e8a78   liuqimichale   泊位
69
  
22fb20b3   songchongxian   城市停车运营监控
70
71
72
73
74
75
76
77
78
79
80
      },
      methods: {
        /*
         * 格式化总泊位
         * */
        formatNumToStr:function(){
          return common.formatNumToStr(this.$options.data().demo);
        },
        /*
         * 泊位占比
         * */
be7e8a78   liuqimichale   泊位
81
        createPie(pieChartOption){
22fb20b3   songchongxian   城市停车运营监控
82
          //debugger;
be7e8a78   liuqimichale   泊位
83
          let root=pieChartOption;
22fb20b3   songchongxian   城市停车运营监控
84
85
86
          let pieChart = echarts.init(document.querySelector('.app-berthBox .berthPie'));
          //占有率
          let zyPercent= (root.seriesData[0].value / (root.seriesData[0].value + root.seriesData[1].value));//注意顺序!!!
be7e8a78   liuqimichale   泊位
87
          console.log(zyPercent)
22fb20b3   songchongxian   城市停车运营监控
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
          let seriesData=root.seriesData;
          const option={
  //          grid: {
  //            top: '0%',left: '0%',
  //            right: '0%',bottom: '0%'
  //          },
            grid: {
              top: 13,left: 10,
              right: 10,bottom: 10,
              containLabel: true
            },
            title: { show:false },
            tooltip: {show:false},
            series: [{
              name: 'pie',type: 'pie',
              center: ['50%', '50%'],
              radius: ['75%', '90%'],
              hoverAnimation: false,
              color: ['#FFB704','#02ABFF'],//占有黄色
              label: {show:false},
              itemStyle: {
                normal: {
                  label: {show: false},
                  labelLine: {show: false},
                  shadowBlur: 40,
                  shadowColor: 'rgba(40, 40, 40,0.5)',
                }
              },
              data: seriesData
            },
            //内环
              {
                name: '', type: 'pie',
                clockWise: true,hoverAnimation: false,
                radius: ['90%', '90%'],
                label: { normal: { position: 'center' }},
                data: [{
                  value: 0,
                  label: {
                    normal: {
be7e8a78   liuqimichale   泊位
128
                      formatter: (zyPercent*100).toFixed(1) + '%',//小数点后一位
22fb20b3   songchongxian   城市停车运营监控
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
                      textStyle: {
                        color: '#fe8b53',
                        fontSize: 18,
                        fontWeight: 'normal'
                      }
                    }
                  }
                }, {
                  tooltip: {show: false},
                  label: {
                    normal: {
                      formatter: '\n占有',
                      textStyle: {
                        color: '#bbeaf9',fontSize: 12
                      }
                    }
                  }
                }]
              }
            ]
          };
          pieChart.setOption(option);
          return pieChart;
        }
      },
  
    }
  </script>
  
  <style scoped  lang="scss">
    .app-berthBox {
      width: 100%;
    .theme-card{
      height: 100%;
    }
    .berthPie{
      position: absolute;
      margin: 0 auto;
      top:0;
      bottom: 0;
      left:0;
      width: 100%;
      height: 100%;
    }
    .bottomBoxLeft,.bottomBoxRight{
      display: inline-block;
      width: 50%;
      height:100%;
      border:0px solid red;
      position: relative;
    }
    .havefreeTb{
      height:100%;width: 100%;
    }
    .havefreeTb td{
      text-align: center;
      vertical-align: middle;
    }
    .havefreeTb >tr> td:last-child{
      font-size: 12px;text-align: left;
    }
    /*空余*/
    .havefreeTb .free{
      background-image: -webkit-linear-gradient(bottom, #00CAFE, #2772F4);
      -webkit-background-clip:text;
      -webkit-text-fill-color:transparent;
      font-size: 24px;
    }
    /*占有*/
    .havefreeTb .have{
      background-image: -webkit-linear-gradient(bottom, #FFBA00, #FF8100);
      -webkit-background-clip:text;
      -webkit-text-fill-color:transparent;
      font-size: 24px;
    }
    .freeText,.haveText{
      margin-top:5px;
    }
    }
  </style>