From f3b0ac1a9582309820e1618a70b5aef219467628 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Wed, 1 Mar 2023 16:02:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=BE=85=E7=BB=B4=E4=BF=AE?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/patrolManage/patrolRecord.js | 60 +++++++++++++++++-- weapp/package/troubleshooting/index.json | 3 + .../troubleshooting/shootingForm/index.json | 3 + 3 files changed, 61 insertions(+), 5 deletions(-) diff --git a/api/app/lib/controllers/patrolManage/patrolRecord.js b/api/app/lib/controllers/patrolManage/patrolRecord.js index 4974c5c..d6a18cf 100644 --- a/api/app/lib/controllers/patrolManage/patrolRecord.js +++ b/api/app/lib/controllers/patrolManage/patrolRecord.js @@ -1,6 +1,6 @@ 'use strict'; -async function findPatrolRecord(ctx, next) { +async function findPatrolRecord (ctx, next) { let rslt = []; let error = { name: 'FindError', message: '获取巡检记录失败' }; try { @@ -136,7 +136,7 @@ async function findPatrolRecord(ctx, next) { } } -async function addPatrolRecord(ctx, next) { +async function addPatrolRecord (ctx, next) { let error = { name: 'addError', message: '新增巡检记录失败' }; const transaction = await ctx.fs.dc.orm.transaction(); try { @@ -151,8 +151,14 @@ async function addPatrolRecord(ctx, next) { const lastInspectionTime = pointRecord.length ? pointRecord[0].dataValues.inspectionTime : null; let record = { patrolPlanId, lastInspectionTime, inspectionTime, points, alarm, pointId } - await models.PatrolRecord.create(record, transaction); + const recordRes = await models.PatrolRecord.create(record, transaction); + if (alarm) { + await models.PatrolRecord.create({ + patrolRecordId: recordRes.id, + state: 1, + }, transaction); + } // 更新巡检次数统计 const curPlanRecord = await models.PatrolRecord.findAndCountAll({ where: { patrolPlanId } @@ -177,8 +183,51 @@ async function addPatrolRecord(ctx, next) { } } +async function getPatrolRecordIssueHandle (ctx) { + try { + const { models } = ctx.fs.dc; + const { userId, userInfo } = ctx.fs.api + + const { type, } = ctx.query + + let findOption = { + where: { + + }, + include: [{ + model: models.PatrolRecord + }] + } + + if (type == 'backlog') { + // 待办 + let stateArr = [] + if (userInfo) { + + } + findOption.where = { + ...findOption.where, + + } + } else if (type == 'haveDone') { + // 已办 + } + + const res = await models.findAll(findOption) + + ctx.status = 200; + ctx.body = {} + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } +} + // 新建维修处理计划成功 -function addPatrolRecordIssueHandle(opts) { +function addPatrolRecordIssueHandle (opts) { return async function (ctx, next) { const models = ctx.fs.dc.models; @@ -197,7 +246,7 @@ function addPatrolRecordIssueHandle(opts) { // 修改维修处理计划 -function editPatrolRecordIssueHandle(opts) { +function editPatrolRecordIssueHandle (opts) { return async function (ctx, next) { try { @@ -222,6 +271,7 @@ function editPatrolRecordIssueHandle(opts) { module.exports = { findPatrolRecord, addPatrolRecord, + getPatrolRecordIssueHandle, addPatrolRecordIssueHandle, editPatrolRecordIssueHandle diff --git a/weapp/package/troubleshooting/index.json b/weapp/package/troubleshooting/index.json index b5d5be3..d8f06e3 100644 --- a/weapp/package/troubleshooting/index.json +++ b/weapp/package/troubleshooting/index.json @@ -1,4 +1,7 @@ { + "navigationBarBackgroundColor": "#1979ff", + "navigationBarTextStyle": "white", + "navigationBarTitleText": "问题处理", "usingComponents": { "van-button": "@vant/weapp/button/index", "van-field": "@vant/weapp/field/index", diff --git a/weapp/package/troubleshooting/shootingForm/index.json b/weapp/package/troubleshooting/shootingForm/index.json index 31ef396..7cc8b02 100644 --- a/weapp/package/troubleshooting/shootingForm/index.json +++ b/weapp/package/troubleshooting/shootingForm/index.json @@ -1,4 +1,7 @@ { + "navigationBarBackgroundColor": "#1979ff", + "navigationBarTextStyle": "white", + "navigationBarTitleText": "问题处理", "usingComponents": { "van-button": "@vant/weapp/button/index", "van-field": "@vant/weapp/field/index",