wenlele 2 years ago
parent
commit
aca8e13268
  1. 15
      api/app/lib/controllers/patrolPlan/patrolPlan.js
  2. 1
      web/client/src/sections/patrolManage/containers/patrolPlan.js

15
api/app/lib/controllers/patrolPlan/patrolPlan.js

@ -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 }
}
}

1
web/client/src/sections/patrolManage/containers/patrolPlan.js

@ -84,6 +84,7 @@ function PatrolPlan(props) {
dataIndex: 'action',
key: 'action',
search: false,
width: 200,
render: (_, record) => {
return <>
<Button type="link" onClick={() => {

Loading…
Cancel
Save