|
|
|
@ -37,7 +37,7 @@ Page({ |
|
|
|
uploadImageList: [],//图片上传的数组
|
|
|
|
imageId:1, |
|
|
|
addHiddenDangeList:[], |
|
|
|
currentDate: new Date().getTime(), |
|
|
|
currentDate:null, |
|
|
|
minDate: new Date(2020, 0, 1).getTime(), |
|
|
|
maxDate: new Date(2030, 11, 31).getTime(), |
|
|
|
showtime:false, |
|
|
|
@ -55,6 +55,7 @@ Page({ |
|
|
|
this.showRecordData() |
|
|
|
this.toOinspectionStaff() |
|
|
|
this.securityCheckk() |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
@ -66,14 +67,22 @@ Page({ |
|
|
|
* 生命周期函数--监听页面显示 |
|
|
|
*/ |
|
|
|
onShow() { |
|
|
|
|
|
|
|
|
|
|
|
console.log(111111); |
|
|
|
debugger |
|
|
|
console.log(this.getCurrentDateTime()); |
|
|
|
this.setData({ |
|
|
|
currentDate:this.getCurrentDateTime() |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 生命周期函数--监听页面隐藏 |
|
|
|
*/ |
|
|
|
onHide() { |
|
|
|
|
|
|
|
this.setData({ |
|
|
|
currentDate:null |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
@ -118,11 +127,13 @@ Page({ |
|
|
|
console.log(event.detail); |
|
|
|
this.data.checkboxOptions.forEach((item,index)=>{ |
|
|
|
if(event.detail.findIndex(item=>item==index) != -1){ |
|
|
|
console.log("我被选中了") |
|
|
|
item.hazardStatus = 0 |
|
|
|
}else{ |
|
|
|
item.hazardStatus = 1 |
|
|
|
} |
|
|
|
}) |
|
|
|
console.log(this.data.checkboxOptions) |
|
|
|
this.setData({ |
|
|
|
checkboxValue:event.detail, |
|
|
|
}) |
|
|
|
@ -156,13 +167,14 @@ Page({ |
|
|
|
}); |
|
|
|
}, |
|
|
|
showRecordData() { |
|
|
|
console.log("我执行了") |
|
|
|
let parm = { |
|
|
|
id: this.data.companyId |
|
|
|
} |
|
|
|
showRecord(parm).then(res => { |
|
|
|
console.log(res) |
|
|
|
if(res.data[0].hiddenDangeList){ |
|
|
|
let checkboxOptions = res.data[0].hiddenDangeList.filter(item=>item.hazardStatus === 0).map(item=>({hazardDesc:item.hazardDesc,hazardStatus:0})); |
|
|
|
let checkboxOptions = res.data[0].hiddenDangeList.filter(item=>item.hazardStatus === 0).map(item=>({hazardDesc:item.hazardDesc,hazardStatus:1})); |
|
|
|
let checkboxOptionsnumber=checkboxOptions.length+1; |
|
|
|
console.log(checkboxOptionsnumber) |
|
|
|
this.setData({ |
|
|
|
@ -173,6 +185,7 @@ Page({ |
|
|
|
this.setData({ |
|
|
|
showList:res.data |
|
|
|
}) |
|
|
|
console.log(this.data.checkboxOptions) |
|
|
|
console.log(this.data.showList) |
|
|
|
}) |
|
|
|
}, |
|
|
|
@ -234,32 +247,10 @@ Page({ |
|
|
|
this.setData({ |
|
|
|
newContent: e.detail.value |
|
|
|
}); |
|
|
|
console.log('添加后的数组:', this.data.newContent); |
|
|
|
console.log(this.data.checkboxOptions) |
|
|
|
}, |
|
|
|
addAnother() { |
|
|
|
if ( !this.data.newContent) { |
|
|
|
wx.showModal({ |
|
|
|
title: '提示', |
|
|
|
content: '输入不能为空', |
|
|
|
success (res) { |
|
|
|
if (res.confirm) { |
|
|
|
console.log('用户点击确定') |
|
|
|
} else if (res.cancel) { |
|
|
|
console.log('用户点击取消') |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}else{ |
|
|
|
let newArr = this.data.addHiddenDangeList.concat({ hazardDesc: this.data.newContent, hazardStatus: 0 }); |
|
|
|
this.setData({ |
|
|
|
addHiddenDangeList: newArr, |
|
|
|
newContent: '', // 清空输入框的值
|
|
|
|
}); |
|
|
|
console.log('添加后的数组:', this.data.addHiddenDangeList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
// 删除选中的图片
|
|
|
|
deleteImage(e) { |
|
|
|
console.log(this.data.uploadImageList,'data中'); |
|
|
|
@ -280,10 +271,27 @@ Page({ |
|
|
|
const hours = now.getHours().toString().padStart(2, '0'); |
|
|
|
const minutes = now.getMinutes().toString().padStart(2, '0'); |
|
|
|
const seconds = now.getSeconds().toString().padStart(2, '0'); |
|
|
|
debugger |
|
|
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; |
|
|
|
}, |
|
|
|
|
|
|
|
handelClickSave(){ |
|
|
|
console.log(this.data.checkboxOptions) |
|
|
|
console.log(this.data.newContent) |
|
|
|
console.log("zhixingle") |
|
|
|
console.log(this.data.newContent) |
|
|
|
if (this.data.newContent) { |
|
|
|
let newArr = this.data.addHiddenDangeList.concat({ |
|
|
|
hazardDesc: this.data.newContent, |
|
|
|
hazardStatus: 0 |
|
|
|
}); |
|
|
|
console.log(newArr) |
|
|
|
this.setData({ |
|
|
|
addHiddenDangeList: newArr, |
|
|
|
}); |
|
|
|
} |
|
|
|
console.log(this.data.checkboxOptions) |
|
|
|
console.log(this.data.addHiddenDangeList) |
|
|
|
if(this.data.selectedOptions.length === 0){ |
|
|
|
wx.showToast({ |
|
|
|
title: '请选择检查人员', |
|
|
|
@ -298,14 +306,34 @@ handelClickSave(){ |
|
|
|
}) |
|
|
|
return false |
|
|
|
} |
|
|
|
if(this.data.checkResultFlag == 0 && !this.data.reviewTime){ |
|
|
|
if(this.data.checkResultFlag == 0 && !this.data.getData){ |
|
|
|
wx.showToast({ |
|
|
|
title: '请选择拟复查时间', |
|
|
|
icon:'none' |
|
|
|
}) |
|
|
|
return false |
|
|
|
} |
|
|
|
if(this.data.checkResultFlag == 0 && this.data.checkboxOptions.length<0){ |
|
|
|
console.log(this.data.checkboxOptions) |
|
|
|
let hasHazardStatus1 = false; |
|
|
|
this.data.checkboxOptions.forEach(item => { |
|
|
|
if (item.hazardStatus === 0) { |
|
|
|
hasHazardStatus1 = true; |
|
|
|
// 如果找到了符合条件的元素,可以直接 return 结束循环
|
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
// let checkbox = this.data.checkboxOptions.map(item => {
|
|
|
|
// // item.hazardStatus = 0;
|
|
|
|
// // return item;
|
|
|
|
// if (item.hazardStatus = 0) {
|
|
|
|
// return
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// console.log(checkbox)
|
|
|
|
console.log( "11",hasHazardStatus1) |
|
|
|
if(this.data.checkResultFlag == 0 && !hasHazardStatus1 && this.data.addHiddenDangeList.length<1){ |
|
|
|
console.log("1111",hasHazardStatus1) |
|
|
|
wx.showToast({ |
|
|
|
title: '请填写隐患明细', |
|
|
|
icon:'none' |
|
|
|
@ -316,17 +344,22 @@ handelClickSave(){ |
|
|
|
const hours = now.getHours().toString().padStart(2, '0'); |
|
|
|
const minutes = now.getMinutes().toString().padStart(2, '0'); |
|
|
|
const seconds = now.getSeconds().toString().padStart(2, '0'); |
|
|
|
console.log(this.data.checkboxOptions) |
|
|
|
console.log(this.data.addHiddenDangeList) |
|
|
|
let form = { |
|
|
|
companyId:this.data.companyId, |
|
|
|
checkTime:this.getCurrentDateTime(), |
|
|
|
checkPersonsIdList:this.data.selectedOptions, |
|
|
|
checkResultFlag:this.data.checkResultFlag, |
|
|
|
reviewTime:`${this.data.reviewTime} ${hours}:${minutes}:${seconds}`, |
|
|
|
reviewTime:this.data.getData, |
|
|
|
hiddenDangeList:this.data.checkboxOptions.concat(this.data.addHiddenDangeList), |
|
|
|
attachmentUrls:this.data.uploadImageList.map(item=>({fileName:item.originFileName,attachmentUrl:item.ossUrl.url})), |
|
|
|
remark:this.data.remark, |
|
|
|
address:"" |
|
|
|
} |
|
|
|
console.log(this.data.checkboxOptions) |
|
|
|
console.log(this.data.addHiddenDangeList) |
|
|
|
console.log(this.data.hiddenDangeList) |
|
|
|
if (!this.data.reviewTime) { |
|
|
|
form.reviewTime=null |
|
|
|
} |
|
|
|
@ -506,22 +539,7 @@ pickerChange: function(e) { |
|
|
|
checkResultFlag:e.detail.value, |
|
|
|
checkResultFlagName:this.data.array[e.detail.value] |
|
|
|
}); |
|
|
|
if (e.detail.value) { |
|
|
|
console.log(this.data.checkboxOptions) |
|
|
|
if (this.data.addHiddenDangeList && this.data.checkboxOptions.length<0) { |
|
|
|
wx.showModal({ |
|
|
|
title: '提示', |
|
|
|
content: '隐患最少输入一条', |
|
|
|
success (res) { |
|
|
|
if (res.confirm) { |
|
|
|
console.log('用户点击确定') |
|
|
|
} else if (res.cancel) { |
|
|
|
console.log('用户点击取消') |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
console.log(this.data.checkboxOptions) |
|
|
|
}, |
|
|
|
pickerChange1: function(e) { |
|
|
|
this.setData({ |
|
|
|
@ -552,7 +570,7 @@ onInput(event) { |
|
|
|
this.setData({ |
|
|
|
getData:formattedDateTime |
|
|
|
}) |
|
|
|
|
|
|
|
console.log(this.data.getData) |
|
|
|
}, |
|
|
|
|
|
|
|
onConfirm(event) { |
|
|
|
|