1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8"/>
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
- <title>可视化编辑</title>
- <link rel="stylesheet" href="../../../../assets/libs/layui/css/layui.css"/>
- <link rel="stylesheet" href="../../../../assets/module/admin.css?v=312"/>
- <link rel="stylesheet" href="../../../../assets/css/editormap.css?v=312"/>
- <link rel="stylesheet" type="text/css" href="../../../../assets/libs/leaflet/leaflet-draw/leaflet.draw-src.css">
- <link rel="stylesheet" type="text/css" href="../../../../assets/libs/leaflet/leaflet.css">
- <link rel="stylesheet" href="../../../../assets/module/formSelects/formSelects-v4.css"/>
- <style>
- .risk_point_dot {
- width: 30px;
- height: 30px;
- border-radius: 15px !important;
- text-align: center;
- color: #fff;
- vertical-align: middle;
- display: table-cell;
- }
- .level_ {
- background-color: #0b0b0b;
- }
- .level1_ {
- background-color: red;
- }
- .level2_ {
- background-color: #FB7437;
- }
- .level3_ {
- background-color: #FFDC44;
- }
- .level4_ {
- background-color: #14C2FB;
- }
- .risk_point_text {
- display: table-cell;
- vertical-align: middle;
- height: 30px;
- padding-left: 10px;
- }
- .info li {
- font-size: 15px;
- color: #222;
- line-height: 29px;
- margin-top: 10px;
- }
- .layui-layer-content {
- overflow: auto !important;
- }
- </style>
- </head>
- <body>
- <!-- 页面加载loading -->
- <div class="page-loading">
- <div class="ball-loader">
- <span></span><span></span><span></span><span></span>
- </div>
- </div>
- <!-- 正文开始 -->
- <div class="layui-fluid">
- <div class="layui-card">
- <div class="layui-card-header">
- 可视化编辑
- </div>
- <div class="layui-card-body">
- <div class="layui-form toolbar" lay-filter="formFilter">
- <div class="layui-row">
- <div class="layui-col-md5">
- <div class="layui-form-item">
- <div class="layui-inline">
- <label class="layui-form-label w-auto w-padding">选择背景图:</label>
- <div class="layui-input-inline mr0">
- <select id="entMapList" name="entMapList" lay-filter="entMapList" lay-verType="tips"
- class="layui-input-block">
- <option value="">选择背景图</option>
- </select>
- </div>
- </div>
- </div>
- </div>
- <div class="col-md-2 pull-right">
- <a id="showUploadDlg1" class="layui-link" href="javascript:;">➕更换地图背景</a>
- </div>
- </div>
- </div>
- <div class="layui-row">
- <div class="layui-col-xs6 layui-col-sm6 layui-col-md2">
- <div class="layui-tab layui-tab-card" lay-filter="dangerSource" style="height: 715px;overflow:auto">
- <!-- <ul class="layui-tab-title">-->
- <!-- <li class="layui-this" lay-id="1">设备设施</li>-->
- <!-- <li lay-id="2">作业活动</li>-->
- <!-- </ul>-->
- <div class="layui-tab-content" style="height: 655px;">
- <div class="layui-tab-item layui-show">
- <ul id="facilityIconList" class="icon-box-ul">
- </ul>
- </div>
- <div class="layui-tab-item">
- <ul id="jobIconList" class="icon-box-ul">
- </ul>
- </div>
- </div>
- </div>
- </div>
- <div class="layui-col-xs6 layui-col-sm6 layui-col-md8">
- <div class="right-map" style="height: 715px">
- <div class="map-container" id="map"></div>
- </div>
- </div>
- <div class="layui-col-xs4 layui-col-sm12 layui-col-md2">
- <div class="icon-form-box" style="display: none">
- <form class="layui-form">
- <input type="hidden" name="entMapId" id="entMapId">
- <div class="my-form-group">
- <h3 class="riskp-detail">风险点基本信息:</h3>
- <div class="my-form-item">
- <label>站点信息:</label>
- <div id="my-marker">
- </div>
- <div id="my-marker-title">
- </div>
- </div>
- <div class="my-form-item">
- <label for="riskPointName" class="marker-name">名称:</label>
- <input type="text" id="riskPointName" name="riskPointName" placeholder="请输入风险点名称">
- </div>
- </div>
- <div class="layui-btn-group my-btn-group">
- <a href="javascript:;" class="layui-btn " id="saveMarker" lay-filter="saveMarker"
- lay-submit>保存</a>
- <a href="javascript:;" class="layui-btn layui-btn-primary " id="deleteMarker">撤销</a>
- <a href="javascript:;" class="layui-btn layui-btn-danger " id="deleteMarker_"
- style="display: none">删除</a>
- </div>
- </form>
- </div>
- <div id="info" class="info">
- <fieldset class="layui-elem-field">
- <legend>使用说明</legend>
- <div class="layui-field-box">
- <ul>
- <li>1.点击选中设备设施或者作业活动分组下面的图标</li>
- <li>2.点击地图绘制点</li>
- <li>3.编辑信息保存风险点</li>
- </ul>
- </div>
- </fieldset>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- js部分 -->
- <script type="text/javascript" src="../../../../assets/libs/layui/layui.js"></script>
- <script type="text/javascript" src="../../../../assets/js/common.js?v=312"></script>
- <script type="text/javascript" src="../../../../assets/libs/jquery/jquery-3.2.1.min.js"></script>
- <script src="../../../../assets/libs/leaflet/leaflet.js"></script>
- <script src="../../../../assets/libs/leaflet/leaflet-draw/leaflet.draw-src.js"></script>
- <script src="../../../../assets/libs/leaflet/leaflet-draw/local.js"></script>
- <script src="../../../../assets/libs/leaflet/proj4-compressed.js"></script>
- <script src="../../../../assets/libs/leaflet/proj4leaflet.js"></script>
- <script type="text/html" id="upTpl">
- <form id="modelUserForm" lay-filter="modelUserForm" class="layui-form model-form">
- <div class="layui-form-item">
- <label class="layui-form-label w-padding">名称:</label>
- <div class="layui-input-block">
- <input name="entMapName" id="entMapName" placeholder="请输入名称" type="text" class="layui-input"/>
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label w-padding">背景图:</label>
- <div class="layui-input-block" id="uploadImg">
- <div class="layui-upload-drag">
- <i class="layui-icon"></i>
- <p>点击上传,或将文件拖拽到此处</p>
- </div>
- <img src="" id="vMapImg" width="100px">
- </div>
- <input name="mapImg" id="mapImg" type="hidden" class="layui-input">
- </div>
- <div class="layui-form-item text-right">
- <button class="layui-btn" lay-filter="modelSubmit" lay-submit>保存</button>
- <button class="layui-btn layui-btn-primary" type="button" ew-event="closePageDialog">取消</button>
- </div>
- </form>
- </script>
- <script>
- var resultData;
- var imgPath, viewImgPath, map;
- var entMapList;
- var loadFlag = true;
- layui.use(['index', 'layer', 'form', 'table', 'util', 'admin', 'zTree', 'uParas', '_groupTree', 'element', 'laydate', 'notice', '_zTree', 'upload'], function () {
- var $ = layui.jquery;
- var layer = layui.layer;
- var element = layui.element;
- var form = layui.form;
- var index = layui.index;
- var table = layui.table;
- var util = layui.util;
- var admin = layui.admin;
- var uParas = layui.uParas;
- var _groupTree = layui._groupTree;
- var laydate = layui.laydate;
- var notice = layui.notice;
- var _zTree = layui._zTree;
- var upload = layui.upload;
- date = new Date();
- // _groupTree.init(insTb);
- // insTb.reload();
- var entMapId = uParas.getUrlParam("entMapId");
- if (entMapId != null && entMapId != undefined) {
- $("#entMapId").val(entMapId);
- }
- $.getJSON(uParas.baseUrl + "/ent/map/getList", {mapType: 2}, function (result) {
- var entMap;
- if (result.data != null) {
- entMapList = result.data;
- if (entMapId != null && entMapId != undefined) {
- $.each(result.data, function (i, field) {
- if (field.mapId.toString() === entMapId) {
- imgPath = field.mapRasterLayer;
- uParas.initSimpleSelectX("entMapList", "formFilter", result, "mapName", "mapId", entMapId);
- return;
- }
- });
- } else {
- entMap = result.data[0];
- imgPath = entMap.mapRasterLayer;
- uParas.initSimpleSelectX("entMapList", "formFilter", result, "mapName", "mapId", entMap.mapId);
- $("#entMapId").val(entMap.mapId);
- }
- }
- });
- // var url = uParas.baseUrl + "/ent/dangerSource/query?limit=1000";
- var url = uParas.baseUrl + "/ent/parkConf/query?limit=1000";
- /*初始化危险源数据*/
- $.getJSON(url, function (result) {
- resultData = result;
- loadDangerSource(result, 1);
- uParas.cache("dangerSourceList", result.data);
- });
- //监听下拉选择
- form.on('select(entMapList)', function (data) {
- if (data.value != "") {
- $.each(entMapList, function (i, field) {
- if (field.mapId.toString() === data.value) {
- imgPath = field.mapRasterLayer;
- return;
- }
- });
- $("#entMapId").val(data.value);
- myBmap.clearMapController();
- myBmap.init(form, uParas, riskPointLevelFunc, _zTree);
- loadMapData.init(_riskPointType, uParas, riskPointLevelFunc, _zTree);
- }
- });
- // 渲染laydate
- var myDate = new Date();
- laydate.render({
- elem: '#activeStartTime',
- format: 'yyyy-MM-dd HH:mm:ss',
- type: 'datetime',
- min: myDate.toLocaleString()
- });
- laydate.render({
- elem: '#activeEndTime',
- format: 'yyyy-MM-dd HH:mm:ss',
- type: 'datetime',
- min: myDate.toLocaleString()
- });
- //监听Tab切换,以改变地址hash值
- var _riskPointType;
- element.on('tab(dangerSource)', function () {
- var riskPointType = this.getAttribute('lay-id');
- loadDangerSource(resultData, riskPointType);
- });
- //监听是否激活
- form.on('radio(isActive)', function (data) {
- if (data.value == 0) {
- $("#activeTime").hide();
- } else {
- $("#activeTime").show();
- }
- });
- function loadDangerSource(result, riskPointType) {
- var out = {};
- var array = new Array();
- $.each(result.data, function (i, field) {
- // if (field.riskPointType == riskPointType) {
- array.push(field);
- // }
- });
- out.data = array;
- loadIcon(out, riskPointType);
- loadMapData.init(riskPointType, uParas, riskPointLevelFunc, _zTree);
- _riskPointType = riskPointType;
- }
- $('#showUploadDlg1').on('click', function () {
- saveMap(2);
- });
- $('#showUploadDlg2').on('click', function () {
- saveMap(3);
- });
- function saveMap(type) {
- admin.open({
- type: 1,
- title: '上传图片',
- content: $('#upTpl').html(),
- success: function (layero, index) {
- upload.render({
- elem: '#uploadImg'
- , url: uParas.baseUrl + '/admin/uploadImages'
- , done: function (res) {
- $("#mapImg").val(res.data[0]);
- $("#vMapImg").attr("src", uParas.baseUrl + res.data[0]);
- }
- });
- var url = uParas.baseUrl + '/ent/map/save';
- form.on('submit(modelSubmit)', function (data) {
- layer.load();
- var obj = data.field;
- obj.mapRasterLayer = $("#mapImg").val();
- obj.mapType = type;
- obj.mapName = $("#entMapName").val();
- admin.req(url, obj, function (resp) {
- layer.closeAll('loading');
- if (resp.code == 1) {
- layer.close(index);
- layer.msg(resp.msg);
- } else {
- layer.msg(resp.msg);
- }
- }, 'POST');
- return false;
- });
- }
- });
- }
- /**
- * 1f 2J
- * @param resp
- * @param type
- * @param ulDivName
- */
- function loadIcon(resp, type) {
- var defImgPath = '../../../../assets/images/icon/facility.png';
- var li = "";
- $.each(resp.data, function (i, field) {
- var riskPointLevel = riskPointLevelFunc(field.dangerSourceLevel);
- var imgPath = field.dangerImg;
- if (imgPath == null || imgPath == "") {
- imgPath = defImgPath;
- } else {
- imgPath = imgPath;
- }
- if (field.parkParentId == 0) {
- li += '<li class="iconCategory">' + field.parkName + '</li>';
- $.each(resp.data, function (i, _field) {
- if (field.parkId == _field.parkParentId) {
- riskPointLevel = riskPointLevelFunc(_field.dangerSourceLevel);
- li += `<li><a href="javascript:;" id="${_field.parkId}" class="marker-icon">
- <img src="${imgPath}" id="${_field.parkId}" type="${type}" lv="${_field.dangerSourceLevel}" name="${_field.parkName}"></a>
- <span>${_field.parkName}</span></li>`;
- }
- });
- }
- });
- $("#facilityIconList").html('');
- $("#facilityIconList").append(li);
- }
- function riskPointLevelFunc(value) {
- var opts = '<div class="riskPointLevel">';
- if (value == 1) {
- opts += "<div class='notify'><span class='heartbit'></span><span><img src='../../../../assets/images/lv/red.png' style='width: 28px;height: 28px;'/></span></div>";
- } else if (value == 2) {
- opts += "<img src='../../../../assets/images/lv/orange.png' style='width: 28px;height: 28px;'/>";
- } else if (value == 3) {
- opts += "<img src='../../../../assets/images/lv/yellow.png' style='width: 28px;height: 28px;'/>";
- } else if (value == 4) {
- opts += "<img src='../../../../assets/images/lv/blue.png' style='width: 28px;height: 28px;'/>";
- } else {
- opts += "无";
- }
- opts += "</div>"
- return opts;
- }
- $("#deleteMarker_").click(function () {
- layer.confirm('确定要删除么?', {
- skin: 'layui-layer-admin',
- shade: .1
- }, function (i) {
- $.getJSON(uParas.baseUrl + "/ent/riskPoint/delete/" + $("#riskPointId").val(), {}, function (result) {
- layer.closeAll();
- if (result.code == 1) {
- notice.msg(result.msg, {icon: 1});
- $(".icon-form-box").hide();
- $("#info").show();
- setTimeout(function () {
- loadMapData.init(_riskPointType, uParas, riskPointLevelFunc, _zTree);
- }, 1000)
- }
- });
- });
- })
- setTimeout(function () {
- myBmap.init(form, uParas, riskPointLevelFunc, _zTree);
- }, 1000);
- });
- var myBmap = {
- mapContainer: "map", //地图容器
- mapTile: "http://online{s}.map.bdimg.com/tile/?qt=vtile&x={x}&y={y}&z={z}&styles=pl&scaler=2&udt=20181205", //切片图层
- myIcon: null, //保存创建的icon
- myMarker: null, //保存自己创建marker
- myMarkerType: 0, //marker类型
- myMarkerId: null, //markerId
- isSave: true, //是否保存标记
- checkedIcon: null, //保存选中的icon
- title: null,
- deleteMarkerId: null, //保存删除得markerId
- myMarkerGroup: L.layerGroup(),
- myMarkerGroupInit: L.layerGroup(),
- mapControl: null, // 地图控制器,用来清除叠加控制
- data: {},
- plotLayer: null,
- init: function (form, uParas, riskPointLevelFunc, _zTree) {
- _form = form;
- var _this = this;
- // 初始化默认操作
- this.clearPlotLayer() // 默认清空绘制点位
- this.myMarkerGroup.clearLayers(); // 图层
- this.isSave = true
- clearForm()
- //初始化地图
- var map_type = 2;
- if (map_type == 4) {
- baidu_map();
- } else {
- image_map();
- }
- // 增加区域绘制工具栏
- this.plotLayer = plotLayer = this.plotLayer != null ? this.plotLayer : L.featureGroup(), map.addLayer(plotLayer);
- var e = {
- position: "topright",
- draw: {
- polyline: {shapeOptions: {color: "#0000ff", weight: 3}},
- polygon: {allowIntersection: !0, showArea: !0, shapeOptions: {color: "#0000ff", weight: 2}},
- rectangle: {shapeOptions: {color: "#0000ff", weight: 2}},
- circle: false,
- circlemarker: false,
- marker: false
- },
- edit: {
- featureGroup: plotLayer,
- remove: !0,
- edit: false
- }
- }, n = mapControl = new L.Control.Draw(e);
- map.addControl(n)
- function draw_createdHandler(t) {
- t.layerType;
- var o = t.layer;
- plotLayer.addLayer(o)
- var all = o.toGeoJSON();
- var drawIds = $("#drawIds").val();
- $("#drawIds").remove();
- if (drawIds != undefined) {
- drawIds = drawIds + "#" + JSON.stringify(all.geometry.coordinates) + ";" + all.geometry.type;
- } else {
- drawIds = JSON.stringify(all.geometry.coordinates) + ";" + all.geometry.type
- }
- $(".my-marker-type").append('<input type="hidden" id="drawIds" name="drawIds" value="' + drawIds + '">');
- }
- function draw_deletedHandler(t) {
- $("#drawIds").remove();
- }
- // baidu_map()
- //地图鼠标事件
- map.off('click').on('click', function (e) {
- var point = [];
- if (_this.myIcon != null) {
- var myIcon1 = L.icon({
- iconUrl: _this.myIcon,
- iconSize: [40, 40],
- // iconAnchor: [0, 0]
- })
- // console.log(myIcon1);
- _this.myIcon = null; //将myIcon 置为null 防止鼠标在地图上移动或者点击再次做绘制
- point.push(e.latlng.lat, e.latlng.lng);
- _this.myMarker = L.marker([e.latlng.lat, e.latlng.lng], {icon: myIcon1});
- _this.myMarker.on('click', markerClick); //标记点击事件
- //_this.myMarker.addTo(map); //添加marker到地图上
- _this.myMarkerGroup.addLayer(_this.myMarker);
- _this.myMarkerGroup.addTo(map);
- _this.deleteMarkerId = _this.myMarker._leaflet_id; //保存当前markerId
- clearForm(); //清空函数
- $("#my-marker").append(_this.checkedIcon); //在表单中进行回显
- $("#my-marker-title").append(_this.title); //在表单中进行回显
- var latlngArray = "[" + e.latlng.lat + "," + e.latlng.lng + "]";
- $("#my-marker-title").append('<input type="hidden" id="latlng" name="latlng" value="' + latlngArray + '">');
- $("#my-marker-title").append('<input type="hidden" id="dangerSourceId" name="dangerSourceId" value="' + _this.myMarkerId + '">');
- map.on(L.Draw.Event.CREATED, draw_createdHandler), map.on(L.Draw.Event.DELETED, draw_deletedHandler)
- $(".icon-form-box").show();
- $("#info").hide();
- $("#deleteMarker_").hide();
- $("#deleteMarker").show();
- var inGroupNumber = {
- reload: function (obj) {
- uParas.initFormSelects("liablePerson", uParas.baseUrl + '/admin/common/getUsersByGroupId?gId=' + obj.where.groupId, "accountRealName", "aId");
- }
- }
- _zTree._init('/admin/common/getGroupLists', 'gId', 'groupParent', 'groupName', 'gId', 0, 'groupTree_', inGroupNumber, 'menuContent_', 'liableGroupIdName', 'liableGroupId');
- }
- })
- //左侧icon得点击事件
- $(".icon-box-ul").off('click').on('click', 'a', function (event) {
- if (_this.isSave) {
- _this.isSave = false;
- var curParent = $(event.currentTarget).parent();
- var tarSrc = $(event.target).attr('src');
- var title = $(event.target).attr('name');
- var id = $(event.target).attr('id');
- var type = $(event.target).attr('type');
- var riskPointMinLevel = $(event.target).attr('lv');
- _this.data.riskPointMinLevel = riskPointMinLevel;
- _this.data.type = type;
- $('.icon-active').removeClass('icon-active');
- $(event.currentTarget).addClass('icon-active');
- _this.myIcon = tarSrc;
- //复制icon进行拖动
- _this.myMarkerId = id;
- // _this.myMarkerType = type;
- _this.checkedIcon = '<img src="' + tarSrc + '" width="40px" height="40px"/>';
- // //console.log(_this.checkedIcon)
- _this.title = title;
- } else {
- layer.msg('请先保存标记!');
- }
- })
- _form.on('submit(saveMarker)', function (data) {
- var sendData = data.field;
- if (sendData.riskPointName == "") {
- layer.msg("请输入名称!");
- return;
- }
- sendData.riskPointType = sendData.type;
- $.ajax({
- type: "post",
- url: uParas.baseUrl + "/ent/riskPointMap/saveDangerSourceMap",
- data: sendData,
- dataType: "json",
- success: function (result) {
- if (result.code === 1) {
- layer.msg("保存成功");
- _this.isSave = true;
- $(".my-marker-box>ul>li:not(:last-child)").remove();
- if (map._layers[_this.deleteMarkerId] != null) {
- map.removeLayer(map._layers[_this.deleteMarkerId]);
- }
- clearForm(); //清空函数
- setTimeout(function () {
- loadMapData.init(sendData.type, uParas, riskPointLevelFunc, _zTree);
- }, 1000)
- $(".icon-form-box").hide();
- $("#info").show();
- } else {
- layer.msg(result.msg);
- }
- }
- });
- });
- // 标记click事件
- function markerClick(e) {
- _this.deleteMarkerId = e.target._leaflet_id;
- }
- //删除marker事件
- $("#deleteMarker").click(function () {
- _this.isSave = true;
- $(".my-marker-box>ul>li:not(:last-child)").remove();
- if (map._layers[_this.deleteMarkerId] != null) {
- map.removeLayer(map._layers[_this.deleteMarkerId]);
- }
- plotLayer.clearLayers();
- clearForm(); //清空函数
- });
- // 添加标注
- $("#addMarker").click(function () {
- layerOpen();
- })
- // 删除单个标记
- $(".my-marker-box>ul").on('click', 'span', function (e) {
- $(e.target).parent().remove();
- var eles = $(".my-marker-box>ul>li");
- var ids = '';
- var lv = 4;
- $.each(eles, function (index, item) {
- var id = $(item).find('img').attr('id');
- var lvSon = $(item).find('img').attr('lv');
- if (id != undefined) {
- ids += id + ",";
- if (Number(lvSon) < Number(lv)) {
- lv = lvSon;
- }
- }
- });
- $("#dangerSourceIds").remove();
- $("#riskPointMinLevelSon").remove();
- $(".my-marker-type").append('<input type="hidden" id="riskPointMinLevelSon" name="riskPointMinLevelSon" value="' + lv + '">');
- $(".my-marker-type").append('<input type="hidden" id="dangerSourceIds" name="dangerSourceIds" value="' + ids + '">');
- })
- //底图为图片
- function image_map() {
- if (map == undefined || map._loaded == undefined) {
- map = L.map(_this.mapContainer, {
- crs: L.CRS.Simple,
- center: L.latLng(50.5, 30.5),
- minZoom: 0,
- zoom: 0,
- attributionControl: false
- });
- } else {
- loadFlag = false;
- }
- var yx = L.latLng;
- var xy = function xy(x, y) {
- if (L.Util.isArray(x)) {
- return yx(x[1], x[0]);
- }
- return yx(y, x);
- };
- // map.eachLayer(function (layer) {
- // map.removeLayer(layer);
- // });
- map.addLayer(_this.myMarkerGroupInit);
- map.addLayer(_this.myMarkerGroup);
- var bounds = [xy(-600, -600), xy(300, 300)];
- L.imageOverlay(imgPath, bounds).addTo(map);
- map.fitBounds(bounds);
- }
- //底图为百度地图
- function baidu_map() {
- var maxZoom = 26;
- var crs = new L.Proj.CRS('EPSG:3395',
- '+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs', {
- resolutions: function () {
- level = 19;
- var res = [];
- res[0] = Math.pow(2, 18);
- for (var i = 1; i < level; i++) {
- res[i] = Math.pow(2, (18 - i))
- }
- return res;
- }(),
- origin: [0, 0],
- bounds: L.bounds([20037508.342789244, 0], [0, 20037508.342789244])
- });
- var image = new L.TileLayer(_this.mapTile, {
- maxZoom: maxZoom,
- minZoom: 10,
- subdomains: [0, 1, 2],
- tms: true
- });
- map = L.map(_this.mapContainer, {
- crs: crs,
- layers: [image]
- });
- map.setView([34.474387, 109.490437], 14);
- }
- function clearForm() {
- $("#my-marker").html(""); //清除icon;
- $('.icon-active').removeClass('icon-active'); //移除已选class
- $(".my-marker-type>input").remove(); //移除标记类型中得input
- $("#markerType").html(""); //清空标记类型
- $("#riskPointName").val(""); //清空标记类型
- $(".my-marker-box>ul>li:not(:last-child)").remove();
- $("#drawIds").remove();
- $("#drawType").remove();
- $("#my-marker-title").html("");
- $("#riskPointDesc").val('');
- $("#activeStartTime").val('');
- $("#activeEndTime").val('');
- $("#riskPointPlaces").val('');
- $('#liableGroupIdName').val('');
- $('#liablePerson').html('');
- }
- function layerOpen() {
- var outIds = $("#dangerSourceId").val();
- if ($("#dangerSourceIds").val() != undefined) {
- outIds += "," + $("#dangerSourceIds").val();
- }
- if (outIds == undefined) {
- outIds = new Array();
- }
- var defImgPath = "";
- var jobPng = "../../../../assets/images/icon/job.png";
- var facilityPng = "../../../../assets/images/icon/facility.png";
- //var dangerSourceList = layui.data(uParas.tableName).dangerSourceList;
- var html = '<div class="">';
- html += '<div class="danger-src-date popup-icon-box" style="width: 550px;float: left;margin-left: 20px;"><ul>';
- $.each(resultData.data, function (i, field) {
- var type = field.riskPointType;
- var riskPointLevel = riskPointLevelFunc(field.dangerSourceLevel);
- var imgPath = field.dangerImg;
- if (type == 1) {
- defImgPath = facilityPng;
- } else {
- defImgPath = jobPng;
- }
- if (imgPath == null || imgPath == "") {
- imgPath = defImgPath;
- } else {
- imgPath = uParas.baseUrl + imgPath;
- }
- var id = field.dangerSrcId;
- if (field.riskPointType == 1) {
- // if (outIds.indexOf(id) == -1) {
- if (field.parentDangerSrcId == -1) {
- // if (field.riskCount == field.riskCountParent) {
- if (field.riskCountParent == 0) {
- html += '<li class="iconCategory_">' + field.dangerSrcName + '</li>';
- html += `<li onclick="iconClick(this)"><a href="javascript:;" id="${field.dangerSrcId}" class="marker-icon"><span style='font-size: 18px;margin-top: 10px;'>✦ </span>
- <img src="${imgPath}" id="${field.dangerSrcId}" type="${type}" lv="${field.dangerSourceLevel}" name="${field.dangerSrcName}" style='width: 25px;height: 25px;'></a>
- <span style="margin-left: 10px;color: #0c5df1;">${field.dangerSrcName}</span>${riskPointLevel}</li>`;
- } else {
- html += '<li class="iconCategory_">' + field.dangerSrcName + '</li>';
- $.each(resultData.data, function (i, _field) {
- var _id = _field.dangerSrcId;
- if (outIds.indexOf(_id) == -1) {
- if (field.dangerSrcId == _field.parentDangerSrcId) {
- var _type = _field.riskPointType;
- var _riskPointLevel = riskPointLevelFunc(_field.dangerSourceLevel);
- var _imgPath = _field.dangerImg;
- if (_type == 1) {
- defImgPath = facilityPng;
- } else {
- defImgPath = jobPng;
- }
- if (_imgPath == null || _imgPath == "") {
- _imgPath = defImgPath;
- } else {
- _imgPath = uParas.baseUrl + _imgPath
- }
- // li += `<li><a href="javascript:;" id="${_field.dangerSrcId}" class="marker-icon">
- // <img src="${imgPath}" id="${_field.dangerSrcId}" type="${type}" lv="${_field.dangerSourceLevel}" name="${_field.dangerSrcName}"></a>
- // <span>${_field.dangerSrcName}</span>${riskPointLevel}</li>`;
- html += `<li onclick="iconClick(this)"><a href="javascript:;" id="${_field.dangerSrcId}" class="marker-icon"><span style='font-size: 18px;margin-top: 10px;'>✦ </span>
- <img src="${_imgPath}" id="${_field.dangerSrcId}" type="${_type}" lv="${_field.dangerSourceLevel}" name="${_field.dangerSrcName}" style='width: 25px;height: 25px;'></a>
- <span style="margin-left: 10px;color: #0c5df1;">${_field.dangerSrcName}</span>${_riskPointLevel}</li>`;
- }
- }
- });
- }
- // }
- }
- // else {
- // html += `<li onclick="iconClick(this)"><a href="javascript:;" id="${field.dangerSrcId}" class="marker-icon"><span style='font-size: 18px;margin-top: 10px;'>✦ </span>
- // <img src="${imgPath}" id="${field.dangerSrcId}" type="${type}" lv="${field.dangerSourceLevel}" name="${field.dangerSrcName}" style='width: 25px;height: 25px;'></a>
- // <span style="margin-left: 10px;color: #0c5df1;">${field.dangerSrcName}</span>${riskPointLevel}</li>`;
- // }
- // }
- }
- });
- html += '</ul></div>';
- html += '<div class="danger-src-date popup-icon-box" style="float: left;width: 550px;"><ul>';
- $.each(resultData.data, function (i, field) {
- var type = field.riskPointType;
- var riskPointLevel = riskPointLevelFunc(field.dangerSourceLevel);
- var imgPath = field.dangerImg;
- if (type == 1) {
- defImgPath = facilityPng;
- } else {
- defImgPath = jobPng;
- }
- if (imgPath == null || imgPath == "") {
- imgPath = defImgPath;
- } else {
- imgPath = uParas.baseUrl + imgPath;
- }
- var id = field.dangerSrcId;
- if (field.riskPointType == 2) {
- if (field.parentDangerSrcId == -1) {
- if (field.riskCount == field.riskCountParent) {
- html += '<li class="iconCategory_">' + field.dangerSrcName + '</li>';
- html += `<li onclick="iconClick(this)"><a href="javascript:;" id="${field.dangerSrcId}" class="marker-icon"><span style='font-size: 18px;margin-top: 10px;'>✦ </span>
- <img src="${imgPath}" id="${field.dangerSrcId}" type="${type}" lv="${field.dangerSourceLevel}" name="${field.dangerSrcName}" style='width: 25px;height: 25px;'></a>
- <span style="margin-left: 10px;color: #0c5df1;">${field.dangerSrcName}</span>${riskPointLevel}</li>`;
- } else {
- html += '<li class="iconCategory_">' + field.dangerSrcName + '</li>';
- $.each(resultData.data, function (i, _field) {
- var _id = _field.dangerSrcId;
- if (outIds.indexOf(_id) == -1) {
- if (field.dangerSrcId == _field.parentDangerSrcId) {
- var _type = _field.riskPointType;
- var _riskPointLevel = riskPointLevelFunc(_field.dangerSourceLevel);
- var _imgPath = _field.dangerImg;
- if (_type == 1) {
- defImgPath = facilityPng;
- } else {
- defImgPath = jobPng;
- }
- if (_imgPath == null || _imgPath == "") {
- _imgPath = defImgPath;
- } else {
- _imgPath = uParas.baseUrl + _imgPath
- }
- // li += `<li><a href="javascript:;" id="${_field.dangerSrcId}" class="marker-icon">
- // <img src="${imgPath}" id="${_field.dangerSrcId}" type="${type}" lv="${_field.dangerSourceLevel}" name="${_field.dangerSrcName}"></a>
- // <span>${_field.dangerSrcName}</span>${riskPointLevel}</li>`;
- html += `<li onclick="iconClick(this)"><a href="javascript:;" id="${_field.dangerSrcId}" class="marker-icon"><span style='font-size: 18px;margin-top: 10px;'>✦ </span>
- <img src="${_imgPath}" id="${_field.dangerSrcId}" type="${_type}" lv="${_field.dangerSourceLevel}" name="${_field.dangerSrcName}" style='width: 25px;height: 25px;'></a>
- <span style="margin-left: 10px;color: #0c5df1;">${_field.dangerSrcName}</span>${_riskPointLevel}</li>`;
- }
- }
- });
- }
- // }
- }
- }
- });
- html += '</ul></div></div>';
- layer.open({
- title: '【设备设施】' + '<span style="margin-left: 470px;">【作业活动】</span>',
- btn: ['确定', '取消'],
- type: 1,
- area: ['1200px', '60%'], //宽高
- content: html,
- yes: yes
- });
- }
- function yes(index) {
- var eles = $(".popup-icon-box>ul>li");
- var li = '';
- var ids = '';
- var lv = 4;
- $.each(eles, function (index, item) {
- if ($(item).hasClass('icon-active')) {
- var imgSrc = $(item).find('img').attr('src');
- var id = $(item).find('img').attr('id');
- var title = $(item).find('img').attr('name');
- var div = $(item).find('div').html();
- var lvSon = $(item).find('img').attr('lv');
- li += '<li><img src="' + imgSrc + '" id="' + id + '"lv=' + lvSon + ' ><span>x</span><p>' + title + '</p><div class="riskPointLevel">' + div + '</div></li>';
- if (id != undefined) {
- ids += id + ",";
- if (Number(lvSon) < lv) {
- lv = lvSon;
- }
- }
- }
- });
- $("#myMarkerBox>ul").prepend(li);
- if ($("#dangerSourceIds").val() != undefined) {
- ids += $("#dangerSourceIds").val();
- }
- $("#dangerSourceIds").remove();
- $("#riskPointMinLevelSon").remove();
- $(".my-marker-type").append('<input type="hidden" id="riskPointMinLevelSon" name="riskPointMinLevelSon" value="' + lv + '">');
- $(".my-marker-type").append('<input type="hidden" id="dangerSourceIds" name="dangerSourceIds" value="' + ids + '">');
- layer.close(index);
- }
- },
- clearPlotLayer: function () {
- if (this.plotLayer != null) {
- this.plotLayer.clearLayers()
- }
- },
- clearMapController() { // 清除地图控制器
- map.removeControl(mapControl)
- }
- }
- var loadMapData = {
- jobPng: "../../../../assets/images/icon/job.png",
- facilityPng: "../../../../assets/images/icon/facility.png",
- init: function (type, uParas, riskPointLevelFunc, _zTree) {
- var _uParas = uParas;
- var riskPointLevelFunc = riskPointLevelFunc;
- var _zTree = _zTree;
- var jobIcon = L.icon({
- iconUrl: loadMapData.jobPng,
- iconSize: [38, 45],
- popupAnchor: [0, -16]
- });
- var facilityIcon = L.icon({
- iconUrl: loadMapData.facilityPng,
- iconSize: [38, 45],
- popupAnchor: [0, -16]
- });
- function icon(imgUrl) {
- return L.icon({
- iconUrl: imgUrl,
- iconSize: [38, 45],
- popupAnchor: [0, -16]
- });
- }
- initMapData(type, uParas);
- function initMapData(type, uParas) {
- var groupId = $("#groupId").val();
- if (type == undefined) {
- type = 1
- } else {
- myBmap.myMarkerGroupInit.clearLayers();
- }
- myBmap.myMarkerGroupInit.clearLayers();
- var entMapId = $("#entMapId").val();
- $.getJSON(uParas.baseUrl + "/ent/parkQr/getRiskPointMap", {
- entMapId: entMapId
- }, function (result) {
- if (result.code == 1) {
- $.each(result.data, function (index, item) {
- var markerData = item.markerData;
- if (markerData != null) {
- var optionsData = {
- mapId: item.id,
- riskPointId: item.riskPointId,
- type: type,
- title: item.markerTitle
- };
- if (item.dangerImg != null && item.dangerImg != "") {
- optionsData.iconUrl = imgPathFun(item.dangerImg, type);
- } else {
- if (type === 2) {
- optionsData.iconUrl = loadMapData.jobPng;
- } else {
- optionsData.iconUrl = loadMapData.facilityPng;
- }
- }
- if (item.markerType == 3) {
- var data = new Array();
- $.each($.parseJSON(markerData), function (index, item) {
- data[index] = new Array(item[1], item[0]);
- });
- L.polygon(data, optionsData).addTo(myBmap.myMarkerGroupInit).bindPopup(item.markerTitle).on('click', onMapClick);
- } else if (item.markerType == 1) {
- if (item.dangerImg != null && item.dangerImg != "") {
- optionsData.icon = icon(uParas.baseUrl + item.dangerImg);
- } else {
- if (type == 2) {
- optionsData.icon = jobIcon;
- } else {
- optionsData.icon = facilityIcon;
- }
- }
- L.marker($.parseJSON(markerData), optionsData).addTo(myBmap.myMarkerGroupInit).bindPopup(item.markerTitle).on('click', onMapClick);
- } else if (item.markerType == 2) {
- var data = new Array();
- $.each($.parseJSON(markerData), function (index, item) {
- data[index] = new Array(item[1], item[0]);
- });
- L.polyline(data, optionsData).addTo(myBmap.myMarkerGroupInit).bindPopup(item.markerTitle).on('click', onMapClick);
- }
- }
- });
- }
- });
- }
- function imgPathFun(imgPath, type) {
- var defImgPath = "";
- var jobPng = "../../../../assets/images/icon/job.png";
- var facilityPng = "../../../../assets/images/icon/facility.png";
- if (type == "1") {
- defImgPath = facilityPng;
- } else {
- defImgPath = jobPng;
- }
- if (imgPath == null || imgPath == "") {
- return defImgPath;
- } else {
- if (imgPath.indexOf("http:") != -1) {
- defImgPath = imgPath;
- } else {
- defImgPath = uParas.baseUrl + imgPath;
- }
- }
- return defImgPath;
- }
- function onMapClick(e) {
- $(".icon-form-box").show();
- $("#info").hide();
- var options = e.target.options;
- var data = {};
- data.mapId = options.mapId;
- data.riskPointId = options.riskPointId;
- $("#deleteMarker").hide();
- $("#deleteMarker_").show();
- $("#my-marker").html('<img src="' + options.iconUrl + '"/>');
- $("#markerType").html(options.type == 2 ? '作业活动' : '设备设施');
- $("#riskPointName").val(options.title);
- $.getJSON("/ent/parkQr/findMapDataById", data, function (result) {
- if (result.code == 1) {
- var item = result.data[0];
- var index = item.dangerSourceIds;
- var arr = new Array();
- if (index != null) {
- if (index.indexOf(',') != -1) {
- arr = index.split(',');
- } else {
- arr = [index];
- }
- }
- $("#my-marker-title").html("");
- $("#my-marker-title").append(item.dangerSrcName);
- $("#type").remove();
- $("#my-marker-title").append('<input type="hidden" id="type" name="type" value="' + options.type + '">');
- $("#riskPointId").remove();
- $("#my-marker-title").append('<input type="hidden" id="riskPointId" name="riskPointId" value="' + item.riskPointId + '">');
- $("#dangerSourceId").remove();
- $("#my-marker-title").append('<input type="hidden" id="dangerSourceId" name="dangerSourceId" value="' + item.dangerSrcId + '">');
- }
- });
- }
- }
- }
- function iconClick(e) {
- $(e).toggleClass('icon-active')
- }
- </script>
- </body>
- </html>
|