Browse Source

获取待维修信息

master
巴林闲侠 2 years ago
parent
commit
f3b0ac1a95
  1. 60
      api/app/lib/controllers/patrolManage/patrolRecord.js
  2. 3
      weapp/package/troubleshooting/index.json
  3. 3
      weapp/package/troubleshooting/shootingForm/index.json

60
api/app/lib/controllers/patrolManage/patrolRecord.js

@ -1,6 +1,6 @@
'use strict'; 'use strict';
async function findPatrolRecord(ctx, next) { async function findPatrolRecord (ctx, next) {
let rslt = []; let rslt = [];
let error = { name: 'FindError', message: '获取巡检记录失败' }; let error = { name: 'FindError', message: '获取巡检记录失败' };
try { 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: '新增巡检记录失败' }; let error = { name: 'addError', message: '新增巡检记录失败' };
const transaction = await ctx.fs.dc.orm.transaction(); const transaction = await ctx.fs.dc.orm.transaction();
try { try {
@ -151,8 +151,14 @@ async function addPatrolRecord(ctx, next) {
const lastInspectionTime = pointRecord.length ? pointRecord[0].dataValues.inspectionTime : null; const lastInspectionTime = pointRecord.length ? pointRecord[0].dataValues.inspectionTime : null;
let record = { patrolPlanId, lastInspectionTime, inspectionTime, points, alarm, pointId } 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({ const curPlanRecord = await models.PatrolRecord.findAndCountAll({
where: { patrolPlanId } 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) { return async function (ctx, next) {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
@ -197,7 +246,7 @@ function addPatrolRecordIssueHandle(opts) {
// 修改维修处理计划 // 修改维修处理计划
function editPatrolRecordIssueHandle(opts) { function editPatrolRecordIssueHandle (opts) {
return async function (ctx, next) { return async function (ctx, next) {
try { try {
@ -222,6 +271,7 @@ function editPatrolRecordIssueHandle(opts) {
module.exports = { module.exports = {
findPatrolRecord, findPatrolRecord,
addPatrolRecord, addPatrolRecord,
getPatrolRecordIssueHandle,
addPatrolRecordIssueHandle, addPatrolRecordIssueHandle,
editPatrolRecordIssueHandle editPatrolRecordIssueHandle

3
weapp/package/troubleshooting/index.json

@ -1,4 +1,7 @@
{ {
"navigationBarBackgroundColor": "#1979ff",
"navigationBarTextStyle": "white",
"navigationBarTitleText": "问题处理",
"usingComponents": { "usingComponents": {
"van-button": "@vant/weapp/button/index", "van-button": "@vant/weapp/button/index",
"van-field": "@vant/weapp/field/index", "van-field": "@vant/weapp/field/index",

3
weapp/package/troubleshooting/shootingForm/index.json

@ -1,4 +1,7 @@
{ {
"navigationBarBackgroundColor": "#1979ff",
"navigationBarTextStyle": "white",
"navigationBarTitleText": "问题处理",
"usingComponents": { "usingComponents": {
"van-button": "@vant/weapp/button/index", "van-button": "@vant/weapp/button/index",
"van-field": "@vant/weapp/field/index", "van-field": "@vant/weapp/field/index",

Loading…
Cancel
Save