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.
 
 
 
 

147 lines
3.1 KiB

// package/inspectionReport/inspectionReport.js
import { getStructuresList, getPatrolReport } from "../../utils/getApiUrl";
import { Request } from "../../common";
const moment = require("../../utils/moment");
Page({
/**
* 页面的初始数据
*/
data: {
structures: [], // 结构物
struLoading: false,
struVisible: false,
dateVisible: false,
curStru: 0, // 选中结构物index
startTime: new Date().getTime(),
endTime: new Date().getTime(),
formatStartTime: moment(new Date().getTime()).format('YYYY-MM-DD'),
formatEndTime: moment(new Date().getTime()).format('YYYY-MM-DD'),
report: [1, 2], // 巡检报告
},
showPopup(e) {
const { item } = e.currentTarget.dataset;
this.setData({ [`${item}Visible`]: true });
},
onClose(e) {
const { item } = e.currentTarget.dataset;
this.setData({ [`${item}Visible`]: false });
console.log('请求报告')
// 获取报告
// const body = {}
// Request.get(getPatrolReport(body)).then(res => {
// console.log(res)
// })
},
onStruChange(e) {
if (e.detail) {
const { value, index } = e.detail;
console.log(`当前值:${value}, 当前索引:${index}`);
this.setData({
curStru: index
})
}
},
// 时间选择
onStartTimeChange(event) {
this.setData({
startTime: event.detail,
formatStartTime: moment(event.detail).format('YYYY-MM-DD')
});
},
onEndTimeChange(event) {
this.setData({
endTime: event.detail,
formatEndTime: moment(event.detail).format('YYYY-MM-DD'),
});
},
download() {
wx.showLoading({ title: '下载中...' });
wx.downloadFile({
url: 'http://10.8.16.102:5900/_file-server/project/d178aef7-4a88-41c4-aa82-4254fbcf884e/16518450744352.jpg', // 仅为示例,并非真实的资源
success(downloadRes) {
wx.hideLoading();
if (downloadRes.statusCode === 200) {
const filePath = downloadRes.tempFilePath;
wx.openDocument({
filePath: filePath,
success: function (res) {
console.log('打开文档成功');
}
})
}
}
})
},
getStructuresList() {
this.setData({ struLoading: true });
Request.get(getStructuresList()).then(res => {
this.setData({
struLoading: false,
structures: ['全部', ...res.rows.map(s => s.name)]
})
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.getStructuresList();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})