|
|
@ -91,19 +91,19 @@ Page({ |
|
|
|
|
|
|
|
showRecordData() { |
|
|
|
this.setData({ |
|
|
|
checkboxOptions:null |
|
|
|
checkboxOptions:[] |
|
|
|
}) |
|
|
|
let parm = { |
|
|
|
id: this.data.companyId |
|
|
|
} |
|
|
|
showRecord(parm).then(res => { |
|
|
|
if(res.data[0].hiddenDangeList){ |
|
|
|
let checkboxOptions = res.data[0].hiddenDangeList.filter(item=>item.hazardStatus === 0).map(item=>({hazardDesc:item.hazardDesc,hazardStatus:0,id:item.id})); |
|
|
|
let checkboxOptions = res.data[0].hiddenDangeList.filter(item=>item.hazardStatus === 0).map(item=>({hazardDesc:item.hazardDesc,hazardStatus:0})); |
|
|
|
this.setData({ |
|
|
|
checkboxOptions, |
|
|
|
checkboxOptions: checkboxOptions || [], |
|
|
|
beforeFlag: res.data[0].checkResultFlag |
|
|
|
}) |
|
|
|
console.log(this.data.checkboxOptions); |
|
|
|
console.log(this.data.beforeFlag); |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
@ -146,55 +146,80 @@ Page({ |
|
|
|
}) |
|
|
|
return false |
|
|
|
} |
|
|
|
|
|
|
|
if(this.data.checkResultFlag == 0 && this.data.checkboxValue.length<1&&!this.data.hazardDesc2){ |
|
|
|
|
|
|
|
if(this.data.checkResultFlag == 0 && this.data.checkboxValue.length<1&&!this.data.newContent){ |
|
|
|
wx.showToast({ |
|
|
|
title: '隐患明细最少输入一条', |
|
|
|
icon:'none' |
|
|
|
}) |
|
|
|
return false |
|
|
|
} |
|
|
|
this.data.checkboxOptions.forEach(item => { |
|
|
|
if(this.checkboxValue.findIndex(itemC=>itemC === item.value) == -1){ |
|
|
|
item.hazardStatus = '1'; |
|
|
|
}else{ |
|
|
|
item.hazardStatus = '0'; |
|
|
|
} |
|
|
|
}) |
|
|
|
console.log(this.data.checkboxValue); |
|
|
|
console.log(this.data.checkboxOptions); |
|
|
|
let form={ companyId: this.data.companyId, |
|
|
|
if (this.data.checkboxOptions) { |
|
|
|
console.log(this.data.checkboxOptions) |
|
|
|
this.data.checkboxOptions.forEach(item => { |
|
|
|
console.log(item) |
|
|
|
console.log(this.data.checkboxValue) |
|
|
|
if(this.data.checkboxValue.findIndex(itemC=>itemC === item.value) == -1){ |
|
|
|
item.hazardStatus = '1'; |
|
|
|
}else{ |
|
|
|
item.hazardStatus = '0'; |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
if (this.data.newContent) { |
|
|
|
let newArr = this.data.addHiddenDangeList.concat({ |
|
|
|
hazardDesc: this.data.newContent, |
|
|
|
hazardStatus: 0 |
|
|
|
}); |
|
|
|
console.log(newArr) |
|
|
|
this.setData({ |
|
|
|
addHiddenDangeList: newArr, |
|
|
|
}); |
|
|
|
} |
|
|
|
if (this.data.hazardDesc2) { |
|
|
|
let newArr = this.data.addHiddenDangeList.concat({ |
|
|
|
hazardDesc: this.data.hazardDesc2, |
|
|
|
hazardStatus: 2 |
|
|
|
}); |
|
|
|
console.log(newArr) |
|
|
|
this.setData({ |
|
|
|
addHiddenDangeList: newArr, |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
let form={ |
|
|
|
companyId: this.data.companyId, |
|
|
|
checkTime: this.getCurrentDateTime(), |
|
|
|
checkPersonsIdList: this.data.checkPersonsIdList, |
|
|
|
checkResultFlag: this.data.checkResultFlag, |
|
|
|
reviewTime:this.data.getData, |
|
|
|
hiddenDangeList:null, |
|
|
|
hiddenDangeList:this.data.checkboxOptions.concat(this.data.addHiddenDangeList), |
|
|
|
attachmentUrls:this.data.uploadImageList.map(item=>({fileName:item.originFileName,attachmentUrl:item.ossUrl.url})), |
|
|
|
remark: '', |
|
|
|
remark: this.data.remarks, |
|
|
|
reviewAddress:this.data.addressContent |
|
|
|
} |
|
|
|
if (!this.data.reviewTime) { |
|
|
|
form.reviewTime=null |
|
|
|
} |
|
|
|
// if (!this.data.reviewTime) {
|
|
|
|
// form.reviewTime=null
|
|
|
|
// }
|
|
|
|
console.log(form) |
|
|
|
// addRecord(
|
|
|
|
// form
|
|
|
|
// ).then(
|
|
|
|
// res => {
|
|
|
|
// if(res.code == 0){
|
|
|
|
// wx.showToast({
|
|
|
|
// title: '新增成功',
|
|
|
|
// duration:2000,
|
|
|
|
// success:function(){
|
|
|
|
// setTimeout(()=>{
|
|
|
|
// wx.navigateBack({
|
|
|
|
// delta: 1
|
|
|
|
// })
|
|
|
|
// },2000)
|
|
|
|
// }
|
|
|
|
// })
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
addRecord( |
|
|
|
form |
|
|
|
).then( |
|
|
|
res => { |
|
|
|
if(res.code == 0){ |
|
|
|
wx.showToast({ |
|
|
|
title: '新增成功', |
|
|
|
duration:2000, |
|
|
|
success:function(){ |
|
|
|
setTimeout(()=>{ |
|
|
|
wx.navigateBack({ |
|
|
|
delta: 1 |
|
|
|
}) |
|
|
|
},2000) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|