jhwxapp/miniprogram/pages/safety_manage/index.js

565 lines
14 KiB
JavaScript
Raw Normal View History

2023-09-02 23:45:35 +08:00
// pages/newAddPage/safetyManagement/index.js
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
2024-03-19 23:25:38 +08:00
active: 1,
loginName: "",
deptId: "",
2023-09-02 23:45:35 +08:00
projectName: '',
projectId: '',
//教育培训
2024-03-19 23:25:38 +08:00
videoSurvey: [{
name: '应急演练',
value: 0,
prop: 0
},
{
name: '专项培训',
value: 0,
prop: 0
}
2023-09-02 23:45:35 +08:00
],
2024-03-19 23:25:38 +08:00
trainList: [],
trainTotal: 0,
emergencyDrillList: [],
emergencyDrillTotal: 0,
2023-09-02 23:45:35 +08:00
//特种作业人员
2024-03-19 23:25:38 +08:00
specialStatistics: [{
name: '其它',
value: 0,
prop: 0
}],
insuranceStatistics: [{
name: '安责险',
value: 0,
prop: 0
}, {
name: '一切险',
value: 0,
prop: 0
}],
deptWorksStatistics: [{
name: '劳务人员',
value: 0,
prop: 0
}, {
name: '监理人员',
value: 0,
prop: 0
}, {
name: '总包人员',
value: 0,
prop: 0
}],
2023-09-02 23:45:35 +08:00
securityCheck: {
routineRectificationRate: 0, //常规整改率
2024-03-19 23:25:38 +08:00
routineProblemTotal: 0, //常规问题总数
routineCheckNumber: 0, //常规检查次数
2023-09-02 23:45:35 +08:00
specialRectificationRate: 0, //专项整改率
2024-03-19 23:25:38 +08:00
specialProblemTotal: 0, //专项问题总数
specialCheckNumber: 0, //专项检查次数
2023-09-02 23:45:35 +08:00
},
2024-03-19 23:25:38 +08:00
menuList: [],
request: app.globalData.reqUrl,
todoDb: 0,
approveDb: 0,
aq: 0,
2023-09-02 23:45:35 +08:00
},
//项目切换 返回值
onProjectSelect(e) {
this.onClickShow();
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()
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
var that = this
wx.getStorage({
key: 'userinfo',
success: function (res) {
console.log(res.data);
that.setData({
loginName: res.data.loginName,
deptId: res.data.deptId,
projectName: app.globalData.projectName,
projectId: app.globalData.projectId,
2024-03-19 23:25:38 +08:00
initData: {
text: app.globalData.projectName,
id: app.globalData.projectId
}
2023-09-02 23:45:35 +08:00
})
that.selectMenuList(res.data.loginName);
that.initPage(app.globalData.projectId);
2024-03-19 23:25:38 +08:00
that.awaitTask(res.data.minRoleId, res.data.deptId, res.data.loginName, res.data.userId);
2023-09-02 23:45:35 +08:00
}
})
},
/**
* 初始化项目安全管理
*/
initPage(projectId) {
2024-03-19 23:25:38 +08:00
this.getTrainList(projectId, 0);
2023-09-02 23:45:35 +08:00
this.getSecurityCheck(projectId);
this.getSpecial(projectId);
this.getDeptWorks(projectId);
this.getPojectInsurance(projectId);
//this.getTraining(projectId);
2024-03-19 23:25:38 +08:00
this.getTrainList(projectId, 1);
2023-09-02 23:45:35 +08:00
},
2024-03-19 23:25:38 +08:00
selectMenuList: function (loginName) {
2023-09-02 23:45:35 +08:00
var that = this;
wx.request({
2024-03-19 23:25:38 +08:00
url: app.globalData.reqUrl + '/wechat/selectRoleMenuList',
data: {
username: loginName,
type: "aq"
2023-09-02 23:45:35 +08:00
},
2024-03-19 23:25:38 +08:00
method: "get",
success: function (res) {
res = res.data;
if (res.code == '200') {
that.setData({
menuList: res.data
})
2023-09-02 23:45:35 +08:00
}
}
})
},
/**
* 教育培训
*/
getTraining(projectId) {
wx.request({
url: app.globalData.reqUrl + '/wechat/projectTrain/selectGroupCountByProjectId',
2024-03-19 23:25:38 +08:00
data: {
projectId: projectId
},
method: "get",
2023-09-02 23:45:35 +08:00
success: res => {
res = res.data;
2024-03-19 23:25:38 +08:00
if (res.code == 200) {
let sum = 0;
res.data.forEach((it, idx) => {
sum += it.total;
2023-09-02 23:45:35 +08:00
});
2024-03-19 23:25:38 +08:00
let videoSurvey = [];
res.data.forEach((it, idx) => {
videoSurvey.push({
name: it.typeName,
value: it.total,
prop: (it.total / sum * 100).toFixed(2)
});
2023-09-02 23:45:35 +08:00
});
//数据绑定
this.setData({
videoSurvey
})
}
}
})
},
/**
* 特种人员
*/
getSpecial(projectId) {
wx.request({
url: app.globalData.reqUrl + '/wechat/projectSpecial/selectGroupCountByProjectId',
2024-03-19 23:25:38 +08:00
data: {
projectId: projectId
},
method: "get",
2023-09-02 23:45:35 +08:00
success: res => {
res = res.data;
2024-03-19 23:25:38 +08:00
if (res.code == 200 && res.data) {
let sum = 0;
let otherSum = 0;
let flag = true;
res.data.forEach((it, idx) => {
sum += it.total;
if (idx > 4 && res.data.length > 6) {
otherSum += it.total;
2023-09-11 09:45:21 +08:00
}
2023-09-02 23:45:35 +08:00
});
2024-03-19 23:25:38 +08:00
let specialStatistics = [];
res.data.forEach((it, idx) => {
if (flag) {
specialStatistics.push({
name: it.typeName,
value: it.total,
prop: (it.total / sum * 100).toFixed(2)
});
if (idx > 3 && res.data.length > 6) {
specialStatistics.push({
name: "其它工种",
value: otherSum,
prop: (otherSum / sum * 100).toFixed(2)
});
flag = false;
2023-09-11 09:45:21 +08:00
}
}
2023-09-02 23:45:35 +08:00
});
//数据绑定
this.setData({
specialStatistics
})
}
}
})
},
/**
* 专项培训&&应急演练
*/
2024-03-19 23:25:38 +08:00
getTrainList(projectId, type) {
2023-09-02 23:45:35 +08:00
let that = this;
wx.request({
url: app.globalData.reqUrl + '/wechat/projectTrain/list',
2024-03-19 23:25:38 +08:00
data: {
projectId: projectId,
trainType: type,
deptId: 0
},
method: "get",
2023-09-02 23:45:35 +08:00
success: res => {
res = res.data;
2024-03-19 23:25:38 +08:00
if (res.code == 200) {
if (type == "1") {
//数据绑定
this.setData({
emergencyDrillList: res.data,
emergencyDrillTotal: res.data.length
})
} else {
//数据绑定
this.setData({
trainList: res.data,
trainTotal: res.data.length
})
2023-09-02 23:45:35 +08:00
}
}
}
})
},
/**
* 项目人员
*/
getDeptWorks(projectId) {
wx.request({
url: app.globalData.reqUrl + '/wechat/projectDeptWroks/findSumByProjectId',
2024-03-19 23:25:38 +08:00
data: {
projectId: projectId
},
method: "get",
2023-09-02 23:45:35 +08:00
success: res => {
res = res.data;
2024-03-19 23:25:38 +08:00
if (res.code == 200) {
if (res.data) {
let sum = 0;
let deptWorksStatistics = [];
if (res.data.contractorPersonnel) {
sum += res.data.contractorPersonnel;
2023-09-02 23:45:35 +08:00
}
2024-03-19 23:25:38 +08:00
if (res.data.servicePersonnel) {
sum += res.data.servicePersonnel;
2023-09-02 23:45:35 +08:00
}
2024-03-19 23:25:38 +08:00
if (res.data.supervisorPersonnel) {
sum += res.data.supervisorPersonnel;
2023-09-02 23:45:35 +08:00
}
2024-03-19 23:25:38 +08:00
if (res.data.servicePersonnel) {
deptWorksStatistics.push({
name: "劳务人员",
value: res.data.servicePersonnel,
prop: (res.data.servicePersonnel / sum * 100).toFixed(2)
});
} else {
deptWorksStatistics.push({
name: "劳务人员",
value: 0,
prop: (0 / sum * 100).toFixed(2)
});
2023-09-02 23:45:35 +08:00
}
2024-03-19 23:25:38 +08:00
if (res.data.supervisorPersonnel) {
deptWorksStatistics.push({
name: "监理人员",
value: res.data.supervisorPersonnel,
prop: (res.data.supervisorPersonnel / sum * 100).toFixed(2)
});
} else {
deptWorksStatistics.push({
name: "监理人员",
value: 0,
prop: (0 / sum * 100).toFixed(2)
});
2023-09-02 23:45:35 +08:00
}
2024-03-19 23:25:38 +08:00
if (res.data.contractorPersonnel) {
deptWorksStatistics.push({
name: "总包人员",
value: res.data.contractorPersonnel,
prop: (res.data.contractorPersonnel / sum * 100).toFixed(2)
});
} else {
deptWorksStatistics.push({
name: "总包人员",
value: 0,
prop: (0 / sum * 100).toFixed(2)
});
2023-09-02 23:45:35 +08:00
}
//数据绑定
2024-03-19 23:25:38 +08:00
this.setData({
deptWorksStatistics
})
2023-09-02 23:45:35 +08:00
}
}
}
})
},
/**
* 获取项目保险数据
*/
2024-03-19 23:25:38 +08:00
getPojectInsurance(projectId) {
2023-09-02 23:45:35 +08:00
wx.request({
url: app.globalData.reqUrl + '/wechat/projectInsurance/selectGroupCountByProjectId',
2024-03-19 23:25:38 +08:00
data: {
projectId: projectId
},
method: "get",
2023-09-02 23:45:35 +08:00
success: res => {
res = res.data;
2024-03-19 23:25:38 +08:00
if (res.code == 200 && res.data) {
let sum = 0;
res.data.forEach((it, idx) => {
sum += it.total;
2023-09-02 23:45:35 +08:00
});
2024-03-19 23:25:38 +08:00
let insuranceStatistics = [];
if (res.data.length == 2) {
res.data.forEach((it, idx) => {
insuranceStatistics.push({
name: it.insuranceTypeName,
value: it.total,
prop: (it.total / sum * 100).toFixed(2)
});
2023-09-02 23:45:35 +08:00
});
2024-03-19 23:25:38 +08:00
} else {
res.data.forEach((it, idx) => {
if (it.insuranceType == "1") {
insuranceStatistics.push({
name: it.insuranceTypeName,
value: it.total,
prop: (it.total / sum * 100).toFixed(2)
});
insuranceStatistics.push({
name: "安责险",
value: 0,
prop: 0
});
} else {
insuranceStatistics.push({
name: it.insuranceTypeName,
value: it.total,
prop: (it.total / sum * 100).toFixed(2)
});
insuranceStatistics.push({
name: "一切险",
value: 0,
prop: 0
});
2023-09-02 23:45:35 +08:00
}
});
}
//数据绑定
this.setData({
insuranceStatistics
})
}
}
})
},
/**
* 获取安全检查数据
*/
getSecurityCheck(projectId) {
wx.request({
url: app.globalData.reqUrl + '/wechat/projectProblemmodify/selectGroupCountByProjectId',
2024-03-19 23:25:38 +08:00
data: {
projectId: projectId,
infoType: "0"
},
method: "get",
2023-09-02 23:45:35 +08:00
success: res => {
res = res.data;
2024-03-19 23:25:38 +08:00
if (res.code == 200) {
2023-09-02 23:45:35 +08:00
//数据绑定
2024-03-19 23:25:38 +08:00
res.data.forEach((it, idx) => {
if (it.problemType == "1") {
2023-09-02 23:45:35 +08:00
this.setData({
"securityCheck.routineRectificationRate": (it.comTotal / it.total * 100).toFixed(2),
2023-09-03 00:47:14 +08:00
"securityCheck.routineProblemTotal": it.comTotal,
2023-09-02 23:45:35 +08:00
"securityCheck.routineCheckNumber": it.total
})
2024-03-19 23:25:38 +08:00
} else {
2023-09-02 23:45:35 +08:00
this.setData({
"securityCheck.specialRectificationRate": (it.comTotal / it.total * 100).toFixed(2),
2023-09-03 00:47:14 +08:00
"securityCheck.specialProblemTotal": it.comTotal,
2023-09-02 23:45:35 +08:00
"securityCheck.specialCheckNumber": it.total,
})
}
});
}
}
})
},
2023-09-03 00:47:14 +08:00
goZXPX() {
wx.setStorageSync('nav-menu', "aq");
2023-09-02 23:45:35 +08:00
wx.navigateTo({
2023-09-03 00:47:14 +08:00
url: '../../pageage/project_train/list/index?trainType=0',
2023-09-02 23:45:35 +08:00
})
},
/**
2023-09-03 00:47:14 +08:00
* 安全隐患页面
2023-09-02 23:45:35 +08:00
*/
2023-09-03 00:47:14 +08:00
goAQYH() {
wx.setStorageSync('nav-menu', "aq");
wx.redirectTo({
url: '../../pageage/project_problemmodify/security/list/index',
})
},
goTZRY() {
wx.setStorageSync('nav-menu', "aq");
wx.redirectTo({
url: '../../pageage/project_special/list/index',
})
},
goXMBX() {
wx.setStorageSync('nav-menu', "aq");
wx.redirectTo({
url: '../../pageage/project_insurance/list/index',
})
},
goZGRY() {
wx.setStorageSync('nav-menu', "aq");
wx.redirectTo({
url: '../../pageage/project_deptWorks/list/index',
})
},
goYJYL() {
wx.setStorageSync('nav-menu', "aq");
2023-09-02 23:45:35 +08:00
wx.navigateTo({
2023-09-03 00:47:14 +08:00
url: '../../pageage/project_train/list/index?trainType=1',
2023-09-02 23:45:35 +08:00
})
},
/****************************底部导航********************************/
2024-03-19 23:25:38 +08:00
2023-09-03 14:08:39 +08:00
onClickShow() {
2024-03-19 23:25:38 +08:00
this.setData({
loadShow: true
});
2023-09-03 14:08:39 +08:00
},
onClickHide() {
2024-03-19 23:25:38 +08:00
this.setData({
loadShow: false
});
},
2023-09-03 14:08:39 +08:00
// 底部导航
2024-03-19 23:25:38 +08:00
onChange(event) {
2023-09-03 14:08:39 +08:00
// event.detail 的值为当前选中项的索引
2024-03-19 23:25:38 +08:00
this.setData({
active: event.detail
});
},
2023-09-03 14:08:39 +08:00
2024-03-19 23:25:38 +08:00
goMenu: function (event) {
2023-09-02 23:45:35 +08:00
wx.setStorageSync('nav-menu', "aq");
2023-09-24 23:17:05 +08:00
wx.redirectTo({
2023-09-02 23:45:35 +08:00
url: event.currentTarget.dataset.url
})
},
/**
* 项目概况页面
*/
XMGK: function () {
wx.redirectTo({
2024-03-19 23:25:38 +08:00
url: '../xiangmugaikuang/index'
2023-09-02 23:45:35 +08:00
})
},
//跳转到质量管理
2024-03-19 23:25:38 +08:00
ZLGL: function () {
2023-09-02 23:45:35 +08:00
wx.redirectTo({
2024-03-19 23:25:38 +08:00
url: '../quality_manage/index'
})
2023-09-02 23:45:35 +08:00
},
//跳转到进度管理
2024-03-19 23:25:38 +08:00
JDGL: function () {
2024-03-09 14:01:46 +08:00
//app.toast("敬请期待!");
wx.redirectTo({
2024-03-19 23:25:38 +08:00
url: '../../pageage/project_schedule/list/index'
})
2023-09-02 23:45:35 +08:00
},
/**
* 更多功能
*/
GDGN: function () {
wx.redirectTo({
2024-03-19 23:25:38 +08:00
url: '../gengduogongneng/index'
2023-09-02 23:45:35 +08:00
})
},
2024-03-19 23:25:38 +08:00
//查询当前登录人的代办任务
awaitTask(minRoleId, deptId, loginName, userId) {
let param = {
"businessKey": app.globalData.projectId,
"nowRole": minRoleId,
"nowDept": deptId,
"nowUserName": loginName,
"nowUser": userId,
"activeName": "await"
}
var that = this;
wx.request({
url: app.globalData.reqUrl + '/wechat/flowTask/myAwaitFlowTaskListCount',
data: param,
method: "post",
success: function (res) {
res = res.data;
if (res.code == "200") {
that.setData({
2024-04-21 13:08:16 +08:00
todoDb: res.data.todo+res.data.approveLZYJ,
2024-03-19 23:25:38 +08:00
approveDb: res.data.approve + res.data.zlCount,
aq: res.data.aqCount
})
2023-09-17 15:28:13 +08:00
}
2024-03-19 23:25:38 +08:00
}
})
},
})