diff --git a/api/app/lib/controllers/patrolManage/patrolRecord.js b/api/app/lib/controllers/patrolManage/patrolRecord.js index 35c796a..181d996 100644 --- a/api/app/lib/controllers/patrolManage/patrolRecord.js +++ b/api/app/lib/controllers/patrolManage/patrolRecord.js @@ -231,7 +231,8 @@ async function getPatrolRecordIssueHandle (ctx) { findOption.where['$or'].push({ state: 1 }) findOption.where['$or'].push({ state: 3 }) } - findOption.where['$or'].push({ state: 2, approvePerson: { id: userId } }) + // 有审批权限且关注此结构物 + // findOption.where['$or'].push({ state: 2, approvePerson: { id: userId } }) findOption.where['$or'].push({ state: 4, repairPerson: { id: userId } }) findOption.where['$or'].push({ state: 5, checkPerson: { id: userId } }) findOption.where['$or'].push({ state: 7, repairPerson: { id: userId } }) diff --git a/weapp/package/troubleshooting/shootingForm/index.js b/weapp/package/troubleshooting/shootingForm/index.js index 2833484..d86079e 100644 --- a/weapp/package/troubleshooting/shootingForm/index.js +++ b/weapp/package/troubleshooting/shootingForm/index.js @@ -31,6 +31,7 @@ Page({ planApprovalPerson: '', planApprovalTime: '', repair: '', + repairImgs: [], // 表单控制 isPlanState: false, @@ -91,10 +92,10 @@ Page({ }) if (issue.state > 1) { 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({ maintenancePersonIndex: maintenancePersonIndex, - maintenancePersonDepartmentShow: focusPerson[maintenancePersonIndex].department.name, + maintenancePersonDepartmentShow: maintenancePersonIndex >= 0 ? focusPerson[maintenancePersonIndex].department.name : '', qualityPersonIndex: focusPerson.findIndex(f => f.id == issue.checkPerson.id), planStartTime: moment(issue.startTime).unix(), planStartTimeShow: moment(issue.startTime).format('YYYY-MM-DD HH:mm:ss'), @@ -205,96 +206,91 @@ Page({ chooseImg: function (e) { // 这里是选取图片的方法 const that = this; let pics = []; - // const detailPics = that.data.inspectContent[e.currentTarget.dataset.item].imgs; - // if (detailPics.length >= 20) { - // wx.showToast({ - // title: '最多选择20张图片上传', - // icon: 'none' - // }); - // return; - // } - // wx.chooseMedia({ - // count: 20, // 基础库2.25.0前,最多可支持9个文件,2.25.0及以后最多可支持20个文件 - // mediaType: ['image'], // 文件类型 - // sizeType: ['original', 'compressed'], // original 原图,compressed 压缩图,默认二者都有 - // sourceType: ['album', 'camera'], // album 从相册选图,camera 使用相机,默认二者都有 - // success: function (res) { - // const imgs = res.tempFiles; - // for (let i = 0; i < imgs.length; i++) { - // if (res.tempFiles[i].size > 15728640) { - // wx.showToast({ title: '图片大于15M,不可上传', icon: 'none' }); - // return; - // } - // const fileNameArr = res.tempFiles[i].tempFilePath.split('.'); - // const extension = res.tempFiles[i].tempFilePath.split('.')[fileNameArr.length - 1]; - // if (extension !== 'jpg' && extension !== 'png' && extension !== 'jpeg') { - // wx.showToast({ title: '只能上传jpg、jpeg、png格式的图片', icon: 'none' }); - // return; - // } - // pics.push(imgs[i].tempFilePath) - // } - // that.uploadimg({ - // url: getApp().globalData.webUrl + '_upload/attachments/project', // 图片上传的接口 - // path: pics, // 选取的图片的地址数组 - // }, e.currentTarget.dataset.item); - // }, - // }) + const detailPics = that.data.repairImgs + if (detailPics.length >= 20) { + wx.showToast({ + title: '最多选择20张图片上传', + icon: 'none' + }); + return; + } + wx.chooseMedia({ + count: 20, // 基础库2.25.0前,最多可支持9个文件,2.25.0及以后最多可支持20个文件 + mediaType: ['image'], // 文件类型 + sizeType: ['original', 'compressed'], // original 原图,compressed 压缩图,默认二者都有 + sourceType: ['album', 'camera'], // album 从相册选图,camera 使用相机,默认二者都有 + success: function (res) { + const imgs = res.tempFiles; + for (let i = 0; i < imgs.length; i++) { + if (res.tempFiles[i].size > 15728640) { + wx.showToast({ title: '图片大于15M,不可上传', icon: 'none' }); + return; + } + const fileNameArr = res.tempFiles[i].tempFilePath.split('.'); + const extension = res.tempFiles[i].tempFilePath.split('.')[fileNameArr.length - 1]; + if (extension !== 'jpg' && extension !== 'png' && extension !== 'jpeg') { + wx.showToast({ title: '只能上传jpg、jpeg、png格式的图片', icon: 'none' }); + return; + } + pics.push(imgs[i].tempFilePath) + } + that.uploadimg({ + url: getApp().globalData.webUrl + '_upload/attachments/project', // 图片上传的接口 + path: pics, // 选取的图片的地址数组 + }, 'repairImgs'); + }, + }) }, //多张图片上传 uploadimg: function (data, itemName) { - // wx.showLoading({ - // title: '上传中...', - // mask: true, - // }) - // let that = this, - // i = data.i ? data.i : 0, - // success = data.success ? data.success : 0, - // fail = data.fail ? data.fail : 0; - // let imgs = that.data.inspectContent[itemName].imgs; - // wx.uploadFile({ - // url: data.url, - // filePath: data.path[i], - // name: 'file', - // success: (resp) => { - // wx.hideLoading(); - // success++; - // let str = JSON.parse(resp.data) // 返回的结果,可能不同项目结果不一样 - // str = str.uploaded - // console.log(str); - // if (imgs.length >= 20) { - // const inspectContent = that.data.inspectContent; - // inspectContent[itemName].imgs = imgs; - // that.setData({ - // inspectContent, - // }); - // return false; - // } else { - // imgs.push(str); - // const inspectContent = that.data.inspectContent; - // inspectContent[itemName].imgs = imgs; - // that.setData({ - // inspectContent, - // }) - // } - // }, - // fail: (res) => { - // fail++; - // console.log('fail:' + i + "fail:" + fail); - // }, - // complete: () => { - // i++; - // if (i == data.path.length) { // 当图片传完时,停止调用 - // console.log('执行完毕'); - // console.log('成功:' + success + " 失败:" + fail); - // } else { // 若图片还没有传完,则继续调用函数 - // data.i = i; - // data.success = success; - // data.fail = fail; - // that.uploadimg(data, itemName); // 递归,回调自己 - // } - // } - // }); + wx.showLoading({ + title: '上传中...', + mask: true, + }) + let that = this, + i = data.i ? data.i : 0, + success = data.success ? data.success : 0, + fail = data.fail ? data.fail : 0; + let imgs = that.data[itemName]; + wx.uploadFile({ + url: data.url, + filePath: data.path[i], + name: 'file', + success: (resp) => { + wx.hideLoading(); + success++; + console.log(resp); + let str = JSON.parse(resp.data) // 返回的结果,可能不同项目结果不一样 + str = str.uploaded + console.log(str); + if (imgs.length >= 20) { + return false; + } else { + let imgs_ = JSON.parse(JSON.stringify(imgs)) + imgs_.push(str); + that.setData({ + [itemName]: imgs_, + }) + } + }, + fail: (res) => { + fail++; + console.log('fail:' + i + "fail:" + fail); + }, + complete: () => { + i++; + if (i == data.path.length) { // 当图片传完时,停止调用 + console.log('执行完毕'); + console.log('成功:' + success + " 失败:" + fail); + } else { // 若图片还没有传完,则继续调用函数 + data.i = i; + data.success = success; + data.fail = fail; + that.uploadimg(data, itemName); // 递归,回调自己 + } + } + }); }, // 删除图片 diff --git a/weapp/package/troubleshooting/shootingForm/index.wxml b/weapp/package/troubleshooting/shootingForm/index.wxml index f3a25d6..06c5f42 100644 --- a/weapp/package/troubleshooting/shootingForm/index.wxml +++ b/weapp/package/troubleshooting/shootingForm/index.wxml @@ -108,30 +108,34 @@ - - 维修处理 - - - - - 完工图片 - - - - - - - + + + 维修处理 + + + + + 完工图片 + + + + + + + + + + + + + + - - + + 质检验收 @@ -159,7 +163,7 @@ - + 提交