|
@ -31,6 +31,7 @@ Page({ |
|
|
planApprovalPerson: '', |
|
|
planApprovalPerson: '', |
|
|
planApprovalTime: '', |
|
|
planApprovalTime: '', |
|
|
repair: '', |
|
|
repair: '', |
|
|
|
|
|
repairImgs: [], |
|
|
|
|
|
|
|
|
// 表单控制
|
|
|
// 表单控制
|
|
|
isPlanState: false, |
|
|
isPlanState: false, |
|
@ -91,10 +92,10 @@ Page({ |
|
|
}) |
|
|
}) |
|
|
if (issue.state > 1) { |
|
|
if (issue.state > 1) { |
|
|
let maintenancePersonIndex = focusPerson.findIndex(f => f.id == issue.repairPerson.id) |
|
|
let maintenancePersonIndex = focusPerson.findIndex(f => f.id == issue.repairPerson.id) |
|
|
console.log(issue.startTime, moment(issue.startTime).format('YYYY-MM-DD HH:mm:ss')); |
|
|
console.log(maintenancePersonIndex, issue.startTime, moment(issue.startTime).format('YYYY-MM-DD HH:mm:ss')); |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
maintenancePersonIndex: maintenancePersonIndex, |
|
|
maintenancePersonIndex: maintenancePersonIndex, |
|
|
maintenancePersonDepartmentShow: focusPerson[maintenancePersonIndex].department.name, |
|
|
maintenancePersonDepartmentShow: maintenancePersonIndex >= 0 ? focusPerson[maintenancePersonIndex].department.name : '', |
|
|
qualityPersonIndex: focusPerson.findIndex(f => f.id == issue.checkPerson.id), |
|
|
qualityPersonIndex: focusPerson.findIndex(f => f.id == issue.checkPerson.id), |
|
|
planStartTime: moment(issue.startTime).unix(), |
|
|
planStartTime: moment(issue.startTime).unix(), |
|
|
planStartTimeShow: moment(issue.startTime).format('YYYY-MM-DD HH:mm:ss'), |
|
|
planStartTimeShow: moment(issue.startTime).format('YYYY-MM-DD HH:mm:ss'), |
|
@ -205,96 +206,91 @@ Page({ |
|
|
chooseImg: function (e) { // 这里是选取图片的方法
|
|
|
chooseImg: function (e) { // 这里是选取图片的方法
|
|
|
const that = this; |
|
|
const that = this; |
|
|
let pics = []; |
|
|
let pics = []; |
|
|
// const detailPics = that.data.inspectContent[e.currentTarget.dataset.item].imgs;
|
|
|
const detailPics = that.data.repairImgs |
|
|
// if (detailPics.length >= 20) {
|
|
|
if (detailPics.length >= 20) { |
|
|
// wx.showToast({
|
|
|
wx.showToast({ |
|
|
// title: '最多选择20张图片上传',
|
|
|
title: '最多选择20张图片上传', |
|
|
// icon: 'none'
|
|
|
icon: 'none' |
|
|
// });
|
|
|
}); |
|
|
// return;
|
|
|
return; |
|
|
// }
|
|
|
} |
|
|
// wx.chooseMedia({
|
|
|
wx.chooseMedia({ |
|
|
// count: 20, // 基础库2.25.0前,最多可支持9个文件,2.25.0及以后最多可支持20个文件
|
|
|
count: 20, // 基础库2.25.0前,最多可支持9个文件,2.25.0及以后最多可支持20个文件
|
|
|
// mediaType: ['image'], // 文件类型
|
|
|
mediaType: ['image'], // 文件类型
|
|
|
// sizeType: ['original', 'compressed'], // original 原图,compressed 压缩图,默认二者都有
|
|
|
sizeType: ['original', 'compressed'], // original 原图,compressed 压缩图,默认二者都有
|
|
|
// sourceType: ['album', 'camera'], // album 从相册选图,camera 使用相机,默认二者都有
|
|
|
sourceType: ['album', 'camera'], // album 从相册选图,camera 使用相机,默认二者都有
|
|
|
// success: function (res) {
|
|
|
success: function (res) { |
|
|
// const imgs = res.tempFiles;
|
|
|
const imgs = res.tempFiles; |
|
|
// for (let i = 0; i < imgs.length; i++) {
|
|
|
for (let i = 0; i < imgs.length; i++) { |
|
|
// if (res.tempFiles[i].size > 15728640) {
|
|
|
if (res.tempFiles[i].size > 15728640) { |
|
|
// wx.showToast({ title: '图片大于15M,不可上传', icon: 'none' });
|
|
|
wx.showToast({ title: '图片大于15M,不可上传', icon: 'none' }); |
|
|
// return;
|
|
|
return; |
|
|
// }
|
|
|
} |
|
|
// const fileNameArr = res.tempFiles[i].tempFilePath.split('.');
|
|
|
const fileNameArr = res.tempFiles[i].tempFilePath.split('.'); |
|
|
// const extension = res.tempFiles[i].tempFilePath.split('.')[fileNameArr.length - 1];
|
|
|
const extension = res.tempFiles[i].tempFilePath.split('.')[fileNameArr.length - 1]; |
|
|
// if (extension !== 'jpg' && extension !== 'png' && extension !== 'jpeg') {
|
|
|
if (extension !== 'jpg' && extension !== 'png' && extension !== 'jpeg') { |
|
|
// wx.showToast({ title: '只能上传jpg、jpeg、png格式的图片', icon: 'none' });
|
|
|
wx.showToast({ title: '只能上传jpg、jpeg、png格式的图片', icon: 'none' }); |
|
|
// return;
|
|
|
return; |
|
|
// }
|
|
|
} |
|
|
// pics.push(imgs[i].tempFilePath)
|
|
|
pics.push(imgs[i].tempFilePath) |
|
|
// }
|
|
|
} |
|
|
// that.uploadimg({
|
|
|
that.uploadimg({ |
|
|
// url: getApp().globalData.webUrl + '_upload/attachments/project', // 图片上传的接口
|
|
|
url: getApp().globalData.webUrl + '_upload/attachments/project', // 图片上传的接口
|
|
|
// path: pics, // 选取的图片的地址数组
|
|
|
path: pics, // 选取的图片的地址数组
|
|
|
// }, e.currentTarget.dataset.item);
|
|
|
}, 'repairImgs'); |
|
|
// },
|
|
|
}, |
|
|
// })
|
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
//多张图片上传
|
|
|
//多张图片上传
|
|
|
uploadimg: function (data, itemName) { |
|
|
uploadimg: function (data, itemName) { |
|
|
// wx.showLoading({
|
|
|
wx.showLoading({ |
|
|
// title: '上传中...',
|
|
|
title: '上传中...', |
|
|
// mask: true,
|
|
|
mask: true, |
|
|
// })
|
|
|
}) |
|
|
// let that = this,
|
|
|
let that = this, |
|
|
// i = data.i ? data.i : 0,
|
|
|
i = data.i ? data.i : 0, |
|
|
// success = data.success ? data.success : 0,
|
|
|
success = data.success ? data.success : 0, |
|
|
// fail = data.fail ? data.fail : 0;
|
|
|
fail = data.fail ? data.fail : 0; |
|
|
// let imgs = that.data.inspectContent[itemName].imgs;
|
|
|
let imgs = that.data[itemName]; |
|
|
// wx.uploadFile({
|
|
|
wx.uploadFile({ |
|
|
// url: data.url,
|
|
|
url: data.url, |
|
|
// filePath: data.path[i],
|
|
|
filePath: data.path[i], |
|
|
// name: 'file',
|
|
|
name: 'file', |
|
|
// success: (resp) => {
|
|
|
success: (resp) => { |
|
|
// wx.hideLoading();
|
|
|
wx.hideLoading(); |
|
|
// success++;
|
|
|
success++; |
|
|
// let str = JSON.parse(resp.data) // 返回的结果,可能不同项目结果不一样
|
|
|
console.log(resp); |
|
|
// str = str.uploaded
|
|
|
let str = JSON.parse(resp.data) // 返回的结果,可能不同项目结果不一样
|
|
|
// console.log(str);
|
|
|
str = str.uploaded |
|
|
// if (imgs.length >= 20) {
|
|
|
console.log(str); |
|
|
// const inspectContent = that.data.inspectContent;
|
|
|
if (imgs.length >= 20) { |
|
|
// inspectContent[itemName].imgs = imgs;
|
|
|
return false; |
|
|
// that.setData({
|
|
|
} else { |
|
|
// inspectContent,
|
|
|
let imgs_ = JSON.parse(JSON.stringify(imgs)) |
|
|
// });
|
|
|
imgs_.push(str); |
|
|
// return false;
|
|
|
that.setData({ |
|
|
// } else {
|
|
|
[itemName]: imgs_, |
|
|
// imgs.push(str);
|
|
|
}) |
|
|
// const inspectContent = that.data.inspectContent;
|
|
|
} |
|
|
// inspectContent[itemName].imgs = imgs;
|
|
|
}, |
|
|
// that.setData({
|
|
|
fail: (res) => { |
|
|
// inspectContent,
|
|
|
fail++; |
|
|
// })
|
|
|
console.log('fail:' + i + "fail:" + fail); |
|
|
// }
|
|
|
}, |
|
|
// },
|
|
|
complete: () => { |
|
|
// fail: (res) => {
|
|
|
i++; |
|
|
// fail++;
|
|
|
if (i == data.path.length) { // 当图片传完时,停止调用
|
|
|
// console.log('fail:' + i + "fail:" + fail);
|
|
|
console.log('执行完毕'); |
|
|
// },
|
|
|
console.log('成功:' + success + " 失败:" + fail); |
|
|
// complete: () => {
|
|
|
} else { // 若图片还没有传完,则继续调用函数
|
|
|
// i++;
|
|
|
data.i = i; |
|
|
// if (i == data.path.length) { // 当图片传完时,停止调用
|
|
|
data.success = success; |
|
|
// console.log('执行完毕');
|
|
|
data.fail = fail; |
|
|
// console.log('成功:' + success + " 失败:" + fail);
|
|
|
that.uploadimg(data, itemName); // 递归,回调自己
|
|
|
// } else { // 若图片还没有传完,则继续调用函数
|
|
|
} |
|
|
// data.i = i;
|
|
|
} |
|
|
// data.success = success;
|
|
|
}); |
|
|
// data.fail = fail;
|
|
|
|
|
|
// that.uploadimg(data, itemName); // 递归,回调自己
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 删除图片
|
|
|
// 删除图片
|
|
|