Browse Source

新增巡查记录

lisu_V4.3.1
mk 1 year ago
parent
commit
a7d3fea423
  1. 156
      subpages/InspectionReport/pages/InspectionReport/InspectionReport.js
  2. 18
      subpages/InspectionReport/pages/InspectionReport/InspectionReport.wxml
  3. 2
      subpages/safetyinspection/pages/safetyinspection/safetyinspection.js
  4. 4
      utils/config.js

156
subpages/InspectionReport/pages/InspectionReport/InspectionReport.js

@ -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({

18
subpages/InspectionReport/pages/InspectionReport/InspectionReport.wxml

@ -16,7 +16,7 @@
<view class="conclusion">
<text class="prosecutors_req">*</text>
<text class="prosecutors_pre">企业名称</text>
<picker class="prosecutors_name" bindchange="pickerChange2" value="{{index}}" range="{{fmData.namesArray}}">
<picker class="prosecutors_name" bindchange="pickerChange2" range-key="name" value="{{index}}" range="{{companyList}}">
<view class="{{gridNName?'':'gray'}}">
{{gridNName?gridNName:'请选择'}}
</view>
@ -40,7 +40,7 @@
<view class="pitfall">
<view class="prosecutors">
<view>
<text class="prosecutors_req">*</text>
<text class="prosecutors_req" wx:if="{{checkResultFlag == 0}}">*</text>
<text class="prosecutors_pre">隐患明细</text>
</view>
</view>
@ -50,7 +50,7 @@
</van-checkbox-group>
</view>
<view class="input1">
<input bindinput="changeNewPassword" type="text" placeholder=" 请输入" />
<input bindinput="changeHazardDesc" type="text" value="{{hazardDesc}}" placeholder=" 请输入" />
</view>
<view class="add" bind:tap="addAnother">
<image src="../../../../images/add.png" class="add_img"></image>
@ -72,7 +72,7 @@
</van-checkbox-group>
</view> -->
<view class="input1">
<input bindinput="changeHazardDesc" type="text" placeholder="请输入" value="{{ hazardDesc }}" />
<input bindinput="changeHazardDescStatus2" type="text" placeholder="请输入" value="{{ hazardDesc2 }}" />
</view>
</view>
@ -82,8 +82,8 @@
<text class="prosecutors_req">*</text>
<text class="prosecutors_pre">检查结论</text>
<picker class="prosecutors_name" bindchange="pickerChange" value="{{index}}" range="{{array}}">
<view class="{{gridName?'':'gray'}}">
{{gridName?gridName:'请选择'}}
<view class="{{checkResultName?'':'gray'}}">
{{checkResultName?checkResultName:'请选择'}}
</view>
</picker>
</view>
@ -93,7 +93,7 @@
</view>
<view class="prosecutors">
<view class="prosecutors_data">
<text class="prosecutors_req">*</text>
<text class="prosecutors_req" wx:if="{{checkResultFlag == 0}}">*</text>
<text class="prosecutors_pre">拟复查时间</text>
<view>
<picker mode="date" class="prosecutors_name" bindchange="pickerChange1" value="{{data}}">
@ -121,7 +121,7 @@
wx:key="imageId">
<image class="issue-image" src="{{item.ossUrl.url}}" />
<image wx:if="{{!item.uploaded}}" class="loading" src="../../../../images/loading.gif" />
<image bindtap="deleteImage" data-imageid="{{item.imageId}}" class="close" wx:else src="../../../../images/loading.gif" />
<image bindtap="deleteImage" data-imageid="{{item.imageId}}" class="close" wx:else src="../../../../images/icon_close.png" />
</view>
<image wx:if="{{uploadImageList.length < 3}}" src="../../../../images/addphoto.png" bindtap="chooseImage" />
</view>
@ -142,7 +142,7 @@
<van-popup show="{{ showPopup }}" closeable close-icon="close" position="bottom" custom-style="height: 50%" bind:close="onClose">
<view class="popup-content">
<van-checkbox-group value="{{selectedOptions}}" bind:change="onChange1">
<van-checkbox name="{{item.name}}" data-value="{{item.value}}" wx:for="{{arr}}">{{item.name}}</van-checkbox>
<van-checkbox name="{{item.staffId}}" wx:for="{{arr}}">{{item.name}}</van-checkbox>
</van-checkbox-group>
<button bindtap="confirmSelection">确定</button>
</view>

2
subpages/safetyinspection/pages/safetyinspection/safetyinspection.js

@ -251,7 +251,7 @@ handelClickSave(){
})
return false
}
if(this.data.checkResultFlag == 0 && this.data.hiddenDangeList.length<0){
if(this.data.checkResultFlag == 0 && this.data.checkboxOptions.length<0){
wx.showToast({
title: '请填写隐患明细',
icon:'none'

4
utils/config.js

@ -5,13 +5,13 @@ module.exports = {
};
function BASEURL() {
// return 'https://epmet-preview.elinkservice.cn/api/' // 演示环境
return 'https://epmet-preview.elinkservice.cn/api/' // 演示环境
// return 'http://192.168.1.144/api/' //测试环境
// return 'http://219.146.91.110:30801/api/'
// return 'https://epmet-preview.elinkservice.cn/api/' // 演示环境
// return 'http://192.168.1.144/api/' //测试环境
return 'http://219.146.91.110:30801/api/'
// return 'http://219.146.91.110:30801/api/'
//return http://219.146.91.110:30801/api //外网
}

Loading…
Cancel
Save