Browse Source

小程序统计web预警数据

master
liujiangyong 2 years ago
parent
commit
251e8f5e11
  1. 2
      api/app/lib/controllers/organization/user.js
  2. 63
      weapp/package/troubleshooting/shootingForm/index.js

2
api/app/lib/controllers/organization/user.js

@ -172,7 +172,7 @@ async function getUser (ctx, next) {
const models = ctx.fs.dc.models;
const { depId } = ctx.params;
let userRes = null;
if (depId !== 'undefined') {
if (depId !== 'undefined' && depId !== 'null') {
userRes = await models.User.findAll({
where: {
departmentId: parseInt(depId),

63
weapp/package/troubleshooting/shootingForm/index.js

@ -1,5 +1,5 @@
// package/troubleshooting/shootingForm/index.js
import { getPatrolRecordIssueHandleById, getStructuresUsers, editPatrolRecordIssueHandle } from "../../../utils/getApiUrl";
import { getPatrolRecordIssueHandleById, getStructuresUsers, editPatrolRecordIssueHandle, getPatrolRecord } from "../../../utils/getApiUrl";
import { Request } from "../../../common";
const moment = require("../../../utils/moment");
@ -324,7 +324,7 @@ Page({
});
},
confirm (e) {
async confirm (e) {
const { approve } = e.target.dataset
const { state } = this.data.data
const {
@ -379,16 +379,73 @@ Page({
nextState = 5
successMsg = '上报成功'
} else if (state == 5) {
if (approve == 'agree') {
// 统计web预计管理要用的数据
const { PatrolRecord } = this.data.data;
let yanshoushijian = moment().format('YYYY-MM-DD HH:mm:ss');
let yanshoucishu = undefined;
let yujingafchishu = undefined;
let yujingshijian = undefined;
let isgaojing = undefined;
await Request.get(getPatrolRecord('all', moment().subtract(50, 'years').format('YYYY-MM-DD HH:mm:ss'), moment().format('YYYY-MM-DD HH:mm:ss'), true, null)).then(res => {
const formatData = res.filter(r => (
r.pointId === PatrolRecord.pointId
&& r.points.projectId === PatrolRecord.points.projectId
&& r.patrolRecordIssueHandles
&& r.patrolRecordIssueHandles.length
&& r.patrolRecordIssueHandles[0].yanshoushijian
)).sort((a, b) => moment(b.patrolRecordIssueHandles[0].yanshoushijian).valueOf() - moment(a.patrolRecordIssueHandles[0].yanshoushijian).valueOf())
if (formatData.length) {
if (!formatData[0].patrolRecordIssueHandles[0].isgaojing) {
// 未告警
if (formatData[0].patrolRecordIssueHandles[0].yanshoucishu === 2) {
// 验收次数等于2
yujingshijian = moment().format('YYYY-MM-DD HH:mm:ss');
yanshoucishu = formatData[0].patrolRecordIssueHandles[0].yanshoucishu + 1;
} else if (formatData[0].patrolRecordIssueHandles[0].yanshoucishu >= 3) {
yujingshijian = formatData[0].patrolRecordIssueHandles[0].yujingshijian;
yanshoucishu = formatData[0].patrolRecordIssueHandles[0].yanshoucishu + 1;
} else {
// 验收不等于2
yanshoucishu = formatData[0].patrolRecordIssueHandles[0].yanshoucishu + 1;
}
} else {
// 告警
if (formatData[0].patrolRecordIssueHandles[0].yujingafchishu === 2) {
isgaojing = false;
yanshoucishu = 3;
yujingshijian = moment().format('YYYY-MM-DD HH:mm:ss');
} else {
isgaojing = true;
yujingafchishu = formatData[0].patrolRecordIssueHandles[0].yujingafchishu + 1;
}
}
} else {
// 没验收过
yanshoucishu = 1;
}
confirmData = {
...confirmData,
checkOpinion: checkDesc,
cost,
checkImage: checkImgs,
yanshoushijian,
yanshoucishu,
yujingafchishu,
yujingshijian,
isgaojing,
// checkPerson: { id: userInfo.id, name: userInfo.name }
}
if (approve == 'agree') {
})
nextState = 6
} else {
confirmData = {
...confirmData,
checkOpinion: checkDesc,
cost,
checkImage: checkImgs,
// checkPerson: { id: userInfo.id, name: userInfo.name }
}
nextState = 7
}
successMsg = '验收完成'

Loading…
Cancel
Save