|
|
@ -4,14 +4,13 @@ const App = getApp() |
|
|
|
import { |
|
|
|
showRecord,addRecord,inspectionStaff,securityCheckk |
|
|
|
} from "../../../../utils/api" |
|
|
|
|
|
|
|
import {timestampToTime} from "../../../../utils/index" |
|
|
|
const config = require('../../../../utils/config') |
|
|
|
Page({ |
|
|
|
/** |
|
|
|
* 页面的初始数据 |
|
|
|
*/ |
|
|
|
data: { |
|
|
|
checkboxOptionsnumber:0, |
|
|
|
orgid:'', |
|
|
|
orgType:'', |
|
|
|
pageNo:'1', |
|
|
@ -20,7 +19,6 @@ Page({ |
|
|
|
imageUrls:[], |
|
|
|
remark:'',//备注
|
|
|
|
reviewTime:'', |
|
|
|
checkResultFlag:'', |
|
|
|
array: ['不合格', '合格'], // 选择器的数据源
|
|
|
|
arrlist:[], |
|
|
|
fileList: [], |
|
|
@ -35,21 +33,33 @@ Page({ |
|
|
|
checkboxValue:[], |
|
|
|
uploadImageList: [],//图片上传的数组
|
|
|
|
imageId:1, |
|
|
|
addHiddenDangeList:[] |
|
|
|
addHiddenDangeList:[], |
|
|
|
currentDate: new Date().getTime(), |
|
|
|
minDate: new Date(2020, 0, 1).getTime(), |
|
|
|
maxDate: new Date(2030, 11, 31).getTime(), |
|
|
|
showtime:false, |
|
|
|
checkResultFlag:null, |
|
|
|
checkResultFlagRouter:null, |
|
|
|
hazardStatus2:null, |
|
|
|
name:"" |
|
|
|
}, |
|
|
|
/** |
|
|
|
* 生命周期函数--监听页面加载 |
|
|
|
*/ |
|
|
|
onLoad(options) { |
|
|
|
this.setData({ |
|
|
|
companyId: options.resiId, |
|
|
|
orgid:App.globalData.user.agencyId |
|
|
|
}) |
|
|
|
console.log(App.globalData) |
|
|
|
if(options){ |
|
|
|
this.setData({ |
|
|
|
|
|
|
|
companyId: options.resiId, |
|
|
|
orgid:App.globalData.user.agencyId, |
|
|
|
checkResultFlagRouter:options.flag, |
|
|
|
currentDateShow:timestampToTime(new Date().getTime(),1) |
|
|
|
}) |
|
|
|
} |
|
|
|
this.showRecordData() |
|
|
|
this.toOinspectionStaff() |
|
|
|
this.securityCheckk() |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
@ -61,14 +71,18 @@ Page({ |
|
|
|
* 生命周期函数--监听页面显示 |
|
|
|
*/ |
|
|
|
onShow() { |
|
|
|
|
|
|
|
// this.setData({
|
|
|
|
// currentDate:this.getCurrentDateTime()
|
|
|
|
// })
|
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 生命周期函数--监听页面隐藏 |
|
|
|
*/ |
|
|
|
onHide() { |
|
|
|
|
|
|
|
this.setData({ |
|
|
|
currentDate:null |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
@ -99,24 +113,42 @@ Page({ |
|
|
|
data |
|
|
|
}) => { |
|
|
|
console.log(data) |
|
|
|
var firstItem = data.list[0]; |
|
|
|
console.log(firstItem) |
|
|
|
this.setData({ |
|
|
|
reviewAddress:firstItem.address, |
|
|
|
companyList: data.list, |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
handelShowTime(){ |
|
|
|
this.setData({ |
|
|
|
showtime:true |
|
|
|
}) |
|
|
|
}, |
|
|
|
onChange(event) { |
|
|
|
console.log(event.detail); |
|
|
|
this.data.checkboxOptions.forEach((item,index)=>{ |
|
|
|
if(event.detail.findIndex(item=>item==index) != -1){ |
|
|
|
item.hazardStatus = 1 |
|
|
|
}else{ |
|
|
|
console.log("我被选中了") |
|
|
|
item.hazardStatus = 0 |
|
|
|
}else{ |
|
|
|
item.hazardStatus = 1 |
|
|
|
} |
|
|
|
}) |
|
|
|
console.log(this.data.checkboxOptions) |
|
|
|
this.setData({ |
|
|
|
checkboxValue:event.detail, |
|
|
|
}) |
|
|
|
}, |
|
|
|
handelConfirmDate(value){ |
|
|
|
this.setData({ |
|
|
|
showtime:false, |
|
|
|
currentDateShow:timestampToTime(value.detail,1), |
|
|
|
currentDate:value.detail |
|
|
|
|
|
|
|
}) |
|
|
|
}, |
|
|
|
afterRead(event) { |
|
|
|
const { |
|
|
|
file |
|
|
@ -150,20 +182,34 @@ Page({ |
|
|
|
id: this.data.companyId |
|
|
|
} |
|
|
|
showRecord(parm).then(res => { |
|
|
|
console.log(res) |
|
|
|
res.data.forEach(item => { |
|
|
|
if (item.hiddenDangeList) { |
|
|
|
item.hiddenDangeList0 = []; |
|
|
|
item.hiddenDangeList1 = []; |
|
|
|
item.hiddenDangeList2 = []; |
|
|
|
item.hiddenDangeList.forEach(itemC => { |
|
|
|
if (itemC.hazardStatus === 0) { |
|
|
|
item.hiddenDangeList0.push(itemC); |
|
|
|
} else if (itemC.hazardStatus === 1) { |
|
|
|
item.hiddenDangeList1.push(itemC); |
|
|
|
}else if (itemC.hazardStatus === 2) { |
|
|
|
item.hiddenDangeList2.push(itemC); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
if(res.data[0].hiddenDangeList){ |
|
|
|
let checkboxOptions = res.data[0].hiddenDangeList.filter(item=>item.hazardStatus === 0).map(item=>({hazardDesc:item.hazardDesc,hazardStatus:0})); |
|
|
|
let checkboxOptionsnumber=checkboxOptions.length+1; |
|
|
|
console.log(checkboxOptionsnumber) |
|
|
|
let checkboxOptions = res.data[0].hiddenDangeList.filter(item=>item.hazardStatus === 0).map(item=>({hazardDesc:item.hazardDesc,hazardStatus:1})); |
|
|
|
this.setData({ |
|
|
|
checkboxOptions, |
|
|
|
checkboxOptionsnumber |
|
|
|
}) |
|
|
|
} |
|
|
|
this.setData({ |
|
|
|
showList:res.data |
|
|
|
}) |
|
|
|
console.log(this.data.showList) |
|
|
|
console.log(this.data.checkboxOptions) |
|
|
|
console.log(this.data.showList,'seeeeee') |
|
|
|
}) |
|
|
|
}, |
|
|
|
toOinspectionStaff(){ |
|
|
@ -182,7 +228,6 @@ Page({ |
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
showPopup() { |
|
|
|
this.setData({ showPopup: true }); // 点击按钮显示弹出层
|
|
|
|
}, |
|
|
@ -226,15 +271,7 @@ Page({ |
|
|
|
newContent: e.detail.value |
|
|
|
}); |
|
|
|
}, |
|
|
|
addAnother() { |
|
|
|
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中'); |
|
|
@ -246,6 +283,11 @@ Page({ |
|
|
|
uploadImageList: this.data.uploadImageList |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
changenewHazardStatus2(e){ |
|
|
|
this.setData({ |
|
|
|
hazardStatus2:e.detail.value |
|
|
|
}) |
|
|
|
}, |
|
|
|
getCurrentDateTime() { |
|
|
|
const now = new Date(); |
|
|
@ -259,6 +301,18 @@ Page({ |
|
|
|
}, |
|
|
|
|
|
|
|
handelClickSave(){ |
|
|
|
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: '请选择检查人员', |
|
|
@ -273,21 +327,46 @@ handelClickSave(){ |
|
|
|
}) |
|
|
|
return false |
|
|
|
} |
|
|
|
if(this.data.checkResultFlag == 0 && !this.data.reviewTime){ |
|
|
|
if(this.data.checkResultFlag == 0 && !this.data.currentDate){ |
|
|
|
wx.showToast({ |
|
|
|
title: '请选择拟复查时间', |
|
|
|
icon:'none' |
|
|
|
}) |
|
|
|
return false |
|
|
|
} |
|
|
|
if(this.data.checkResultFlag == 0 && this.data.checkboxOptions.length<0){ |
|
|
|
if(this.data.checkResultFlagRouter == 1 && !this.data.hazardStatus2){ |
|
|
|
wx.showToast({ |
|
|
|
title: '请填写整改要求', |
|
|
|
icon:'none' |
|
|
|
}) |
|
|
|
return false |
|
|
|
} |
|
|
|
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)
|
|
|
|
if(this.data.checkResultFlag == 0 && !hasHazardStatus1 && this.data.addHiddenDangeList.length<1){ |
|
|
|
console.log("1111",hasHazardStatus1) |
|
|
|
wx.showToast({ |
|
|
|
title: '请填写隐患明细', |
|
|
|
icon:'none' |
|
|
|
}) |
|
|
|
return false |
|
|
|
} |
|
|
|
|
|
|
|
const now = new Date(); |
|
|
|
const hours = now.getHours().toString().padStart(2, '0'); |
|
|
|
const minutes = now.getMinutes().toString().padStart(2, '0'); |
|
|
@ -297,28 +376,33 @@ handelClickSave(){ |
|
|
|
checkTime:this.getCurrentDateTime(), |
|
|
|
checkPersonsIdList:this.data.selectedOptions, |
|
|
|
checkResultFlag:this.data.checkResultFlag, |
|
|
|
reviewTime:`${this.data.reviewTime} ${hours}:${minutes}:${seconds}`, |
|
|
|
reviewTime:this.data.currentDateShow, |
|
|
|
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:"" |
|
|
|
reviewAddress:"" |
|
|
|
} |
|
|
|
console.log(this.data.checkboxOptions.concat(this.data.addHiddenDangeList)) |
|
|
|
addRecord(form).then(res => { |
|
|
|
if(res.code == 0){ |
|
|
|
wx.showToast({ |
|
|
|
title: '新增成功', |
|
|
|
duration:2000, |
|
|
|
success:function(){ |
|
|
|
setTimeout(()=>{ |
|
|
|
wx.navigateBack({ |
|
|
|
delta: 1 |
|
|
|
}) |
|
|
|
},2000) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
if(this.data.hazardStatus2){ |
|
|
|
form.hiddenDangeList.push({hazardDesc:this.data.hazardStatus2,hazardStatus:2}) |
|
|
|
} |
|
|
|
this.setData({ |
|
|
|
newContent:null |
|
|
|
}) |
|
|
|
// addRecord(form).then(res => {
|
|
|
|
// if(res.code == 0){
|
|
|
|
// wx.showToast({
|
|
|
|
// title: '新增成功',
|
|
|
|
// duration:2000,
|
|
|
|
// success:function(){
|
|
|
|
// setTimeout(()=>{
|
|
|
|
// wx.navigateBack({
|
|
|
|
// delta: 1
|
|
|
|
// })
|
|
|
|
// },2000)
|
|
|
|
// }
|
|
|
|
// })
|
|
|
|
// }
|
|
|
|
// })
|
|
|
|
console.log(form); |
|
|
|
}, |
|
|
|
chooseImage() { |
|
|
@ -479,6 +563,7 @@ pickerChange: function(e) { |
|
|
|
checkResultFlag:e.detail.value, |
|
|
|
checkResultFlagName:this.data.array[e.detail.value] |
|
|
|
}); |
|
|
|
console.log(this.data.checkboxOptions) |
|
|
|
}, |
|
|
|
pickerChange1: function(e) { |
|
|
|
this.setData({ |
|
|
@ -492,6 +577,38 @@ bindRemarkInput(e){ |
|
|
|
console.log(this.data.remark) |
|
|
|
console.log(this.data.remark) |
|
|
|
}, |
|
|
|
closePopup() { |
|
|
|
this.setData({ showPopup: false }); |
|
|
|
}, |
|
|
|
|
|
|
|
onInput(event) { |
|
|
|
var date = new Date(event.detail); |
|
|
|
var year = date.getFullYear(); |
|
|
|
var month = ("0" + (date.getMonth() + 1)).slice(-2); |
|
|
|
var day = ("0" + date.getDate()).slice(-2); |
|
|
|
var hour = ("0" + date.getHours()).slice(-2); |
|
|
|
var minute = ("0" + date.getMinutes()).slice(-2); |
|
|
|
var second = ("0" + date.getSeconds()).slice(-2); |
|
|
|
var formattedDateTime = year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second; |
|
|
|
console.log(formattedDateTime); |
|
|
|
this.setData({ |
|
|
|
getData:formattedDateTime |
|
|
|
}) |
|
|
|
console.log(this.data.getData) |
|
|
|
}, |
|
|
|
|
|
|
|
onConfirm(event) { |
|
|
|
const { value } = event.detail; |
|
|
|
this.setData({ |
|
|
|
currentDate: value, |
|
|
|
showtime: false |
|
|
|
}); |
|
|
|
console.log('选中的日期时间:', new Date(value)); |
|
|
|
}, |
|
|
|
|
|
|
|
onCancel() { |
|
|
|
this.setData({ showtime: false }); |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|