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.
167 lines
4.3 KiB
167 lines
4.3 KiB
// package/inspectionReport/inspectionReport.js
|
|
import { getStructuresList, getPatrolReport } from "../../utils/getApiUrl";
|
|
import { Request } from "../../common";
|
|
const moment = require("../../utils/moment");
|
|
|
|
Page({
|
|
formatStartTime: moment(new Date().getTime()).format('YYYY-MM-DD'),
|
|
formatEndTime: moment(new Date().getTime()).format('YYYY-MM-DD'),
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
structures: [], // 结构物
|
|
curStruId: 'all', // 选中结构物id
|
|
startTime: new Date().getTime(),
|
|
endTime: new Date().getTime(),
|
|
|
|
report: [], // 巡检报告
|
|
},
|
|
|
|
onClose(e) {
|
|
// 获取报告
|
|
this.getPatrolReport();
|
|
},
|
|
|
|
onStruChange(e) {
|
|
if (e.detail) {
|
|
this.setData({
|
|
curStruId: e.detail
|
|
})
|
|
}
|
|
},
|
|
// 时间选择
|
|
onStartTimeChange(event) {
|
|
this.formatStartTime= moment(event.detail).format('YYYY-MM-DD')
|
|
this.setData({
|
|
startTime: event.detail,
|
|
});
|
|
},
|
|
onEndTimeChange(event) {
|
|
this.formatEndTime=moment(event.detail).format('YYYY-MM-DD')
|
|
this.setData({
|
|
endTime: event.detail,
|
|
});
|
|
},
|
|
|
|
download(e) {
|
|
const { url } = e.currentTarget.dataset;
|
|
wx.showLoading({ title: '下载中...' });
|
|
wx.downloadFile({
|
|
url: getApp().globalData.imgUrl + url,
|
|
success(downloadRes) {
|
|
wx.hideLoading();
|
|
if (downloadRes.statusCode === 200) {
|
|
const filePath = downloadRes.tempFilePath;
|
|
wx.openDocument({
|
|
filePath,
|
|
showMenu: true,
|
|
fileType:url.includes('xlsx')?'xlsx':url.includes('docx')?'docx':'',
|
|
success: function (res) {
|
|
console.log('打开文档成功');
|
|
},
|
|
fail: function (error) {
|
|
wx.hideLoading();
|
|
console.error('打开文档失败', error);
|
|
}
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
|
|
getPatrolReport() {
|
|
const { curStruId, } = this.data;
|
|
const params = {
|
|
projectId: curStruId === 'all' ? '' : curStruId,
|
|
startTime: this.formatStartTime + ' 00:00:00',
|
|
endTime: this.formatEndTime + ' 23:59:59',
|
|
}
|
|
wx.showLoading({ title: '查询中...' });
|
|
Request.get(getPatrolReport(params)).then(res => {
|
|
wx.hideLoading();
|
|
this.setData({
|
|
report: res.rows?.filter(i=>i?.excelPath.includes('xjGL'))?.map(r => {
|
|
const fileName = r.excelPath.substring(r.excelPath.lastIndexOf('/') + 1);
|
|
return { ...r, fileName, inspectTm: moment(r.inspectTm).format('YYYY-MM-DD HH:mm:ss') }
|
|
})
|
|
})
|
|
})
|
|
},
|
|
|
|
getStructuresList() {
|
|
Request.get(getStructuresList()).then(res => {
|
|
const filterData=res.rows.filter(s => s.type=='管廊' )
|
|
this.setData({
|
|
structures: [
|
|
{ text: '全部', value: 'all' },
|
|
...filterData.map(p=>(
|
|
{ text: p.name, value: p.id }
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
]
|
|
}, () => {
|
|
this.getPatrolReport(); })
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
this.getStructuresList();
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
}
|
|
})
|