|
@ -5,284 +5,284 @@ const moment = require("../../utils/moment"); |
|
|
|
|
|
|
|
|
Page({ |
|
|
Page({ |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 页面的初始数据 |
|
|
* 页面的初始数据 |
|
|
*/ |
|
|
*/ |
|
|
data: { |
|
|
data: { |
|
|
/* 待巡检 */ |
|
|
/* 待巡检 */ |
|
|
dataList: [], |
|
|
dataList: [], |
|
|
limit: 10, //条数
|
|
|
limit: 10, //条数
|
|
|
page: 0, //当前页
|
|
|
page: 0, //当前页
|
|
|
count: '', //总条数
|
|
|
count: '', //总条数
|
|
|
hidden: true, |
|
|
hidden: true, |
|
|
currentTab: '0', |
|
|
currentTab: '0', |
|
|
/* 巡检记录 */ |
|
|
/* 巡检记录 */ |
|
|
ResList: [ //阅读状态
|
|
|
ResList: [ //阅读状态
|
|
|
{ |
|
|
{ |
|
|
value: 'all', |
|
|
value: 'all', |
|
|
text: '全部', |
|
|
text: '全部', |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
value: 'normal', |
|
|
value: 'normal', |
|
|
text: '正常', |
|
|
text: '正常', |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
value: 'abnormal', |
|
|
value: 'abnormal', |
|
|
text: '异常', |
|
|
text: '异常', |
|
|
} |
|
|
} |
|
|
], |
|
|
], |
|
|
ResIndex: 0, //巡检结果
|
|
|
ResIndex: 0, //巡检结果
|
|
|
recordDataList: [], |
|
|
recordDataList: [], |
|
|
isPickerRender: false, |
|
|
isPickerRender: false, |
|
|
isPickerShow: false, |
|
|
isPickerShow: false, |
|
|
startTime: "开始日期", //开始日期
|
|
|
startTime: "开始日期", //开始日期
|
|
|
endTime: "结束日期", //结束日期
|
|
|
endTime: "结束日期", //结束日期
|
|
|
pickerConfig: { //自定义时间选择器配置项
|
|
|
pickerConfig: { //自定义时间选择器配置项
|
|
|
endDate: true, //是否需要结束时间,为true时显示开始时间和结束时间两个picker
|
|
|
endDate: true, //是否需要结束时间,为true时显示开始时间和结束时间两个picker
|
|
|
column: "day", //可选的最小时间范围day、hour、minute、second
|
|
|
column: "day", //可选的最小时间范围day、hour、minute、second
|
|
|
dateLimit: true, //是否现在时间可选范围,false时可选任意时间;当为数字n时,范围是当前时间的最近n天
|
|
|
dateLimit: true, //是否现在时间可选范围,false时可选任意时间;当为数字n时,范围是当前时间的最近n天
|
|
|
initStartTime: "", //picker初始时间
|
|
|
initStartTime: "", //picker初始时间
|
|
|
initEndTime: "", //picker初始结束时间
|
|
|
initEndTime: "", //picker初始结束时间
|
|
|
// limitStartTime: "", //最小可选时间
|
|
|
// limitStartTime: "", //最小可选时间
|
|
|
// limitEndTime: "" //最大可选时间
|
|
|
// limitEndTime: "" //最大可选时间
|
|
|
|
|
|
}, |
|
|
|
|
|
recordHidden: true, |
|
|
}, |
|
|
}, |
|
|
recordHidden: true, |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 顶部tab切换
|
|
|
// 顶部tab切换
|
|
|
clickTab(e) { |
|
|
clickTab (e) { |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
currentTab: e.currentTarget.dataset.current |
|
|
currentTab: e.currentTarget.dataset.current |
|
|
}) |
|
|
}) |
|
|
if (e.currentTarget.dataset.current == '0') { |
|
|
if (e.currentTarget.dataset.current == '0') { |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
page: 0, |
|
|
page: 0, |
|
|
dataList: [] |
|
|
dataList: [] |
|
|
}, () => { |
|
|
}, () => { |
|
|
this.getPatrolPlan(); |
|
|
this.getPatrolPlan(); |
|
|
}) |
|
|
}) |
|
|
} else if (e.currentTarget.dataset.current == '1') { |
|
|
} else if (e.currentTarget.dataset.current == '1') { |
|
|
this.getPatrolRecord(); |
|
|
this.getPatrolRecord(); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/***** 待巡检的方法 *****/ |
|
|
/***** 待巡检的方法 *****/ |
|
|
// 开始巡检
|
|
|
// 开始巡检
|
|
|
bindStart(e) { |
|
|
bindStart (e) { |
|
|
let data = JSON.stringify(e.currentTarget.dataset.item); |
|
|
let data = JSON.stringify(e.currentTarget.dataset.item); |
|
|
wx.navigateTo({ |
|
|
wx.navigateTo({ |
|
|
url: '/package/startInspection/startInspection?data=' + encodeURIComponent(data), |
|
|
url: '/package/startInspection/startInspection?data=' + encodeURIComponent(data), |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 获取巡检计划
|
|
|
// 获取巡检计划
|
|
|
getPatrolPlan: function () { |
|
|
getPatrolPlan: function () { |
|
|
let that = this; |
|
|
let that = this; |
|
|
let { page, limit } = that.data; |
|
|
let { page, limit } = that.data; |
|
|
wx.showLoading({ |
|
|
wx.showLoading({ |
|
|
title: '加载中', |
|
|
title: '加载中', |
|
|
}) |
|
|
}) |
|
|
const userInfo = wx.getStorageSync('userInfo'); |
|
|
const userInfo = wx.getStorageSync('userInfo'); |
|
|
Request.get(getPatrolPlan(), { limit, page, userId: userInfo.id }).then(res => { |
|
|
Request.get(getPatrolPlan(), { limit, page, userId: userInfo.id }).then(res => { |
|
|
if (res.rows.length == 0) { |
|
|
if (res.rows.length == 0) { |
|
|
that.setData({ |
|
|
that.setData({ |
|
|
dataList: res.rows, |
|
|
dataList: res.rows, |
|
|
hidden: false |
|
|
hidden: false |
|
|
|
|
|
}) |
|
|
|
|
|
wx.hideLoading() |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
let dataSource = res.rows.map(e => { |
|
|
|
|
|
e.startTime = moment(e.startTime).format('YYYY-MM-DD'); |
|
|
|
|
|
e.endTime = moment(e.endTime).format('YYYY-MM-DD'); |
|
|
|
|
|
return e; |
|
|
|
|
|
}) |
|
|
|
|
|
var arr1 = that.data.dataList; //从data获取当前dataList数组
|
|
|
|
|
|
var arr2 = dataSource; //从此次请求返回的数据中获取新数组
|
|
|
|
|
|
arr1 = arr1.concat(arr2); //合并数组
|
|
|
|
|
|
that.setData({ |
|
|
|
|
|
dataList: arr1, |
|
|
|
|
|
count: res.count, //总条数
|
|
|
|
|
|
hidden: true |
|
|
|
|
|
}) |
|
|
|
|
|
wx.hideLoading() |
|
|
}) |
|
|
}) |
|
|
wx.hideLoading() |
|
|
}, |
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
let dataSource = res.rows.map(e => { |
|
|
|
|
|
e.startTime = moment(e.startTime).format('YYYY-MM-DD'); |
|
|
|
|
|
e.endTime = moment(e.endTime).format('YYYY-MM-DD'); |
|
|
|
|
|
return e; |
|
|
|
|
|
}) |
|
|
|
|
|
var arr1 = that.data.dataList; //从data获取当前dataList数组
|
|
|
|
|
|
var arr2 = dataSource; //从此次请求返回的数据中获取新数组
|
|
|
|
|
|
arr1 = arr1.concat(arr2); //合并数组
|
|
|
|
|
|
that.setData({ |
|
|
|
|
|
dataList: arr1, |
|
|
|
|
|
count: res.count, //总条数
|
|
|
|
|
|
hidden: true |
|
|
|
|
|
}) |
|
|
|
|
|
wx.hideLoading() |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/***** 巡检记录的方法 *****/ |
|
|
/***** 巡检记录的方法 *****/ |
|
|
// 巡检结果
|
|
|
// 巡检结果
|
|
|
bindPickerRes(e) { |
|
|
bindPickerRes (e) { |
|
|
let that = this; |
|
|
let that = this; |
|
|
that.setData({ |
|
|
that.setData({ |
|
|
ResIndex: e.detail.value |
|
|
ResIndex: e.detail.value |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 时间选择器显示
|
|
|
// 时间选择器显示
|
|
|
pickerShow: function () { |
|
|
pickerShow: function () { |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
isPickerShow: true, |
|
|
isPickerShow: true, |
|
|
isPickerRender: true, |
|
|
isPickerRender: true, |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 时间选择器隐藏
|
|
|
// 时间选择器隐藏
|
|
|
pickerHide: function () { |
|
|
pickerHide: function () { |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
isPickerShow: false, |
|
|
isPickerShow: false, |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 获取选择时间
|
|
|
// 获取选择时间
|
|
|
setPickerTime: function (val) { |
|
|
setPickerTime: function (val) { |
|
|
let data = val.detail; |
|
|
let data = val.detail; |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
startTime: data.startTime, |
|
|
startTime: data.startTime, |
|
|
endTime: data.endTime |
|
|
endTime: data.endTime |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 清空提交日期筛选框
|
|
|
// 清空提交日期筛选框
|
|
|
bindClearDate() { |
|
|
bindClearDate () { |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
startTime: '开始日期', |
|
|
startTime: '开始日期', |
|
|
endTime: '结束日期' |
|
|
endTime: '结束日期' |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 查询
|
|
|
// 查询
|
|
|
bindSearch() { |
|
|
bindSearch () { |
|
|
this.getPatrolRecord(); |
|
|
this.getPatrolRecord(); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 查看详情
|
|
|
// 查看详情
|
|
|
bindDetail(e) { |
|
|
bindDetail (e) { |
|
|
let data = JSON.stringify(e.currentTarget.dataset.item); |
|
|
let data = JSON.stringify(e.currentTarget.dataset.item); |
|
|
wx.navigateTo({ |
|
|
wx.navigateTo({ |
|
|
url: '/package/polling/inspectionRecordDetail/inspectionRecordDetail?data=' + encodeURIComponent(data), |
|
|
url: '/package/polling/inspectionRecordDetail/inspectionRecordDetail?data=' + encodeURIComponent(data), |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 获取巡检记录
|
|
|
// 获取巡检记录
|
|
|
getPatrolRecord: function () { |
|
|
getPatrolRecord: function () { |
|
|
let that = this; |
|
|
let that = this; |
|
|
let { endTime, startTime, ResList, ResIndex } = that.data; |
|
|
let { endTime, startTime, ResList, ResIndex } = that.data; |
|
|
let sevenYearAgo = moment().subtract(7, 'days').format('YYYY-MM-DD 00:00:00'); |
|
|
let sevenYearAgo = moment().subtract(7, 'days').format('YYYY-MM-DD 00:00:00'); |
|
|
let currentData = moment().startOf('days').format('YYYY-MM-DD 23:59:59'); |
|
|
let currentData = moment().startOf('days').format('YYYY-MM-DD 23:59:59'); |
|
|
let alarm = ResList[ResIndex].value == 'all' ? 'null' : ResList[ResIndex].value == 'normal' ? false : true; |
|
|
let alarm = ResList[ResIndex].value == 'all' ? 'null' : ResList[ResIndex].value == 'normal' ? false : true; |
|
|
wx.showLoading({ |
|
|
wx.showLoading({ |
|
|
title: '加载中' |
|
|
title: '加载中' |
|
|
}) |
|
|
|
|
|
Request.get(getPatrolRecord('all', startTime == '开始日期' ? sevenYearAgo : startTime + ' 00:00:00', endTime == '结束日期' ? currentData : endTime + ' 23:59:59', alarm, 'null')).then(res => { |
|
|
|
|
|
if (res.length == 0) { |
|
|
|
|
|
that.setData({ |
|
|
|
|
|
recordDataList: res, |
|
|
|
|
|
recordHidden: false |
|
|
|
|
|
}) |
|
|
}) |
|
|
wx.hideLoading() |
|
|
Request.get(getPatrolRecord('all', startTime == '开始日期' ? sevenYearAgo : startTime + ' 00:00:00', endTime == '结束日期' ? currentData : endTime + ' 23:59:59', alarm, 'null')).then(res => { |
|
|
return; |
|
|
if (res.length == 0) { |
|
|
} |
|
|
that.setData({ |
|
|
let dataSource = res.map(e => { |
|
|
recordDataList: res, |
|
|
e.lastInspectionTime = e.lastInspectionTime ? moment(e.lastInspectionTime).format('YYYY-MM-DD') : '--'; |
|
|
recordHidden: false |
|
|
e.inspectionTime = moment(e.inspectionTime).format('YYYY-MM-DD'); |
|
|
}) |
|
|
return e; |
|
|
wx.hideLoading() |
|
|
}) |
|
|
return; |
|
|
that.setData({ |
|
|
} |
|
|
recordDataList: dataSource, |
|
|
let dataSource = res.map(e => { |
|
|
recordHidden: true |
|
|
e.lastInspectionTime = e.lastInspectionTime ? moment(e.lastInspectionTime).format('YYYY-MM-DD') : '--'; |
|
|
}) |
|
|
e.inspectionTime = moment(e.inspectionTime).format('YYYY-MM-DD'); |
|
|
wx.hideLoading() |
|
|
return e; |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
that.setData({ |
|
|
|
|
|
recordDataList: dataSource, |
|
|
|
|
|
recordHidden: true |
|
|
|
|
|
}) |
|
|
|
|
|
wx.hideLoading() |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 生命周期函数--监听页面加载 |
|
|
* 生命周期函数--监听页面加载 |
|
|
*/ |
|
|
*/ |
|
|
onLoad(options) { |
|
|
onLoad (options) { |
|
|
this.getPatrolPlan(); |
|
|
this.getPatrolPlan(); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 生命周期函数--监听页面初次渲染完成 |
|
|
* 生命周期函数--监听页面初次渲染完成 |
|
|
*/ |
|
|
*/ |
|
|
onReady() { |
|
|
onReady () { |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 生命周期函数--监听页面显示 |
|
|
* 生命周期函数--监听页面显示 |
|
|
*/ |
|
|
*/ |
|
|
onShow() { |
|
|
onShow () { |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 生命周期函数--监听页面隐藏 |
|
|
* 生命周期函数--监听页面隐藏 |
|
|
*/ |
|
|
*/ |
|
|
onHide() { |
|
|
onHide () { |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 生命周期函数--监听页面卸载 |
|
|
* 生命周期函数--监听页面卸载 |
|
|
*/ |
|
|
*/ |
|
|
onUnload() { |
|
|
onUnload () { |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 页面相关事件处理函数--监听用户下拉动作 |
|
|
* 页面相关事件处理函数--监听用户下拉动作 |
|
|
*/ |
|
|
*/ |
|
|
onPullDownRefresh() { |
|
|
onPullDownRefresh () { |
|
|
let that = this; |
|
|
let that = this; |
|
|
if (that.data.currentTab == '0') { |
|
|
if (that.data.currentTab == '0') { |
|
|
that.setData({ |
|
|
that.setData({ |
|
|
dataList: [], |
|
|
dataList: [], |
|
|
page: 0, //当前页
|
|
|
page: 0, //当前页
|
|
|
count: '', //总条数
|
|
|
count: '', //总条数
|
|
|
}) |
|
|
}) |
|
|
that.getPatrolPlan() |
|
|
that.getPatrolPlan() |
|
|
// 手动控制回弹
|
|
|
// 手动控制回弹
|
|
|
wx.stopPullDownRefresh(); |
|
|
wx.stopPullDownRefresh(); |
|
|
} else if (that.data.currentTab == '1') { |
|
|
} else if (that.data.currentTab == '1') { |
|
|
that.setData({ |
|
|
that.setData({ |
|
|
recordDataList: [], |
|
|
recordDataList: [], |
|
|
ResIndex: 0, //巡检结果
|
|
|
ResIndex: 0, //巡检结果
|
|
|
startTime: "开始日期", //开始日期
|
|
|
startTime: "开始日期", //开始日期
|
|
|
endTime: "结束日期", //结束日期
|
|
|
endTime: "结束日期", //结束日期
|
|
|
}) |
|
|
}) |
|
|
that.getPatrolRecord() |
|
|
that.getPatrolRecord() |
|
|
// 手动控制回弹
|
|
|
// 手动控制回弹
|
|
|
wx.stopPullDownRefresh(); |
|
|
wx.stopPullDownRefresh(); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 页面上拉触底事件的处理函数 |
|
|
* 页面上拉触底事件的处理函数 |
|
|
*/ |
|
|
*/ |
|
|
onReachBottom() { |
|
|
onReachBottom () { |
|
|
let _that = this; |
|
|
let _that = this; |
|
|
if (_that.data.currentTab == '0') { |
|
|
if (_that.data.currentTab == '0') { |
|
|
let page = _that.data.page + 1; //获取当前页数并+1
|
|
|
let page = _that.data.page + 1; //获取当前页数并+1
|
|
|
let { dataList, count } = _that.data; |
|
|
let { dataList, count } = _that.data; |
|
|
if (dataList.length == count) { |
|
|
if (dataList.length == count) { |
|
|
wx.showToast({ |
|
|
wx.showToast({ |
|
|
title: '没有更多数据了...', |
|
|
title: '没有更多数据了...', |
|
|
icon: 'none', |
|
|
icon: 'none', |
|
|
}) |
|
|
}) |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
_that.setData({ |
|
|
_that.setData({ |
|
|
page: page, //更新当前页数
|
|
|
page: page, //更新当前页数
|
|
|
}) |
|
|
}) |
|
|
_that.getPatrolPlan() |
|
|
_that.getPatrolPlan() |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 用户点击右上角分享 |
|
|
* 用户点击右上角分享 |
|
|
*/ |
|
|
*/ |
|
|
onShareAppMessage() { |
|
|
onShareAppMessage () { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |