From d4a6df4b0d2ee716d9c10305c731ae5bdd08cc48 Mon Sep 17 00:00:00 2001 From: wenlele Date: Mon, 30 Jan 2023 16:50:10 +0800 Subject: [PATCH] =?UTF-8?q?=E7=82=B9=E4=BD=8D=E5=88=A0=E9=99=A4=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../projectRegime/projectSituation.js | 36 +++++++++++++------ web/client/index.ejs | 5 +-- web/client/index.html | 3 ++ 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/api/app/lib/controllers/projectRegime/projectSituation.js b/api/app/lib/controllers/projectRegime/projectSituation.js index b35c8c8..6b3fe83 100644 --- a/api/app/lib/controllers/projectRegime/projectSituation.js +++ b/api/app/lib/controllers/projectRegime/projectSituation.js @@ -246,37 +246,53 @@ async function delPosition (ctx, next) { if (pointOne) { const patrolPlanLIst = await models.PatrolPlan.findAll({ where: { - structureId: pointOne.id, + structureId: pointOne.projectId, }, - attributes: ['id', 'structureId', 'points'], }) - patrolPlanLIst.map(async v => { + + for (var u of patrolPlanLIst) { const points = [] - v.points.map(r => { - if (r.id !== id) { + u.points.map(r => { + if (r.id == id) { + } else { points.push(r) } }) - v.points = points + u.points = points await models.PatrolRecord.destroy({ where: { pointId: id, - patrolPlanId: v.id + patrolPlanId: u.id } }) if (points.length > 0) { - await models.PatrolPlan.create(v) + let data = { + name: u.dataValues.name, + way: u.dataValues.way, + structureId: u.dataValues.structureId, + startTime: u.dataValues.startTime, + endTime: u.dataValues.endTime, + frequency: u.dataValues.frequency, + points: u.dataValues.points, + userId: u.dataValues.userId, + patrolCount: u.dataValues.patrolCount + } + await models.PatrolPlan.update(data,{ + where: { + id: u.dataValues.id + } + }) } else { await models.PatrolPlan.destroy({ where: { - id: v.id + id: u.id } }) } + } - }) } await models.Point.destroy({ diff --git a/web/client/index.ejs b/web/client/index.ejs index 5ca7a53..8b1f426 100644 --- a/web/client/index.ejs +++ b/web/client/index.ejs @@ -5,8 +5,9 @@ - + + diff --git a/web/client/index.html b/web/client/index.html index ceaa2e4..ad9326e 100644 --- a/web/client/index.html +++ b/web/client/index.html @@ -6,6 +6,9 @@ + +