|
|
@ -88,9 +88,20 @@ async function updatePatrolPlan(ctx, next) { |
|
|
|
|
|
|
|
async function delPatrolPlan(ctx, next) { |
|
|
|
try { |
|
|
|
let errMsg = '删除巡检计划失败'; |
|
|
|
|
|
|
|
const models = ctx.fs.dc.models; |
|
|
|
const { id } = ctx.params; |
|
|
|
|
|
|
|
const record = await models.PatrolRecord.findOne({ |
|
|
|
where: { patrolPlanId: id } |
|
|
|
}); |
|
|
|
|
|
|
|
if (record) { |
|
|
|
errMsg = '不能删除有巡检记录的计划'; |
|
|
|
throw errMsg; |
|
|
|
} |
|
|
|
|
|
|
|
await models.PatrolPlan.destroy({ |
|
|
|
where: { id } |
|
|
|
}) |
|
|
@ -99,9 +110,7 @@ async function delPatrolPlan(ctx, next) { |
|
|
|
} catch (error) { |
|
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
|
ctx.status = 400; |
|
|
|
ctx.body = { |
|
|
|
"message": '删除巡检计划失败' |
|
|
|
} |
|
|
|
ctx.body = { message: error } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|