Browse Source

列表未刷新

data-page-V4.3.1
是小王呀\24601 1 year ago
parent
commit
96c84338a1
  1. 65
      subpages/InspectionReport/pages/InspectionReport/InspectionReport.js
  2. 4
      subpages/InspectionReport/pages/InspectionReport/InspectionReport.wxml
  3. 112
      subpages/safetyinspection/pages/safetyinspection/safetyinspection.js
  4. 8
      subpages/safetyinspection/pages/safetyinspection/safetyinspection.wxml

65
subpages/InspectionReport/pages/InspectionReport/InspectionReport.js

@ -122,6 +122,19 @@ Page({
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}, },
submitBiao() { submitBiao() {
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,
});
}
if(!this.data.companyId){ if(!this.data.companyId){
wx.showToast({ wx.showToast({
title: '请选择企业', title: '请选择企业',
@ -150,8 +163,9 @@ Page({
}) })
return false return false
} }
console.log( this.data.addHiddenDangeLis) console.log( this.data.addHiddenDangeList)
if(this.data.checkResultFlag == 0 && this.data.addHiddenDangeList){
if(this.data.checkResultFlag == 0 && this.data.addHiddenDangeList.length<1){
wx.showToast({ wx.showToast({
title: '隐患明细最少输入一条', title: '隐患明细最少输入一条',
icon:'none' icon:'none'
@ -162,7 +176,11 @@ Page({
const hours = now.getHours().toString().padStart(2, '0'); const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0'); const minutes = now.getMinutes().toString().padStart(2, '0');
const seconds = now.getSeconds().toString().padStart(2, '0'); const seconds = now.getSeconds().toString().padStart(2, '0');
console.log(this.data.getData) let checkboxOptions =this.data.addHiddenDangeList.filter(item=>item.hazardStatus === 0).map(item=>({hazardDesc:item.hazardDesc,hazardStatus:2,requirements:this.data.hazardDesc2}));
this.setData({
addHiddenDangeList:checkboxOptions
})
console.log(this.data.addHiddenDangeList)
let form={ companyId: this.data.companyId, let form={ companyId: this.data.companyId,
checkTime: this.getCurrentDateTime(), checkTime: this.getCurrentDateTime(),
checkPersonsIdList: this.data.checkPersonsIdList, checkPersonsIdList: this.data.checkPersonsIdList,
@ -176,24 +194,25 @@ Page({
if (!this.data.reviewTime) { if (!this.data.reviewTime) {
form.reviewTime=null form.reviewTime=null
} }
addRecord( console.log(form)
form // addRecord(
).then( // form
res => { // ).then(
if(res.code == 0){ // res => {
wx.showToast({ // if(res.code == 0){
title: '新增成功', // wx.showToast({
duration:2000, // title: '新增成功',
success:function(){ // duration:2000,
setTimeout(()=>{ // success:function(){
wx.navigateBack({ // setTimeout(()=>{
delta: 1 // wx.navigateBack({
}) // delta: 1
},2000) // })
} // },2000)
}) // }
} // })
}); // }
// });
}, },
@ -347,6 +366,7 @@ Page({
this.setData({ this.setData({
hazardDesc2: e.detail.value hazardDesc2: e.detail.value
}); });
console.log(this.data.hazardDesc2)
}, },
changenewContent(e){ changenewContent(e){
this.setData({ this.setData({
@ -354,7 +374,8 @@ Page({
}); });
}, },
addAnother() { addAnother() {
let newArr = this.data.addHiddenDangeList.concat({ hazardDesc: this.data.newContent, hazardStatus: 0 }); let newArr = this.data.addHiddenDangeList.concat({ hazardDesc: this.data.newContent, hazardStatus: 0, requirements:this.data.hazardDesc2});
console.log()
this.setData({ this.setData({
addHiddenDangeList: newArr, addHiddenDangeList: newArr,
newContent: '', // 清空输入框的值 newContent: '', // 清空输入框的值

4
subpages/InspectionReport/pages/InspectionReport/InspectionReport.wxml

@ -56,10 +56,10 @@
<view class="input1"> <view class="input1">
<input bindinput="changenewContent" type="text" value="{{newContent}}" placeholder=" 请输入" /> <input bindinput="changenewContent" type="text" value="{{newContent}}" placeholder=" 请输入" />
</view> </view>
<view class="add" bind:tap="addAnother"> <!-- <view class="add" bind:tap="addAnother">
<image src="../../../../images/add.png" class="add_img"></image> <image src="../../../../images/add.png" class="add_img"></image>
<text>再添加一条</text> <text>再添加一条</text>
</view> </view> -->
</view> </view>

112
subpages/safetyinspection/pages/safetyinspection/safetyinspection.js

@ -37,7 +37,7 @@ Page({
uploadImageList: [],//图片上传的数组 uploadImageList: [],//图片上传的数组
imageId:1, imageId:1,
addHiddenDangeList:[], addHiddenDangeList:[],
currentDate: new Date().getTime(), currentDate:null,
minDate: new Date(2020, 0, 1).getTime(), minDate: new Date(2020, 0, 1).getTime(),
maxDate: new Date(2030, 11, 31).getTime(), maxDate: new Date(2030, 11, 31).getTime(),
showtime:false, showtime:false,
@ -55,6 +55,7 @@ Page({
this.showRecordData() this.showRecordData()
this.toOinspectionStaff() this.toOinspectionStaff()
this.securityCheckk() this.securityCheckk()
}, },
/** /**
@ -67,13 +68,21 @@ Page({
*/ */
onShow() { onShow() {
console.log(111111);
debugger
console.log(this.getCurrentDateTime());
this.setData({
currentDate:this.getCurrentDateTime()
})
}, },
/** /**
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */
onHide() { onHide() {
this.setData({
currentDate:null
})
}, },
/** /**
@ -118,11 +127,13 @@ Page({
console.log(event.detail); console.log(event.detail);
this.data.checkboxOptions.forEach((item,index)=>{ this.data.checkboxOptions.forEach((item,index)=>{
if(event.detail.findIndex(item=>item==index) != -1){ if(event.detail.findIndex(item=>item==index) != -1){
console.log("我被选中了")
item.hazardStatus = 0 item.hazardStatus = 0
}else{ }else{
item.hazardStatus = 1 item.hazardStatus = 1
} }
}) })
console.log(this.data.checkboxOptions)
this.setData({ this.setData({
checkboxValue:event.detail, checkboxValue:event.detail,
}) })
@ -156,13 +167,14 @@ Page({
}); });
}, },
showRecordData() { showRecordData() {
console.log("我执行了")
let parm = { let parm = {
id: this.data.companyId id: this.data.companyId
} }
showRecord(parm).then(res => { showRecord(parm).then(res => {
console.log(res) console.log(res)
if(res.data[0].hiddenDangeList){ 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; let checkboxOptionsnumber=checkboxOptions.length+1;
console.log(checkboxOptionsnumber) console.log(checkboxOptionsnumber)
this.setData({ this.setData({
@ -173,6 +185,7 @@ Page({
this.setData({ this.setData({
showList:res.data showList:res.data
}) })
console.log(this.data.checkboxOptions)
console.log(this.data.showList) console.log(this.data.showList)
}) })
}, },
@ -234,32 +247,10 @@ Page({
this.setData({ this.setData({
newContent: e.detail.value 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) { deleteImage(e) {
console.log(this.data.uploadImageList,'data中'); console.log(this.data.uploadImageList,'data中');
@ -280,10 +271,27 @@ Page({
const hours = now.getHours().toString().padStart(2, '0'); const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0'); const minutes = now.getMinutes().toString().padStart(2, '0');
const seconds = now.getSeconds().toString().padStart(2, '0'); const seconds = now.getSeconds().toString().padStart(2, '0');
debugger
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}, },
handelClickSave(){ 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){ if(this.data.selectedOptions.length === 0){
wx.showToast({ wx.showToast({
title: '请选择检查人员', title: '请选择检查人员',
@ -298,14 +306,34 @@ handelClickSave(){
}) })
return false return false
} }
if(this.data.checkResultFlag == 0 && !this.data.reviewTime){ if(this.data.checkResultFlag == 0 && !this.data.getData){
wx.showToast({ wx.showToast({
title: '请选择拟复查时间', title: '请选择拟复查时间',
icon:'none' icon:'none'
}) })
return false 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({ wx.showToast({
title: '请填写隐患明细', title: '请填写隐患明细',
icon:'none' icon:'none'
@ -316,17 +344,22 @@ handelClickSave(){
const hours = now.getHours().toString().padStart(2, '0'); const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0'); const minutes = now.getMinutes().toString().padStart(2, '0');
const seconds = now.getSeconds().toString().padStart(2, '0'); const seconds = now.getSeconds().toString().padStart(2, '0');
console.log(this.data.checkboxOptions)
console.log(this.data.addHiddenDangeList)
let form = { let form = {
companyId:this.data.companyId, companyId:this.data.companyId,
checkTime:this.getCurrentDateTime(), checkTime:this.getCurrentDateTime(),
checkPersonsIdList:this.data.selectedOptions, checkPersonsIdList:this.data.selectedOptions,
checkResultFlag:this.data.checkResultFlag, checkResultFlag:this.data.checkResultFlag,
reviewTime:`${this.data.reviewTime} ${hours}:${minutes}:${seconds}`, reviewTime:this.data.getData,
hiddenDangeList:this.data.checkboxOptions.concat(this.data.addHiddenDangeList), hiddenDangeList:this.data.checkboxOptions.concat(this.data.addHiddenDangeList),
attachmentUrls:this.data.uploadImageList.map(item=>({fileName:item.originFileName,attachmentUrl:item.ossUrl.url})), attachmentUrls:this.data.uploadImageList.map(item=>({fileName:item.originFileName,attachmentUrl:item.ossUrl.url})),
remark:this.data.remark, remark:this.data.remark,
address:"" address:""
} }
console.log(this.data.checkboxOptions)
console.log(this.data.addHiddenDangeList)
console.log(this.data.hiddenDangeList)
if (!this.data.reviewTime) { if (!this.data.reviewTime) {
form.reviewTime=null form.reviewTime=null
} }
@ -506,22 +539,7 @@ pickerChange: function(e) {
checkResultFlag:e.detail.value, checkResultFlag:e.detail.value,
checkResultFlagName:this.data.array[e.detail.value] checkResultFlagName:this.data.array[e.detail.value]
}); });
if (e.detail.value) { console.log(this.data.checkboxOptions)
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('用户点击取消')
}
}
})
}
}
}, },
pickerChange1: function(e) { pickerChange1: function(e) {
this.setData({ this.setData({
@ -552,7 +570,7 @@ onInput(event) {
this.setData({ this.setData({
getData:formattedDateTime getData:formattedDateTime
}) })
console.log(this.data.getData)
}, },
onConfirm(event) { onConfirm(event) {

8
subpages/safetyinspection/pages/safetyinspection/safetyinspection.wxml

@ -33,10 +33,10 @@
<view class="input1"> <view class="input1">
<input bindinput="changenewContent" value="{{newContent}}" type="text" placeholder=" 请输入新的隐患信息" /> <input bindinput="changenewContent" value="{{newContent}}" type="text" placeholder=" 请输入新的隐患信息" />
</view> </view>
<view class="add" bind:tap="addAnother"> <!-- <view class="add" bind:tap="addAnother">
<image src="../../../../images/add.png" class="add_img"></image> <image src="../../../../images/add.png" class="add_img"></image>
<text>再添加一条</text> <text>再添加一条</text>
</view> </view> -->
</view> </view>
<view class="prosecutors" > <view class="prosecutors" >
<text class="prosecutors_req">*</text> <text class="prosecutors_req">*</text>
@ -59,8 +59,8 @@
<view class="nes" bind:tap="showTime"> <view class="nes" bind:tap="showTime">
<view class="conclusion"> <view class="conclusion">
<text class="prosecutors_pre">拟复查时间</text> <text class="prosecutors_pre">拟复查时间</text>
<view class="{{getData?'prosecutors_name':'gray'}}"> <view class="{{currentDate?'prosecutors_name':'gray'}}">
{{getData?getData:'请选择'}} {{currentDate?currentDate:'请选择'}}
</view> </view>
<!-- <picker mode="date" class="prosecutors_name" bindchange="pickerChange1" value="{{reviewTime}}"> <!-- <picker mode="date" class="prosecutors_name" bindchange="pickerChange1" value="{{reviewTime}}">
<view class="{{reviewTime?'':'gray'}}"> <view class="{{reviewTime?'':'gray'}}">

Loading…
Cancel
Save