From 8d837b97ffb27e4e26f067c1febde353bfdf91cf Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Fri, 23 Apr 2021 09:16:27 +0800
Subject: [PATCH] Merge branch 'master' of http://s16s652780.51mypc.cn:49896/r/jfpt-Vue
---
public/map/widgets/securityMap/SecurityMap.js | 184 ++++++++++++++++++++++++---------------------
1 files changed, 97 insertions(+), 87 deletions(-)
diff --git a/public/map/widgets/securityMap/SecurityMap.js b/public/map/widgets/securityMap/SecurityMap.js
index dd96a88..afed30a 100644
--- a/public/map/widgets/securityMap/SecurityMap.js
+++ b/public/map/widgets/securityMap/SecurityMap.js
@@ -125,18 +125,10 @@
_siteLayer: new GraphicsLayer(),
layuiLayer: null,
layuiLadate: null,
- tabIndex: 0,
// 保留添加实体图层的变量
addEntitys: null,
entitysData: [],
-
-
- // 用来存储区域名称
- globalRegionName: null,
-
- // 用来区域得最大最小经纬度
- currentDrawing: [],
// 存储新增点,线,面,数据的地方
polygonData: [],
@@ -144,8 +136,11 @@
editToolbar: null,
addPolygonEntitys: null,
- // 巡逻区域或者巡逻路线的描述
- routeOrRegionDescribe: null,
+ //是否选中电子围栏区域
+ isChecked: false,
+
+ //当前处警员是否已有电子围栏
+ isEngineer: false,
// 用来记录巡逻区域或者巡逻路线的下标的
patrolIndex: 0,
@@ -156,6 +151,10 @@
y: 0,
offset: null,
moveThis: null,
+
+ //基础路径
+ //pathUrl: "http://localhost:89",
+ pathUrl: "https://web.byisf.com/api/blade-jfpts",
// 电子围栏需要新增的Id
newElectronicFenceId: null,
@@ -170,6 +169,7 @@
this._map = options.map;
objThis = this;
+ //创建图层
this.addEntitys = new GraphicsLayer({
id: 'addEntitys'
});
@@ -193,6 +193,51 @@
startup: function() {
objThis._map.addLayer(objThis._siteLayer);
+ var that = this;
+
+ //删除电子围栏点击事件
+ $(".mapBtn .delete").click(function() {
+ //需选中电子围栏,然后进行删除
+ layer.confirm('是否确认删除', {
+ btn: ['确定', '取消'], //按钮
+ title: false
+ }, function() {
+ //删除数据库数据
+ $.ajax({
+ url: that.pathUrl + '/enclosure/enclosure/deleteByAnumber',
+ type: 'POST',
+ dataType: 'JSON',
+ data: {
+ anumber: anumber
+ },
+ success: function(result) {
+ if (result.code == 200) {
+ layui.use('layer', function() {
+ layui.layer.msg('删除电子围栏成功!')
+ })
+ }
+ }
+ })
+ that.addPolygonEntitys.clear();
+ //修改围栏状态
+ that.isEngineer = false;
+ })
+ })
+
+ //新增电子围栏
+ $('.mapBtn .insert').click(function() {
+ if (that.isEngineer) {
+ layui.use('layer', function() {
+ layui.layer.msg('已存在电子围栏');
+ })
+ } else {
+ layui.use('layer', function() {
+ layui.layer.msg('请开始划分电子围栏');
+ })
+ that.polygonFlag = true;
+ }
+ })
+
},
//根据key 取value值
@@ -211,19 +256,20 @@
//页面打开后,获取参数数据
open: function() {
var that = this;
+ //获取父页面传过来的参数
var lgtd = that.getQueryStringByKey('jd');
var lttd = that.getQueryStringByKey('wd');
- if (lgtd == null || lgtd == "") {
- return;
- }
anumber = that.getQueryStringByKey('code');
realname = that.getQueryString('name');
- //所在位置标记
- that.addPoint(that.addEntitys, lgtd, lttd, './images/security.png');
+ //如果处警员的位置信息存在
+ if (lgtd != null && lgtd != "") {
+ //所在位置标记
+ that.addPoint(that.addEntitys, lgtd, lttd, './images/security.png');
+ }
+
//获取当前处警员的电子围栏信息
$.ajax({
- url: 'https://web.byisf.com/api/blade-jfpts/enclosure/enclosure/selectEnclosureDetail',
- //url: 'http://localhost:89/enclosure/enclosure/selectEnclosureDetail',
+ url: this.pathUrl + '/enclosure/enclosure/selectEnclosureDetail',
type: 'GET',
dataType: 'JSON',
data: {
@@ -244,19 +290,14 @@
entityArr.push([Number(coordinate[i].split(' ')[0]), Number(coordinate[i].split(' ')[1])]);
}
}
+ that.isEngineer = true;
that.addPolygon(that.addPolygonEntitys, entityArr);
} else {
//如果无电子围栏信息,则提示请编辑电子围栏信息
//编辑好电子围栏信息后,将当前处警员的电子围栏信息保存到数据库
that.newElectronicFenceId = null;
-
- layui.use('layer', function() {
- layui.layer.msg('请开始划分电子围栏');
- })
- that.polygonFlag = true;
that.newElectronicFenceId = anumber;
}
-
}
}
})
@@ -298,8 +339,7 @@
//将数据存入数据库
$.ajax({
- url: 'https://web.byisf.com/api/blade-jfpts/enclosure/enclosure/insertes',
- //url: 'http://localhost:89/enclosure/enclosure/insertes',
+ url: that.pathUrl + '/enclosure/enclosure/insertes',
type: 'POST',
dataType: 'JSON',
data: {
@@ -308,24 +348,32 @@
routeInfo: dataStr
},
success: function(result) {
- if (result.code == 200) {}
+ if (result.code == 200) {
+ layui.use('layer', function() {
+ layui.layer.msg('新增电子围栏成功!')
+ })
+ }
}
})
}
+ //修改电子围栏数据状态
+ that.isEngineer = true;
+ //修改电子围栏选中状态
+ that.isChecked = false;
+ //修改电子围栏编辑状态
that.polygonFlag = false;
-
}
}
},
// 鼠标点击事件
clickHand: function() {
-
+ var that = this;
var self = this;
self._map.onClick = mapClick;
+ //点击事件
function mapClick(evt) {
- debugger;
var normalizedVal = webMercatorUtils.xyToLngLat(evt.mapPoint.x, evt.mapPoint.y);
var y = self._map.toMap({
spatialReference: '4326',
@@ -354,11 +402,14 @@
// 保存当前点击得图形
// self.currentDrawing = evt.graphic;
+ that.isChecked = true;
+
self.modifyPolygon();
self.activateToolbar(evt.graphic);
} else { // 点击不在图形上
-
+ //修改电子围栏选中状态
+ that.isChecked = false;
self.modifyPolygon()
}
}
@@ -386,30 +437,24 @@
x = ($(window).width() - 184);
}
- if (self.tabIndex == 1 || self.tabIndex == 2) {
+ if (self.polygonFlag == true) {
+ $('.securityMapTips').stop().show();
- if (self.polygonFlag == true) {
- $('.police-dispatching .tips').stop().show();
-
- if (self.polygonData.length == 0) {
- $('.police-dispatching .tips').text('单击左键开始绘制。');
- } else {
- if (e.clientY > ($(window).height() - 98)) {
- y = ($(window).height() - 88);
- }
- $('.police-dispatching .tips').text('单击左键新增加点。单击右键完成绘制。');
- }
-
- $('.police-dispatching .tips').css({
- 'top': y,
- 'left': x,
- })
+ if (self.polygonData.length == 0) {
+ $('.securityMapTips').text('单击左键开始绘制。');
} else {
- $('.police-dispatching .tips').stop().hide();
+ if (e.clientY > ($(window).height() - 98)) {
+ y = ($(window).height() - 88);
+ }
+ $('.securityMapTips').text('单击左键新增加点。单击右键完成绘制。');
}
+ $('.securityMapTips').css({
+ 'top': y,
+ 'left': x,
+ })
} else {
- $('.police-dispatching .tips').stop().hide();
+ $('.securityMapTips').stop().hide();
}
})
},
@@ -457,8 +502,7 @@
//更新电子围栏数据
$.ajax({
- url: 'https://web.byisf.com/api/blade-jfpts/enclosure/enclosure/updatee',
- //url: 'http://localhost:89/enclosure/enclosure/updatee',
+ url: this.pathUrl + '/enclosure/enclosure/updatee',
type: 'POST',
dataType: 'JSON',
data: {
@@ -507,44 +551,8 @@
close: function() {},
- // 获取当前时间,以及昨天现在的时间
- getTime: function getTime() {
- var timestamp = Date.parse(new Date());
-
- // 当前时间
- var currentTime = new Date(timestamp);
- // 年
- var currentY = currentTime.getFullYear();
- // 月
- var currentM = currentTime.getMonth() + 1 < 10 ? '0' + (currentTime.getMonth() + 1) : currentTime.getMonth() + 1;
- // 日
- var currentD = currentTime.getDate() < 10 ? '0' + currentTime.getDate() : currentTime.getDate();
- // 时
- var currentH = currentTime.getHours() < 10 ? '0' + currentTime.getHours() : currentTime.getHours();
- // 分
- var currentDd = currentTime.getMinutes() < 10 ? '0' + currentTime.getMinutes() : currentTime.getMinutes();
- // 明天
- var tomorrowTime = new Date(timestamp - 60 * 60 * 24 * 1000);
- // 年
- var tomorrowY = tomorrowTime.getFullYear();
- // 月
- var tomorrowM = tomorrowTime.getMonth() + 1 < 10 ? '0' + (tomorrowTime.getMonth() + 1) : tomorrowTime.getMonth() + 1;
- // 日
- var tomorrowD = tomorrowTime.getDate() < 10 ? '0' + tomorrowTime.getDate() : tomorrowTime.getDate();
- // 时
- var tomorrowH = tomorrowTime.getHours() < 10 ? '0' + tomorrowTime.getHours() : tomorrowTime.getHours();
- // 分
- var tomorrowDd = tomorrowTime.getMinutes() < 10 ? '0' + tomorrowTime.getMinutes() : tomorrowTime.getMinutes();
- return {
- current: currentY + '-' + currentM + '-' + currentD + ' ' + currentH + ':' + currentDd,
- tomorrow: tomorrowY + '-' + tomorrowM + '-' + tomorrowD + ' ' + tomorrowH + ':' + tomorrowDd,
- month: currentM + currentD
- };
- },
-
// 创建实体图层
createEntitys: function(entitys, entityContent, name, item, lgtd, lttd, outlineColors) {
-
var symbol = new esri.symbol.PictureMarkerSymbol(outlineColors, 33, 48);
symbol.name = name;
var pt = new Point(lgtd, lttd, new esri.SpatialReference({
@@ -581,5 +589,7 @@
}
});
+
+
return Widget;
});
\ No newline at end of file
--
Gitblit v1.9.3