519 lines
14 KiB
JavaScript
519 lines
14 KiB
JavaScript
import {
|
||
syncFileUpload
|
||
} from '../../../utils/request'
|
||
import {
|
||
getDictCache,
|
||
selectProjectAuditinfoList
|
||
} from '../../../api/publics'
|
||
import {
|
||
getProjectFunVerify,
|
||
updateProjectFunVerify
|
||
} from '../../../api/projectFunVerify'
|
||
const app = getApp()
|
||
Page({
|
||
|
||
/**
|
||
* 页面的初始数据
|
||
*/
|
||
data: {
|
||
maxDate: new Date(2088, 1, 1).getTime(),
|
||
deptId: "",
|
||
projectId: "",
|
||
projectName: "",
|
||
loginName: "",
|
||
userName: "",
|
||
rectifierData: [],
|
||
rectifierData2: [],
|
||
imageInfoData: [],
|
||
checkingResult: "1",
|
||
//验收时间
|
||
checkTime: '',
|
||
qualityUser: "",
|
||
qualityUserName: "",
|
||
superviseUser: "",
|
||
superviseUserName: "",
|
||
checkName: "",
|
||
intro: "",
|
||
infoData: {},
|
||
activeName: "",
|
||
flowRecordList: [],
|
||
minUrls: [],
|
||
checkType: "",
|
||
dataTypeList: [],
|
||
list: [{
|
||
id: 1,
|
||
text: "合格"
|
||
}, {
|
||
id: 2,
|
||
text: "不合格"
|
||
}],
|
||
request: app.globalData.reqUrl,
|
||
flowNodes: [{
|
||
text: '开始'
|
||
}, {
|
||
text: '提交申请'
|
||
}, {
|
||
text: '监理审批'
|
||
}, {
|
||
text: '结束'
|
||
}],
|
||
limit: 999,
|
||
active: 1,
|
||
checkFiles: "",
|
||
fileType: ["doc", "docx", "xls", "xlsx", "ppt", "pptx", "pdf", "png", "jpg", "jpeg"],
|
||
fileUrlArray: []
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面加载
|
||
*/
|
||
onLoad(options) {
|
||
let {
|
||
id
|
||
} = options
|
||
//获取缓存数据
|
||
wx.getStorage({
|
||
key: 'userinfo',
|
||
success: res => {
|
||
this.setData({
|
||
id,
|
||
projectId: app.globalData.projectId,
|
||
projectName: app.globalData.projectName,
|
||
deptId: res.data.deptId,
|
||
loginName: res.data.loginName,
|
||
userName: res.data.nickName
|
||
})
|
||
this.getProjectUserData();
|
||
this.getDataTypeList();
|
||
this.getInfo();
|
||
this.getAuditinfo();
|
||
}
|
||
})
|
||
},
|
||
|
||
//查询项目人员数据
|
||
getProjectUserData() {
|
||
let that = this
|
||
wx.request({
|
||
url: app.globalData.reqUrl + '/wechat/projectuserinfo/selectProjectUnitUser',
|
||
method: "get",
|
||
data: {
|
||
unitType: "4",
|
||
projectId: that.data.projectId
|
||
},
|
||
header: {
|
||
'content-type': 'application/x-www-form-urlencoded'
|
||
},
|
||
success(res) {
|
||
res = res.data
|
||
if (res.code == 200) {
|
||
let tempData = []
|
||
that.setData({
|
||
rectifierData: res.data,
|
||
})
|
||
}
|
||
}
|
||
})
|
||
|
||
wx.request({
|
||
url: app.globalData.reqUrl + '/wechat/projectuserinfo/selectProjectUnitUser',
|
||
method: "get",
|
||
data: {
|
||
unitType: "2",
|
||
projectId: that.data.projectId
|
||
},
|
||
header: {
|
||
'content-type': 'application/x-www-form-urlencoded'
|
||
},
|
||
success(res) {
|
||
res = res.data
|
||
if (res.code == 200) {
|
||
let tempData = []
|
||
that.setData({
|
||
rectifierData2: res.data,
|
||
})
|
||
}
|
||
}
|
||
})
|
||
},
|
||
|
||
//查询验收类型数据
|
||
getDataTypeList() {
|
||
getDictCache('project_fun_verify_type').then(res => {
|
||
if (res.code == 200) {
|
||
let list = [];
|
||
res.data.forEach(item =>{
|
||
list.push({id:item.dictValue,text:item.dictLabel});
|
||
});
|
||
this.setData({
|
||
dataTypeList: list
|
||
})
|
||
}
|
||
});
|
||
},
|
||
|
||
//切换验收结果
|
||
onSelectType(e) {
|
||
this.setData({
|
||
checkingResult: e.detail.id
|
||
})
|
||
},
|
||
|
||
//验收类型
|
||
onSelectType(e) {
|
||
this.setData({
|
||
checkType: e.detail.id
|
||
})
|
||
},
|
||
|
||
//工序部位
|
||
onInputCheckNameValue(e) {
|
||
this.setData({
|
||
checkName:e.detail.value
|
||
})
|
||
},
|
||
|
||
//验收描述
|
||
onInputIntroValue(e) {
|
||
let intro = e.detail.value
|
||
this.setData({
|
||
intro
|
||
})
|
||
},
|
||
|
||
//验收时间
|
||
onInputTime(e) {
|
||
let checkTime = e.detail
|
||
this.setData({
|
||
checkTime
|
||
})
|
||
},
|
||
|
||
/**
|
||
* 获取安全检查详情信息
|
||
*
|
||
*/
|
||
getInfo() {
|
||
getProjectFunVerify(this.data.id).then(res =>{
|
||
if(res.code==200){
|
||
let imageInfoData = [];
|
||
if (res.data.imageUrls) {
|
||
res.data.imageUrls.split(',').forEach(element => {
|
||
imageInfoData.push(this.data.request + element + '.min.jpg');
|
||
});
|
||
}
|
||
let checkFiles = [];
|
||
if (res.data.checkFiles) {
|
||
res.data.checkFiles.split(",").forEach(item => {
|
||
let it = item.split('/');
|
||
checkFiles.push({
|
||
'name': it[it.length - 1],
|
||
path: item
|
||
});
|
||
});
|
||
}
|
||
this.setData({
|
||
infoData: res.data,
|
||
fileUrlArray: checkFiles,
|
||
checkType: res.data.checkType,
|
||
qualityUser: res.data.qualityUser,
|
||
qualityUserName: res.data.qualityUserName,
|
||
superviseUser: res.data.superviseUser,
|
||
superviseUserName: res.data.superviseUserName,
|
||
checkName: res.data.checkName,
|
||
intro: res.data.intro,
|
||
checkTime: res.data.checkDate,
|
||
imageInfoData
|
||
})
|
||
}
|
||
});
|
||
},
|
||
|
||
/**
|
||
* 查询流程日志
|
||
*/
|
||
getAuditinfo() {
|
||
let param = {
|
||
fromType: "5",
|
||
fromId: this.data.id
|
||
}
|
||
selectProjectAuditinfoList(param).then(res =>{
|
||
if (res.code == 200) {
|
||
this.setData({
|
||
flowRecordList: res.data
|
||
})
|
||
}
|
||
});
|
||
},
|
||
|
||
// 手风琴
|
||
onChange(event) {
|
||
this.setData({
|
||
activeName: event.detail,
|
||
});
|
||
},
|
||
|
||
// list 上传图片
|
||
onImagesArr(e) {
|
||
var data = this.data.imageInfoData
|
||
data = e.detail
|
||
this.setData({
|
||
imageInfoData: data
|
||
})
|
||
},
|
||
|
||
//添加质量专员
|
||
onAddQualityUser(e) {
|
||
if (e.detail.length > 0) {
|
||
this.setData({
|
||
qualityUser: e.detail[0].phoneNumber,
|
||
qualityUserName: e.detail[0].userName
|
||
})
|
||
}
|
||
},
|
||
|
||
//添加监理专员
|
||
onAddSuperviseUser(e) {
|
||
if (e.detail.length > 0) {
|
||
this.setData({
|
||
superviseUser: e.detail[0].phoneNumber,
|
||
superviseUserName: e.detail[0].userName
|
||
})
|
||
}
|
||
},
|
||
|
||
//取消页面
|
||
cancelSaveView() {
|
||
this.returnToPage()
|
||
},
|
||
|
||
//保存
|
||
onProblemSubmitSave() {
|
||
let that = this
|
||
let {
|
||
id,
|
||
qualityUser,
|
||
qualityUserName,
|
||
superviseUser,
|
||
superviseUserName,
|
||
checkName,
|
||
intro,
|
||
checkTime,
|
||
imageInfoData,
|
||
loginName,
|
||
checkType,
|
||
checkFiles
|
||
} = that.data;
|
||
//数据效验
|
||
if (id == "") {
|
||
app.toast("数据异常,请刷新页面重试!")
|
||
return;
|
||
}
|
||
if (imageInfoData.length == 0) {
|
||
app.toast("请上传检验报告!")
|
||
return;
|
||
}
|
||
if (checkType == "") {
|
||
app.toast("请选择检验类型!")
|
||
return;
|
||
}
|
||
if (qualityUser == "" || qualityUserName == "") {
|
||
app.toast("请选择质量专员!")
|
||
return;
|
||
}
|
||
if (superviseUser == "" || superviseUserName == "") {
|
||
app.toast("请选择监理专员!")
|
||
return;
|
||
}
|
||
if (checkName == "") {
|
||
app.toast("请填写检验名称!")
|
||
return;
|
||
}
|
||
if (checkTime == "") {
|
||
app.toast("请选择验收时间!")
|
||
return;
|
||
}
|
||
if (intro == "") {
|
||
app.toast("请填写检验描述!")
|
||
return;
|
||
}
|
||
if (checkFiles.length > 0) {
|
||
for (let i = 0; i < checkFiles.length; i++) {
|
||
let _fileType = checkFiles[i].path.split('.');
|
||
_fileType = _fileType[_fileType.length - 1].toLowerCase();
|
||
//判断附件类型,如果是图片直接展示,非图片则显示附件
|
||
if (that.data.fileType.indexOf(_fileType) == -1) {
|
||
app.toast("当前 [ " + _fileType + " ] 文件不支持上传!")
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
let _images = [];
|
||
let _checkFiles = [];
|
||
imageInfoData.forEach(async (item) => {
|
||
let uploadUrl = app.globalData.uploadUrl + '/common/upload'
|
||
let name = "file"
|
||
//这里复杂的图片上传,改为同步上传,因为小程序只能上传一张图片
|
||
if (item.indexOf(that.data.request) > -1) {
|
||
_images.push(item.replace(that.data.request, "").replace(".min.jpg", ""));
|
||
} else {
|
||
let obj = await that.syncUploadImage(uploadUrl, item, name);
|
||
_images.push(obj.data.fileName);
|
||
}
|
||
//验证图片上传完毕
|
||
if (_images.length == imageInfoData.length) {
|
||
let params = {
|
||
id,
|
||
qualityUser,
|
||
qualityUserName,
|
||
superviseUser,
|
||
superviseUserName,
|
||
checkType,
|
||
checkName,
|
||
checkDate: checkTime,
|
||
intro,
|
||
//checkResult:checkingResult,
|
||
approveStatus: "1",
|
||
createBy: loginName,
|
||
imageUrls: _images.toString()
|
||
}
|
||
if (checkFiles.length > 0) {
|
||
checkFiles.forEach(async (file) => {
|
||
if (file.path.indexOf('/profile/') > -1) {
|
||
_checkFiles.push(file.path);
|
||
} else {
|
||
let obj = await that.syncUploadImage(uploadUrl, file.path, name);
|
||
_checkFiles.push(obj.data.fileName);
|
||
}
|
||
if (checkFiles.length == _checkFiles.length) {
|
||
params.checkFiles = _checkFiles.toString();
|
||
this.submitForm(params);
|
||
}
|
||
});
|
||
} else {
|
||
this.submitForm(params);
|
||
}
|
||
}
|
||
})
|
||
},
|
||
|
||
/**
|
||
* 提交表单
|
||
* @param {*} params
|
||
*/
|
||
submitForm(data){
|
||
updateProjectFunVerify(data).then(res =>{
|
||
if (res.code == 200) {
|
||
app.toast("修改成功!")
|
||
setTimeout(() => {
|
||
wx.redirectTo({
|
||
url: '../list/index',
|
||
})
|
||
}, 200)
|
||
}
|
||
})
|
||
},
|
||
|
||
/**
|
||
* 这里考虑上传图片异步问题,封装为同步
|
||
*/
|
||
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)
|
||
}
|
||
});
|
||
})
|
||
},
|
||
|
||
returnToPage: function () {
|
||
/*关闭当前页面,跳转到应用内的某个页面。但是不允许跳转到 tabbar 页面*/
|
||
wx.redirectTo({
|
||
url: '../list/index',
|
||
})
|
||
},
|
||
|
||
/**
|
||
* 相关附件上传
|
||
* @param {*} options
|
||
*/
|
||
otherFileUpload(options) {
|
||
let file = options.detail;
|
||
this.setData({
|
||
checkFiles: file
|
||
});
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面初次渲染完成
|
||
*/
|
||
onReady() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面显示
|
||
*/
|
||
onShow() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面隐藏
|
||
*/
|
||
onHide() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面卸载
|
||
*/
|
||
onUnload() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 页面相关事件处理函数--监听用户下拉动作
|
||
*/
|
||
onPullDownRefresh() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 页面上拉触底事件的处理函数
|
||
*/
|
||
onReachBottom() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 用户点击右上角分享
|
||
*/
|
||
onShareAppMessage() {
|
||
|
||
}
|
||
}) |