| | |
| | | </template> |
| | | |
| | | <script> |
| | | import * as echarts from 'echarts' |
| | | import { getInParkUserData, getRataList, getReportList, reportExportExcel } from '@/api/business' |
| | | export default { |
| | | data() { |
| | | return { |
| | | info: null, |
| | | isGroupBy: 0, |
| | | radio: 'month', |
| | | value: '', |
| | | dateType: 'month', |
| | | date: '', |
| | | date1: '', |
| | | import * as echarts from 'echarts' |
| | | import { getInParkUserData, getRataList, getReportList, reportExportExcel } from '@/api/business' |
| | | export default { |
| | | data () { |
| | | return { |
| | | info: null, |
| | | isGroupBy: 0, |
| | | radio: 'month', |
| | | value: '', |
| | | dateType: 'month', |
| | | date: '', |
| | | date1: '', |
| | | |
| | | listZB: [], |
| | | column: [], |
| | | list: [] |
| | | } |
| | | }, |
| | | mounted() { |
| | | var now = new Date(); |
| | | var year = now.getFullYear(); |
| | | var month = now.getMonth() + 1 > 9 ? now.getMonth() + 1 : `0${now.getMonth() + 1}`; |
| | | this.value = `${year}-${month}` |
| | | this.date1 = `${year}-${month}` |
| | | listZB: [], |
| | | column: [], |
| | | list: [] |
| | | } |
| | | }, |
| | | mounted () { |
| | | var now = new Date() |
| | | var year = now.getFullYear() |
| | | var month = now.getMonth() + 1 > 9 ? now.getMonth() + 1 : `0${now.getMonth() + 1}` |
| | | this.value = `${year}-${month}` |
| | | this.date1 = `${year}-${month}` |
| | | |
| | | this.getData() |
| | | this.getRataLists() |
| | | this.getReportLists() |
| | | }, |
| | | methods: { |
| | | // 导出 |
| | | daochu () { |
| | | reportExportExcel({ dateStr: this.date1, isGroupBy: this.isGroupBy, type: 1 }).then(res => { |
| | | this.download(res) |
| | | }) |
| | | }, |
| | | methods: { |
| | | // 导出 |
| | | daochu() { |
| | | reportExportExcel({ dateStr: this.date1, isGroupBy: this.isGroupBy, type: 1 }).then(res => { |
| | | this.download(res) |
| | | changeBB () { |
| | | if (this.radio === 'month') { |
| | | const now = new Date() |
| | | const year = now.getFullYear() |
| | | const month = now.getMonth() + 1 > 9 ? now.getMonth() + 1 : `0${now.getMonth() + 1}` |
| | | this.date1 = `${year}-${month}` |
| | | } else { |
| | | const now = new Date() |
| | | const year = now.getFullYear() |
| | | this.date1 = `${year}` |
| | | } |
| | | this.getReportLists() |
| | | }, |
| | | // 入园车辆统计表 |
| | | getReportLists () { |
| | | getReportList({ dateStr: this.date1, isGroupBy: this.isGroupBy, type: 1 }) |
| | | .then(res => { |
| | | if (!res || res.length === 0) { |
| | | this.column = [] |
| | | this.list = [] |
| | | return |
| | | } |
| | | this.column = res[0] |
| | | this.list = res.slice(1).map(row => { |
| | | const obj = {} |
| | | this.column.forEach((header, index) => { |
| | | obj[header] = row[index] |
| | | }) |
| | | return obj |
| | | }) |
| | | // if (res.length === 0) { |
| | | // this.column = [] |
| | | // this.list = [] |
| | | // return |
| | | // } |
| | | // |
| | | // this.column = res[0] |
| | | // this.list = res.slice(1, res.length); |
| | | }) |
| | | }, |
| | | changeBB() { |
| | | if (this.radio === 'month') { |
| | | let now = new Date(); |
| | | let year = now.getFullYear(); |
| | | let month = now.getMonth() + 1 > 9 ? now.getMonth() + 1 : `0${now.getMonth() + 1}`; |
| | | this.date1 = `${year}-${month}` |
| | | } else { |
| | | let now = new Date(); |
| | | let year = now.getFullYear(); |
| | | this.date1 = `${year}` |
| | | } |
| | | this.getReportLists() |
| | | }, |
| | | // 入园车辆统计表 |
| | | getReportLists() { |
| | | getReportList({ dateStr: this.date1, isGroupBy: this.isGroupBy, type: 1 }) |
| | | .then(res => { |
| | | if (res.length === 0) { |
| | | this.column = [] |
| | | this.list = [] |
| | | return |
| | | } |
| | | |
| | | this.column = res[0] |
| | | |
| | | this.list = res.slice(1).map(row => { |
| | | const obj = {}; |
| | | this.column.forEach((header, index) => { |
| | | obj[header] = row[index]; |
| | | }); |
| | | return obj; |
| | | }); |
| | | |
| | | // if (res.length === 0) { |
| | | // this.column = [] |
| | | // this.list = [] |
| | | // return |
| | | // } |
| | | // |
| | | // this.column = res[0] |
| | | // this.list = res.slice(1, res.length); |
| | | }) |
| | | }, |
| | | changeDateType() { |
| | | if (this.dateType === 'month') { |
| | | let now = new Date(); |
| | | let year = now.getFullYear(); |
| | | let month = now.getMonth() + 1 > 9 ? now.getMonth() + 1 : `0${now.getMonth() + 1}`; |
| | | this.value = `${year}-${month}` |
| | | } else { |
| | | let now = new Date(); |
| | | let year = now.getFullYear(); |
| | | this.value = `${year}` |
| | | } |
| | | this.getRataLists() |
| | | }, |
| | | // 车辆分类统计 |
| | | getRataLists() { |
| | | getRataList({ dateStr: this.value, isGroupBy: this.isGroupBy, type: 1 }) |
| | | .then(res => { |
| | | this.listZB = res |
| | | // this.$nextTick(() => { |
| | | // this.initDept() |
| | | // }) |
| | | setTimeout(() => { |
| | | this.initDept() |
| | | }, 1000) |
| | | }) |
| | | }, |
| | | // 基础数据 |
| | | getData() { |
| | | getInParkUserData({ isGroupBy: this.isGroupBy, type: 1 }).then(res => { |
| | | this.info = res |
| | | }, |
| | | changeDateType () { |
| | | if (this.dateType === 'month') { |
| | | const now = new Date() |
| | | const year = now.getFullYear() |
| | | const month = now.getMonth() + 1 > 9 ? now.getMonth() + 1 : `0${now.getMonth() + 1}` |
| | | this.value = `${year}-${month}` |
| | | } else { |
| | | const now = new Date() |
| | | const year = now.getFullYear() |
| | | this.value = `${year}` |
| | | } |
| | | this.getRataLists() |
| | | }, |
| | | // 车辆分类统计 |
| | | getRataLists () { |
| | | getRataList({ dateStr: this.value, isGroupBy: this.isGroupBy, type: 1 }) |
| | | .then(res => { |
| | | this.listZB = res |
| | | // this.$nextTick(() => { |
| | | // this.initType() |
| | | // this.initDept() |
| | | // }) |
| | | setTimeout(() => { |
| | | this.initType() |
| | | this.initDept() |
| | | }, 1000) |
| | | }) |
| | | }, |
| | | // 全年入园车辆趋势 |
| | | initType() { |
| | | if (!this.info.cumulativeDataList) return |
| | | }, |
| | | // 基础数据 |
| | | getData () { |
| | | getInParkUserData({ isGroupBy: this.isGroupBy, type: 1 }).then(res => { |
| | | this.info = res |
| | | // this.$nextTick(() => { |
| | | // this.initType() |
| | | // }) |
| | | setTimeout(() => { |
| | | this.initType() |
| | | }, 1000) |
| | | }) |
| | | }, |
| | | // 全年入园车辆趋势 |
| | | initType () { |
| | | if (!this.info.cumulativeDataList) return |
| | | |
| | | const myChart = echarts.init(document.querySelector('.echart1')) |
| | | const myChart = echarts.init(document.querySelector('.echart1')) |
| | | |
| | | let names = this.info.cumulativeDataList.map(item => item.name) |
| | | let datas = this.info.cumulativeDataList.map(item => item.total) |
| | | const names = this.info.cumulativeDataList.map(item => item.name) |
| | | const datas = this.info.cumulativeDataList.map(item => item.total) |
| | | |
| | | let option = { |
| | | grid: { |
| | | left: '0%', |
| | | right: '5%', |
| | | bottom: '10%', |
| | | top: '10%', |
| | | containLabel: true |
| | | const option = { |
| | | grid: { |
| | | left: '0%', |
| | | right: '5%', |
| | | bottom: '10%', |
| | | top: '10%', |
| | | containLabel: true |
| | | }, |
| | | tooltip: { |
| | | trigger: 'axis', |
| | | axisPointer: { |
| | | type: 'line' |
| | | } |
| | | }, |
| | | xAxis: { |
| | | type: 'category', |
| | | data: names |
| | | }, |
| | | yAxis: { |
| | | type: 'value', |
| | | axisLine: { |
| | | show: true |
| | | }, |
| | | tooltip: { |
| | | trigger: 'axis', |
| | | axisPointer: { |
| | | type: 'line' |
| | | axisLabel: { |
| | | formatter: function (value) { |
| | | // 四舍五入到最近的整数 |
| | | return Math.round(value) |
| | | } |
| | | }, |
| | | xAxis: { |
| | | type: 'category', |
| | | data: names |
| | | }, |
| | | yAxis: { |
| | | type: 'value', |
| | | axisLine: { |
| | | show: true |
| | | }, |
| | | axisLabel: { |
| | | formatter: function (value) { |
| | | // 四舍五入到最近的整数 |
| | | return Math.round(value); |
| | | } |
| | | }, |
| | | graphic: { |
| | | elements: [ |
| | | { |
| | | type: 'text', |
| | | left: 'left', |
| | | top: 'top', |
| | | style: { |
| | | text: '人员数', |
| | | textAlign: 'center', |
| | | fill: '#333' |
| | | } |
| | | } |
| | | }, |
| | | graphic: { |
| | | elements: [ |
| | | { |
| | | type: 'text', |
| | | left: 'left', |
| | | top: 'top', |
| | | style: { |
| | | text: '人员数', |
| | | textAlign: 'center', |
| | | fill: '#333' |
| | | } |
| | | } |
| | | ] |
| | | }, |
| | | series: [ |
| | | { |
| | | data: datas, |
| | | type: 'line', |
| | | areaStyle: { |
| | | normal: { |
| | | color: { |
| | | x: 0, |
| | | y: 0, |
| | | x2: 0, |
| | | y2: 1, |
| | | colorStops: [{ |
| | | offset: 0, |
| | | color: '#207FF7' // 0% 处的颜色 |
| | | }, { |
| | | offset: 1, |
| | | color: 'rgba(255,255,255,.2)' // 100% 处的颜色 |
| | | }], |
| | | globalCoord: false // 缺省为 false |
| | | } |
| | | } |
| | | }, |
| | | lineStyle: { // 线条样式 |
| | | ] |
| | | }, |
| | | series: [ |
| | | { |
| | | data: datas, |
| | | type: 'line', |
| | | areaStyle: { |
| | | normal: { |
| | | color: { |
| | | type: 'linear', |
| | | x: 0, |
| | | y: 0, |
| | | x2: 0, |
| | | y2: 1, |
| | | colorStops: [{ |
| | | offset: 0, color: '#207FF7' // 0% 处的颜色 |
| | | offset: 0, |
| | | color: '#207FF7' // 0% 处的颜色 |
| | | }, { |
| | | offset: 1, color: '#207FF7' // 100% 处的颜色 |
| | | }] |
| | | }, |
| | | width: 2 // 线条粗细 |
| | | offset: 1, |
| | | color: 'rgba(255,255,255,.2)' // 100% 处的颜色 |
| | | }], |
| | | globalCoord: false // 缺省为 false |
| | | } |
| | | } |
| | | }, |
| | | lineStyle: { // 线条样式 |
| | | color: { |
| | | type: 'linear', |
| | | x: 0, |
| | | y: 0, |
| | | x2: 0, |
| | | y2: 1, |
| | | colorStops: [{ |
| | | offset: 0, color: '#207FF7' // 0% 处的颜色 |
| | | }, { |
| | | offset: 1, color: '#207FF7' // 100% 处的颜色 |
| | | }] |
| | | }, |
| | | symbol: 'circle', |
| | | symbolSize: 10, |
| | | itemStyle: { |
| | | borderWidth: 1, |
| | | borderColor: '#fff', |
| | | color: '#207FF7' |
| | | }, |
| | | smooth: false |
| | | } |
| | | ] |
| | | } |
| | | myChart.setOption(option) |
| | | window.addEventListener('resize', function () { // 执行 |
| | | myChart.resize() |
| | | }) |
| | | }, |
| | | // 车辆分类统计 |
| | | initDept() { |
| | | if (!this.listZB) return |
| | | |
| | | const dom = document.getElementById('echart2') |
| | | console.log(dom) |
| | | const myChart = echarts.init(dom) |
| | | |
| | | let data = this.listZB.map(item => { |
| | | return { |
| | | value: item.total, |
| | | name: item.name |
| | | width: 2 // 线条粗细 |
| | | }, |
| | | symbol: 'circle', |
| | | symbolSize: 10, |
| | | itemStyle: { |
| | | borderWidth: 1, |
| | | borderColor: '#fff', |
| | | color: '#207FF7' |
| | | }, |
| | | smooth: false |
| | | } |
| | | }) |
| | | ] |
| | | } |
| | | myChart.setOption(option) |
| | | window.addEventListener('resize', function () { // 执行 |
| | | myChart.resize() |
| | | }) |
| | | }, |
| | | // 车辆分类统计 |
| | | initDept () { |
| | | if (!this.listZB) return |
| | | |
| | | let option = { |
| | | tooltip: { |
| | | trigger: 'item', |
| | | }, |
| | | legend: { |
| | | show: false, |
| | | orient: 'vertical', |
| | | left: 'left' |
| | | }, |
| | | series : [ |
| | | { |
| | | name: '访问来源', |
| | | type: 'pie', |
| | | radius: ['34%', '50%'], |
| | | labelLine: { |
| | | normal: { |
| | | length: 30, |
| | | length2: 70, |
| | | const dom = document.getElementById('echart2') |
| | | console.log(dom) |
| | | const myChart = echarts.init(dom) |
| | | |
| | | const data = this.listZB.map(item => { |
| | | return { |
| | | value: item.total, |
| | | name: item.name |
| | | } |
| | | }) |
| | | |
| | | const option = { |
| | | tooltip: { |
| | | trigger: 'item' |
| | | }, |
| | | legend: { |
| | | show: false, |
| | | orient: 'vertical', |
| | | left: 'left' |
| | | }, |
| | | series: [ |
| | | { |
| | | name: '访问来源', |
| | | type: 'pie', |
| | | radius: ['34%', '50%'], |
| | | labelLine: { |
| | | normal: { |
| | | length: 30, |
| | | length2: 70 |
| | | } |
| | | }, |
| | | label: { |
| | | formatter: '{a|{b}} {d}%', |
| | | rich: { |
| | | a: { |
| | | color: '#333333', |
| | | fontSize: 14, |
| | | fontWeight: 500 |
| | | } |
| | | }, |
| | | label: { |
| | | formatter: "{a|{b}} {d}%", |
| | | rich: { |
| | | a: { |
| | | color: '#333333', |
| | | fontSize: 14, |
| | | fontWeight: 500 |
| | | } |
| | | }, |
| | | padding: [0,-50,20,-100] |
| | | }, |
| | | data: data |
| | | } |
| | | ] |
| | | } |
| | | myChart.setOption(option) |
| | | window.addEventListener('resize', function () { // 执行 |
| | | myChart.resize() |
| | | }) |
| | | }, |
| | | initDept3() { |
| | | const myChart = echarts.init(document.querySelector('#echart3')) |
| | | |
| | | let option = { |
| | | grid: { |
| | | left: '5%', |
| | | right: '10%', |
| | | bottom: '0%', |
| | | top: '20%', |
| | | containLabel: true |
| | | }, |
| | | xAxis: { |
| | | type: 'category', |
| | | data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] |
| | | }, |
| | | yAxis: { |
| | | type: 'value' |
| | | }, |
| | | series: [ |
| | | { |
| | | data: [150, 230, 224, 218, 135, 147, 260], |
| | | type: 'line' |
| | | } |
| | | ] |
| | | } |
| | | myChart.setOption(option) |
| | | window.addEventListener('resize', function () { // 执行 |
| | | myChart.resize() |
| | | }) |
| | | padding: [0, -50, 20, -100] |
| | | }, |
| | | data: data |
| | | } |
| | | ] |
| | | } |
| | | myChart.setOption(option) |
| | | window.addEventListener('resize', function () { // 执行 |
| | | myChart.resize() |
| | | }) |
| | | }, |
| | | initDept3 () { |
| | | const myChart = echarts.init(document.querySelector('#echart3')) |
| | | |
| | | const option = { |
| | | grid: { |
| | | left: '5%', |
| | | right: '10%', |
| | | bottom: '0%', |
| | | top: '20%', |
| | | containLabel: true |
| | | }, |
| | | xAxis: { |
| | | type: 'category', |
| | | data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] |
| | | }, |
| | | yAxis: { |
| | | type: 'value' |
| | | }, |
| | | series: [ |
| | | { |
| | | data: [150, 230, 224, 218, 135, 147, 260], |
| | | type: 'line' |
| | | } |
| | | ] |
| | | } |
| | | myChart.setOption(option) |
| | | window.addEventListener('resize', function () { // 执行 |
| | | myChart.resize() |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | |
| | | |
| | | .main_table { |
| | | display: flex; |
| | | align-items: start; |
| | | align-items: flex-start; |
| | | justify-content: space-between; |
| | | margin-top: 10px; |
| | | .main_table_list { |
| | |
| | | padding: 20px; |
| | | box-sizing: border-box; |
| | | /*border-right: 12px solid #f7f7f7;*/ |
| | | |
| | | |
| | | .echart1 { |
| | | width: 100%; |