From f527157896001fb63444168f78b7b46e9e4306f8 Mon Sep 17 00:00:00 2001 From: chenze <1824191732@qq.com> Date: Mon, 19 Aug 2024 08:43:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E5=AF=B9=E5=BA=94?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/admin/repair/repairStats.js | 8 + src/views/admin/repair/RepairStatistics.vue | 266 +++++++++++++------- 2 files changed, 189 insertions(+), 85 deletions(-) diff --git a/src/api/admin/repair/repairStats.js b/src/api/admin/repair/repairStats.js index ba5c9a1..9e6a651 100644 --- a/src/api/admin/repair/repairStats.js +++ b/src/api/admin/repair/repairStats.js @@ -62,6 +62,14 @@ export function floorStats (parameter) { }) } +export function selectDeviceStats (parameter) { + return axios({ + url: api.repairStats + '/deviceStats', + method: 'get', + params: parameter + }) +} + export function deviceTypeStats (parameter) { return axios({ url: api.repairStats + '/deviceTypeStats', diff --git a/src/views/admin/repair/RepairStatistics.vue b/src/views/admin/repair/RepairStatistics.vue index a488eaa..1a84bcb 100644 --- a/src/views/admin/repair/RepairStatistics.vue +++ b/src/views/admin/repair/RepairStatistics.vue @@ -94,24 +94,23 @@
楼层负责人情况
- - 按月 + + 按月 按年 - - +
@@ -123,11 +122,23 @@
故障统计
- + 按月 按年 - + + +
@@ -154,18 +165,30 @@
-
故障统计
+
项目详情
- - 按周 + 按月 按年 - + + +
import * as echarts from 'echarts' -import { repairAdminStats, repairStats, floorStats } from '@/api/admin/repair/repairStats' +import { + repairAdminStats, + repairStats, + floorStats, + deviceTypeStats, + selectDeviceStats +} from '@/api/admin/repair/repairStats' export default { name: 'RepairStatistics', @@ -199,8 +228,24 @@ export default { queryParam: {}, selectedRowKeys: [], selectedRows: [], - deviceType: '', + faultStatsCount: [], + deviceType: { + type: '', + time: '', + open: false + }, + fault: { + type: '', + time: '', + open: false + }, yearShowOne: false, + // + floor: { + type: '', + time: '', + open: false + }, // 表头 columns: [ { @@ -237,29 +282,7 @@ export default { } ], // 加载数据方法 必须为 Promise 对象 - loadData: [ - { - key: '1', - name: 'John Brown', - age: 32, - address: 'New York No. 1 Lake Park, New York No. 1 Lake Park', - tags: ['nice', 'developer'] - }, - { - key: '2', - name: 'Jim Green', - age: 42, - address: 'London No. 2 Lake Park, London No. 2 Lake Park', - tags: ['loser'] - }, - { - key: '3', - name: 'Joe Black', - age: 32, - address: 'Sidney No. 1 Lake Park, Sidney No. 1 Lake Park', - tags: ['cool', 'teacher'] - } - ] + loadData: [] } }, mounted () { @@ -267,6 +290,7 @@ export default { this.repairCount() this.getfloorStats() this.deviceStats() + this.faultStats() // this.createEchartCake('echart2', { // bottom: 10, @@ -278,8 +302,7 @@ export default { // left: 'right', // orient: 'vertical' // }) - this.createEchartLine('echart4') - this.createColumnEcharrt('echart5') + this.createEchartCake('echart6', { bottom: 'center', right: '10%', @@ -287,33 +310,96 @@ export default { }) }, methods: { + // 使用openChange事件控制日期下拉面板显示与收起 + openChange (open) { + this.floor.open = open + }, + // 使用panelChange事件控制选中年份的方法 + panelChange (value) { + // 接收panelChange返回的值 + this.floor.time = value + const date1 = new Date(this.floor.time).getFullYear() + floorStats({ date: date1 }).then(res => { + this.createEchartLine('echart4', res.data) + }) + this.floor.open = false + }, + // 选择-楼层负责人情况 + selectFloor (value, option) { + this.floor.type = value + }, + clickFloor (a, c) { + this.floor.time = c + console.log(c) + floorStats({ date: c }).then(res => { + this.createEchartLine('echart4', res.data) + }) + }, - // 弹出日历和关闭日历的回调 - openChangeOne (status) { - if (status) { - this.yearShowOne = true - } + // 故障统计 使用openChange事件控制日期下拉面板显示与收起 + openFaultChange (open) { + this.fault.open = open }, - // 得到年份选择器的值 - panelChangeOne (value) { - this.yearShowOne = false - this.deviceType = value - console.log(this.deviceType) + // 使用panelChange事件控制选中年份的方法 + panelFaultChange (value) { + // 接收panelChange返回的值 + this.fault.time = value + const date1 = new Date(this.fault.time).getFullYear() + this.fault.open = false }, - selectWeek (value) { - this.deviceType = value - console.log(this.deviceType) + // 选择-楼层负责人情况 + selectFault (value, option) { + this.fault.type = value }, + clickFault (a, c) { + this.fault.time = c + console.log(c) + }, + + // 使用openChange事件控制日期下拉面板显示与收起 + openDeviceTypeChange (open) { + this.deviceType.open = open + }, + // 使用panelChange事件控制选中年份的方法 + panelDeviceTypeChange (value) { + // 接收panelChange返回的值 + this.deviceType.time = value + this.deviceType.open = false + const date1 = new Date(this.deviceType.time).getFullYear() + deviceTypeStats({ date: date1 }).then(res => { + this.loadData = res.rows + }) + }, + // 选择-楼层负责人情况 + selectDeviceType (value, option) { + this.deviceType.type = value + }, + clickDeviceType (a, c) { + console.log(c) + this.deviceType.time = c + deviceTypeStats({ date: c }).then(res => { + this.loadData = res.rows + }) + }, + adminStats () { repairAdminStats().then(res => { this.adminStatsCount = res.repairAdminStats }) }, deviceStats () { - deviceTypeStats({ date: '2024-08' }).then(res => { + let date = this.formatDate() + deviceTypeStats({ date: date }).then(res => { this.loadData = res.rows }) }, + faultStats () { + selectDeviceStats({ date: '2024-08' }).then(res => { + this.faultStatsCount = res.data + this.createColumnEcharrt('echart5', res.data) + }) + }, + getYearCount () { this.type = 'year' repairStats().then(res => { @@ -366,10 +452,18 @@ export default { }, // 楼层负责人情况 getfloorStats () { - floorStats().then(res => { - console.log(res) + let date = this.formatDate() + floorStats({ date: date }).then(res => { + this.createEchartLine('echart4', res.data) }) }, + formatDate () { + let date = new Date() + let myyear = date.getFullYear() + let mymonth = date.getMonth() + 1 + mymonth < 10 ? mymonth = '0' + mymonth : mymonth + return `${myyear}-${mymonth}` + }, onSelectChange (selectedRowKeys, selectedRows) { this.selectedRowKeys = selectedRowKeys @@ -416,14 +510,12 @@ export default { } // 使用刚指定的配置项和数据显示图表。 myChart.setOption(option) - }, - createEchartLine (id) { + } + , + createEchartLine (id, data) { // 基于准备好的dom,初始化echarts实例 let myChart = echarts.init(document.getElementById(id)) let option = { - title: { - text: 'World Population' - }, tooltip: { trigger: 'axis', axisPointer: { @@ -443,34 +535,39 @@ export default { }, yAxis: { type: 'category', - data: ['Brazil', 'Indonesia', 'USA', 'India', 'China', 'World'] + data: data.y }, series: [ { - name: '2011', + name: '故障数量', type: 'bar', - data: [18203, 23489, 29034, 104970, 131744, 630230] + data: data.total }, { - name: '2012', + name: '数量类型', type: 'bar', - data: [19325, 23438, 31000, 121594, 134141, 681807] + data: data.finish } ] } // 使用刚指定的配置项和数据显示图表。 myChart.setOption(option) - }, - createColumnEcharrt (id) { + } + , + createColumnEcharrt (id, data) { + data.x = data.x.map(item => { + if (item && item.length > 4) { + item = item.substring(0, 4) + '..' + } + return item + }) + // 基于准备好的dom,初始化echarts实例 let myChart = echarts.init(document.getElementById(id)) // There should not be negative values in rawData const rawData = [ - [100, 302, 301, 334, 390, 330, 320], - [320, 132, 101, 134, 90, 230, 210], - [220, 182, 191, 234, 290, 330, 310], - [150, 212, 201, 154, 190, 330, 410], - [820, 832, 901, 934, 1290, 1330, 1320] + data.total, + data.finish ] const totalData = [] for (let i = 0; i < rawData[0].length; ++i) { @@ -487,11 +584,8 @@ export default { bottom: 50 } const series = [ - 'Direct', - 'Mail Ad', - 'Affiliate Ad', - 'Video Ad', - 'Search Engine' + '未完成', + '已完成' ].map((name, sid) => { return { name, @@ -517,7 +611,7 @@ export default { }, xAxis: { type: 'category', - data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] + data: data.x }, series } @@ -526,6 +620,8 @@ export default { } } } + +