|
|
@ -2,14 +2,14 @@ |
|
|
|
import * as echarts from '../../components/ec-canvas/echarts'; |
|
|
|
import { |
|
|
|
getAllPatrol, |
|
|
|
getDevices,getProjectList |
|
|
|
getDevices, getProjectList |
|
|
|
} from "../../../utils/getApiUrl"; |
|
|
|
import { |
|
|
|
Request |
|
|
|
} from "../../../common"; |
|
|
|
const moment = require("../../../utils/moment"); |
|
|
|
|
|
|
|
function setOption(chart, seriesData, xData) { |
|
|
|
function setOption (chart, seriesData, xData) { |
|
|
|
const option = { |
|
|
|
grid: { |
|
|
|
top: '5%', |
|
|
@ -20,7 +20,10 @@ function setOption(chart, seriesData, xData) { |
|
|
|
}, |
|
|
|
xAxis: { |
|
|
|
type: 'category', |
|
|
|
data: xData |
|
|
|
data: xData, |
|
|
|
// axisLabel: {
|
|
|
|
// formatter: '{value}'
|
|
|
|
// }
|
|
|
|
}, |
|
|
|
yAxis: { |
|
|
|
type: 'value', |
|
|
@ -28,7 +31,7 @@ function setOption(chart, seriesData, xData) { |
|
|
|
series: [{ |
|
|
|
data: seriesData, |
|
|
|
type: 'line' |
|
|
|
}, ] |
|
|
|
},] |
|
|
|
}; |
|
|
|
chart.setOption(option); |
|
|
|
} |
|
|
@ -73,9 +76,9 @@ Page({ |
|
|
|
/** |
|
|
|
* 生命周期函数--监听页面加载 |
|
|
|
*/ |
|
|
|
onLoad(options) { |
|
|
|
const projectList=decodeURIComponent(options.arrayData) |
|
|
|
const complexArray = JSON.parse(projectList); |
|
|
|
onLoad (options) { |
|
|
|
const projectList = decodeURIComponent(options.arrayData) |
|
|
|
const complexArray = JSON.parse(projectList); |
|
|
|
const { |
|
|
|
windowHeight |
|
|
|
} = wx.getSystemInfoSync() |
|
|
@ -117,9 +120,9 @@ Page({ |
|
|
|
// 查找匹配项目
|
|
|
|
const project = complexArray.find((project) => project.id === point.projectId); |
|
|
|
if (project) { |
|
|
|
device.project = project; |
|
|
|
device.project = project; |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
expiringDevices.push(device); |
|
|
|
} |
|
|
|
// 检查设备的 dateGuarantee 是否在日期范围内
|
|
|
@ -140,10 +143,28 @@ Page({ |
|
|
|
// const label = `${year}-${month}`;
|
|
|
|
// xAxisLabels.push(label);
|
|
|
|
const nextMonth = new Date(currentDate.getFullYear(), currentDate.getMonth() + i, 1); |
|
|
|
const month = nextMonth.toLocaleDateString('en-US', { |
|
|
|
month: 'short' |
|
|
|
}); // 获取月份的缩写
|
|
|
|
xAxisLabels.push(month); |
|
|
|
const month = nextMonth |
|
|
|
.getMonth() |
|
|
|
// .toLocaleDateString('en-US', {
|
|
|
|
// month: 'short'
|
|
|
|
// }); // 获取月份的缩写
|
|
|
|
|
|
|
|
const month_ = { |
|
|
|
"0": "Jan", |
|
|
|
"1": "Feb", |
|
|
|
"2": "Mar", |
|
|
|
"3": "Apr", |
|
|
|
"4": "May", |
|
|
|
"5": "Jun", |
|
|
|
"6": "Jul", |
|
|
|
"7": "Aug", |
|
|
|
"8": "Sep", |
|
|
|
"9": "Oct", |
|
|
|
"10": "Nov", |
|
|
|
"11": "Dec" |
|
|
|
}[month] |
|
|
|
console.log('月', month_); |
|
|
|
xAxisLabels.push(month_); |
|
|
|
} |
|
|
|
//过期的
|
|
|
|
const guaranteedRate = res.filter(item => moment(item.dateGuarantee).isBefore(moment()))?.length || 0 |
|
|
@ -153,7 +174,7 @@ Page({ |
|
|
|
count: res.length, |
|
|
|
guaranteedRate: guaranteedRate, |
|
|
|
warrantyPeriod: warrantyPeriod, |
|
|
|
next30days:expiringDevices |
|
|
|
next30days: expiringDevices |
|
|
|
}) |
|
|
|
setTimeout(() => { |
|
|
|
this.initChart(monthlyCounts, xAxisLabels) |
|
|
@ -168,49 +189,49 @@ Page({ |
|
|
|
/** |
|
|
|
* 生命周期函数--监听页面初次渲染完成 |
|
|
|
*/ |
|
|
|
onReady() { |
|
|
|
onReady () { |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 生命周期函数--监听页面显示 |
|
|
|
*/ |
|
|
|
onShow() { |
|
|
|
onShow () { |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 生命周期函数--监听页面隐藏 |
|
|
|
*/ |
|
|
|
onHide() { |
|
|
|
onHide () { |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 生命周期函数--监听页面卸载 |
|
|
|
*/ |
|
|
|
onUnload() { |
|
|
|
onUnload () { |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 页面相关事件处理函数--监听用户下拉动作 |
|
|
|
*/ |
|
|
|
onPullDownRefresh() { |
|
|
|
onPullDownRefresh () { |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 页面上拉触底事件的处理函数 |
|
|
|
*/ |
|
|
|
onReachBottom() { |
|
|
|
onReachBottom () { |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 用户点击右上角分享 |
|
|
|
*/ |
|
|
|
onShareAppMessage() { |
|
|
|
onShareAppMessage () { |
|
|
|
|
|
|
|
} |
|
|
|
}) |