|
|
@ -15,8 +15,7 @@ Page({ |
|
|
|
* 页面的初始数据 |
|
|
|
*/ |
|
|
|
data: { |
|
|
|
hiddenDangeList: [ |
|
|
|
], |
|
|
|
hiddenDangeList: [], |
|
|
|
newObj:[], |
|
|
|
addRecord: [], |
|
|
|
attachmentUrl: '', |
|
|
@ -37,14 +36,12 @@ Page({ |
|
|
|
happenTime: "", |
|
|
|
content: "", //内容
|
|
|
|
address: "", //地址
|
|
|
|
namesArray: [], |
|
|
|
AllnamesArray: [], |
|
|
|
checkPersons: '' |
|
|
|
}, |
|
|
|
imageUrl: '', |
|
|
|
remarks: '', //备注
|
|
|
|
getData: '', |
|
|
|
gridName: '', |
|
|
|
checkResultName: '', |
|
|
|
array: ['不合格', '合格'], // 选择器的数据源
|
|
|
|
arrlist: [], |
|
|
|
fileList: [], |
|
|
@ -55,24 +52,17 @@ Page({ |
|
|
|
// 用于存放复选框选择的结果
|
|
|
|
result: [], |
|
|
|
// 用于存放输入框的值
|
|
|
|
newPassword: '', |
|
|
|
hazardDesc: '', |
|
|
|
hazardDesc2:'', |
|
|
|
uploadImageList: [], |
|
|
|
imageId: 1, |
|
|
|
arr: [ |
|
|
|
// {value:"1",name:'小王'},
|
|
|
|
// {value:"2",name:'李四'},
|
|
|
|
// {value:"3",name:'张三'}
|
|
|
|
], |
|
|
|
arr1: [ |
|
|
|
// {value:"1",name:'1.车间一些软件设备出现生锈断裂情况严重'},
|
|
|
|
// {value:"2",name:'2.还有部分货运车辆已过年检。'},
|
|
|
|
], |
|
|
|
arr: [], |
|
|
|
arr1: [], |
|
|
|
}, |
|
|
|
/** |
|
|
|
* 生命周期函数--监听页面加载 |
|
|
|
*/ |
|
|
|
onLoad(options) { |
|
|
|
console.log(options.resiId) |
|
|
|
this.setData({ |
|
|
|
companyId: options.resiId |
|
|
|
}) |
|
|
@ -80,22 +70,67 @@ Page({ |
|
|
|
key: 'CMJBZ-4DECI-JXGGN-5B4WU-QLV2H-B5BEJ' |
|
|
|
}) |
|
|
|
this.reverseLocation() |
|
|
|
// this.ToaddRecord()
|
|
|
|
this.getList() |
|
|
|
}, |
|
|
|
|
|
|
|
getCurrentDateTime() { |
|
|
|
const now = new Date(); |
|
|
|
const year = now.getFullYear(); |
|
|
|
const month = (now.getMonth() + 1).toString().padStart(2, '0'); |
|
|
|
const day = now.getDate().toString().padStart(2, '0'); |
|
|
|
const hours = now.getHours().toString().padStart(2, '0'); |
|
|
|
const minutes = now.getMinutes().toString().padStart(2, '0'); |
|
|
|
const seconds = now.getSeconds().toString().padStart(2, '0'); |
|
|
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; |
|
|
|
}, |
|
|
|
submitBiao() { |
|
|
|
console.log("122131") |
|
|
|
const currentDate = new Date(); |
|
|
|
if(!this.data.companyId){ |
|
|
|
wx.showToast({ |
|
|
|
title: '请选择企业', |
|
|
|
icon:'none' |
|
|
|
}) |
|
|
|
return false |
|
|
|
} |
|
|
|
if(this.data.selectedOptions.length === 0){ |
|
|
|
wx.showToast({ |
|
|
|
title: '请选择检查人员', |
|
|
|
icon:'none' |
|
|
|
}) |
|
|
|
return false |
|
|
|
} |
|
|
|
if(!this.data.checkResultFlag){ |
|
|
|
wx.showToast({ |
|
|
|
title: '请选择检查结论', |
|
|
|
icon:'none' |
|
|
|
}) |
|
|
|
return false |
|
|
|
} |
|
|
|
if(this.data.checkResultFlag == 0 && !this.data.reviewTime){ |
|
|
|
wx.showToast({ |
|
|
|
title: '请选择拟复查时间', |
|
|
|
icon:'none' |
|
|
|
}) |
|
|
|
return false |
|
|
|
} |
|
|
|
if(this.data.checkResultFlag == 0 && this.data.hiddenDangeList.length<0){ |
|
|
|
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'); |
|
|
|
const seconds = now.getSeconds().toString().padStart(2, '0'); |
|
|
|
addRecord({ |
|
|
|
companyId: this.data.companyId, |
|
|
|
checkTime: currentDate, |
|
|
|
checkTime: this.getCurrentDateTime(), |
|
|
|
checkPersonsIdList: this.data.checkPersonsIdList, |
|
|
|
checkResultFlag: this.data.checkResultFlag, |
|
|
|
reviewTime: this.data.reviewTime, |
|
|
|
hiddenDangeList: this.data.hiddenDangeList, |
|
|
|
attachmentUrls: this.data.uploadImageList, |
|
|
|
remark: '123' |
|
|
|
reviewTime:`${this.data.reviewTime} ${hours}:${minutes}:${seconds}`, |
|
|
|
hiddenDangeList:[...this.data.hiddenDangeList,{hazardStatus:2,hazardDesc:this.data.hazardDesc2}] , |
|
|
|
attachmentUrls:this.data.uploadImageList.map(item=>({fileName:item.originFileName,attachmentUrl:item.ossUrl.url})), |
|
|
|
remark: '' |
|
|
|
}).then(({ |
|
|
|
data |
|
|
|
}) => { |
|
|
@ -111,24 +146,9 @@ Page({ |
|
|
|
}).then(({ |
|
|
|
data |
|
|
|
}) => { |
|
|
|
// console.log("123131",data.list)
|
|
|
|
this.setData({ |
|
|
|
marsi: data.list, |
|
|
|
total: data.total |
|
|
|
}) |
|
|
|
this.setData({ |
|
|
|
'fmData.AllnamesArray': data.list.map(item => ({ |
|
|
|
id: item.id, |
|
|
|
name: item.name |
|
|
|
})), |
|
|
|
'fmData.namesArray': data.list.map(item => (item.name)), |
|
|
|
|
|
|
|
'fmData.checkPersons': data.list.map((item, index) => ({ |
|
|
|
value: index, |
|
|
|
name: item.checkPersons |
|
|
|
})), |
|
|
|
companyList: data.list, |
|
|
|
}); |
|
|
|
// console.log("123131", this.data.fmData.namesArray.map(item => item.name));
|
|
|
|
}); |
|
|
|
inspectionStaff({ |
|
|
|
orgId: App.globalData.user.agencyId, |
|
|
@ -142,8 +162,6 @@ Page({ |
|
|
|
arr: data.staffList |
|
|
|
}) |
|
|
|
}); |
|
|
|
///
|
|
|
|
|
|
|
|
}, |
|
|
|
/** |
|
|
|
* 生命周期函数--监听页面初次渲染完成 |
|
|
@ -185,8 +203,6 @@ Page({ |
|
|
|
this.setData({ |
|
|
|
result: event.detail |
|
|
|
}); |
|
|
|
|
|
|
|
// event.detail 为当前输入的值
|
|
|
|
console.log(this.data.result); |
|
|
|
console.log(this.data.hiddenDangeList); |
|
|
|
|
|
|
@ -240,67 +256,55 @@ Page({ |
|
|
|
confirmSelection() { |
|
|
|
// 点击确定按钮后触发,处理选中的复选框项
|
|
|
|
console.log("选中的项:", this.data.selectedOptions); |
|
|
|
|
|
|
|
const selectedName = this.data.selectedOptions; |
|
|
|
let names = [] |
|
|
|
this.data.arr.forEach(item=>{ |
|
|
|
if(this.data.selectedOptions.findIndex(itemC=>itemC === item.staffId) != -1){ |
|
|
|
names.push(item.name) |
|
|
|
} |
|
|
|
}) |
|
|
|
this.setData({ |
|
|
|
showPopup: false, |
|
|
|
selectedNames: selectedName |
|
|
|
}); |
|
|
|
const matchedStaffIds = []; |
|
|
|
this.data.arr.forEach(item => { |
|
|
|
if (selectedName.includes(item.name)) { |
|
|
|
matchedStaffIds.push(item.staffId); |
|
|
|
} |
|
|
|
selectedNames: names, |
|
|
|
checkPersonsIdList:this.data.selectedOptions |
|
|
|
}); |
|
|
|
}, |
|
|
|
changeHazardDesc(e) { |
|
|
|
this.setData({ |
|
|
|
checkPersonsIdList: matchedStaffIds |
|
|
|
hazardDesc: e.detail.value |
|
|
|
}); |
|
|
|
// 关闭弹出层
|
|
|
|
|
|
|
|
}, |
|
|
|
changeNewPassword(e) { |
|
|
|
console.log("执行了") |
|
|
|
changeHazardDescStatus2(e){ |
|
|
|
this.setData({ |
|
|
|
newPassword: e.detail.value |
|
|
|
hazardDesc2: e.detail.value |
|
|
|
}); |
|
|
|
console.log(this.data.newPassword) |
|
|
|
}, |
|
|
|
addAnother() { |
|
|
|
let newValue = this.data.arr1.length + 1; // 根据数组长度确定新值
|
|
|
|
let newArr = this.data.arr1.concat({ |
|
|
|
value: newValue.toString(), |
|
|
|
name: this.data.newPassword |
|
|
|
name: this.data.hazardDesc |
|
|
|
}); |
|
|
|
this.setData({ |
|
|
|
arr1: newArr, |
|
|
|
newPassword: '', // 清空输入框的值
|
|
|
|
hazardDesc: '', // 清空输入框的值
|
|
|
|
}); |
|
|
|
const nameArray = this.data.arr1.map(item => item.name); |
|
|
|
console.log("111",nameArray) |
|
|
|
nameArray.forEach(value => { |
|
|
|
console.log( "qqq") |
|
|
|
// 创建一个新的对象,设置 hazardDesc 属性为当前值
|
|
|
|
this.data.newObj = { |
|
|
|
hazardStatus: '0', // 如果需要同时设置 hazardStatus 属性,可以在这里进行设置
|
|
|
|
hazardDesc: value |
|
|
|
}; |
|
|
|
console.log( this.data.newObj) |
|
|
|
// 将新对象添加到 hiddenDangeList 数组中
|
|
|
|
console.log(this.data.hiddenDangeList) |
|
|
|
}); |
|
|
|
|
|
|
|
this.data.hiddenDangeList.push(this.data.newObj); |
|
|
|
console.log(this.data.hiddenDangeList) |
|
|
|
}, |
|
|
|
pickerChange: function (e) { |
|
|
|
// 更新当前选中的索引
|
|
|
|
console.log(e.detail.value), |
|
|
|
this.setData({ |
|
|
|
gridName: this.data.array[e.detail.value] |
|
|
|
checkResultName: this.data.array[e.detail.value], |
|
|
|
checkResultFlag:e.detail.value |
|
|
|
}); |
|
|
|
this.data.checkResultFlag = e.detail.value |
|
|
|
console.log(this.data.gridName) |
|
|
|
// 在这里可以根据选择的值进行相应的逻辑处理
|
|
|
|
}, |
|
|
|
pickerChange1: function (e) { |
|
|
|
// 更新当前选中的索引
|
|
|
@ -315,9 +319,9 @@ Page({ |
|
|
|
pickerChange2: function (e) { |
|
|
|
// 更新当前选中的索引
|
|
|
|
this.setData({ |
|
|
|
gridNName: this.data.fmData.namesArray[e.detail.value] |
|
|
|
gridNName: this.data.companyList[e.detail.value].name, |
|
|
|
companyId:this.data.companyList[e.detail.value].id |
|
|
|
}); |
|
|
|
this.data.addRecord = this.data.fmData.AllnamesArray[e.detail.value].id |
|
|
|
}, |
|
|
|
bindRemarkInput(e) { |
|
|
|
this.setData({ |
|
|
|