leftBar.vue 11 KB
Newer Older
纪泽龙's avatar
纪泽龙 committed
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 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 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322
<template>
  <div> 
    <div class="left-top" style="margin-top: 70px;width: 430px;margin-left: 10px;display: flex;justify-content: space-around;">
      <div style="width: 40%;text-align: center;color: #00ffff;">
        <p>从业人员数</p>
        <span style="font-family: 'arialbd';font-size: 30px;background-image:-webkit-linear-gradient(bottom,#f0c41b,#e4dbb7);-webkit-background-clip:text;-webkit-text-fill-color:transparent;  ">{{datanow.congyeNum}}</span>
      </div>
      <div style="width: 40%;text-align: center;color: #00ffff;">
        <p>管道长度(m)</p>
        <span style="font-family: 'arialbd';font-size: 30px;background-image:-webkit-linear-gradient(bottom,#f86742,#f0c41b);-webkit-background-clip:text;-webkit-text-fill-color:transparent;  ">{{datanow.guandaoNum}}</span>
      </div>
    </div>
    
    <div>
      <div class="item1" style="margin-top: 40px;">
        <span class="dot">
          <span class="dot-inner"></span>
        </span>
        <span>安全监管</span>
        <div class="fong-div" style="width: 8px;height: 12px;background-color: #2c888899;float: right;margin-top: 10px;transform: skewX(-25deg)"></div> 
        <div class="fong-div" style="width: 8px;height: 12px;background-color: #24b1b1b3;float: right;margin-top: 10px;margin-right: 10px;transform: skewX(-25deg)"></div> 
        <div class="fong-div" style="width: 8px;height: 12px;background-color: #11e9e9b3;float: right;margin-top: 10px;margin-right: 10px;transform: skewX(-25deg)"></div> 
      </div>
  </div>
  <div id="main1" style="width: 100%;height: 280px;"></div>
    <div class="echarts-two" style="margin-top: 30px;width: 430px;margin-left: 10px;">
      <div>
        <div class="item1">
          <span class="dot">
            <span class="dot-inner"></span>
          </span>
          <span>任务完成率</span>
          <div class="fong-div" style="width: 8px;height: 12px;background-color: #2c888899;float: right;margin-top: 10px;transform: skewX(-25deg)"></div> 
          <div class="fong-div" style="width: 8px;height: 12px;background-color: #24b1b1b3;float: right;margin-top: 10px;margin-right: 10px;transform: skewX(-25deg)"></div> 
          <div class="fong-div" style="width: 8px;height: 12px;background-color: #11e9e9b3;float: right;margin-top: 10px;margin-right: 10px;transform: skewX(-25deg)"></div> 
        </div>
      </div>
      <div id="myCharttwo" :style="{width: '450px', height: '300px'}"></div>
      <div class="titleTex" style="height: 20px;margin-top: 0px;font-size: 15px;">
        ● 已完成数量:{{datanow.renwu[1]}}
      </div>
      <div class="titleTex" style="height: 20px;margin-top: 0px;font-size: 15px;color: #0099ff">
        ● 未成数量:{{datanow.renwu[0]}}
      </div>
    </div>
  </div>
</template>

<script>
  // 引入基本模板
  let echarts = require('echarts/lib/echarts')
  // 引入柱状图组件
  require('echarts/lib/chart/bar')
  // 引入提示框和title组件
  require('echarts/lib/component/tooltip')
  require('echarts/lib/component/title')
  export default {
    data () {
      return {
          dataAll:{
              congyeNum:1544,
              guandaoNum:3658495,
              shigu1:[820, 932, 901, 934, 1290, 1330, 1320,820, 932, 901, 934, 1290],
              shigu2:[452, 786, 456, 732, 458, 165, 198,489, 158, 358, 345, 675],
              shigu3:[ 932, 901, 198,489, 158, 358, 345, 675,  901, 934, 1290, 888],
              renwu:[50,92],
              renwuzong:142
          },
          dataone:{
              congyeNum:521,
              guandaoNum:1254848,
              shigu1:[223, 44, 332, 321, 458, 456, 653,122, 345, 133, 421, 123],
              shigu2:[123, 234, 456, 567, 235, 12,89, 158, 158, 145, 175,224],
              shigu3:[ 432, 301, 108,189, 18, 158, 145, 175,  401, 334, 590, 388],
              renwu:[4,27],
              renwuzong:31
          },
          datatwo:{
              congyeNum:488,
              guandaoNum:1244495,
              shigu1:[653,122, 345, 133, 456, 653,122, 345, 133, 421, 123,500],
              shigu2:[432, 301, 456, 567, 235, 12, 145, 175,  401, 334, 590, 388],
              shigu3:[ 123, 234, 108,189, 18, 158, 123, 234, 456, 567, 235, 12],
              renwu:[8,25],
              renwuzong:33
          },
          datathree:{
              congyeNum:535,
              guandaoNum:1189492,
              shigu1:[653,122, 345, 133, 456, 653,122, 345, 133, 421, 123,500],
              shigu2:[432, 301, 456, 567, 456, 653,122, 175,  401, 334, 590, 388],
              shigu3:[ 334, 590, 388, 133, 456, 123, 234, 653,122, 345, 133],
              renwu:[38,40],
              renwuzong:78
          },
          datanow:{
              renwu:[0,0]
          }
      };
     },
     mounted(){
        this.datanow = this.dataAll;
        this.drawLine(this.datanow);
        this.initdata(this.datanow);
      },
    methods: {
        choice(index){
            console.log("-----"+index)
            if(index==0){
                this.datanow = this.dataAll;
                this.drawLine(this.datanow);
                this.initdata(this.datanow);
            }else
            if(index==1){
                this.datanow = this.dataone;
                this.drawLine(this.datanow);
                this.initdata(this.datanow);
            }else if(index==2){
                this.datanow = this.datatwo;
                this.drawLine(this.datanow);
                this.initdata(this.datanow);
            }else if(index==3){
                this.datanow = this.datathree;
                this.drawLine(this.datanow);
                this.initdata(this.datanow);
            }
        },
      drawLine(data){
                // 基于准备好的dom,初始化echarts实例
                let myChart = echarts.init(document.getElementById('main1'))
                // 绘制图表
                myChart.setOption({
                    legend: {
                        top:20,
                        textStyle:{
                            color:"#fff"
                        },
                    },
                    
                    grid: {  
                            left: '5%',  
                            right: '7%',  
                            bottom: '4%', 
                            containLabel: true  
                        },
                    xAxis: {
                        axisLine: {
                            show: true,
                            lineStyle: {
                                color: '#bbb6b6',
                            },
                        },
                        axisTick: {           //去掉坐标轴刻线
                            show: false
                        },
                        type: 'category',
                        data: ['1', '2', '3', '4', '5', '6', '7','8', '9', '10', '11', '12']
                    },
                    yAxis: {
                        axisLine: {
                            show: true,
                            lineStyle: {
                                color: '#bbb6b6'
                            },
                        },
                        splitLine: {
                            show:true,
                            lineStyle:{
                                type:"dashed",
                                color: '#bbb6b6',
                            }
                        },
                        type: 'value'
                    },
                    series: [
                        {
                            name:"事故数量",
                            data: data.shigu1,
                            type: 'line',
                            smooth: true
                        },
                        {
                            data: data.shigu2,
                            type: 'line',
                            smooth: true,
                            name:"隐患整治数"
                        },
                        {
                            data: data.shigu3,
                            type: 'line',
                            smooth: true,
                            name:"预警数量"
                        }
                    ]
                });
            },
      initdata(data){
          // 基于准备好的dom,初始化echarts实例
          //console.log(data.renwu[0]+"=-=-=-"+data.renwu[1])
          let myChart2 = this.$echarts.init(document.getElementById('myCharttwo'))
          // 绘制图表
          myChart2.setOption({
              title: {
                  text: '任务总数量:'+data.renwuzong,
                  left: 'center',
                  top :20,
                  textStyle:{
                      color: "#00ffff"
                  }
              },
            tooltip: {
              trigger: 'item',
            },
            series: [
              {
                name: '任务概况',
                type: 'pie',
                radius: '70%',
                center: ['50%','58%'],
                data: [
                  { 
                    value: data.renwu[0],
                    name: '未完成',
                    itemStyle: { color: '#09f' }
                },
                  { 
                    value: data.renwu[1],
                      name: '已完成' ,
                    itemStyle: { color: '#00ffff' }
                  },
                ],
                  label:{
                    color:'#fff',
                      fontSize: 18
                  },
                emphasis: {
                  itemStyle: {
                    shadowBlur: 10,
                    shadowOffsetX: 0,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                  }
                }
              }
            ]
          });
      },




    }
  }
</script>

<style lang="scss" scoped>
  
/* @font-face {
  font-family: 'arialbd';
} */
.item1{
    width: 95%;
    height: 30px;
    font-size: 18px;
    line-height: 30px;
    color: #ffffff;
    padding-left: 10px;
    margin-top: 10px;
    font-weight: 700;
    font-style: italic;
    margin-left: 10px;
    background-image: linear-gradient(to left, #122033, rgb(51 152 243 / 50%) 50%, #111a22);
}
.dot {
        display: inline-block;
        position: relative;
        width: 10px;
        height: 10px;
        background: rgb(30, 185, 190);
        border-radius: 50%;
        margin-right: 10px;
        margin-left: 10px;
        margin-bottom: 2px;
    }

    .dot-inner {
        background: #44d7dc;
        position: absolute;
        top: 0;
        left: 0;
        box-sizing: border-box;
        display: block;
        width: 100%;
        height: 100%;
        border-radius: 50%;
        -webkit-animation: vabDot 1.2s ease-in-out infinite;
        animation: vabDot 1.2s ease-in-out infinite;
    }

    @-webkit-keyframes vabDot {
        0% {
            opacity: .6;
            transform: scale(.8)
        }

        to {
            opacity: 0;
            transform: scale(2.4)
        }
    }

    @keyframes vabDot {
        0% {
            opacity: .6;
            transform: scale(.8)
        }

        to {
            opacity: 0;
            transform: scale(2.4)
        }
    }
</style>