You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

254 lines
6.6 KiB

// package/bindTroubleshooting/index.js
import { getPatrolRecordIssueHandle, getStructuresUsers } from "../../utils/getApiUrl";
import { Request } from "../../common";
const moment = require("../../utils/moment");
let setFilterStartTime = 0
let setFilterEndTime = 0
Page({
/**
* 页面的初始数据
*/
data: {
userInfo: wx.getStorageSync("userInfo"),
//
dataList: [],
currentTab: '0',
// 筛选选择
structList: [],
structResult: [],
pointList: [],
pointResult: [],
// 时间筛选
startTime: '',
endTime: '',
//
timeSelectedUnrealFlag: true,
powerCheckDetail: false
},
// 顶部tab切换
clickTab (e) {
this.setData({
currentTab: e.currentTarget.dataset.current
})
if (e.currentTarget.dataset.current == '0') {
} else if (e.currentTarget.dataset.current == '1') {
}
this.setData({
page: 0,
dataList: []
}, () => {
this.getData({
type: e.currentTarget.dataset.current == '0' ? 'backlog' : 'haveDone'
});
})
},
getData (params) {
Request.get(getPatrolRecordIssueHandle(), {
...params,
}).then(res => {
this.setData({
dataList: res.map(r => {
return {
...r,
createTime: r.createTime ? moment(r.createTime).format('YYYY-MM-DD HH:mm:ss') : '--'
}
})
})
})
},
// 筛选选择
onStructChange (event) {
const { structList, pointList } = this.data
let nextPointList = []
for (let s of structList) {
if (event.detail.some(ed => ed == s.id)) {
// 选了这个结构物
for (let sp of s.points) {
let corPoint = pointList.find(pl => pl.id == sp.id)
if (corPoint) {
// 有这个点
nextPointList.push({
...sp,
selected: corPoint.selected
})
} else {
nextPointList.push({
...sp,
selected: true
})
}
}
}
}
this.setData({
structResult: event.detail,
pointList: nextPointList,
})
},
structToggle (event) {
const { index } = event.currentTarget.dataset;
const checkbox = this.selectComponent(`.checkboxes-struct-${index}`);
checkbox.toggle();
},
onPointChange (event) {
this.setData({
pointResult: event.detail,
});
},
pointToggle (event) {
const { index, id } = event.currentTarget.dataset;
// const checkbox = this.selectComponent(`.checkboxes-point-${id}`);
// checkbox.toggle();
const { pointList } = this.data
let pointList_ = JSON.parse(JSON.stringify(pointList))
pointList_[index].selected = !pointList_[index].selected
this.setData({
pointList: pointList_
})
},
noop () { },
// 时间选择
onStartTimeChange (event) {
const { timeSelectedUnrealFlag, startTime, endTime } = this.data
if (timeSelectedUnrealFlag && event.detail == 1640966400000) {
return
}
if(new Date().getTime() - setFilterStartTime < 100){
return
}
setFilterStartTime = new Date().getTime()
this.setData({
startTime: event.detail,
endTime: endTime ? endTime : 1640966400000
});
},
onEndTimeChange (event) {
const { timeSelectedUnrealFlag, startTime, endTime } = this.data
console.log('结束时间', timeSelectedUnrealFlag, event, new Date().getTime());
if (timeSelectedUnrealFlag && event.detail == 1640966400000) {
return
}
if(new Date().getTime() - setFilterEndTime < 100){
return
}
setFilterEndTime = new Date().getTime()
this.setData({
startTime: startTime ? startTime : 1640966400000,
endTime: event.detail,
});
return
},
onDropDownClose () {
const { currentTab, startTime, endTime, pointList, structResult } = this.data
this.getData({
type: currentTab == '0' ? 'backlog' : 'haveDone',
startTime,
endTime,
pointId: pointList.length ? (() => {
let sendPointId = []
for (let p of pointList) {
if (p.selected) {
sendPointId.push(p.id)
}
}
if (!sendPointId.length) {
sendPointId.push('-1')
}
return sendPointId.join(',')
})() : structResult.length ? '-1' : ''
})
},
// 页面跳转
toShootingForm (e) {
const { shootingid } = e.currentTarget.dataset
wx.navigateTo({
url: '/package/troubleshooting/shootingForm/index?shootingid=' + shootingid + '&tabIndex=' + this.data.currentTab,
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad (options) {
Request.get(getStructuresUsers(), {}).then(res => {
this.setData({
structList: res
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady () {
this.getData({
type: 'backlog'
});
setTimeout(() => {
this.setData({
timeSelectedUnrealFlag: false
})
}, 1000)
if (this.data.userInfo && this.data.userInfo.userResources.includes('CHAKANXIANGQING') || this.data.userInfo.username == 'SuperAdmin') {
this.setData({
powerCheckDetail: true
})
}
},
/**
* 生命周期函数--监听页面显示
*/
onShow () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage () {
}
})