From 251e8f5e11976cda22a9a55e00e1788c41e31aa2 Mon Sep 17 00:00:00 2001 From: liujiangyong Date: Fri, 10 Mar 2023 10:43:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=BB=9F=E8=AE=A1we?= =?UTF-8?q?b=E9=A2=84=E8=AD=A6=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/organization/user.js | 2 +- .../troubleshooting/shootingForm/index.js | 75 ++++++++++++++++--- 2 files changed, 67 insertions(+), 10 deletions(-) diff --git a/api/app/lib/controllers/organization/user.js b/api/app/lib/controllers/organization/user.js index 66c1c2b..1cc26ac 100644 --- a/api/app/lib/controllers/organization/user.js +++ b/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), diff --git a/weapp/package/troubleshooting/shootingForm/index.js b/weapp/package/troubleshooting/shootingForm/index.js index ee6da0a..b0a1c66 100644 --- a/weapp/package/troubleshooting/shootingForm/index.js +++ b/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) { - confirmData = { - ...confirmData, - checkOpinion: checkDesc, - cost, - checkImage: checkImgs, - // checkPerson: { id: userInfo.id, name: userInfo.name } - } 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 } + } + }) nextState = 6 } else { + confirmData = { + ...confirmData, + checkOpinion: checkDesc, + cost, + checkImage: checkImgs, + // checkPerson: { id: userInfo.id, name: userInfo.name } + } nextState = 7 } successMsg = '验收完成'