2023-09-01 02:28:39 +08:00
|
|
|
|
// pageage/project_checking/info/index.js
|
|
|
|
|
const app = getApp()
|
|
|
|
|
Page({
|
|
|
|
|
|
2024-05-03 10:37:27 +08:00
|
|
|
|
/**
|
|
|
|
|
* 页面的初始数据
|
|
|
|
|
*/
|
|
|
|
|
data: {
|
|
|
|
|
id: "",
|
|
|
|
|
infoData: {},
|
|
|
|
|
loadShow: false,
|
|
|
|
|
loginName: "",
|
|
|
|
|
showDel: false,
|
|
|
|
|
detectionImageList: [],
|
|
|
|
|
minDetectionFileImages: [],
|
|
|
|
|
detectionFiles: [],
|
|
|
|
|
list: [{
|
|
|
|
|
id: 1,
|
|
|
|
|
text: "合格"
|
|
|
|
|
}, {
|
|
|
|
|
id: 2,
|
|
|
|
|
text: "不合格"
|
|
|
|
|
}],
|
|
|
|
|
detectionResult: "1",
|
|
|
|
|
detectionFileData: [],
|
|
|
|
|
fileType: ["pdf", "png", "jpg", "jpeg"],
|
|
|
|
|
request: app.globalData.reqUrl,
|
|
|
|
|
flowNodes: [{
|
|
|
|
|
text: '开始'
|
|
|
|
|
}, {
|
|
|
|
|
text: '提交申请'
|
|
|
|
|
}, {
|
|
|
|
|
text: '检测报告'
|
|
|
|
|
}, {
|
|
|
|
|
text: '监理审批'
|
|
|
|
|
}, {
|
|
|
|
|
text: '结束'
|
|
|
|
|
}],
|
|
|
|
|
active: 2,
|
|
|
|
|
attachments: []
|
|
|
|
|
},
|
2023-09-01 02:28:39 +08:00
|
|
|
|
|
2024-05-03 10:37:27 +08:00
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
|
*/
|
|
|
|
|
onLoad(options) {
|
|
|
|
|
let {
|
|
|
|
|
id
|
|
|
|
|
} = options
|
|
|
|
|
//获取缓存数据
|
|
|
|
|
wx.getStorage({
|
|
|
|
|
key: 'userinfo',
|
|
|
|
|
success: res => {
|
|
|
|
|
this.setData({
|
|
|
|
|
id,
|
|
|
|
|
loginName: res.data.loginName
|
|
|
|
|
})
|
|
|
|
|
this.getInfo();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
2023-09-01 02:28:39 +08:00
|
|
|
|
|
2024-05-03 10:37:27 +08:00
|
|
|
|
//取消页面
|
|
|
|
|
cancelSaveView() {
|
|
|
|
|
this.returnToPage()
|
|
|
|
|
},
|
2023-09-01 02:28:39 +08:00
|
|
|
|
|
2024-05-03 10:37:27 +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 imageUrls = [];
|
|
|
|
|
let minImageUrls = [];
|
|
|
|
|
let fileUrls = [];
|
|
|
|
|
//判断附件
|
|
|
|
|
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 {
|
|
|
|
|
fileUrls.push(element);
|
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
|
|
|
|
|
});
|
|
|
|
|
});
|
2023-09-01 02:28:39 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-03 10:37:27 +08:00
|
|
|
|
that.setData({
|
|
|
|
|
infoData: res.data,
|
|
|
|
|
attachments,
|
|
|
|
|
detectionImageList: imageUrls,
|
|
|
|
|
minDetectionFileImages: minImageUrls,
|
|
|
|
|
detectionFiles: fileUrls,
|
|
|
|
|
loadShow: false
|
|
|
|
|
})
|
|
|
|
|
//判断当前能否删除
|
|
|
|
|
if (res.data.createBy == that.data.loginName) {
|
2023-09-01 02:28:39 +08:00
|
|
|
|
that.setData({
|
2024-05-03 10:37:27 +08:00
|
|
|
|
showDel: true
|
2023-09-01 02:28:39 +08:00
|
|
|
|
})
|
|
|
|
|
}
|
2024-05-03 10:37:27 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
2023-09-01 02:28:39 +08:00
|
|
|
|
|
2024-05-03 10:37:27 +08:00
|
|
|
|
//保存
|
|
|
|
|
onSubmitSave() {
|
|
|
|
|
this.setData({
|
|
|
|
|
loadShow: true
|
|
|
|
|
})
|
|
|
|
|
let that = this
|
|
|
|
|
let {
|
|
|
|
|
id,
|
|
|
|
|
detectionResult,
|
|
|
|
|
detectionFileData,
|
|
|
|
|
loginName
|
|
|
|
|
} = that.data;
|
|
|
|
|
//数据效验
|
|
|
|
|
if (id == "" || loginName == "") {
|
|
|
|
|
app.toast("数据异常,请刷新页面重试!")
|
|
|
|
|
that.setData({
|
|
|
|
|
loadShow: false
|
|
|
|
|
})
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// if(detectionResult==""){
|
|
|
|
|
// app.toast("请选择检测结果!")
|
|
|
|
|
// that.setData({
|
|
|
|
|
// loadShow:false
|
|
|
|
|
// })
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
if (detectionFileData.length == 0) {
|
|
|
|
|
app.toast("请上传检测报告!")
|
|
|
|
|
that.setData({
|
|
|
|
|
loadShow: false
|
|
|
|
|
})
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
let _fileType = detectionFileData[0].path.split('.');
|
|
|
|
|
_fileType = _fileType[_fileType.length - 1].toLowerCase();
|
|
|
|
|
//判断附件类型,如果是图片直接展示,非图片则显示附件
|
|
|
|
|
if (this.data.fileType.indexOf(_fileType) == -1) {
|
|
|
|
|
app.toast("检测报告不支持 [ " + _fileType + " ] 格式!")
|
|
|
|
|
that.setData({
|
|
|
|
|
loadShow: false
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
detectionFileData.forEach(async (item) => {
|
|
|
|
|
let uploadUrl = app.globalData.uploadUrl + '/common/upload'
|
|
|
|
|
let uploadName = "file"
|
|
|
|
|
//这里复杂的图片上传,改为同步上传,因为小程序只能上传一张图片
|
|
|
|
|
let obj = await that.syncUploadImage(uploadUrl, item.path, uploadName);
|
|
|
|
|
let params = {
|
|
|
|
|
id,
|
|
|
|
|
checkState: "2",
|
|
|
|
|
//detectionResult,
|
|
|
|
|
detectionFile: obj.data.fileName,
|
|
|
|
|
approveStatus: "1",
|
|
|
|
|
updateBy: loginName
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wx.request({
|
|
|
|
|
url: app.globalData.reqUrl + "/wechat/projectDetection/edit",
|
|
|
|
|
method: "POST",
|
|
|
|
|
data: params,
|
|
|
|
|
header: {
|
|
|
|
|
"Username": loginName,
|
|
|
|
|
"Content-Type": "application/json"
|
|
|
|
|
},
|
|
|
|
|
success(res) {
|
|
|
|
|
that.setData({
|
|
|
|
|
loadShow: false
|
|
|
|
|
})
|
|
|
|
|
res = res.data
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
app.toast("提交成功!")
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
wx.redirectTo({
|
|
|
|
|
url: '../list/index',
|
2023-09-01 02:28:39 +08:00
|
|
|
|
})
|
2024-05-03 10:37:27 +08:00
|
|
|
|
}, 200)
|
2023-09-01 02:28:39 +08:00
|
|
|
|
}
|
2024-05-03 10:37:27 +08:00
|
|
|
|
}
|
2023-09-01 02:28:39 +08:00
|
|
|
|
})
|
2024-05-03 10:37:27 +08:00
|
|
|
|
})
|
2023-09-01 02:28:39 +08:00
|
|
|
|
},
|
|
|
|
|
|
2024-05-03 10:37:27 +08:00
|
|
|
|
/**
|
|
|
|
|
* 这里考虑上传图片异步问题,封装为同步
|
|
|
|
|
*/
|
|
|
|
|
syncUploadImage(url, uploadFile, name) {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
wx.uploadFile({
|
|
|
|
|
url, // 上传的服务器接口地址
|
|
|
|
|
filePath: uploadFile,
|
|
|
|
|
header: {
|
|
|
|
|
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
|
|
|
|
|
},
|
|
|
|
|
name, //上传的所需字段,后端提供
|
|
|
|
|
formData: {
|
|
|
|
|
user: 'test'
|
|
|
|
|
},
|
|
|
|
|
success: (res) => {
|
|
|
|
|
// 上传完成操作
|
|
|
|
|
const data = JSON.parse(res.data)
|
|
|
|
|
resolve({
|
|
|
|
|
data: data
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
fail: (err) => {
|
|
|
|
|
//上传失败:修改pedding为reject
|
|
|
|
|
console.log("访问接口失败", err);
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: "网络出错,上传失败",
|
|
|
|
|
icon: 'none',
|
|
|
|
|
duration: 1000
|
|
|
|
|
});
|
|
|
|
|
reject(err)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
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-05-03 10:37:27 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
2023-09-01 02:28:39 +08:00
|
|
|
|
|
2023-09-24 23:17:05 +08:00
|
|
|
|
//跳转修改页面
|
2024-05-03 10:37:27 +08:00
|
|
|
|
onUpdate: function () {
|
2023-09-24 23:17:05 +08:00
|
|
|
|
let id = this.data.id;
|
|
|
|
|
wx.redirectTo({
|
|
|
|
|
url: `../edit/index?id=${id}`,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
2024-05-03 10:37:27 +08:00
|
|
|
|
//展示图片
|
|
|
|
|
showImg: function (e) {
|
|
|
|
|
var that = this;
|
|
|
|
|
wx.previewImage({
|
|
|
|
|
urls: that.data.imageList,
|
|
|
|
|
current: that.data.imageList[e.currentTarget.dataset.index]
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
//展示图片
|
|
|
|
|
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);
|
|
|
|
|
})
|
2023-09-01 02:28:39 +08:00
|
|
|
|
wx.previewImage({
|
2024-05-03 10:37:27 +08:00
|
|
|
|
urls: list,
|
|
|
|
|
current: imgs[e.currentTarget.dataset.index]
|
2023-09-01 02:28:39 +08:00
|
|
|
|
})
|
2024-05-03 10:37:27 +08:00
|
|
|
|
}
|
2023-09-01 02:28:39 +08:00
|
|
|
|
},
|
|
|
|
|
|
2024-05-03 10:37:27 +08:00
|
|
|
|
//选择检测类型
|
|
|
|
|
onSelect(e) {
|
|
|
|
|
this.setData({
|
|
|
|
|
detectionResult: e.detail.id
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
fileUpload(options) {
|
|
|
|
|
let file = options.detail;
|
|
|
|
|
this.setData({
|
|
|
|
|
detectionFileData: file
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 下载附件
|
|
|
|
|
* @param {*} e
|
|
|
|
|
*/
|
|
|
|
|
downFile: 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-01 02:28:39 +08:00
|
|
|
|
})
|
2024-05-03 10:37:27 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
returnToPage: function () {
|
|
|
|
|
/*关闭当前页面,跳转到应用内的某个页面。但是不允许跳转到 tabbar 页面*/
|
|
|
|
|
wx.redirectTo({
|
|
|
|
|
url: '../list/index',
|
|
|
|
|
})
|
|
|
|
|
},
|
2023-09-01 02:28:39 +08:00
|
|
|
|
|
2024-05-03 10:37:27 +08:00
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
|
*/
|
|
|
|
|
onReady() {
|
2023-09-01 02:28:39 +08:00
|
|
|
|
|
2024-05-03 10:37:27 +08:00
|
|
|
|
},
|
2023-09-01 02:28:39 +08:00
|
|
|
|
|
2024-05-03 10:37:27 +08:00
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
|
*/
|
|
|
|
|
onShow() {
|
2023-09-01 02:28:39 +08:00
|
|
|
|
|
2024-05-03 10:37:27 +08:00
|
|
|
|
},
|
2023-09-01 02:28:39 +08:00
|
|
|
|
|
2024-05-03 10:37:27 +08:00
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
|
*/
|
|
|
|
|
onHide() {
|
2023-09-01 02:28:39 +08:00
|
|
|
|
|
2024-05-03 10:37:27 +08:00
|
|
|
|
},
|
2023-09-01 02:28:39 +08:00
|
|
|
|
|
2024-05-03 10:37:27 +08:00
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
|
*/
|
|
|
|
|
onUnload() {
|
2023-09-01 02:28:39 +08:00
|
|
|
|
|
2024-05-03 10:37:27 +08:00
|
|
|
|
},
|
2023-09-01 02:28:39 +08:00
|
|
|
|
|
2024-05-03 10:37:27 +08:00
|
|
|
|
/**
|
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
|
*/
|
|
|
|
|
onPullDownRefresh() {
|
2023-09-01 02:28:39 +08:00
|
|
|
|
|
2024-05-03 10:37:27 +08:00
|
|
|
|
},
|
2023-09-01 02:28:39 +08:00
|
|
|
|
|
2024-05-03 10:37:27 +08:00
|
|
|
|
/**
|
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
|
*/
|
|
|
|
|
onReachBottom() {
|
2023-09-01 02:28:39 +08:00
|
|
|
|
|
2024-05-03 10:37:27 +08:00
|
|
|
|
},
|
2023-09-01 02:28:39 +08:00
|
|
|
|
|
2024-05-03 10:37:27 +08:00
|
|
|
|
/**
|
|
|
|
|
* 用户点击右上角分享
|
|
|
|
|
*/
|
|
|
|
|
onShareAppMessage() {
|
2023-09-01 02:28:39 +08:00
|
|
|
|
|
2024-05-03 10:37:27 +08:00
|
|
|
|
}
|
2023-09-01 02:28:39 +08:00
|
|
|
|
})
|