Skip to content
b-overview.component.ts 5.83 KiB
Newer Older
wangqinghua's avatar
wangqinghua committed
import {Component, OnInit, ViewChild} from '@angular/core';
wangqinghua's avatar
wangqinghua committed
import {BusinessService} from '../business.service';
import {NzMessageService} from 'ng-zorro-antd';
import {color} from '../../app.constants';
wangqinghua's avatar
wangqinghua committed
import {WorkReportComponent} from '../modal/work-report/work-report.component';
wangqinghua's avatar
wangqinghua committed

@Component({
wangqinghua's avatar
wangqinghua committed
    selector: 'smart-b-overview',
    templateUrl: './b-overview.component.html',
wangqinghua's avatar
wangqinghua committed
    styles: [
wangqinghua's avatar
wangqinghua committed
        `            
wangqinghua's avatar
wangqinghua committed
            p{
                margin: 0;
            }
wangqinghua's avatar
wangqinghua committed
            .flex-center {
                display: flex;
                justify-content: center;
                align-items: center
            }
            .flex-item > p{
                margin: 10px 0;
            }

            .leftDiv {
                padding-right: 10px
            }

            .leftDiv-container {
                border: 1px solid #ddd;
            }

            .rightDiv {
                border: 1px solid #ddd;
                padding: 10px !important;
            }

            .rightDiv > p {
wangqinghua's avatar
wangqinghua committed
                padding: 10px;
wangqinghua's avatar
wangqinghua committed
            }

            .rightDiv > p > span {
wangqinghua's avatar
wangqinghua committed
                float: right;
wangqinghua's avatar
wangqinghua committed
            }
            .main-color-font {
                color: #6097b7;
                font-size: 20px
            }
            .follow {
                padding: 5px;
                position: relative;
            }

            .follow-container {
                border: 1px solid #ddd;
            }

            .follow-title {
                border-bottom: 1px solid #ddd;
                padding: 10px 5px;
                background-color: #eee;
            }

            .height-150 {
                height: 150px;
            }

            .container-top {
                height: 75px;
                padding: 10px;
                border-bottom: 1px solid #dddddd;
                border-right: 1px solid #dddddd;
            }

            .container-bottom {
                height: 75px;
                padding: 10px;
                display: flex;
                align-items: center;
                border-bottom: 1px solid #dddddd;
                border-right: 1px solid #dddddd;
            }
            .margin-0-10{
                margin: 0 10px;
            }
            .calcle-follow{
                position: absolute;
                top: 15px;
                right: 15px;
            }
            .chart-font{
wangqinghua's avatar
wangqinghua committed
                padding-left: 20px;
wangqinghua's avatar
wangqinghua committed
                font-size: 12px;
                position: absolute;
                top: 50%;
                right: 5%;
                transform: translate(10%,-50%);
            }
            :host ::ng-deep  .ant-tag{
                height: 16px;
                vertical-align: middle;
            }
        `
    ]
wangqinghua's avatar
wangqinghua committed
})
export class BOverviewComponent implements OnInit {
wangqinghua's avatar
wangqinghua committed
    @ViewChild('smartWorkReport') smartWorkReport: WorkReportComponent;
wangqinghua's avatar
wangqinghua committed

wangqinghua's avatar
wangqinghua committed
    color = color;
    list;
wangqinghua's avatar
wangqinghua committed

wangqinghua's avatar
wangqinghua committed
    constructor(private busineSer: BusinessService, private message: NzMessageService) {
    }
wangqinghua's avatar
wangqinghua committed

wangqinghua's avatar
wangqinghua committed
    ngOnInit() {
        this.getList();
    }

    getList() {
        this.busineSer.itserviceOverview().subscribe(
            (res) => {
                if (res.errCode == 10000) {
                    this.list = res.data;
wangqinghua's avatar
wangqinghua committed
                    this.echartView();
wangqinghua's avatar
wangqinghua committed
                } else {
                    this.message.error(res.errMsg);
                }
            }
        );
    }

wangqinghua's avatar
wangqinghua committed
    echartView(){
        this.list.forEach(e=>{
            e.available = e.available.split("%")[0];
            e.optionLeft = {
                tooltip: {
                    trigger: 'item',
                    formatter: "{a} <br/>{b}: {c} ({d}%)"
                },
                series: [
                    {
                        name:'可用性',
                        type:'pie',
                        radius: ['50%', '70%'],
                        avoidLabelOverlap: false,
                        label: {
                            normal: {
                                show: true,
                                position: 'center'
                            },
                        },
                        color:['#80ba78','#dddddd'],
                        labelLine: {
                            normal: {
                                show: false
                            }
                        },
                        data:[
                            {
                                value:e.available,
                                name:'可用性',
                            },
                            {
                                value:100 - e.available,
                                name:'',
                            }
                        ]
                    }
                ]
            };
            e.optionRight = {
                tooltip: {
                    trigger: 'item',
                    formatter: "{a} <br/>{b}: {c} ({d}%)"
                },
                color:['#5dd2d2','#dddddd'],
                series: [
                    {
                        name:'重要用户',
                        type:'pie',
                        radius: ['50%', '70%'],
                        avoidLabelOverlap: false,
                        label: {
                            normal: {
                                show: true,
                                position: 'center'
                            },
                        },
                        labelLine: {
                            normal: {
                                show: false
                            }
                        },
                        data:[
                            {value:e.available, name:'重要用户'},
                            {value:100 - e.available, name:''}
                        ]
                    }
                ]
            };
        })
    }

wangqinghua's avatar
wangqinghua committed
    // 查看运行报告
    reportDetail(item){
        this.smartWorkReport.showModal(item);
    }
wangqinghua's avatar
wangqinghua committed

}