diff --git a/subpages/InspectionReport/pages/InspectionReport/InspectionReport.js b/subpages/InspectionReport/pages/InspectionReport/InspectionReport.js index e3e2874..3eb514c 100644 --- a/subpages/InspectionReport/pages/InspectionReport/InspectionReport.js +++ b/subpages/InspectionReport/pages/InspectionReport/InspectionReport.js @@ -18,7 +18,6 @@ Page({ data: { showtime:false, checkboxOptions:[], - checkboxOptionsnumber:0, hiddenDangeList: [], newObj:[], addRecord: [], @@ -67,7 +66,8 @@ Page({ newContent:'', currentDate: new Date().getTime(), minDate: new Date(2020, 0, 1).getTime(), - maxDate: new Date(2030, 11, 31).getTime() + maxDate: new Date(2030, 11, 31).getTime(), + checkboxValue:[] }, /** * 生命周期函数--监听页面加载 @@ -90,25 +90,21 @@ Page({ }, showRecordData() { - console.log(this.data.companyId) + this.setData({ + checkboxOptions:null + }) 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 checkboxOptionsnumber=checkboxOptions.length+1; - console.log(checkboxOptionsnumber) + let checkboxOptions = res.data[0].hiddenDangeList.filter(item=>item.hazardStatus === 0).map(item=>({hazardDesc:item.hazardDesc,hazardStatus:0,id:item.id})); this.setData({ checkboxOptions, - checkboxOptionsnumber + beforeFlag: res.data[0].checkResultFlag }) + console.log(this.data.checkboxOptions); } - this.setData({ - showList:res.data - }) - console.log(this.data.showList) }) }, getCurrentDateTime() { @@ -122,19 +118,6 @@ Page({ return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; }, 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){ wx.showToast({ title: '请选择企业', @@ -163,30 +146,29 @@ Page({ }) return false } - console.log( this.data.addHiddenDangeList) - if(this.data.checkResultFlag == 0 && this.data.addHiddenDangeList.length<1){ + if(this.data.checkResultFlag == 0 && this.data.checkboxValue.length<1&&!this.data.hazardDesc2){ 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'); - 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) + 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, checkTime: this.getCurrentDateTime(), checkPersonsIdList: this.data.checkPersonsIdList, checkResultFlag: this.data.checkResultFlag, reviewTime:this.data.getData, - hiddenDangeList:this.data.checkboxOptions.concat(this.data.addHiddenDangeList), + hiddenDangeList:null, attachmentUrls:this.data.uploadImageList.map(item=>({fileName:item.originFileName,attachmentUrl:item.ossUrl.url})), remark: '', reviewAddress:this.data.addressContent @@ -277,13 +259,11 @@ Page({ */ onShareAppMessage() {}, onChange(event) { - console.log("111", event) + console.log(event); this.setData({ - result: event.detail + checkboxValue: event.detail }); - console.log(this.data.result); - console.log(this.data.hiddenDangeList); - + console.log(this.data.checkboxValue); }, afterRead(event) { const { @@ -402,7 +382,8 @@ Page({ // 更新当前选中的索引 this.setData({ gridNName: this.data.companyList[e.detail.value].name, - companyId:this.data.companyList[e.detail.value].id + companyId:this.data.companyList[e.detail.value].id, + checkboxValue:[] }); this.showRecordData() }, diff --git a/subpages/InspectionReport/pages/InspectionReport/InspectionReport.wxml b/subpages/InspectionReport/pages/InspectionReport/InspectionReport.wxml index 5c41e5e..dddd8a0 100644 --- a/subpages/InspectionReport/pages/InspectionReport/InspectionReport.wxml +++ b/subpages/InspectionReport/pages/InspectionReport/InspectionReport.wxml @@ -44,13 +44,16 @@ * - 隐患明细 + {{beforeFlag == 1?'隐患明细':'未整改隐患'}} + + {{index + 1}}. {{item.hazardDesc}} + {{index+1}}.{{item.hazardDesc}} + wx:for-item="item"> {{item.hazardDesc}} @@ -62,21 +65,17 @@ --> - - + - + * + 整改要求 - - - - + + + + @@ -138,7 +137,7 @@ 备注 -