jhprjv2/ruoyi-ui-app/miniprogram/pageage/safetyManagement/securityCheck/index.js

361 lines
10 KiB
JavaScript

// pageage/safetyManagement/securityCheckGR/index.js
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
loginName:"",
userName:"",
projectId:"",
projectData:{},
projectNameArgs:"",
initData: {},
show:false,
stateNav:1,
statePosit:1,
listData:[],
listDataed:[],
//常规检查总数
conventionNumber:0,
//转向检查总数
specialNumber:0,
//待整改总数
unRectifyNumber:0,
//已整改整数
rectifyNumber:0
},
onClose(){
this.setData({ show: false });
},
showPopup() {
this.setData({ show: true });
},
goGCLB(){
wx.redirectTo({
url: '../../../pages/newAddPage/safetyManagement/index',
})
},
// 常规检查 专项检查 选择
onStateSelect(e){
let state = e.currentTarget.dataset.state;
this.setData({
stateNav:state,
});
this.getProjectCorrespondence(app.globalData.projectId)
},
//待整改 已整改 选择
onStatePosit(e){
let state = e.currentTarget.dataset.state;
this.setData({
statePosit:state,
});
},
//项目切换 返回值
onProjectSelect(e) {
let projectId = e.detail.id;
let projectName = e.detail.text;
app.globalData.projectId = projectId;
app.globalData.projectName = projectName;
this.setData({
projectId: projectId,
projectName: projectName,
})
this.onLoad()
},
skipCheckView(){
let {szh} = this.data.projectData
wx.navigateTo({
url: `../addSafetyInspect/index?projectId=${szh}`,
})
},
getSaftCheckDetialsInfo(e){
console.log(e);
let {id,projectId,checkType,checkpoint,rectify_time,inspect_time} = e.currentTarget.dataset.set
wx.navigateTo({
url: `../problemRectification/index?id=${id}&projectId=${projectId}&checkType=${checkType}&checkpoint=${checkpoint}&rectify_time=${rectify_time}&inspect_time=${inspect_time}`,
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
//获取缓存数据
wx.getStorage({
key: 'userinfo',
success:res=>{
this.setData({
loginName:res.data.loginName,
userName:res.data.userName,
projectId:app.globalData.projectId,
projectNameArgs:app.globalData.projectName,
initData:{text:app.globalData.projectName,id:app.globalData.projectId}
})
this.getProjectCorrespondence(app.globalData.projectId)
}
})
},
/**
* 项目对应关系
*/
getProjectCorrespondence(projectId) {
var that = this;
wx.request({
url: app.globalData.reqUrl + '/weixin/training/getProjectCorrespondence',
data: {
"projectId": projectId,
},
method: "get",
success: function (res) {
that.setData({
projectData: res.data
})
//获取常规检查数据
that.getSaftCheckDataInfoCg();
//获取专项检查数据
that.getSaftCheckDataInfoZx();
}
})
},
/**
* 获取常规检查数据
*/
getSaftCheckDataInfoCg(){
let that = this
let {szh} = that.data.projectData
wx.request({
url: app.globalData.szhUrl+'/api/check/getCheckInfoList',
method:"GET",
data:{
project_id:szh,
large_type:1
},
success(res){
res = res.data
console.log(res);
if(res.code == 200){
let listDataTemp = [];
let listDataTempEd = [];
let tempa =0;
let tempb =0;
that.setData({
//专项检查总数
conventionNumber:res.data.length,
})
res.data.forEach((item,index)=>{
//待整改数
if(!item.afterPhoto){
tempa++;
listDataTemp.push({
id:item.id,
status:item.status,
projectId:item.projectId,
checkType:item.check_type,
title:item.check_type +' '+item.inspect_time,
questions_number: item.problem_number,
rectification_number: item.correct_number,
photo:item.beforePhoto,
rectify_time:item.change_time,
inspect_time:item.inspect_time,
rectify_front_img:item.beforePhoto,
rectify_after_img:item.afterPhoto,
rectification_prop:item.correct_rate,
checkpoint:item.check_position,
})
} else {
//已整改数
tempb++;
listDataTempEd.push({
id:item.id,
status:item.status,
projectId:item.projectId,
checkType:item.check_type,
title:item.check_type +' '+item.inspect_time,
questions_number: item.problem_number,
rectification_number: item.correct_number,
photo:item.beforePhoto,
rectify_time:item.change_time,
inspect_time:item.inspect_time,
rectify_front_img:item.beforePhoto,
rectify_after_img:item.afterPhoto,
rectification_prop:item.correct_rate,
checkpoint:item.check_position,
})
}
})
that.setData({
//专项检查总数
listData:listDataTemp,
})
if(that.data.stateNav == 1){
that.setData({
listData:listDataTemp,
listDataed:listDataTempEd,
unRectifyNumber:tempa,
rectifyNumber:tempb
})
}
}
}
})
},
/**
* 获取专项检查数据
*/
getSaftCheckDataInfoZx(){
let that = this
let {szh} = that.data.projectData
wx.request({
url: app.globalData.szhUrl+'/api/check/getCheckInfoList',
method:"GET",
data:{
project_id:szh,
large_type: 2
},
success(res){
res = res.data
if(res.code == 200){
let listDataTemp = [];
let listDataTempEd = [];
let tempa =0;
let tempb =0;
that.setData({
//专项检查总数
specialNumber:res.data.length,
})
res.data.forEach((item,index)=>{
//待整改数
if(!item.afterPhoto){
tempa++;
listDataTemp.push({
id:item.id,
status:item.status,
projectId:item.projectId,
checkType:item.check_type,
title:item.check_type +' '+item.inspect_time,
questions_number: item.problem_number,
rectification_number: item.correct_number,
photo:item.beforePhoto,
rectify_time:item.change_time,
inspect_time:item.inspect_time,
rectify_front_img:item.beforePhoto,
rectify_after_img:item.afterPhoto,
rectification_prop:item.correct_rate,
checkpoint:item.check_position,
})
} else {
//已整改数
tempb++;
listDataTempEd.push({
id:item.id,
status:item.status,
projectId:item.projectId,
checkType:item.check_type,
title:item.check_type +' '+item.inspect_time,
questions_number: item.problem_number,
rectification_number: item.correct_number,
photo:item.beforePhoto,
rectify_time:item.change_time,
inspect_time:item.inspect_time,
rectify_front_img:item.beforePhoto,
rectify_after_img:item.afterPhoto,
rectification_prop:item.correct_rate,
checkpoint:item.check_position,
})
}
})
that.setData({
//专项检查总数
listData:listDataTemp,
})
if(that.data.stateNav == 2){
that.setData({
listData:listDataTemp,
listDataed:listDataTempEd,
unRectifyNumber:tempa,
rectifyNumber:tempb
})
}
}
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})