|
@ -9,12 +9,16 @@ Page({ |
|
|
* 页面的初始数据 |
|
|
* 页面的初始数据 |
|
|
*/ |
|
|
*/ |
|
|
data: { |
|
|
data: { |
|
|
|
|
|
imgServer: getApp().globalData.imgUrl, |
|
|
|
|
|
userInfo: wx.getStorageSync("userInfo"), |
|
|
data: {}, |
|
|
data: {}, |
|
|
strucFocusUser: {}, |
|
|
strucFocusUser: {}, |
|
|
focusPerson: [], |
|
|
focusPerson: [], |
|
|
shootingid: '', |
|
|
shootingid: '', |
|
|
|
|
|
pointItemCollapseActiveNames: undefined, |
|
|
maintenancePersonIndex: undefined, |
|
|
maintenancePersonIndex: undefined, |
|
|
maintenancePersonId: null, |
|
|
maintenancePersonId: null, |
|
|
|
|
|
maintenancePersonDepartmentShow: '', |
|
|
maintenanceRequirement: '', |
|
|
maintenanceRequirement: '', |
|
|
qualityPersonIndex: undefined, |
|
|
qualityPersonIndex: undefined, |
|
|
planStartTimePopupShow: false, |
|
|
planStartTimePopupShow: false, |
|
@ -24,10 +28,13 @@ Page({ |
|
|
planEndTime: '', |
|
|
planEndTime: '', |
|
|
planEndTimeShow: '', |
|
|
planEndTimeShow: '', |
|
|
planApproval: '', |
|
|
planApproval: '', |
|
|
|
|
|
planApprovalPerson: '', |
|
|
|
|
|
planApprovalTime: '', |
|
|
repair: '', |
|
|
repair: '', |
|
|
|
|
|
|
|
|
// 表单控制
|
|
|
// 表单控制
|
|
|
isPlanState: false, |
|
|
isPlanState: false, |
|
|
|
|
|
isApprove: false, |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -47,15 +54,31 @@ Page({ |
|
|
).then(res => { |
|
|
).then(res => { |
|
|
console.log(res, 222); |
|
|
console.log(res, 222); |
|
|
const [issue, strucUser] = res |
|
|
const [issue, strucUser] = res |
|
|
this.setData({ |
|
|
const nextData = { |
|
|
data: { |
|
|
|
|
|
...issue, |
|
|
...issue, |
|
|
PatrolRecord: { |
|
|
PatrolRecord: { |
|
|
...issue.PatrolRecord, |
|
|
...issue.PatrolRecord, |
|
|
inspectionTime: moment(issue.PatrolRecord.inspectionTime).format('YYYY-MM-DD HH:mm:ss') |
|
|
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({ |
|
|
this.setData({ |
|
|
strucFocusUser: { |
|
|
strucFocusUser: { |
|
@ -66,12 +89,38 @@ Page({ |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
focusPerson: focusPerson |
|
|
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 { |
|
|
} else { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
onPointItemCollapseActiveChange (event) { |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
pointItemCollapseActiveNames: event.detail, |
|
|
|
|
|
}); |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
onMaintenancePersonPopupChange (e) { |
|
|
onMaintenancePersonPopupChange (e) { |
|
|
console.log(e); |
|
|
console.log(e); |
|
|
if (e.target.dataset.type == 'zhijian') { |
|
|
if (e.target.dataset.type == 'zhijian') { |
|
@ -79,11 +128,12 @@ Page({ |
|
|
qualityPersonIndex: e.detail.value |
|
|
qualityPersonIndex: e.detail.value |
|
|
}) |
|
|
}) |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
let selectedUser = this.data.focusPerson[e.detail.value] |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
maintenancePersonIndex: e.detail.value |
|
|
maintenancePersonIndex: e.detail.value, |
|
|
|
|
|
maintenancePersonDepartmentShow: selectedUser ? selectedUser.department.name : '' |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
showPlanStartTimePopup () { |
|
|
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) { // 这里是选取图片的方法
|
|
|
chooseImg: function (e) { // 这里是选取图片的方法
|
|
|
const that = this; |
|
|
const that = this; |
|
@ -241,18 +310,47 @@ Page({ |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
confirm (e) { |
|
|
confirm (e) { |
|
|
|
|
|
console.log(e); |
|
|
|
|
|
const { approve } = e.target.dataset |
|
|
const { state } = this.data.data |
|
|
const { state } = this.data.data |
|
|
|
|
|
const { |
|
|
|
|
|
shootingid, focusPerson, |
|
|
|
|
|
maintenancePersonIndex, maintenancePersonDepartmentShow, qualityPersonIndex, planStartTime, planEndTime, maintenanceRequirement, |
|
|
|
|
|
userInfo, planApproval, |
|
|
|
|
|
} = this.data |
|
|
let nextState = '' |
|
|
let nextState = '' |
|
|
let confirmData = {} |
|
|
let confirmData = {} |
|
|
if (state == 1) { |
|
|
if (state == 1 || state == 3) { |
|
|
nextState = 2 |
|
|
nextState = 2 |
|
|
confirmData = { |
|
|
confirmData = { |
|
|
...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(), |
|
|
} |
|
|
} |
|
|
Request.put(editPatrolRecordIssueHandle(this.data.shootingid), confirmData).then(res => { |
|
|
if (approve == 'agree') { |
|
|
|
|
|
nextState = 4 |
|
|
|
|
|
} else { |
|
|
|
|
|
nextState = 3 |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
Request.put(editPatrolRecordIssueHandle(shootingid), { |
|
|
|
|
|
...confirmData, |
|
|
|
|
|
state: nextState, |
|
|
|
|
|
}).then(res => { |
|
|
|
|
|
// wx.redirectTo({
|
|
|
|
|
|
// url: '/package/troubleshooting/index'
|
|
|
|
|
|
// })
|
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|