zhaobing’
1 year ago
10 changed files with 357 additions and 194 deletions
@ -1,173 +1,242 @@ |
|||||
// package/subSystem/subSystem.js
|
// package/subSystem/subSystem.js
|
||||
import * as echarts from '../components/ec-canvas/echarts'; |
import * as echarts from '../components/ec-canvas/echarts'; |
||||
let chart = null; |
import { |
||||
|
getSubSystemPatrolAbout |
||||
function initChart(canvas, width, height, dpr) { |
} from "../../utils/getApiUrl"; |
||||
const chart = echarts.init(canvas, null, { |
import { |
||||
width: 300, |
Request |
||||
height: 300, |
} from "../../common"; |
||||
devicePixelRatio: dpr // new
|
const moment = require("../../utils/moment"); |
||||
}); |
|
||||
canvas.setChart(chart); |
|
||||
|
|
||||
var option = { |
|
||||
backgroundColor: "#ffffff", |
|
||||
series: [{ |
|
||||
label: { |
|
||||
normal: { |
|
||||
fontSize: 14 |
|
||||
} |
|
||||
}, |
|
||||
type: 'pie', |
|
||||
center: ['50%', '50%'], |
|
||||
radius: ['20%', '40%'], |
|
||||
data: [{ |
|
||||
value: 55, |
|
||||
name: '北京' |
|
||||
}, { |
|
||||
value: 20, |
|
||||
name: '武汉' |
|
||||
}, { |
|
||||
value: 10, |
|
||||
name: '杭州' |
|
||||
}, { |
|
||||
value: 20, |
|
||||
name: '广州' |
|
||||
}, { |
|
||||
value: 38, |
|
||||
name: '上海' |
|
||||
}] |
|
||||
}] |
|
||||
}; |
|
||||
|
|
||||
chart.setOption(option); |
|
||||
return chart; |
|
||||
} |
|
||||
Page({ |
|
||||
|
|
||||
/** |
|
||||
* 页面的初始数据 |
|
||||
*/ |
Page({ |
||||
data: { |
initECharts(option) { |
||||
ec: { |
this.ecComponent.init((canvas, width, height, dpr) => { |
||||
onInit: initChart |
const chart = echarts.init(canvas, null, { |
||||
}, |
width: width, |
||||
date: '', |
height: height, |
||||
show: true, |
devicePixelRatio: dpr, |
||||
selectedDate: new Date(),// 设置默认选中的日期为当前日期
|
}); |
||||
formatter(day) { |
// 设置图表的配置
|
||||
console.log('xxasaasas',day) |
chart.setOption(option); |
||||
const month = day.date.getMonth() + 1; |
|
||||
const date = day.date.getDate(); |
// 将 ECharts 实例保存在数据中
|
||||
const style = {}; |
this.chart = chart; |
||||
if (month === 10) { |
|
||||
if (date === 1) { |
// 返回 ECharts 实例
|
||||
day.bottomInfo = '.'; |
return chart; |
||||
day.className='dayClass' |
}); |
||||
style.backgroundColor = 'red'; |
|
||||
// document.getElementsByClassName('van-calendar__bottom-info')
|
|
||||
} |
|
||||
} |
|
||||
|
|
||||
if (day.type === 'start') { |
|
||||
day.bottomInfo = '入住'; |
|
||||
} else if (day.type === 'end') { |
|
||||
day.bottomInfo = '离店'; |
|
||||
} |
|
||||
day.style = style; |
|
||||
console.log('day111',day) |
|
||||
return day; |
|
||||
}, |
}, |
||||
|
/** |
||||
|
* 页面的初始数据 |
||||
|
*/ |
||||
|
data: { |
||||
|
ec: { |
||||
|
// lazyLoad: true, // 延迟加载 ECharts
|
||||
|
}, |
||||
|
date: '', |
||||
|
show: true, |
||||
|
currentPatrolCount: 0, //当月巡检次数
|
||||
|
currentRepairCount: 0, //当月维修次数
|
||||
|
level1Count: 0, //轻微
|
||||
|
level2Count: 0, //中度
|
||||
|
level3Count: 0, //严重
|
||||
|
selectedDate: new Date(), // 设置默认选中的日期为当前日期
|
||||
|
formatter(day) { |
||||
|
|
||||
|
return day; |
||||
|
}, |
||||
|
|
||||
}, |
}, |
||||
|
|
||||
onDisplay() { |
onDisplay() { |
||||
this.setData({ show: true }); |
this.setData({ |
||||
}, |
show: true |
||||
onClose() { |
}); |
||||
this.setData({ show: false }); |
}, |
||||
}, |
onClose() { |
||||
|
this.setData({ |
||||
onConfirm(event) { |
show: false |
||||
this.setData({ |
}); |
||||
show: false, |
}, |
||||
date: this.formatDate(event.detail), |
|
||||
}); |
onConfirm(event) { |
||||
}, |
this.setData({ |
||||
|
show: false, |
||||
/** |
date: this.formatDate(event.detail), |
||||
* 生命周期函数--监听页面加载 |
}); |
||||
*/ |
}, |
||||
onLoad: function (options) { |
|
||||
wx.setNavigationBarTitle({ |
/** |
||||
title: options.key, |
* 生命周期函数--监听页面加载 |
||||
}); |
*/ |
||||
// 其他渲染逻辑
|
onLoad: function (options) { |
||||
// 创建一个 Date 对象来获取当前日期
|
const {windowHeight}=wx.getSystemInfoSync() |
||||
const currentDate = new Date(); |
const pageHeight=windowHeight - 48 |
||||
// 获取当前年份
|
const that=this |
||||
const currentYear = currentDate.getFullYear(); |
wx.showLoading({ |
||||
// 获取当前月份(注意,月份是从 0 到 11 表示,所以需要加 1)
|
title: '加载中' |
||||
const currentMonth = currentDate.getMonth() + 1; |
}) |
||||
// 获取当前月份的第一天和最后一天
|
// const that = this;
|
||||
const nextMonth = new Date().getMonth() + 1; |
wx.setNavigationBarTitle({ |
||||
const firstDay = new Date().setDate(1); |
title: options.key, |
||||
const lastDay = new Date().setMonth(nextMonth,1) - 86400000; |
}); |
||||
// 更新数据,将年份和月份传递给 WXML 页面
|
//加载初始化数据
|
||||
this.setData({ |
that.getSubSystemPatrolAbout(options) |
||||
currentYear: currentYear, |
//初始化图表的配置项
|
||||
currentMonth: currentMonth, |
// 其他渲染逻辑
|
||||
lastDay:lastDay, |
// 创建一个 Date 对象来获取当前日期
|
||||
firstDay:firstDay |
const currentDate = new Date(); |
||||
}); |
// 获取当前年份
|
||||
}, |
const currentYear = currentDate.getFullYear(); |
||||
|
// 获取当前月份(注意,月份是从 0 到 11 表示,所以需要加 1)
|
||||
/** |
const currentMonth = currentDate.getMonth() + 1; |
||||
* 生命周期函数--监听页面初次渲染完成 |
// 获取当前月份的第一天和最后一天
|
||||
*/ |
const nextMonth = new Date().getMonth() + 1; |
||||
onReady() { |
const firstDay = new Date().setDate(1); |
||||
|
const lastDay = new Date().setMonth(nextMonth, 1) - 86400000; |
||||
}, |
// 更新数据,将年份和月份传递给 WXML 页面
|
||||
|
that.setData({ |
||||
/** |
currentYear: currentYear, |
||||
* 生命周期函数--监听页面显示 |
currentMonth: currentMonth, |
||||
*/ |
lastDay: lastDay, |
||||
onShow() { |
firstDay: firstDay, |
||||
|
pageHeight:pageHeight+'px' |
||||
}, |
}); |
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面隐藏 |
wx.hideLoading() |
||||
*/ |
|
||||
onHide() { |
}, |
||||
|
//过滤轻微,中度,重度的巡检个数
|
||||
}, |
filterLevelCount:function(list,level){ |
||||
|
return list?.filter(i => { |
||||
/** |
const content = i?.points?.inspectContent |
||||
* 生命周期函数--监听页面卸载 |
if (content) { |
||||
*/ |
for (let key in content) { |
||||
onUnload() { |
if (content.hasOwnProperty(key)) { |
||||
|
const subObject = content[key]; |
||||
}, |
return subObject.level===level |
||||
|
} |
||||
/** |
} |
||||
* 页面相关事件处理函数--监听用户下拉动作 |
} |
||||
*/ |
})?.length |
||||
onPullDownRefresh() { |
}, |
||||
|
getSubSystemPatrolAbout: function (options) { |
||||
}, |
let that = this; |
||||
|
//当月开始时间
|
||||
/** |
const STime = moment().startOf('month').format('YYYY-MM-DD') |
||||
* 页面上拉触底事件的处理函数 |
//当月结束时间
|
||||
*/ |
const ETime = moment().endOf('month').format('YYYY-MM-DD') |
||||
onReachBottom() { |
//子系统关键字
|
||||
|
let keywords = options.key |
||||
}, |
// keywords = '管廊'
|
||||
|
const query = { |
||||
/** |
STime, |
||||
* 用户点击右上角分享 |
ETime, |
||||
*/ |
keywords |
||||
onShareAppMessage() { |
} |
||||
|
Request.get(getSubSystemPatrolAbout(query)).then(res => { |
||||
} |
if (res) { |
||||
|
//巡查内容
|
||||
|
that.setData({ |
||||
|
currentRepairCount: res?.filter(i => i?.patrolRecordIssueHandles[0]?.yanshoushijian && parseInt(moment(i?.patrolRecordIssueHandles[0]?.yanshoushijian).format('YYYYMMDD')) === parseInt(moment().format('YYYYMMDD'))).length || 0, |
||||
|
currentPatrolCount: res.length, |
||||
|
level1Count: that.filterLevelCount(res,'轻微')||0, |
||||
|
level2Count: that.filterLevelCount(res,'中度')||0, |
||||
|
level3Count: that.filterLevelCount(res,'严重')||0, |
||||
|
formatter:function(e){ |
||||
|
res?.map(i=>{ |
||||
|
if(moment(i.inspectionTime).format('YYYY-MM-DD')==moment(e.date).format('YYYY-MM-DD')){ |
||||
|
if( i.patrolRecordIssueHandles.length==0){ |
||||
|
e.bottomInfo = '.';e.className = 'greenClass' |
||||
|
}else if( i.patrolRecordIssueHandles.length&& i?.patrolRecordIssueHandles[0]?.yanshoushijian && parseInt(moment(i?.patrolRecordIssueHandles[0]?.yanshoushijian).format('YYYYMMDD')) === parseInt(moment().format('YYYYMMDD'))){ |
||||
|
e.bottomInfo = '.';e.className = 'yellowClass' |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
return e |
||||
|
} |
||||
|
}) |
||||
|
that.ecComponent = that.selectComponent('#mychart-dom-pie'); |
||||
|
console.log('that.level1Count',this.data.level2Count) |
||||
|
var option = { |
||||
|
backgroundColor: "#ffffff", |
||||
|
legend: { |
||||
|
bottom: 10, |
||||
|
left: 'center', |
||||
|
}, |
||||
|
series: [{ |
||||
|
label: { |
||||
|
normal: { |
||||
|
fontSize: 14 |
||||
|
} |
||||
|
}, |
||||
|
type: 'pie', |
||||
|
center: ['50%', '50%'], |
||||
|
radius: ['20%', '40%'], |
||||
|
data:[ {name:'轻微',value:that.data.level1Count}, |
||||
|
{name:'中度',value:that.data.level2Count}, |
||||
|
{name:'重度',value:that.data.level3Count}] |
||||
|
}] |
||||
|
}; |
||||
|
that.initECharts(option); |
||||
|
|
||||
|
wx.hideLoading() |
||||
|
} else { |
||||
|
wx.hideLoading(); |
||||
|
} |
||||
|
}) |
||||
|
}, |
||||
|
/** |
||||
|
* 生命周期函数--监听页面初次渲染完成 |
||||
|
*/ |
||||
|
|
||||
|
onReady() { |
||||
|
|
||||
|
|
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 生命周期函数--监听页面显示 |
||||
|
*/ |
||||
|
onShow() { |
||||
|
|
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 生命周期函数--监听页面隐藏 |
||||
|
*/ |
||||
|
onHide() { |
||||
|
|
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 生命周期函数--监听页面卸载 |
||||
|
*/ |
||||
|
onUnload() { |
||||
|
|
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 页面相关事件处理函数--监听用户下拉动作 |
||||
|
*/ |
||||
|
onPullDownRefresh() { |
||||
|
getSubSystemPatrolAbout() |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 页面上拉触底事件的处理函数 |
||||
|
*/ |
||||
|
onReachBottom() { |
||||
|
|
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 用户点击右上角分享 |
||||
|
*/ |
||||
|
onShareAppMessage() { |
||||
|
|
||||
|
} |
||||
}) |
}) |
Loading…
Reference in new issue