var app = getApp();
|
var dateTimePicker = require('../../utils/dateTimePicker.js'); //日期控件
|
var utils = require('../../utils/util.js')
|
var Constant = require('../../utils/constant.js')
|
Page({
|
|
/**
|
* 页面的初始数据
|
*/
|
data: {
|
historyProductRecordList: [], //按产品查询记录列表
|
historyEmployeeRecordList: [], //按员工查询记录列表
|
tabBarList: [{
|
tabBarName: "按日期",
|
icon: 'time'
|
}, {
|
tabBarName: "按产品",
|
icon: 'goods'
|
}, {
|
tabBarName: "按员工",
|
icon: 'people'
|
}], //底部菜单
|
monthWeeksList: ['日', '一', '二', '三', '四', '五', '六'],
|
tabBarIndex: 0, //底部tabBar的默认下标
|
floatMenu: { //悬浮菜单
|
animation: '',
|
bindtaps: "expand_floatMenu"
|
},
|
employeeNowDay: "", //员工界面--当前时间 年月日
|
employeeHistoryDay: "", //员工界面--历史时间 年月日
|
employeeDateEnd: "", //员工 界面--时间选择器的最大限制时间
|
nowYear: "", //当前年份
|
nowDate: '', //当前年月
|
nowMonth: '', //当前月份
|
nowDay: '', //当前日期
|
nowMonthFirstDay: '', //当前月份的第一天
|
nowMonthLastDay: '', //当前月份的最后一天
|
nowMonthAllDateArr: [], //当前月份所有的日期
|
dateSize: 0,
|
monthMarginLeft: '', //当月天数前面对应的空格数
|
productTypeFilterList: {
|
typeFilerList: [{
|
name: '全部'
|
},
|
{
|
name: '流量计'
|
}, {
|
name: '压力机'
|
}, {
|
name: '水质仪'
|
}, {
|
name: '消防栓'
|
}, {
|
name: '泵'
|
},
|
],
|
typeFilterIndex: 0
|
},
|
productTypeFilterShowStatus: false, //产品类型筛选列表显示状态
|
isDateNextDayAble: true, //日期界面控制是否可以点击下一天的状态值
|
isEmployeeNextDayAble: true, //员工控制是否可以点击下一天的状态值
|
istoexamine: true, //浮动菜单的显示状态
|
},
|
|
/**
|
* 生命周期函数--监听页面加载
|
*/
|
onLoad: function (options) {
|
var systemInfo = wx.getSystemInfoSync();
|
this.setData({
|
dateSize: systemInfo.screenWidth / 7, //根据屏幕宽度变化自动设置宽度
|
});
|
this.getDateTime() //获取年月
|
this.getDateInfo() //获取日期信息
|
this.getOneMonthDate() //获取当月的天数
|
this.getMonthWorryStatus(this.data.nowYear, this.data.nowMonth)
|
},
|
//获取当前月份对应日期的巡检状态及隐患条数
|
getMonthWorryStatus: function (Year, Month) {
|
var that = this
|
let nowMonthAllDateArr = that.data.nowMonthAllDateArr
|
wx.showLoading({
|
title: '数据获取中...',
|
})
|
wx.request({
|
method: 'GET',
|
cache: false,
|
url: Constant.BASE_SERVER_URL + 'Repair/Mobile/InspectRecord/GetDayEmployeeCountByMonth',
|
data: {
|
Year: Year,
|
Month: Month,
|
CorpID: Constant.CorpID
|
},
|
success: res => {
|
wx.hideLoading({
|
complete: com => { //获取隐藏loading框的状态
|
// console.log(com)
|
}
|
})
|
// console.log(res, '128')
|
let result = res.data
|
if (result.Code != 0) {
|
wx.showModal({
|
title: '提示',
|
content: '数据获取失败',
|
})
|
return;
|
}
|
let recordMonthAllDateArr = result.Data
|
for (let i = 0; i < recordMonthAllDateArr.length; i++) {
|
if (nowMonthAllDateArr[i].Day == recordMonthAllDateArr[i].Day) {
|
if (recordMonthAllDateArr[i].Count != 0) {
|
nowMonthAllDateArr[i].selectStatus = true
|
nowMonthAllDateArr[i].Count = recordMonthAllDateArr[i].Count
|
} else {
|
nowMonthAllDateArr[i].selectStatus = false
|
nowMonthAllDateArr[i].Count = recordMonthAllDateArr[i].Count
|
}
|
}
|
}
|
that.setData({
|
nowMonthAllDateArr: nowMonthAllDateArr
|
})
|
// console.log(nowMonthAllDateArr, 'nowMonthAllDateArr')
|
},
|
fail: err => {
|
// console.log(err)
|
}
|
})
|
},
|
//获取所有的产品列表
|
getPageListByProduct: function () {
|
var that = this
|
wx.showLoading({
|
title: '数据获取中...',
|
})
|
wx.request({
|
method: 'GET',
|
cache: false,
|
url: Constant.BASE_SERVER_URL + 'repair/Mobile/InspectRecord/GetAllInspectProduct',
|
data: {
|
CorpID: Constant.CorpID,
|
},
|
success: res => {
|
wx.hideLoading()
|
// console.log(res, '188')
|
let result = res.data
|
if (result.Code != 0) {
|
wx.showModal({
|
title: '提示',
|
content: '数据获取失败',
|
})
|
return;
|
}
|
this.setData({
|
historyProductRecordList: result.Data
|
})
|
},
|
fail: err => {
|
console.log(err)
|
}
|
})
|
},
|
//获取所有巡检员的列表
|
getAllInspectEmployee: function () {
|
var that = this
|
wx.showLoading({
|
title: '数据获取中...',
|
})
|
wx.request({
|
method: 'GET',
|
cache: false,
|
url: Constant.BASE_SERVER_URL + 'repair/Mobile/InspectRecord/GetAllInspectEmployee',
|
data: {
|
CorpID: Constant.CorpID,
|
},
|
success: res => {
|
wx.hideLoading()
|
// console.log(res, '188')
|
let result = res.data
|
if (result.Code != 0) {
|
wx.showModal({
|
title: '提示',
|
content: result.Message,
|
})
|
return;
|
}
|
this.setData({
|
historyEmployeeRecordList: result.Data
|
})
|
},
|
fail: err => {
|
console.log(err)
|
}
|
})
|
},
|
//底部tabBar切换事件
|
tabBarSwitch: function (e) {
|
var that = this
|
let tabBarIndex = that.data.tabBarIndex
|
let index = e.currentTarget.dataset.index
|
if (index == 0) {
|
this.getMonthWorryStatus(this.data.nowYear, this.data.nowMonth)
|
}
|
if (index == 1) {
|
that.getPageListByProduct()
|
}
|
if (index == 2) {
|
that.getAllInspectEmployee()
|
}
|
that.setData({
|
tabBarIndex: index
|
})
|
},
|
//产品界面和员工界面获取日期
|
getDateTime: function () {
|
var that = this;
|
let productNowDay = utils.formatDay(new Date())
|
// console.log(productNowDay)
|
that.setData({
|
productNowDay: productNowDay,
|
productDateEnd: productNowDay,
|
productHistoryDay: productNowDay,
|
employeeNowDay: productNowDay,
|
employeeDateEnd: productNowDay,
|
employeeHistoryDay: productNowDay,
|
});
|
},
|
//获取日历相关参数
|
//获取当月日期
|
getDateInfo: function () {
|
var mydate = new Date();
|
let year = mydate.getFullYear(); //当前年份
|
let month = mydate.getMonth() + 1; //当前的月份
|
let day = mydate.getDate(); //当前日期
|
let firstDay = new Date(year, month - 1, 1).getDay(); //第一天星期几
|
let lastDay = new Date(year, month, 0).getDate(); //当前月份的最后一天
|
this.setData({
|
nowYear: year,
|
nowMonth: month,
|
nowDate: year + '-' + '0' + month,
|
nowMonthfirstDay: firstDay,
|
nowMonthLastDay: lastDay,
|
monthMarginLeft: firstDay * this.data.dateSize
|
})
|
// console.log("今天:" + this.data.nowDate + ',' + firstDay + '----' + lastDay, this.data.monthMarginLeft);
|
},
|
//选择月份
|
nowMonthSelect: function (e) {
|
console.log(e.detail.value)
|
let date = e.detail.value
|
let nowYear = parseInt(date.slice(0, 4))
|
let nowMonth = parseInt(date.slice(5, 7))
|
// console.log(nowYear + '-' + nowMonth)
|
let nowMonthFirstDay = new Date(nowYear, nowMonth - 1, 1);
|
this.data.nowMonthFirstDay = nowMonthFirstDay.getDay();
|
let nowMonthLastDay = new Date(nowYear, nowMonth, 0);
|
this.data.nowMonthLastDay = nowMonthLastDay.getDate();
|
|
this.setData({
|
nowMonth: nowMonth,
|
nowYear: nowYear,
|
monthMarginLeft: this.data.nowMonthFirstDay * this.data.dateSize,
|
nowMonthFirstDay: this.data.nowMonthFirstDay,
|
nowMonthLastDay: this.data.nowMonthLastDay,
|
isDateNextDayAble: false
|
})
|
// console.log(nowYear + '-' + nowMonth)
|
this.getOneMonthDate()
|
},
|
// 获取当前月份的天数
|
getOneMonthDate: function () {
|
let nowMonthAllDateArr = []
|
for (var i = 1; i < this.data.nowMonthLastDay + 1; i++) {
|
nowMonthAllDateArr.push({
|
Day: i
|
});
|
}
|
this.setData({
|
nowMonthAllDateArr: nowMonthAllDateArr,
|
})
|
// console.log(this.data.nowMonthAllDateArr, '204')
|
},
|
//按日期查询界面--上一月
|
prevDateMonth: function () {
|
let nowMonth = "";
|
let nowYear = "";
|
if (this.data.nowMonth == 1) {
|
nowYear = this.data.nowYear - 1
|
this.data.nowMonth = 12;
|
nowMonth = this.data.nowMonth;
|
} else {
|
nowYear = this.data.nowYear;
|
nowMonth = this.data.nowMonth - 1;
|
}
|
|
let nowMonthFirstDay = new Date(nowYear, nowMonth - 1, 1);
|
this.data.nowMonthFirstDay = nowMonthFirstDay.getDay();
|
let nowMonthLastDay = new Date(nowYear, nowMonth, 0);
|
this.data.nowMonthLastDay = nowMonthLastDay.getDate();
|
|
this.setData({
|
nowMonth: nowMonth,
|
nowYear: nowYear,
|
monthMarginLeft: this.data.nowMonthFirstDay * this.data.dateSize,
|
nowMonthFirstDay: this.data.nowMonthFirstDay,
|
nowMonthLastDay: this.data.nowMonthLastDay,
|
isDateNextDayAble: false
|
})
|
// console.log(nowYear + '-' + nowMonth)
|
this.getOneMonthDate()
|
this.getMonthWorryStatus(this.data.nowYear, this.data.nowMonth)
|
},
|
//按日期查询界面--下一月
|
nextDateMonth: function () {
|
let nowMonth = "";
|
let nowYear = "";
|
let historyDate = this.data.nowDate
|
if (this.data.nowMonth == 12) {
|
this.data.nowMonth = 0;
|
nowMonth = this.data.nowMonth;
|
nowYear = this.data.nowYear + 1;
|
} else {
|
nowMonth = this.data.nowMonth + 1;
|
nowYear = this.data.nowYear;
|
}
|
nowMonth = this.data.nowMonth + 1;
|
// console.log(nowMonth, 290)
|
let nowMonthFirstDay = new Date(nowYear, nowMonth - 1, 1);
|
this.data.nowMonthFirstDay = nowMonthFirstDay.getDay();
|
let nowMonthLastDay = new Date(nowYear, nowMonth, 0);
|
this.data.nowMonthLastDay = nowMonthLastDay.getDate();
|
|
let nowDate = nowYear + '-' + (nowMonth < 10 ? '0' + nowMonth : nowMonth)
|
// console.log(nowDate, historyDate)
|
let isDateNextDayAble = false
|
if (nowDate == historyDate) {
|
isDateNextDayAble = true
|
}
|
this.setData({
|
nowMonth: nowMonth,
|
nowYear: nowYear,
|
monthMarginLeft: this.data.nowMonthFirstDay * this.data.dateSize,
|
nowMonthFirstDay: this.data.nowMonthFirstDay,
|
nowMonthLastDay: this.data.nowMonthLastDay,
|
isDateNextDayAble: isDateNextDayAble
|
})
|
// console.log(nowYear + '-' + nowMonth)
|
this.getOneMonthDate()
|
this.getMonthWorryStatus(this.data.nowYear, this.data.nowMonth)
|
},
|
//跳转到某日期的巡检记录
|
jumpMonthDetail: function (e) {
|
console.log(e.currentTarget.dataset.detialDate)
|
let detialDate = e.currentTarget.dataset.detialDate
|
wx.navigateTo({
|
url: '../historyByMonthDetail/index?detialDate=' + detialDate,
|
})
|
},
|
//跳转到某一产品的巡检记录
|
jumpProductDetailPage: function (e) {
|
// console.log(e)
|
let Day = e.currentTarget.dataset.day
|
let mainTabActiveIndex = e.currentTarget.dataset.mainTabIndex
|
let ProductID = e.currentTarget.dataset.productId
|
let ProductName = e.currentTarget.dataset.productName
|
wx.navigateTo({
|
url: '../../product/detail/newPumpDetail/index?id=' + ProductID + '&Name=' + ProductName + '&mainTabActiveIndex=' + mainTabActiveIndex + '&Day=' + Day,
|
})
|
},
|
//跳转到某员工的巡检记录
|
jumpEmployeeDetailPage: function (e) {
|
let EmployeeID = e.currentTarget.dataset.employeeId
|
wx.navigateTo({
|
url: '../historyByEmployeeDetial/index?EmployeeID=' + EmployeeID,
|
})
|
},
|
//按员工查询界面 -- 上一天
|
employeeLastDayClick: function () {
|
this.setData({
|
employeeNowDay: utils.formatDay(utils.GetNextDate(this.data.employeeNowDay, -1)),
|
isEmployeeNextDayAble: false,
|
});
|
},
|
//按员工查询界面 -- 下一天
|
employeeNextDayClick: function () {
|
var day = utils.formatDay(utils.GetNextDate(this.data.employeeNowDay, 1));
|
|
let isEmployeeNextDayAble = false;
|
if (day == this.data.employeeHistoryDay) {
|
isEmployeeNextDayAble = true;
|
}
|
this.setData({
|
employeeNowDay: day,
|
isEmployeeNextDayAble: isEmployeeNextDayAble
|
});
|
},
|
//按产品查询界面 -- 选择日期
|
employeeSelectDate: function (e) {
|
var that = this
|
console.log(e.detail.value)
|
let selectDay = utils.formatDay(utils.GetNextDate(e.detail.value, 0));
|
var isEmployeeNextDayAble = false;
|
if (selectDay == this.data.employeeHistoryDay) {
|
isEmployeeNextDayAble = true;
|
}
|
that.setData({
|
employeeNowDay: selectDay,
|
isEmployeeNextDayAble: isEmployeeNextDayAble
|
})
|
},
|
//产品类型列表过滤显示
|
productTypeFilter: function () {
|
this.data.productTypeFilterShowStatus = !this.data.productTypeFilterShowStatus
|
this.setData({
|
productTypeFilterShowStatus: this.data.productTypeFilterShowStatus
|
})
|
},
|
//产品类型列表选项
|
productTypeOptionsChoice: function (e) {
|
this.setData({
|
"productTypeFilterList.typeFilterIndex": e.currentTarget.dataset.index,
|
productTypeFilterShowStatus: false,
|
})
|
},
|
// 手部触摸开始
|
ListTouchStart(e) {
|
this.setData({
|
ListTouchStart: e.touches[0].pageX,
|
})
|
// console.log(this.data.changeClick)
|
},
|
|
// 手指滑动过程计算方向
|
ListTouchMove(e) {
|
this.setData({
|
tapTouchDirection: e.touches[0].pageX - this.data.ListTouchStart > -50 ? 'right' : 'left',
|
})
|
// console.log(this.data.changeClick)
|
},
|
|
// 手指滑动结束计算滚动
|
ListTouchEnd(e) {
|
if (this.data.tapTouchDirection == 'left') {
|
this.setData({
|
modalName: e.currentTarget.dataset.target,
|
})
|
// console.log(this.data.changeClick)
|
} else {
|
this.setData({
|
modalName: null
|
})
|
}
|
this.setData({
|
tapTouchDirection: null,
|
})
|
},
|
//浮动菜单旋转方法
|
expand_floatMenu: function () {
|
this.setData({
|
floatMenu: {
|
animation: 'animation',
|
bindtaps: "unExpand_floatMenu"
|
}
|
})
|
},
|
unExpand_floatMenu: function () {
|
this.setData({
|
floatMenu: {
|
animation: 'animations',
|
bindtaps: "expand_floatMenu"
|
}
|
})
|
},
|
//悬浮菜单列表收缩方法
|
tapExpandList() {
|
if (this.data.isExpandList == false) {
|
this.setData({
|
isExpandList: true
|
})
|
var historyRecord = this.data.historyRecord
|
for (let i = 0; i < historyRecord.length; i++) {
|
historyRecord[i].isStatus = true
|
}
|
} else {
|
this.setData({
|
isExpandList: false
|
})
|
var historyRecord = this.data.historyRecord
|
for (let i = 0; i < historyRecord.length; i++) {
|
historyRecord[i].isStatus = false
|
}
|
}
|
this.setData({
|
historyRecord: historyRecord
|
})
|
},
|
toTop() { //悬浮菜单回到顶部方法
|
this.setData({
|
scrolltop: 0
|
})
|
},
|
//悬浮菜单刷新方法
|
tapRefreshBtn() {},
|
/**
|
* 生命周期函数--监听页面初次渲染完成
|
*/
|
onReady: function () {
|
wx.hideLoading()
|
},
|
|
/**
|
* 生命周期函数--监听页面显示
|
*/
|
onShow: function () {
|
|
},
|
|
/**
|
* 生命周期函数--监听页面隐藏
|
*/
|
onHide: function () {
|
|
},
|
|
/**
|
* 生命周期函数--监听页面卸载
|
*/
|
onUnload: function () {
|
|
},
|
|
/**
|
* 页面相关事件处理函数--监听用户下拉动作
|
*/
|
onPullDownRefresh: function () {
|
|
},
|
|
/**
|
* 页面上拉触底事件的处理函数
|
*/
|
onReachBottom: function () {
|
// console.log('到底了');
|
},
|
/**
|
* 用户点击右上角分享
|
*/
|
onShareAppMessage: function () {
|
return Constant.Share
|
},
|
})
|