From 8c6751ef3de6d2b0c5eab183daf58decd40b1eb2 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Thu, 2 Mar 2023 17:21:00 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E5=88=B6=E5=AE=9A=E3=80=81=E5=AE=A1=E6=89=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../troubleshooting/shootingForm/index.js | 126 ++++++++++++++++-- .../troubleshooting/shootingForm/index.json | 4 +- .../troubleshooting/shootingForm/index.wxml | 69 ++++++---- 3 files changed, 157 insertions(+), 42 deletions(-) diff --git a/weapp/package/troubleshooting/shootingForm/index.js b/weapp/package/troubleshooting/shootingForm/index.js index 7133fdf..2833484 100644 --- a/weapp/package/troubleshooting/shootingForm/index.js +++ b/weapp/package/troubleshooting/shootingForm/index.js @@ -9,12 +9,16 @@ Page({ * 页面的初始数据 */ data: { + imgServer: getApp().globalData.imgUrl, + userInfo: wx.getStorageSync("userInfo"), data: {}, strucFocusUser: {}, focusPerson: [], shootingid: '', + pointItemCollapseActiveNames: undefined, maintenancePersonIndex: undefined, maintenancePersonId: null, + maintenancePersonDepartmentShow: '', maintenanceRequirement: '', qualityPersonIndex: undefined, planStartTimePopupShow: false, @@ -24,10 +28,13 @@ Page({ planEndTime: '', planEndTimeShow: '', planApproval: '', + planApprovalPerson: '', + planApprovalTime: '', repair: '', // 表单控制 isPlanState: false, + isApprove: false, }, /** @@ -47,15 +54,31 @@ Page({ ).then(res => { console.log(res, 222); const [issue, strucUser] = res - this.setData({ - data: { - ...issue, - PatrolRecord: { - ...issue.PatrolRecord, - inspectionTime: moment(issue.PatrolRecord.inspectionTime).format('YYYY-MM-DD HH:mm:ss') + const nextData = { + ...issue, + PatrolRecord: { + ...issue.PatrolRecord, + inspectionTime: moment(issue.PatrolRecord.inspectionTime).format('YYYY-MM-DD HH:mm:ss'), + points: { + ...issue.PatrolRecord.points, + inspectContent: (() => { + let inspectContent = [] + for (let k in issue.PatrolRecord.points.inspectContent) { + inspectContent.push({ + ...issue.PatrolRecord.points.inspectContent[k], + itemName: k + }) + } + return inspectContent + })() } - }, - isPlanState: issue.state == 1 || issue.state == 3 + } + } + console.log(nextData); + this.setData({ + data: nextData, + isPlanState: issue.state == 1 || issue.state == 3, + isApprove: issue.state == 2 }) this.setData({ strucFocusUser: { @@ -66,12 +89,38 @@ Page({ this.setData({ focusPerson: focusPerson }) + 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')); + this.setData({ + maintenancePersonIndex: maintenancePersonIndex, + maintenancePersonDepartmentShow: 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'), + planEndTimeShow: moment(issue.endTime).format('YYYY-MM-DD HH:mm:ss'), + maintenanceRequirement: issue.repairAsk + }) + } + if (issue.state > 2) { + this.setData({ + planApproval: issue.approveOpinion, + planApprovalPerson: issue.approvePerson ? issue.approvePerson.name : '', + planApprovalTime: issue.approveDate ? moment(issue.approveDate).format('YYYY-MM-DD HH:mm:ss') : '', + }) + } }) } else { } }, + onPointItemCollapseActiveChange (event) { + this.setData({ + pointItemCollapseActiveNames: event.detail, + }); + }, + onMaintenancePersonPopupChange (e) { console.log(e); if (e.target.dataset.type == 'zhijian') { @@ -79,11 +128,12 @@ Page({ qualityPersonIndex: e.detail.value }) } else { + let selectedUser = this.data.focusPerson[e.detail.value] this.setData({ - maintenancePersonIndex: e.detail.value + maintenancePersonIndex: e.detail.value, + maintenancePersonDepartmentShow: selectedUser ? selectedUser.department.name : '' }) } - }, showPlanStartTimePopup () { @@ -132,6 +182,25 @@ Page({ }) }, + onInputChange (e) { + console.log(e); + this.setData({ + [e.target.dataset.type]: e.detail.value + }) + }, + + // 预览图片 + previewImg: function (e) { + console.log(e); + const { index, itemindex } = e.currentTarget.dataset + const imgs = this.data.data.PatrolRecord.points.inspectContent[itemindex].imgs; + const newImgs = imgs.map(i => this.data.imgServer + i); + wx.previewImage({ + current: newImgs[index], + urls: newImgs + }) + }, + // 上传图片 chooseImg: function (e) { // 这里是选取图片的方法 const that = this; @@ -241,18 +310,47 @@ Page({ }, confirm (e) { + console.log(e); + const { approve } = e.target.dataset const { state } = this.data.data + const { + shootingid, focusPerson, + maintenancePersonIndex, maintenancePersonDepartmentShow, qualityPersonIndex, planStartTime, planEndTime, maintenanceRequirement, + userInfo, planApproval, + } = this.data let nextState = '' let confirmData = {} - if (state == 1) { + if (state == 1 || state == 3) { nextState = 2 confirmData = { ...confirmData, - + repairPerson: focusPerson[maintenancePersonIndex], + repairUnit: maintenancePersonDepartmentShow, + checkPerson: focusPerson[qualityPersonIndex], + startTime: moment(planStartTime).format(), + endTime: moment(planEndTime).format(), + repairAsk: maintenanceRequirement, + } + } else if (state == 2) { + confirmData = { + ...confirmData, + approveOpinion: planApproval, + approvePerson: userInfo, + approveDate: moment().format(), + } + if (approve == 'agree') { + nextState = 4 + } else { + nextState = 3 } } - Request.put(editPatrolRecordIssueHandle(this.data.shootingid), confirmData).then(res => { - + Request.put(editPatrolRecordIssueHandle(shootingid), { + ...confirmData, + state: nextState, + }).then(res => { + // wx.redirectTo({ + // url: '/package/troubleshooting/index' + // }) }) }, diff --git a/weapp/package/troubleshooting/shootingForm/index.json b/weapp/package/troubleshooting/shootingForm/index.json index 7cc8b02..46f89d8 100644 --- a/weapp/package/troubleshooting/shootingForm/index.json +++ b/weapp/package/troubleshooting/shootingForm/index.json @@ -10,6 +10,8 @@ "van-picker": "@vant/weapp/picker/index", "van-popup": "@vant/weapp/popup/index", "van-icon": "@vant/weapp/icon/index", - "van-datetime-picker": "@vant/weapp/datetime-picker/index" + "van-datetime-picker": "@vant/weapp/datetime-picker/index", + "van-collapse": "@vant/weapp/collapse/index", + "van-collapse-item": "@vant/weapp/collapse-item/index" } } \ No newline at end of file diff --git a/weapp/package/troubleshooting/shootingForm/index.wxml b/weapp/package/troubleshooting/shootingForm/index.wxml index 419d9e5..f3a25d6 100644 --- a/weapp/package/troubleshooting/shootingForm/index.wxml +++ b/weapp/package/troubleshooting/shootingForm/index.wxml @@ -11,19 +11,30 @@ 问题详情 - - - - - - - 现场照片 - - 123 - - - - + + + + + + + + + + + + + 现场照片 + + + + + + + + + + + 维修计划信息 @@ -33,19 +44,19 @@ {{maintenancePersonIndex||maintenancePersonIndex==0?focusPerson[maintenancePersonIndex].name:'请选择'}} - + - + 质检人 {{qualityPersonIndex||qualityPersonIndex==0?focusPerson[qualityPersonIndex].name:'请选择'}} - + @@ -86,19 +97,21 @@ - + 维修计划审批 - - - + + + + + 维修处理 - + 完工图片 @@ -112,7 +125,7 @@ --> - + @@ -143,15 +156,17 @@ - + - 提交 - - + + 提交 + + + 同意 - + 驳回