Browse Source

点位删除修改

master
wenlele 2 years ago
parent
commit
d4a6df4b0d
  1. 36
      api/app/lib/controllers/projectRegime/projectSituation.js
  2. 5
      web/client/index.ejs
  3. 3
      web/client/index.html

36
api/app/lib/controllers/projectRegime/projectSituation.js

@ -246,37 +246,53 @@ async function delPosition (ctx, next) {
if (pointOne) { if (pointOne) {
const patrolPlanLIst = await models.PatrolPlan.findAll({ const patrolPlanLIst = await models.PatrolPlan.findAll({
where: { where: {
structureId: pointOne.id, structureId: pointOne.projectId,
}, },
attributes: ['id', 'structureId', 'points'],
}) })
patrolPlanLIst.map(async v => {
for (var u of patrolPlanLIst) {
const points = [] const points = []
v.points.map(r => { u.points.map(r => {
if (r.id !== id) { if (r.id == id) {
} else {
points.push(r) points.push(r)
} }
}) })
v.points = points u.points = points
await models.PatrolRecord.destroy({ await models.PatrolRecord.destroy({
where: { where: {
pointId: id, pointId: id,
patrolPlanId: v.id patrolPlanId: u.id
} }
}) })
if (points.length > 0) { 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 { } else {
await models.PatrolPlan.destroy({ await models.PatrolPlan.destroy({
where: { where: {
id: v.id id: u.id
} }
}) })
} }
}
})
} }
await models.Point.destroy({ await models.Point.destroy({

5
web/client/index.ejs

@ -5,8 +5,9 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<link rel="shortcut icon" href="/assets/images/logo.png"> <link rel="shortcut icon" href="/assets/images/logo.png">
<link rel="stylesheet" type="text/css" href="/assets/font_sc/iconfont.css"> <link rel="stylesheet" type="text/css" href="/assets/font_sc/iconfont.css">
<script <script
src="https://webapi.amap.com/maps?v=2.0&key=862a5f37e751bdaeb31130b49bc82e62&plugin=AMap.Adaptor,AMap.Scale,AMap.ToolBar,AMap.DistrictSearch,AMap.Geocoder,AMap.CustomLayer"></script> src="https://webapi.amap.com/maps?v=2.0&key=00f9a29dedcdbd8befec3dfe0cef5003&plugin=AMap.Adaptor,AMap.Scale,AMap.ToolBar,AMap.DistrictSearch,AMap.Geocoder,AMap.CustomLayer,Map3D,ElasticMarker"></script>
<script src="https://webapi.amap.com/loca?v=2.0.0&key=00f9a29dedcdbd8befec3dfe0cef5003"></script>
</head> </head>
<body style="background: transparent"> <body style="background: transparent">

3
web/client/index.html

@ -6,6 +6,9 @@
<title></title> <title></title>
<link rel="shortcut icon" href="/assets/images/logo.png"> <link rel="shortcut icon" href="/assets/images/logo.png">
<link rel="stylesheet" type="text/css" href="/assets/font_sc/iconfont.css"> <link rel="stylesheet" type="text/css" href="/assets/font_sc/iconfont.css">
<script
src="https://webapi.amap.com/maps?v=2.0&key=00f9a29dedcdbd8befec3dfe0cef5003&plugin=AMap.Adaptor,AMap.Scale,AMap.ToolBar,AMap.DistrictSearch,AMap.Geocoder,AMap.CustomLayer,Map3D,ElasticMarker"></script>
<script src="https://webapi.amap.com/loca?v=2.0.0&key=00f9a29dedcdbd8befec3dfe0cef5003"></script>
</head> </head>
<body> <body>

Loading…
Cancel
Save