You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							185 lines
						
					
					
						
							6.6 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							185 lines
						
					
					
						
							6.6 KiB
						
					
					
				
								import * as echarts from '../../../../ec-canvas/echarts';
							 | 
						|
								import {dwdEventReport, event12345Group} from "../../../../utils/statisticsApi";
							 | 
						|
								
							 | 
						|
								var chart;
							 | 
						|
								
							 | 
						|
								function initChart(canvas, width, height, dpr) {
							 | 
						|
								    chart = echarts.init(canvas, null, {
							 | 
						|
								        width: width,
							 | 
						|
								        height: height,
							 | 
						|
								        devicePixelRatio: dpr // 像素比
							 | 
						|
								    });
							 | 
						|
								    canvas.setChart(chart);
							 | 
						|
								
							 | 
						|
								
							 | 
						|
								    return chart;
							 | 
						|
								}
							 | 
						|
								
							 | 
						|
								const formatTime = date => {
							 | 
						|
								    const year = date.getFullYear()
							 | 
						|
								    const month = date.getMonth() + 1
							 | 
						|
								    const day = date.getDate()
							 | 
						|
								    return [year, month, day].map(formatNumber).join('-')
							 | 
						|
								}
							 | 
						|
								const formatNumber = n => {
							 | 
						|
								    n = n.toString()
							 | 
						|
								    return n[1] ? n : '0' + n
							 | 
						|
								}
							 | 
						|
								Component({
							 | 
						|
								    properties: {
							 | 
						|
								        typeCondition: {
							 | 
						|
								            type: Number,
							 | 
						|
								            value: 0,
							 | 
						|
								            observer(val) {
							 | 
						|
								                console.log(val, 11)
							 | 
						|
								                this.getData()
							 | 
						|
								            }
							 | 
						|
								        }
							 | 
						|
								    },
							 | 
						|
								    data: {
							 | 
						|
								        ec: {
							 | 
						|
								            lazyLoad: true
							 | 
						|
								            // onInit: initChart
							 | 
						|
								        },
							 | 
						|
								        tabList: [{
							 | 
						|
								            label: "问题突出类别",
							 | 
						|
								            value: 1
							 | 
						|
								        }, {
							 | 
						|
								            label: '行业领域分析',
							 | 
						|
								            value: 2
							 | 
						|
								        }],
							 | 
						|
								        tabValue: 1
							 | 
						|
								    },
							 | 
						|
								    lifetimes: {
							 | 
						|
								        ready() {
							 | 
						|
								            this.getData()
							 | 
						|
								        }
							 | 
						|
								    },
							 | 
						|
								    methods: {
							 | 
						|
								        tabChange({detail}) {
							 | 
						|
								            this.setData({
							 | 
						|
								                tabValue: this.data.tabList[detail].value
							 | 
						|
								            })
							 | 
						|
								            this.getData()
							 | 
						|
								        },
							 | 
						|
								        getData() {
							 | 
						|
								            this.selectComponent('#hotlineComplaints').init((canvas, width, height, dpr) => {
							 | 
						|
								                chart = echarts.init(canvas, null, {
							 | 
						|
								                    width: width,
							 | 
						|
								                    height: height,
							 | 
						|
								                    devicePixelRatio: dpr // 像素比
							 | 
						|
								                });
							 | 
						|
								                canvas.setChart(chart);
							 | 
						|
								
							 | 
						|
								                let params = {
							 | 
						|
								                    startTime: '',
							 | 
						|
								                    endTime: ''
							 | 
						|
								                }
							 | 
						|
								                let now = new Date();
							 | 
						|
								                if (this.data.typeCondition === 0) {
							 | 
						|
								                    params.startTime = formatTime(new Date(now.getFullYear(), now.getMonth(), 1))
							 | 
						|
								                }
							 | 
						|
								                if (this.data.typeCondition === 1) {
							 | 
						|
								                    params.startTime = formatTime(new Date(now.getFullYear(), now.getMonth() - 1));
							 | 
						|
								                }
							 | 
						|
								                if (this.data.typeCondition === 2) {
							 | 
						|
								                    params.startTime = formatTime(new Date(now.getFullYear(), now.getMonth() - 2));
							 | 
						|
								                }
							 | 
						|
								                if (this.data.typeCondition === 3) {
							 | 
						|
								                    params.startTime = formatTime(new Date(now.getFullYear(), now.getMonth() - 5));
							 | 
						|
								                }
							 | 
						|
								                if (this.data.typeCondition === 4) {
							 | 
						|
								                    params.startTime = formatTime(new Date(now.getFullYear(), now.getMonth() - 11));
							 | 
						|
								                }
							 | 
						|
								
							 | 
						|
								                if (this.data.typeCondition === 1) {
							 | 
						|
								                    params.endTime = formatTime(new Date(now.getFullYear(), now.getMonth(), 0, 23, 59, 59))
							 | 
						|
								                } else {
							 | 
						|
								                    params.endTime = formatTime(new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59))
							 | 
						|
								                }
							 | 
						|
								                dwdEventReport(params).then(({data}) => {
							 | 
						|
								                    console.log(this.tabValue,'this.tabValue')
							 | 
						|
								                    if(this.data.tabValue === 2) {
							 | 
						|
								                        let arr = []
							 | 
						|
								                        for(let i in data.categoryCount) {
							 | 
						|
								                            arr.push(data.categoryCount[i])
							 | 
						|
								                        }
							 | 
						|
								                        data = arr.map(item => {
							 | 
						|
								                            return {
							 | 
						|
								                                name: item.name,
							 | 
						|
								                                value: item.count
							 | 
						|
								                            }
							 | 
						|
								                        });
							 | 
						|
								                    } else {
							 | 
						|
								                        let arr = []
							 | 
						|
								                        for(let i in data.subCategoryCount) {
							 | 
						|
								                            arr.push(data.subCategoryCount[i])
							 | 
						|
								                        }
							 | 
						|
								                        data = arr.map(item => {
							 | 
						|
								                            return {
							 | 
						|
								                                name: item.name,
							 | 
						|
								                                value: item.count
							 | 
						|
								                            }
							 | 
						|
								                        });
							 | 
						|
								                    }
							 | 
						|
								
							 | 
						|
								
							 | 
						|
								                    let color = ["#4F94FF", "#A182FB", "#27D1A7", "#FCBF06", "#FF7108"]
							 | 
						|
								
							 | 
						|
								                    var option = {
							 | 
						|
								                        color,
							 | 
						|
								                        tooltip: {
							 | 
						|
								                            show: true,
							 | 
						|
								                            textStyle: {
							 | 
						|
								                                color: '#000',
							 | 
						|
								                                fontSize: 14
							 | 
						|
								                            },
							 | 
						|
								                            formatter(params) {
							 | 
						|
								                                // console.log(params)
							 | 
						|
								                                if (params.name === '') {
							 | 
						|
								                                    return '';
							 | 
						|
								                                }
							 | 
						|
								                                return `${params.name} : ${params.percent}%`;
							 | 
						|
								                            },
							 | 
						|
								                        },
							 | 
						|
								                        series: [
							 | 
						|
								                            {
							 | 
						|
								                                name: '',
							 | 
						|
								                                type: 'pie',
							 | 
						|
								                                radius: ['40%', '70%'],
							 | 
						|
								                                center: ['50%', '50%'], // 修改为居中
							 | 
						|
								                                avoidLabelOverlap: true,
							 | 
						|
								                                label: {
							 | 
						|
								                                    color: '#333333',
							 | 
						|
								                                    alignTo: 'labelLine',
							 | 
						|
								                                    formatter: '{num|{c}}\n{name|{b}}',
							 | 
						|
								                                    minMargin: 5,
							 | 
						|
								                                    edgeDistance: 10,
							 | 
						|
								                                    lineHeight: 15,
							 | 
						|
								                                    rich: {
							 | 
						|
								                                        num: {
							 | 
						|
								                                            fontSize: 17,
							 | 
						|
								                                            color: '#333333'
							 | 
						|
								                                        },
							 | 
						|
								                                        zb: {
							 | 
						|
								                                            fontSize: 14,
							 | 
						|
								                                            color: '#333333'
							 | 
						|
								                                        }
							 | 
						|
								                                    }
							 | 
						|
								                                },
							 | 
						|
								                                labelLine: {
							 | 
						|
								                                    length: 15,
							 | 
						|
								                                    length2: 0,
							 | 
						|
								                                    maxSurfaceAngle: 80
							 | 
						|
								                                },
							 | 
						|
								                                data: data
							 | 
						|
								                            }
							 | 
						|
								                        ]
							 | 
						|
								                    };
							 | 
						|
								                    chart.setOption(option);
							 | 
						|
								                })
							 | 
						|
								                return chart;
							 | 
						|
								            });
							 | 
						|
								        }
							 | 
						|
								    }
							 | 
						|
								});
							 | 
						|
								
							 |