jhwxapp/miniprogram/pageage/project_checkDetection/info/index.js

340 lines
7.4 KiB
JavaScript
Raw Normal View History

2023-09-01 02:28:39 +08:00
// pageage/project_checking/info/index.js
const app = getApp()
Page({
2024-04-14 21:28:11 +08:00
/**
* 页面的初始数据
*/
data: {
id: "",
infoData: {},
loadShow: false,
loginName: "",
showDel: false,
detectionImageList: [],
minDetectionFileImages: [],
detectionFiles: [],
fileUrls: [],
activeName: "",
flowRecordList: [],
request: app.globalData.reqUrl,
flowNodes: [{
text: '开始'
}, {
text: '提交申请'
}, {
text: '检测报告'
}, {
text: '监理审批'
}, {
text: '结束'
}],
2024-05-03 10:37:27 +08:00
active: 100,
attachments:[],
2024-04-14 21:28:11 +08:00
},
2023-09-01 02:28:39 +08:00
2024-04-14 21:28:11 +08:00
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
let {
id
} = options
//获取缓存数据
wx.getStorage({
key: 'userinfo',
success: res => {
this.setData({
id,
loginName: res.data.loginName
})
this.getInfo();
this.getAuditinfo();
}
})
},
2023-09-01 02:28:39 +08:00
2024-04-14 21:28:11 +08:00
/**
* 获取安全检查详情信息
*
*/
getInfo() {
let {
id
} = this.data
let that = this
wx.request({
url: app.globalData.reqUrl + '/wechat/projectDetection/info',
method: "get",
data: {
id: id
},
success(res) {
res = res.data
if (res.code == 200) {
let state = that.data.active;
if (res.data.approveStatus == null) {
state = 2;
2024-05-03 10:37:27 +08:00
} else if (res.data.approveStatus == "1") {
2024-04-14 21:28:11 +08:00
state = 3;
} else if (res.data.approveStatus == "3") {
state = 2;
}
that.setData({
active: state
})
let imageUrls = [];
let minImageUrls = [];
let fileUrls = [];
let fileNames = [];
//判断附件
if (res.data.detectionFile) {
res.data.detectionFile.split(',').forEach(element => {
let _file = element.split('.');
_file = _file[_file.length - 1].toLocaleUpperCase();
//判断附件类型,如果是图片直接展示,非图片则显示附件
if (_file == "PNG" || _file == "JPG" || _file == "JPEG") {
imageUrls.push(that.data.request + element);
minImageUrls.push(that.data.request + element + '.min.jpg');
} else {
let it = element.split('/');
fileNames.push(it[it.length - 1]);
fileUrls.push(element);
2023-09-01 02:28:39 +08:00
}
2024-04-14 21:28:11 +08:00
});
2023-09-01 02:28:39 +08:00
}
2024-05-03 10:37:27 +08:00
let attachments = [];
if (res.data.attachment) {
let files = JSON.parse(res.data.attachment);
if (files && files.length > 0) {
files.forEach(item => {
let it = item.split('/');
attachments.push({
'name': it[it.length - 1],
path: item
});
});
}
}
2024-04-14 21:28:11 +08:00
that.setData({
infoData: res.data,
2024-05-03 10:37:27 +08:00
attachments,
2024-04-14 21:28:11 +08:00
detectionImageList: imageUrls,
minDetectionFileImages: minImageUrls,
detectionFiles: fileNames,
fileUrls,
loadShow: false
})
//判断当前能否删除
if (res.data.createBy == that.data.loginName && res.data.approveStatus != "4") {
2023-09-23 20:13:40 +08:00
that.setData({
2024-04-14 21:28:11 +08:00
showDel: true
2023-09-23 20:13:40 +08:00
})
}
}
2024-04-14 21:28:11 +08:00
}
})
},
/**
* 查询流程日志
*/
getAuditinfo() {
let that = this
wx.request({
url: app.globalData.reqUrl + '/wechat/projectAuditinfo/selectProjectAuditinfo',
method: "get",
data: {
fromType: "1",
fromId: this.data.id
},
success(res) {
res = res.data
if (res.code == 200) {
that.setData({
flowRecordList: res.data
})
}
}
})
2023-09-23 20:13:40 +08:00
},
// 手风琴
onChange(event) {
this.setData({
activeName: event.detail,
});
},
2024-04-14 21:28:11 +08:00
onDelete() {
//弹出确认
let that = this
wx.showModal({
title: '提示',
content: '是否确定删除此条数据?',
success: function (sm) {
if (sm.confirm) {
// 用户点击了确定 可以调用了
that.deleteData();
} else if (sm.cancel) {
console.log('用户点击取消');
}
}
})
},
deleteData() {
let {
id
} = this.data
wx.request({
url: app.globalData.reqUrl + '/wechat/projectDetection/remove',
header: {
"Username": this.data.loginName,
},
data: {
id: id
},
method: "get",
success(res) {
app.toast("删除成功!")
wx.redirectTo({
url: `../list/index`,
2023-09-01 02:28:39 +08:00
})
2024-04-14 21:28:11 +08:00
}
})
},
2023-09-01 02:28:39 +08:00
2023-09-24 23:17:05 +08:00
//跳转修改页面
2024-04-14 21:28:11 +08:00
onUpdate: function () {
2023-09-24 23:17:05 +08:00
let id = this.data.id;
wx.redirectTo({
url: `../edit/index?id=${id}`,
})
},
2023-09-23 20:13:40 +08:00
//展示图片
2024-04-14 21:28:11 +08:00
showImg: function (e) {
var that = this;
2023-09-23 20:13:40 +08:00
wx.previewImage({
2024-04-14 21:28:11 +08:00
urls: that.data.detectionImageList,
current: that.data.detectionImageList[e.currentTarget.dataset.index]
2023-09-23 20:13:40 +08:00
})
2023-09-01 02:28:39 +08:00
},
2024-04-14 21:28:11 +08:00
downFile: function (e) {
2023-09-17 18:10:31 +08:00
let that = this;
wx.downloadFile({
// 示例 url并非真实存在
2024-04-14 21:28:11 +08:00
url: app.globalData.uploadUrl + '/common/download/resource?resource=' + that.data.fileUrls[0],
2023-09-17 18:10:31 +08:00
success: function (res) {
const filePath = res.tempFilePath
wx.openDocument({
2024-04-14 21:28:11 +08:00
filePath: filePath,
success: function (res) {
console.log('打开文档成功')
},
fail: function (res) {
console.log(res)
}
2023-09-17 18:10:31 +08:00
})
}
2024-04-14 21:28:11 +08:00
})
//app.toast("暂不支持下载!如需下载请前往后台管理系统!!")
2023-09-17 18:10:31 +08:00
},
2024-05-03 10:37:27 +08:00
//展示图片
showImg2: function (e) {
if (this.data.infoData.trustDeed != null) {
let imgs = this.data.infoData.trustDeed.split(',');
let list = [];
imgs.forEach(item => {
list.push(this.data.request + item);
})
wx.previewImage({
urls: list,
current: imgs[e.currentTarget.dataset.index]
})
}
},
/**
* 下载附件
* @param {*} e
*/
downFile2: function (e) {
let {
path,
} = e.currentTarget.dataset.set
wx.downloadFile({
url: app.globalData.uploadUrl + '/common/download/resource?resource=' + path,
success: function (res) {
const filePath = res.tempFilePath
wx.openDocument({
filePath: filePath,
success: function (res) {
console.log('打开文档成功')
},
fail: function (res) {
console.log(res)
}
})
}
})
},
2023-09-23 20:13:40 +08:00
returnToPage: function () {
/*关闭当前页面,跳转到应用内的某个页面。但是不允许跳转到 tabbar 页面*/
wx.redirectTo({
2024-04-14 21:28:11 +08:00
url: '../list/index',
2023-09-23 20:13:40 +08:00
})
},
2023-09-01 02:28:39 +08:00
2024-04-14 21:28:11 +08:00
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
2023-09-01 02:28:39 +08:00
2024-04-14 21:28:11 +08:00
},
2023-09-01 02:28:39 +08:00
2024-04-14 21:28:11 +08:00
/**
* 生命周期函数--监听页面显示
*/
onShow() {
2023-09-01 02:28:39 +08:00
2024-04-14 21:28:11 +08:00
},
2023-09-01 02:28:39 +08:00
2024-04-14 21:28:11 +08:00
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
2023-09-01 02:28:39 +08:00
2024-04-14 21:28:11 +08:00
},
2023-09-01 02:28:39 +08:00
2024-04-14 21:28:11 +08:00
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
2023-09-01 02:28:39 +08:00
2024-04-14 21:28:11 +08:00
},
2023-09-01 02:28:39 +08:00
2024-04-14 21:28:11 +08:00
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
2023-09-01 02:28:39 +08:00
2024-04-14 21:28:11 +08:00
},
2023-09-01 02:28:39 +08:00
2024-04-14 21:28:11 +08:00
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
2023-09-01 02:28:39 +08:00
2024-04-14 21:28:11 +08:00
},
2023-09-01 02:28:39 +08:00
2024-04-14 21:28:11 +08:00
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
2023-09-01 02:28:39 +08:00
2024-04-14 21:28:11 +08:00
}
2023-09-01 02:28:39 +08:00
})