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.
324 lines
9.1 KiB
324 lines
9.1 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"),
|
|
//
|
|
isEdit:false,//管理端控制不可编辑
|
|
dataList: [],
|
|
willdoneList:[],
|
|
currentTab: 0,
|
|
// 筛选选择
|
|
structList: [],
|
|
structResult: [],
|
|
pointList: [],
|
|
pointResult: [],
|
|
// 时间筛选
|
|
startTime: '',
|
|
endTime: '',
|
|
doneLength:0,
|
|
willLength:0,
|
|
// doneVis:false,
|
|
willVis:true,
|
|
//
|
|
timeSelectedUnrealFlag: true,
|
|
powerCheckDetail: false
|
|
},
|
|
|
|
// 顶部tab切换
|
|
clickTab (e) {
|
|
// console.log('e.detail.name',e.detail.name)
|
|
this.setData({
|
|
currentTab: e.detail.name,
|
|
// doneVis:e.detail.name==='待办事项'?true:false,
|
|
willVis:e.detail.name===0?true:false
|
|
})
|
|
this.setData({
|
|
page: 0,
|
|
dataList: [],
|
|
willdoneList:[]
|
|
}, () => {
|
|
this.getData({
|
|
// type: e.detail.name === 0 ? 'backlog' : 'haveDone'
|
|
});
|
|
})
|
|
},
|
|
|
|
getData (params) {
|
|
const userInfo = wx.getStorageSync('userInfo');
|
|
//已办
|
|
Request.get(getPatrolRecordIssueHandle(), {
|
|
...params,type:'haveDone',wx:true
|
|
}).then(res => {
|
|
const rslt=userInfo?.role?.includes('管理')?res.filter(item=>item?.PatrolRecord?.project?.type==='管廊'):res
|
|
this.setData({
|
|
doneLength:rslt.length,
|
|
dataList: rslt.map(r => {
|
|
return {
|
|
...r,
|
|
key:r.id,
|
|
createTime: r.createTime ? moment(r.createTime).format('YYYY-MM-DD HH:mm:ss') : '--'
|
|
}
|
|
})
|
|
})
|
|
})
|
|
//待办
|
|
Request.get(getPatrolRecordIssueHandle(), {
|
|
...params,type:'backlog',wx:true
|
|
}).then(res => {
|
|
const rslt=userInfo?.role?.includes('管理')?res.filter(item=>item?.PatrolRecord?.project?.type==='管廊'):res
|
|
this.setData({
|
|
willLength:rslt.length,
|
|
willdoneList: rslt.map(r => {
|
|
return {
|
|
key:r.id,
|
|
...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
|
|
let params={
|
|
// 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' : ''
|
|
}
|
|
this.getData(params)
|
|
// this.getCount(params)
|
|
},
|
|
|
|
// 页面跳转
|
|
toShootingForm (e) {
|
|
const { shootingid } = e.currentTarget.dataset
|
|
wx.navigateTo({
|
|
url: '/package/troubleshooting/shootingForm/index?shootingid=' + shootingid + '&tabIndex=' + this.data.currentTab,
|
|
})
|
|
},
|
|
//求未办和已办数量
|
|
// getCount(data){
|
|
// Request.get(getPatrolRecordIssueHandle(), {...data,type: 'haveDone'}).then(res=>{
|
|
// console.log('res',res)
|
|
// if(res.length){
|
|
// this.setData({
|
|
// doneLength:res.length
|
|
// })
|
|
// }else{
|
|
// this.setData({
|
|
// doneLength:0
|
|
// })
|
|
// }
|
|
// })
|
|
// Request.get(getPatrolRecordIssueHandle(), {...data,type: 'backlog'}).then(res=>{
|
|
// if(res.length){
|
|
// this.setData({
|
|
// willLength:res.length
|
|
// })
|
|
// }else{
|
|
// this.setData({
|
|
// willLength:0
|
|
// })
|
|
// }
|
|
// })
|
|
// },
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad (options) {
|
|
if(options?.home){
|
|
wx.setNavigationBarTitle({
|
|
title: '维修台账',
|
|
});
|
|
}
|
|
// this.getCount()
|
|
const userInfo = wx.getStorageSync('userInfo');
|
|
let bool=false
|
|
if(userInfo?.role.includes('管理')){
|
|
bool=true
|
|
}
|
|
this.setData({
|
|
isEdit:bool
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow () {
|
|
const userInfo = wx.getStorageSync('userInfo');
|
|
Request.get(getStructuresUsers(), {}).then(res => {
|
|
this.setData({
|
|
structList:userInfo?.username==='SuperAdmin'?res:
|
|
userInfo?.role?.includes('管理')?res.filter(item=>item.type==='管廊'):res
|
|
})
|
|
})
|
|
this.getData({ })
|
|
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
|
|
})
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage () {
|
|
|
|
}
|
|
})
|