<template> <div class="app-container"> <div class="chart-container"> <div class="chart-body"> <ve-histogram :loading="loading" :data="chartData" :settings="chartSettings" :extend="extend" :data-empty="dataEmpty"/> </div> </div> </div> </template> <script> import selectTree from '@/components/SelectTree/singleSelect' import { statisticsByDepartment } from '@/api/assessResult' import { getDeptList } from '@/api/assessRules' export default { name: 'HistogramDeptStatistics', components: { selectTree }, data() { return { chartSettings: { axisSite: { right: ['value2'] }, yAxisType: ['number', 'percent'], yAxisName: ['分数', '权重'], labelMap: { 'text': '权属单位', 'value': '分数', 'value2': '权重' }, type: '' }, extend: { series: { label: { show: true, position: 'top' }, itemStyle: { normal: { barBorderRadius: [3, 3, 0, 0] } }, barMaxWidth: 30 }, xAxis: { axisLabel: { // rotate: 25 // 代表逆时针旋转45度 } } }, listQuery: { deptId: '', startTime: '', endTime: '' }, deptList: [], title: '', deptName: '', deptId: '', dateRange: [], deviceTypeList: [], showDeviceType: true, chartData: { columns: ['text', 'value', 'value2'], rows: [] }, dataEmpty: false, loading: true, chartType: '饼图' } }, mounted() { this.fetchDeptList() this.fetchData() }, methods: { // 查询数据 search() { this.fetchData() }, // 获取数据 fetchData() { this.listLoading = true this.listQuery.deptId = this.deptId this.listQuery.startTime = this.dateRange[0] this.listQuery.endTime = this.dateRange[1] statisticsByDepartment(this.listQuery).then(response => { this.title = this.deptName + '指标考核情况统计图' this.chartData.rows = response.data this.listLoading = false }) }, fetchDeptList() { getDeptList('24').then(response => { this.deptList = response.data this.deptId = this.deptList[0].id this.deptName = this.deptList[0].simplename this.title = this.deptName + '指标考核情况统计图' this.listQuery.deptId = this.deptId // if (this.deptList) { // this.listQuery.dept = this.deptList[0].id // getDeptList(this.listQuery.dept).then(response => { // this.subDeptList = response.data // }) // } }) }, changeType() { if (this.chartType === '饼图') { this.chartType = '柱状图' this.chartSettings.type = 'pie' } else if (this.chartType === '柱状图') { this.chartType = '饼图' this.chartSettings.type = 'histogram' } }, order() { }, changeDept(item) { this.deptName = item.label } } } </script> <style rel="stylesheet/scss" lang="scss" scoped> .app-container{ padding: 10px; } $tableTitleHeight:46px; .table{ margin-bottom: 20px; } .chart-title{ text-align: center; font-size:19px; font-weight:600; margin-top: 40px } .pagination-container{ margin-bottom: 50px; } .table-title{ background-color:rgba(243, 243, 243, 1); height: $tableTitleHeight; .title-header{ line-height:$tableTitleHeight; color: #606266; font-size: 15px; i{ margin-left: 5px; margin-right: 5px; } } } .edit_btns{ .edit_btn{ float:right; margin:7px 3px;//为了需要居中显示margin-top和bottom要用$tableTitleHeight减去按钮原高度除以2 } } .warning-state{ color:red } </style>