trafficMap.html 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  6. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  7. <title>可视化编辑</title>
  8. <link rel="stylesheet" href="../../../../assets/libs/layui/css/layui.css"/>
  9. <link rel="stylesheet" href="../../../../assets/module/admin.css?v=312"/>
  10. <link rel="stylesheet" href="../../../../assets/css/editormap.css?v=312"/>
  11. <link rel="stylesheet" type="text/css" href="../../../../assets/libs/leaflet/leaflet-draw/leaflet.draw-src.css">
  12. <link rel="stylesheet" type="text/css" href="../../../../assets/libs/leaflet/leaflet.css">
  13. <link rel="stylesheet" href="../../../../assets/module/formSelects/formSelects-v4.css"/>
  14. <style>
  15. .risk_point_dot {
  16. width: 30px;
  17. height: 30px;
  18. border-radius: 15px !important;
  19. text-align: center;
  20. color: #fff;
  21. vertical-align: middle;
  22. display: table-cell;
  23. }
  24. .level_ {
  25. background-color: #0b0b0b;
  26. }
  27. .level1_ {
  28. background-color: red;
  29. }
  30. .level2_ {
  31. background-color: #FB7437;
  32. }
  33. .level3_ {
  34. background-color: #FFDC44;
  35. }
  36. .level4_ {
  37. background-color: #14C2FB;
  38. }
  39. .risk_point_text {
  40. display: table-cell;
  41. vertical-align: middle;
  42. height: 30px;
  43. padding-left: 10px;
  44. }
  45. .info li {
  46. font-size: 15px;
  47. color: #222;
  48. line-height: 29px;
  49. margin-top: 10px;
  50. }
  51. .layui-layer-content {
  52. overflow: auto !important;
  53. }
  54. </style>
  55. </head>
  56. <body>
  57. <!-- 页面加载loading -->
  58. <div class="page-loading">
  59. <div class="ball-loader">
  60. <span></span><span></span><span></span><span></span>
  61. </div>
  62. </div>
  63. <!-- 正文开始 -->
  64. <div class="layui-fluid">
  65. <div class="layui-card">
  66. <div class="layui-card-header">
  67. 可视化编辑
  68. </div>
  69. <div class="layui-card-body">
  70. <div class="layui-form toolbar" lay-filter="formFilter">
  71. <div class="layui-row">
  72. <div class="layui-col-md5">
  73. <div class="layui-form-item">
  74. <div class="layui-inline">
  75. <label class="layui-form-label w-auto w-padding">部门:</label>
  76. <div class="layui-input-inline mr0">
  77. <input type="text" id="groupName" name="groupName" value=""
  78. placeholder="点击选择"
  79. class="layui-input" readonly>
  80. <input type="hidden" id="groupId" name="groupId">
  81. <div id="menuContent" class="menuContent">
  82. <ul id="groupTree" class="ztree" style="margin-top:0;"></ul>
  83. </div>
  84. </div>
  85. </div>
  86. <div class="layui-inline">
  87. <label class="layui-form-label w-auto w-padding">选择背景图:</label>
  88. <div class="layui-input-inline mr0">
  89. <select id="entMapList" name="entMapList" lay-filter="entMapList" lay-verType="tips"
  90. class="layui-input-block">
  91. <option value="">选择背景图</option>
  92. </select>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. <div class="col-md-2 pull-right">
  98. <a id="showUploadDlg1" class="layui-link" href="javascript:;">➕更换地图背景</a>
  99. </div>
  100. </div>
  101. </div>
  102. <div class="layui-row">
  103. <div class="layui-col-xs6 layui-col-sm6 layui-col-md2">
  104. <div class="layui-tab layui-tab-card" lay-filter="dangerSource" style="height: 715px;overflow:auto">
  105. <ul class="layui-tab-title">
  106. <li class="layui-this" lay-id="6">矿下交通库</li>
  107. </ul>
  108. <div class="layui-tab-content" style="height: 655px;">
  109. <div class="layui-tab-item layui-show">
  110. <ul id="facilityIconList" class="icon-box-ul">
  111. </ul>
  112. </div>
  113. <div class="layui-tab-item">
  114. <ul id="jobIconList" class="icon-box-ul">
  115. </ul>
  116. </div>
  117. </div>
  118. </div>
  119. </div>
  120. <div class="layui-col-xs6 layui-col-sm6 layui-col-md8">
  121. <div class="right-map" style="height: 715px">
  122. <div class="map-container" id="map"></div>
  123. </div>
  124. </div>
  125. <div class="layui-col-xs4 layui-col-sm12 layui-col-md2">
  126. <div class="icon-form-box" style="display: none">
  127. <form class="layui-form">
  128. <input type="hidden" name="entMapId" id="entMapId">
  129. <div class="my-form-group">
  130. <h3 class="riskp-detail">风险点基本信息:</h3>
  131. <div class="my-form-item">
  132. <label>主危险源:</label>
  133. <div id="my-marker">
  134. </div>
  135. <div id="my-marker-title">
  136. </div>
  137. </div>
  138. <div class="my-form-item my-marker-type">
  139. <!--<label>类型:</label>-->
  140. <!--<span id="markerType"></span>-->
  141. </div>
  142. <div class="my-form-item">
  143. <label for="riskPointName" class="marker-name">名称:</label>
  144. <input type="text" id="riskPointName" name="riskPointName" placeholder="请输入风险点名称">
  145. </div>
  146. <div class="my-form-item">
  147. <label class="control-label">责任部门:</label>
  148. <div style="position: relative;float: left;">
  149. <input type="text" id="liableGroupIdName" name="liableGroupIdName" value=""
  150. placeholder="点击选择" class="form-control" readonly>
  151. <input type="hidden" id="liableGroupId" name="liableGroupId">
  152. <div id="menuContent_" class="menuContent">
  153. <ul id="groupTree_" class="ztree" style="margin-top:0;"></ul>
  154. </div>
  155. </div>
  156. </div>
  157. <div class="my-form-item">
  158. <label for="riskPointName" class="marker-name">描述:</label>
  159. <textarea placeholder="请输入内容" name="riskPointDesc" id="riskPointDesc"
  160. class="layui-textarea"></textarea>
  161. </div>
  162. <div class="my-form-item" style="display: none;">
  163. <label for="riskPointName" class="marker-name">是否激活:</label>
  164. <input type="radio" lay-filter="isActive" name="isActive" value="1" title="激活"
  165. checked>
  166. <input type="radio" lay-filter="isActive" name="isActive" value="0" title="未激活">  
  167. </div>
  168. </div>
  169. <!-- <div class="btn-group my-btn-group">-->
  170. <div class="layui-btn-group my-btn-group">
  171. <a href="javascript:;" class="layui-btn " id="saveMarker" lay-filter="saveMarker"
  172. lay-submit>保存</a>
  173. <a href="javascript:;" class="layui-btn layui-btn-primary " id="deleteMarker">撤销</a>
  174. <a href="javascript:;" class="layui-btn layui-btn-danger " id="deleteMarker_"
  175. style="display: none">删除</a>
  176. </div>
  177. </form>
  178. </div>
  179. <div id="info" class="info">
  180. <fieldset class="layui-elem-field">
  181. <legend>使用说明</legend>
  182. <div class="layui-field-box">
  183. <ul>
  184. <li>1.点击选中设备设施或者作业活动分组下面的图标</li>
  185. <li>2.点击地图绘制点</li>
  186. <li>3.编辑信息保存风险点</li>
  187. </ul>
  188. </div>
  189. </fieldset>
  190. </div>
  191. </div>
  192. </div>
  193. </div>
  194. </div>
  195. </div>
  196. <!-- js部分 -->
  197. <script type="text/javascript" src="../../../../assets/libs/layui/layui.js"></script>
  198. <script type="text/javascript" src="../../../../assets/js/common.js?v=312"></script>
  199. <script type="text/javascript" src="../../../../assets/libs/jquery/jquery-3.2.1.min.js"></script>
  200. <script src="../../../../assets/libs/leaflet/leaflet.js"></script>
  201. <script src="../../../../assets/libs/leaflet/leaflet-draw/leaflet.draw-src.js"></script>
  202. <script src="../../../../assets/libs/leaflet/leaflet-draw/local.js"></script>
  203. <script src="../../../../assets/libs/leaflet/proj4-compressed.js"></script>
  204. <script src="../../../../assets/libs/leaflet/proj4leaflet.js"></script>
  205. <script type="text/html" id="upTpl">
  206. <form id="modelUserForm" lay-filter="modelUserForm" class="layui-form model-form">
  207. <div class="layui-form-item">
  208. <label class="layui-form-label w-padding">名称:</label>
  209. <div class="layui-input-block">
  210. <input name="entMapName" id="entMapName" placeholder="请输入名称" type="text" class="layui-input"/>
  211. </div>
  212. </div>
  213. <div class="layui-form-item">
  214. <label class="layui-form-label w-padding">地图类型:</label>
  215. <div class="layui-input-block">
  216. <select id="useType" name="useType">
  217. <option value="">请选择</option>
  218. <option value="1">四色风险地图</option>
  219. <option value="2">示意图</option>
  220. <option value="3">点位图</option>
  221. </select>
  222. </div>
  223. </div>
  224. <div class="layui-form-item">
  225. <label class="layui-form-label w-padding">背景图:</label>
  226. <div class="layui-input-block" id="uploadImg">
  227. <div class="layui-upload-drag">
  228. <i class="layui-icon"></i>
  229. <p>点击上传,或将文件拖拽到此处</p>
  230. </div>
  231. <img src="" id="vMapImg" width="100px">
  232. </div>
  233. <input name="mapImg" id="mapImg" type="hidden" class="layui-input">
  234. </div>
  235. <div class="layui-form-item">
  236. <label class="layui-form-label w-padding">序号:</label>
  237. <div class="layui-input-block">
  238. <input name="sortNo" id="sortNo" placeholder="请输入序号" type="number" min="1" class="layui-input"/>
  239. </div>
  240. </div>
  241. <div class="layui-form-item text-right">
  242. <button class="layui-btn" lay-filter="modelSubmit" lay-submit>保存</button>
  243. <button class="layui-btn layui-btn-primary" type="button" ew-event="closePageDialog">取消</button>
  244. </div>
  245. </form>
  246. </script>
  247. <script>
  248. var resultData;
  249. var imgPath, viewImgPath, map;
  250. var entMapList;
  251. var loadFlag = true;
  252. layui.use(['index', 'layer', 'form', 'table', 'util', 'admin', 'zTree', 'uParas', '_groupTree', 'element', 'laydate', 'notice', '_zTree', 'upload'], function () {
  253. var $ = layui.jquery;
  254. var layer = layui.layer;
  255. var element = layui.element;
  256. var form = layui.form;
  257. var index = layui.index;
  258. var table = layui.table;
  259. var util = layui.util;
  260. var admin = layui.admin;
  261. var uParas = layui.uParas;
  262. var _groupTree = layui._groupTree;
  263. var laydate = layui.laydate;
  264. var notice = layui.notice;
  265. var _zTree = layui._zTree;
  266. var upload = layui.upload;
  267. date = new Date();
  268. var insTb = {
  269. reload: function (obj, p) {
  270. $.getJSON(uParas.baseUrl + "/ent/riskPoint/riskPointLvCount", {gId: $("#groupId").val()}, function (result) {
  271. if (result.code == 1) {
  272. var allCount = 0, lv1Count = 0, lv2Count = 0, lv3Count = 0, lv4Count = 0;
  273. $.each(result.data, function (i, field) {
  274. if (field.riskPointLevel == 1) {
  275. lv1Count = field.lvCount;
  276. }
  277. if (field.riskPointLevel == 2) {
  278. lv2Count = field.lvCount;
  279. }
  280. if (field.riskPointLevel == 3) {
  281. lv3Count = field.lvCount;
  282. }
  283. if (field.riskPointLevel == 4) {
  284. lv4Count = field.lvCount;
  285. }
  286. if (field.riskPointLevel != null) {
  287. allCount += field.lvCount;
  288. }
  289. });
  290. $(".risk_point_dot.level1_").html(lv1Count);
  291. $(".risk_point_dot.level2_").html(lv2Count);
  292. $(".risk_point_dot.level3_").html(lv3Count);
  293. $(".risk_point_dot.level4_").html(lv4Count);
  294. $(".risk_point_dot.level_").html(allCount);
  295. setTimeout(function () {
  296. loadMapData.init(_riskPointType, uParas, riskPointLevelFunc, _zTree);
  297. }, 1000)
  298. }
  299. });
  300. }
  301. }
  302. _groupTree.init(insTb);
  303. var entMapId = uParas.getUrlParam("entMapId");
  304. if (entMapId != null && entMapId != undefined) {
  305. $("#entMapId").val(entMapId);
  306. }
  307. // 加载地图数据
  308. function requestMapData() {
  309. $.getJSON(uParas.baseUrl + "/ent/map/getList", {mapType: 2, useType: 3}, function (result) {
  310. var entMap;
  311. if (result.data != null) {
  312. entMapList = result.data;
  313. if (entMapId != null && entMapId != undefined) {
  314. $.each(result.data, function (i, field) {
  315. if (field.mapId.toString() === entMapId) {
  316. imgPath = field.mapRasterLayer;
  317. uParas.initSimpleSelectX("entMapList", "formFilter", result, "mapName", "mapId", entMapId);
  318. return;
  319. }
  320. });
  321. } else {
  322. entMap = result.data[0];
  323. imgPath = entMap.mapRasterLayer;
  324. uParas.initSimpleSelectX("entMapList", "formFilter", result, "mapName", "mapId", entMap.mapId);
  325. $("#entMapId").val(entMap.mapId);
  326. }
  327. }
  328. });
  329. }
  330. requestMapData();
  331. var url = uParas.baseUrl + "/ent/dangerSource/query?limit=1000";
  332. /*初始化危险源数据*/
  333. $.getJSON(url, function (result) {
  334. resultData = result;
  335. loadDangerSource(result, 6);
  336. uParas.cache("dangerSourceList", result.data);
  337. });
  338. //监听下拉选择
  339. form.on('select(entMapList)', function (data) {
  340. if (data.value != "") {
  341. $.each(entMapList, function (i, field) {
  342. if (field.mapId.toString() === data.value) {
  343. imgPath = field.mapRasterLayer;
  344. return;
  345. }
  346. });
  347. $("#entMapId").val(data.value);
  348. myBmap.clearMapController();
  349. myBmap.init(form, uParas, riskPointLevelFunc, _zTree);
  350. loadMapData.init(_riskPointType, uParas, riskPointLevelFunc, _zTree);
  351. }
  352. });
  353. // 渲染laydate
  354. var myDate = new Date();
  355. laydate.render({
  356. elem: '#activeStartTime',
  357. format: 'yyyy-MM-dd HH:mm:ss',
  358. type: 'datetime',
  359. min: myDate.toLocaleString()
  360. });
  361. laydate.render({
  362. elem: '#activeEndTime',
  363. format: 'yyyy-MM-dd HH:mm:ss',
  364. type: 'datetime',
  365. min: myDate.toLocaleString()
  366. });
  367. //监听Tab切换,以改变地址hash值
  368. var _riskPointType;
  369. element.on('tab(dangerSource)', function () {
  370. var riskPointType = this.getAttribute('lay-id');
  371. loadDangerSource(resultData, riskPointType);
  372. });
  373. //监听是否激活
  374. form.on('radio(isActive)', function (data) {
  375. if (data.value == 0) {
  376. $("#activeTime").hide();
  377. } else {
  378. $("#activeTime").show();
  379. }
  380. });
  381. function loadDangerSource(result, riskPointType) {
  382. var out = {};
  383. var array = new Array();
  384. $.each(result.data, function (i, field) {
  385. if (field.riskPointType == riskPointType) {
  386. array.push(field);
  387. }
  388. });
  389. out.data = array;
  390. loadIcon(out, riskPointType);
  391. loadMapData.init(riskPointType, uParas, riskPointLevelFunc, _zTree);
  392. _riskPointType = riskPointType;
  393. }
  394. $('#showUploadDlg1').on('click', function () {
  395. saveMap(2);
  396. });
  397. $('#showUploadDlg2').on('click', function () {
  398. saveMap(3);
  399. });
  400. function saveMap(type) {
  401. admin.open({
  402. type: 1,
  403. title: '上传图片',
  404. content: $('#upTpl').html(),
  405. success: function (layero, index) {
  406. form.render();
  407. upload.render({
  408. elem: '#uploadImg'
  409. , url: uParas.baseUrl + '/admin/uploadImages'
  410. , done: function (res) {
  411. $("#mapImg").val(res.data[0]);
  412. $("#vMapImg").attr("src", uParas.baseUrl + res.data[0]);
  413. }
  414. });
  415. var url = uParas.baseUrl + '/ent/map/save';
  416. form.on('submit(modelSubmit)', function (data) {
  417. layer.load();
  418. var obj = data.field;
  419. obj.mapRasterLayer = $("#mapImg").val();
  420. obj.mapType = type;
  421. obj.mapName = $("#entMapName").val();
  422. admin.req(url, obj, function (resp) {
  423. layer.closeAll('loading');
  424. if (resp.code == 1) {
  425. layer.close(index);
  426. layer.msg(resp.msg);
  427. requestMapData();
  428. } else {
  429. layer.msg(resp.msg);
  430. }
  431. }, 'POST');
  432. return false;
  433. });
  434. }
  435. });
  436. }
  437. /**
  438. * 1f 2J
  439. * @param resp
  440. * @param type
  441. * @param ulDivName
  442. */
  443. function loadIcon(resp, type) {
  444. var defImgPath = "";
  445. var jobPng = "../../../../assets/images/icon/job.png";
  446. var facilityPng = "../../../../assets/images/icon/facility.png";
  447. // if (type == "1") {
  448. defImgPath = facilityPng;
  449. // } else {
  450. // defImgPath = jobPng;
  451. // }
  452. var li = "";
  453. $.each(resp.data, function (i, field) {
  454. var riskPointLevel = riskPointLevelFunc(field.dangerSourceLevel);
  455. var imgPath = field.dangerImg;
  456. if (imgPath == null || imgPath == "") {
  457. imgPath = defImgPath;
  458. } else {
  459. imgPath = imgPath;
  460. }
  461. if (field.parentDangerSrcId == -1) {
  462. if (field.riskCount == field.riskCountParent) {
  463. li += '<li class="iconCategory">' + field.dangerSrcName + '</li>';
  464. li += `<li><a href="javascript:;" id="${field.dangerSrcId}" class="marker-icon">
  465. <img src="${imgPath}" id="${field.dangerSrcId}" type="${type}" lv="${field.dangerSourceLevel}" name="${field.dangerSrcName}"></a>
  466. <span>${field.dangerSrcName}</span>${riskPointLevel}</li>`;
  467. } else {
  468. li += '<li class="iconCategory">' + field.dangerSrcName + '</li>';
  469. $.each(resp.data, function (i, _field) {
  470. if (field.dangerSrcId == _field.parentDangerSrcId) {
  471. riskPointLevel = riskPointLevelFunc(_field.dangerSourceLevel);
  472. li += `<li><a href="javascript:;" id="${_field.dangerSrcId}" class="marker-icon">
  473. <img src="${imgPath}" id="${_field.dangerSrcId}" type="${type}" lv="${_field.dangerSourceLevel}" name="${_field.dangerSrcName}"></a>
  474. <span>${_field.dangerSrcName}</span>${riskPointLevel}</li>`;
  475. }
  476. });
  477. }
  478. } else {
  479. li += `<li><a href="javascript:;" id="${field.dangerSrcId}" class="marker-icon">
  480. <img src="${imgPath}" id="${field.dangerSrcId}" type="${type}" lv="${field.dangerSourceLevel}" name="${field.dangerSrcName}"></a>
  481. <span>${field.dangerSrcName}</span>${riskPointLevel}</li>`;
  482. }
  483. });
  484. if (type === "2") {
  485. $("#jobIconList").html('');
  486. $("#jobIconList").append(li);
  487. } else {
  488. $("#facilityIconList").html('');
  489. $("#facilityIconList").append(li);
  490. }
  491. }
  492. function riskPointLevelFunc(value) {
  493. var opts = '<div class="riskPointLevel">';
  494. if (value == 1) {
  495. opts += "<div class='notify'><span class='heartbit'></span><span><img src='../../../../assets/images/lv/red.png' style='width: 28px;height: 28px;'/></span></div>";
  496. } else if (value == 2) {
  497. opts += "<img src='../../../../assets/images/lv/orange.png' style='width: 28px;height: 28px;'/>";
  498. } else if (value == 3) {
  499. opts += "<img src='../../../../assets/images/lv/yellow.png' style='width: 28px;height: 28px;'/>";
  500. } else if (value == 4) {
  501. opts += "<img src='../../../../assets/images/lv/blue.png' style='width: 28px;height: 28px;'/>";
  502. } else {
  503. opts += "无";
  504. }
  505. opts += "</div>"
  506. return opts;
  507. }
  508. $("#deleteMarker_").click(function () {
  509. layer.confirm('确定要删除么?', {
  510. skin: 'layui-layer-admin',
  511. shade: .1
  512. }, function (i) {
  513. $.getJSON(uParas.baseUrl + "/ent/riskPoint/delete/" + $("#riskPointId").val(), {}, function (result) {
  514. layer.closeAll();
  515. if (result.code == 1) {
  516. notice.msg(result.msg, {icon: 1});
  517. $(".icon-form-box").hide();
  518. $("#info").show();
  519. setTimeout(function () {
  520. loadMapData.init(_riskPointType, uParas, riskPointLevelFunc, _zTree);
  521. }, 1000)
  522. }
  523. });
  524. });
  525. })
  526. setTimeout(function () {
  527. myBmap.init(form, uParas, riskPointLevelFunc, _zTree);
  528. }, 1000);
  529. });
  530. var myBmap = {
  531. mapContainer: "map", //地图容器
  532. mapTile: "http://online{s}.map.bdimg.com/tile/?qt=vtile&x={x}&y={y}&z={z}&styles=pl&scaler=2&udt=20181205", //切片图层
  533. myIcon: null, //保存创建的icon
  534. myMarker: null, //保存自己创建marker
  535. myMarkerType: 0, //marker类型
  536. myMarkerId: null, //markerId
  537. isSave: true, //是否保存标记
  538. checkedIcon: null, //保存选中的icon
  539. title: null,
  540. deleteMarkerId: null, //保存删除得markerId
  541. myMarkerGroup: L.layerGroup(),
  542. myMarkerGroupInit: L.layerGroup(),
  543. mapControl: null, // 地图控制器,用来清除叠加控制
  544. data: {},
  545. plotLayer: null,
  546. init: function (form, uParas, riskPointLevelFunc, _zTree) {
  547. _form = form;
  548. var _this = this;
  549. // 初始化默认操作
  550. this.clearPlotLayer() // 默认清空绘制点位
  551. this.myMarkerGroup.clearLayers(); // 图层
  552. this.isSave = true
  553. clearForm()
  554. //初始化地图
  555. var map_type = 2;
  556. if (map_type == 4) {
  557. baidu_map();
  558. } else {
  559. image_map();
  560. }
  561. // 增加区域绘制工具栏
  562. this.plotLayer = plotLayer = this.plotLayer != null ? this.plotLayer : L.featureGroup(), map.addLayer(plotLayer);
  563. var e = {
  564. position: "topright",
  565. draw: {
  566. polyline: {shapeOptions: {color: "#0000ff", weight: 3}},
  567. polygon: {allowIntersection: !0, showArea: !0, shapeOptions: {color: "#0000ff", weight: 2}},
  568. rectangle: {shapeOptions: {color: "#0000ff", weight: 2}},
  569. circle: false,
  570. circlemarker: false,
  571. marker: false
  572. },
  573. edit: {
  574. featureGroup: plotLayer,
  575. remove: !0,
  576. edit: false
  577. }
  578. }, n = mapControl = new L.Control.Draw(e);
  579. map.addControl(n)
  580. function draw_createdHandler(t) {
  581. t.layerType;
  582. var o = t.layer;
  583. plotLayer.addLayer(o)
  584. var all = o.toGeoJSON();
  585. var drawIds = $("#drawIds").val();
  586. $("#drawIds").remove();
  587. if (drawIds != undefined) {
  588. drawIds = drawIds + "#" + JSON.stringify(all.geometry.coordinates) + ";" + all.geometry.type;
  589. } else {
  590. drawIds = JSON.stringify(all.geometry.coordinates) + ";" + all.geometry.type
  591. }
  592. $(".my-marker-type").append('<input type="hidden" id="drawIds" name="drawIds" value="' + drawIds + '">');
  593. }
  594. function draw_deletedHandler(t) {
  595. $("#drawIds").remove();
  596. }
  597. // baidu_map()
  598. //地图鼠标事件
  599. map.off('click').on('click', function (e) {
  600. var point = [];
  601. if (_this.myIcon != null) {
  602. var myIcon1 = L.icon({
  603. iconUrl: _this.myIcon,
  604. iconSize: [40, 40],
  605. // iconAnchor: [0, 0]
  606. })
  607. // console.log(myIcon1);
  608. _this.myIcon = null; //将myIcon 置为null 防止鼠标在地图上移动或者点击再次做绘制
  609. point.push(e.latlng.lat, e.latlng.lng);
  610. _this.myMarker = L.marker([e.latlng.lat, e.latlng.lng], {icon: myIcon1});
  611. _this.myMarker.on('click', markerClick); //标记点击事件
  612. //_this.myMarker.addTo(map); //添加marker到地图上
  613. _this.myMarkerGroup.addLayer(_this.myMarker);
  614. _this.myMarkerGroup.addTo(map);
  615. _this.deleteMarkerId = _this.myMarker._leaflet_id; //保存当前markerId
  616. clearForm(); //清空函数
  617. $("#my-marker").append(_this.checkedIcon); //在表单中进行回显
  618. $("#my-marker-title").append(_this.title); //在表单中进行回显
  619. $("#markerType").html('矿下交通库');
  620. $(".my-marker-type").append('<input type="hidden" id="type" name="type" value="' + _this.data.type + '">');
  621. var latlngArray = "[" + e.latlng.lat + "," + e.latlng.lng + "]";
  622. $(".my-marker-type").append('<input type="hidden" id="latlng" name="latlng" value="' + latlngArray + '">');
  623. $(".my-marker-type").append('<input type="hidden" id="dangerSourceId" name="dangerSourceId" value="' + _this.myMarkerId + '">');
  624. $(".my-marker-type").append('<input type="hidden" id="riskPointMinLevel" name="riskPointMinLevel" value="' + _this.data.riskPointMinLevel + '">');
  625. map.on(L.Draw.Event.CREATED, draw_createdHandler), map.on(L.Draw.Event.DELETED, draw_deletedHandler)
  626. $(".icon-form-box").show();
  627. $("#info").hide();
  628. $("#deleteMarker_").hide();
  629. $("#deleteMarker").show();
  630. var inGroupNumber = {
  631. reload: function (obj) {
  632. uParas.initFormSelects("liablePerson", uParas.baseUrl + '/admin/common/getUsersByGroupId?gId=' + obj.where.groupId, "accountRealName", "aId");
  633. }
  634. }
  635. _zTree._init('/admin/common/getGroupLists', 'gId', 'groupParent', 'groupName', 'gId', 0, 'groupTree_', inGroupNumber, 'menuContent_', 'liableGroupIdName', 'liableGroupId');
  636. }
  637. })
  638. //左侧icon得点击事件
  639. $(".icon-box-ul").off('click').on('click', 'a', function (event) {
  640. if (_this.isSave) {
  641. _this.isSave = false;
  642. var curParent = $(event.currentTarget).parent();
  643. var tarSrc = $(event.target).attr('src');
  644. var title = $(event.target).attr('name');
  645. var id = $(event.target).attr('id');
  646. var type = $(event.target).attr('type');
  647. var riskPointMinLevel = $(event.target).attr('lv');
  648. _this.data.riskPointMinLevel = riskPointMinLevel;
  649. _this.data.type = type;
  650. $('.icon-active').removeClass('icon-active');
  651. $(event.currentTarget).addClass('icon-active');
  652. _this.myIcon = tarSrc;
  653. //复制icon进行拖动
  654. _this.myMarkerId = id;
  655. // _this.myMarkerType = type;
  656. _this.checkedIcon = '<img src="' + tarSrc + '" width="40px" height="40px"/>';
  657. // //console.log(_this.checkedIcon)
  658. _this.title = title;
  659. } else {
  660. layer.msg('请先保存标记!');
  661. }
  662. })
  663. _form.on('submit(saveMarker)', function (data) {
  664. var sendData = data.field;
  665. if (sendData.type == undefined || sendData.type == null) {
  666. layer.msg("请先绘制风险点!");
  667. return;
  668. }
  669. if (sendData.riskPointName == "") {
  670. layer.msg("请输入名称!");
  671. return;
  672. }
  673. sendData.riskPointType = sendData.type;
  674. // sendData.drawIds = $("#drawIds").val();
  675. sendData.riskPointMinLevelSon = $("#riskPointMinLevelSon").val();
  676. // sendData.dangerSourceIds = $("#dangerSourceIds").val();
  677. // console.log(sendData);
  678. $.ajax({
  679. type: "post",
  680. url: uParas.baseUrl + "/ent/riskPointMap/saveDangerSourceMap",
  681. data: sendData,
  682. dataType: "json",
  683. success: function (result) {
  684. if (result.code === 1) {
  685. layer.msg("保存成功");
  686. _this.isSave = true;
  687. $(".my-marker-box>ul>li:not(:last-child)").remove();
  688. if (map._layers[_this.deleteMarkerId] != null) {
  689. map.removeLayer(map._layers[_this.deleteMarkerId]);
  690. }
  691. clearForm(); //清空函数
  692. setTimeout(function () {
  693. loadMapData.init(sendData.type, uParas, riskPointLevelFunc, _zTree);
  694. }, 1000)
  695. $(".icon-form-box").hide();
  696. $("#info").show();
  697. } else {
  698. layer.msg(result.msg);
  699. }
  700. }
  701. });
  702. });
  703. // 标记click事件
  704. function markerClick(e) {
  705. _this.deleteMarkerId = e.target._leaflet_id;
  706. }
  707. //删除marker事件
  708. $("#deleteMarker").click(function () {
  709. _this.isSave = true;
  710. $(".my-marker-box>ul>li:not(:last-child)").remove();
  711. if (map._layers[_this.deleteMarkerId] != null) {
  712. map.removeLayer(map._layers[_this.deleteMarkerId]);
  713. }
  714. plotLayer.clearLayers();
  715. clearForm(); //清空函数
  716. });
  717. // 添加标注
  718. $("#addMarker").click(function () {
  719. layerOpen();
  720. })
  721. // 删除单个标记
  722. $(".my-marker-box>ul").on('click', 'span', function (e) {
  723. $(e.target).parent().remove();
  724. var eles = $(".my-marker-box>ul>li");
  725. var ids = '';
  726. var lv = 4;
  727. $.each(eles, function (index, item) {
  728. var id = $(item).find('img').attr('id');
  729. var lvSon = $(item).find('img').attr('lv');
  730. if (id != undefined) {
  731. ids += id + ",";
  732. if (Number(lvSon) < Number(lv)) {
  733. lv = lvSon;
  734. }
  735. }
  736. });
  737. $("#dangerSourceIds").remove();
  738. $("#riskPointMinLevelSon").remove();
  739. $(".my-marker-type").append('<input type="hidden" id="riskPointMinLevelSon" name="riskPointMinLevelSon" value="' + lv + '">');
  740. $(".my-marker-type").append('<input type="hidden" id="dangerSourceIds" name="dangerSourceIds" value="' + ids + '">');
  741. })
  742. //底图为图片
  743. function image_map() {
  744. if (map == undefined || map._loaded == undefined) {
  745. map = L.map(_this.mapContainer, {
  746. crs: L.CRS.Simple,
  747. center: L.latLng(50.5, 30.5),
  748. minZoom: 0,
  749. zoom: 0,
  750. attributionControl: false
  751. });
  752. } else {
  753. loadFlag = false;
  754. }
  755. var yx = L.latLng;
  756. var xy = function xy(x, y) {
  757. if (L.Util.isArray(x)) {
  758. return yx(x[1], x[0]);
  759. }
  760. return yx(y, x);
  761. };
  762. // map.eachLayer(function (layer) {
  763. // map.removeLayer(layer);
  764. // });
  765. map.addLayer(_this.myMarkerGroupInit);
  766. map.addLayer(_this.myMarkerGroup);
  767. // var bounds = [xy(-600, -600), xy(300, 300)];
  768. var bounds = [xy(-1000, -500), xy(1000, 500)];
  769. L.imageOverlay(imgPath, bounds).addTo(map);
  770. map.fitBounds(bounds);
  771. }
  772. //底图为百度地图
  773. function baidu_map() {
  774. var maxZoom = 26;
  775. var crs = new L.Proj.CRS('EPSG:3395',
  776. '+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs', {
  777. resolutions: function () {
  778. level = 19;
  779. var res = [];
  780. res[0] = Math.pow(2, 18);
  781. for (var i = 1; i < level; i++) {
  782. res[i] = Math.pow(2, (18 - i))
  783. }
  784. return res;
  785. }(),
  786. origin: [0, 0],
  787. bounds: L.bounds([20037508.342789244, 0], [0, 20037508.342789244])
  788. });
  789. var image = new L.TileLayer(_this.mapTile, {
  790. maxZoom: maxZoom,
  791. minZoom: 10,
  792. subdomains: [0, 1, 2],
  793. tms: true
  794. });
  795. map = L.map(_this.mapContainer, {
  796. crs: crs,
  797. layers: [image]
  798. });
  799. map.setView([34.474387, 109.490437], 14);
  800. }
  801. function clearForm() {
  802. $("#my-marker").html(""); //清除icon;
  803. $('.icon-active').removeClass('icon-active'); //移除已选class
  804. $(".my-marker-type>input").remove(); //移除标记类型中得input
  805. $("#markerType").html(""); //清空标记类型
  806. $("#riskPointName").val(""); //清空标记类型
  807. $(".my-marker-box>ul>li:not(:last-child)").remove();
  808. $("#drawIds").remove();
  809. $("#drawType").remove();
  810. $("#my-marker-title").html("");
  811. $("#riskPointDesc").val('');
  812. $("#activeStartTime").val('');
  813. $("#activeEndTime").val('');
  814. $("#riskPointPlaces").val('');
  815. $('#liableGroupIdName').val('');
  816. $('#liablePerson').html('');
  817. }
  818. function layerOpen() {
  819. var outIds = $("#dangerSourceId").val();
  820. if ($("#dangerSourceIds").val() != undefined) {
  821. outIds += "," + $("#dangerSourceIds").val();
  822. }
  823. if (outIds == undefined) {
  824. outIds = new Array();
  825. }
  826. var defImgPath = "";
  827. var jobPng = "../../../../assets/images/icon/job.png";
  828. var facilityPng = "../../../../assets/images/icon/facility.png";
  829. //var dangerSourceList = layui.data(uParas.tableName).dangerSourceList;
  830. var html = '<div class="">';
  831. html += '<div class="danger-src-date popup-icon-box" style="width: 550px;float: left;margin-left: 20px;"><ul>';
  832. $.each(resultData.data, function (i, field) {
  833. var type = field.riskPointType;
  834. var riskPointLevel = riskPointLevelFunc(field.dangerSourceLevel);
  835. var imgPath = field.dangerImg;
  836. if (type == 1) {
  837. defImgPath = facilityPng;
  838. } else {
  839. defImgPath = jobPng;
  840. }
  841. if (imgPath == null || imgPath == "") {
  842. imgPath = defImgPath;
  843. } else {
  844. imgPath = uParas.baseUrl + imgPath;
  845. }
  846. var id = field.dangerSrcId;
  847. if (field.riskPointType == 1) {
  848. if (outIds.indexOf(id) == -1) {
  849. if (field.parentDangerSrcId == -1) {
  850. if (field.riskCount == field.riskCountParent) {
  851. html += '<li class="iconCategory_">' + field.dangerSrcName + '</li>';
  852. html += `<li onclick="iconClick(this)"><a href="javascript:;" id="${field.dangerSrcId}" class="marker-icon"><span style='font-size: 18px;margin-top: 10px;'>✦ </span>
  853. <img src="${imgPath}" id="${field.dangerSrcId}" type="${type}" lv="${field.dangerSourceLevel}" name="${field.dangerSrcName}" style='width: 25px;height: 25px;'></a>
  854. <span style="margin-left: 10px;color: #0c5df1;">${field.dangerSrcName}</span>${riskPointLevel}</li>`;
  855. } else {
  856. html += '<li class="iconCategory_">' + field.dangerSrcName + '</li>';
  857. }
  858. } else {
  859. html += `<li onclick="iconClick(this)"><a href="javascript:;" id="${field.dangerSrcId}" class="marker-icon"><span style='font-size: 18px;margin-top: 10px;'>✦ </span>
  860. <img src="${imgPath}" id="${field.dangerSrcId}" type="${type}" lv="${field.dangerSourceLevel}" name="${field.dangerSrcName}" style='width: 25px;height: 25px;'></a>
  861. <span style="margin-left: 10px;color: #0c5df1;">${field.dangerSrcName}</span>${riskPointLevel}</li>`;
  862. }
  863. }
  864. }
  865. });
  866. html += '</ul></div>';
  867. html += '<div class="danger-src-date popup-icon-box" style="float: left;width: 550px;"><ul>';
  868. $.each(resultData.data, function (i, field) {
  869. var type = field.riskPointType;
  870. var riskPointLevel = riskPointLevelFunc(field.dangerSourceLevel);
  871. var imgPath = field.dangerImg;
  872. if (type == 1) {
  873. defImgPath = facilityPng;
  874. } else {
  875. defImgPath = jobPng;
  876. }
  877. if (imgPath == null || imgPath == "") {
  878. imgPath = defImgPath;
  879. } else {
  880. imgPath = uParas.baseUrl + imgPath;
  881. }
  882. var id = field.dangerSrcId;
  883. if (field.riskPointType == 2) {
  884. if (outIds.indexOf(id) == -1) {
  885. if (field.parentDangerSrcId == -1) {
  886. if (field.riskCount == field.riskCountParent) {
  887. html += '<li class="iconCategory_">' + field.dangerSrcName + '</li>';
  888. html += `<li onclick="iconClick(this)"><a href="javascript:;" id="${field.dangerSrcId}" class="marker-icon"><span style='font-size: 18px;margin-top: 10px;'>➢ </span>
  889. <img src="${imgPath}" id="${field.dangerSrcId}" type="${type}" lv="${field.dangerSourceLevel}" name="${field.dangerSrcName}" style='width: 25px;height: 25px;'></a>
  890. <span style="margin-left: 10px;color: #0c5df1;">${field.dangerSrcName}</span>${riskPointLevel}</li>`;
  891. } else {
  892. html += '<li class="iconCategory_">' + field.dangerSrcName + '</li>';
  893. }
  894. } else {
  895. html += `<li onclick="iconClick(this)"><a href="javascript:;" id="${field.dangerSrcId}" class="marker-icon"><span style='font-size: 18px;margin-top: 10px;'>➢ </span>
  896. <img src="${imgPath}" id="${field.dangerSrcId}" type="${type}" lv="${field.dangerSourceLevel}" name="${field.dangerSrcName}" style='width: 25px;height: 25px;'></a>
  897. <span style="margin-left: 10px;color: #0c5df1;">${field.dangerSrcName}</span>${riskPointLevel}</li>`;
  898. }
  899. }
  900. }
  901. });
  902. html += '</ul></div></div>';
  903. layer.open({
  904. title: '【设备设施】' + '<span style="margin-left: 470px;">【作业活动】</span>',
  905. btn: ['确定', '取消'],
  906. type: 1,
  907. area: ['1200px', '60%'], //宽高
  908. content: html,
  909. yes: yes
  910. });
  911. }
  912. function yes(index) {
  913. var eles = $(".popup-icon-box>ul>li");
  914. var li = '';
  915. var ids = '';
  916. var lv = 4;
  917. $.each(eles, function (index, item) {
  918. if ($(item).hasClass('icon-active')) {
  919. var imgSrc = $(item).find('img').attr('src');
  920. var id = $(item).find('img').attr('id');
  921. var title = $(item).find('img').attr('name');
  922. var div = $(item).find('div').html();
  923. var lvSon = $(item).find('img').attr('lv');
  924. li += '<li><img src="' + imgSrc + '" id="' + id + '"lv=' + lvSon + ' ><span>x</span><p>' + title + '</p><div class="riskPointLevel">' + div + '</div></li>';
  925. if (id != undefined) {
  926. ids += id + ",";
  927. if (Number(lvSon) < lv) {
  928. lv = lvSon;
  929. }
  930. }
  931. }
  932. });
  933. $("#myMarkerBox>ul").prepend(li);
  934. if ($("#dangerSourceIds").val() != undefined) {
  935. ids += $("#dangerSourceIds").val();
  936. }
  937. $("#dangerSourceIds").remove();
  938. $("#riskPointMinLevelSon").remove();
  939. $(".my-marker-type").append('<input type="hidden" id="riskPointMinLevelSon" name="riskPointMinLevelSon" value="' + lv + '">');
  940. $(".my-marker-type").append('<input type="hidden" id="dangerSourceIds" name="dangerSourceIds" value="' + ids + '">');
  941. layer.close(index);
  942. }
  943. },
  944. clearPlotLayer: function () {
  945. if (this.plotLayer != null) {
  946. this.plotLayer.clearLayers()
  947. }
  948. },
  949. clearMapController() { // 清除地图控制器
  950. map.removeControl(mapControl)
  951. }
  952. }
  953. var loadMapData = {
  954. jobPng: "../../../../assets/images/icon/job.png",
  955. facilityPng: "../../../../assets/images/icon/facility.png",
  956. init: function (type, uParas, riskPointLevelFunc, _zTree) {
  957. var _uParas = uParas;
  958. var riskPointLevelFunc = riskPointLevelFunc;
  959. var _zTree = _zTree;
  960. var jobIcon = L.icon({
  961. iconUrl: loadMapData.jobPng,
  962. iconSize: [38, 45],
  963. popupAnchor: [0, -16]
  964. });
  965. var facilityIcon = L.icon({
  966. iconUrl: loadMapData.facilityPng,
  967. iconSize: [38, 45],
  968. popupAnchor: [0, -16]
  969. });
  970. function icon(imgUrl) {
  971. return L.icon({
  972. iconUrl: imgUrl,
  973. iconSize: [38, 45],
  974. popupAnchor: [0, -16]
  975. });
  976. }
  977. initMapData(type, uParas);
  978. function initMapData(type, uParas) {
  979. var groupId = $("#groupId").val();
  980. if (type == undefined) {
  981. type = 6
  982. } else {
  983. myBmap.myMarkerGroupInit.clearLayers();
  984. }
  985. myBmap.myMarkerGroupInit.clearLayers();
  986. var entMapId = $("#entMapId").val();
  987. $.getJSON(uParas.baseUrl + "/ent/riskPointMap/getRiskPointMap", {
  988. riskPointType: type,
  989. gId: groupId,
  990. entMapId: entMapId
  991. }, function (result) {
  992. if (result.code == 1) {
  993. $.each(result.data, function (index, item) {
  994. var markerData = item.markerData;
  995. if (markerData != null) {
  996. var optionsData = {
  997. mapId: item.id,
  998. riskPointId: item.riskPointId,
  999. type: type,
  1000. title: item.markerTitle
  1001. };
  1002. if (item.dangerImg != null && item.dangerImg != "") {
  1003. optionsData.iconUrl = imgPathFun(item.dangerImg, type);
  1004. } else {
  1005. if (type === 2) {
  1006. optionsData.iconUrl = loadMapData.jobPng;
  1007. } else {
  1008. optionsData.iconUrl = loadMapData.facilityPng;
  1009. }
  1010. }
  1011. if (item.markerType == 3) {
  1012. var data = new Array();
  1013. $.each($.parseJSON(markerData), function (index, item) {
  1014. data[index] = new Array(item[1], item[0]);
  1015. });
  1016. L.polygon(data, optionsData).addTo(myBmap.myMarkerGroupInit).bindPopup(item.markerTitle).on('click', onMapClick);
  1017. } else if (item.markerType == 1) {
  1018. if (item.dangerImg != null && item.dangerImg != "") {
  1019. optionsData.icon = icon(uParas.baseUrl + item.dangerImg);
  1020. } else {
  1021. if (type == 2) {
  1022. optionsData.icon = jobIcon;
  1023. } else {
  1024. optionsData.icon = facilityIcon;
  1025. }
  1026. }
  1027. L.marker($.parseJSON(markerData), optionsData).addTo(myBmap.myMarkerGroupInit).bindPopup(item.markerTitle).on('click', onMapClick);
  1028. } else if (item.markerType == 2) {
  1029. var data = new Array();
  1030. $.each($.parseJSON(markerData), function (index, item) {
  1031. data[index] = new Array(item[1], item[0]);
  1032. });
  1033. L.polyline(data, optionsData).addTo(myBmap.myMarkerGroupInit).bindPopup(item.markerTitle).on('click', onMapClick);
  1034. }
  1035. }
  1036. });
  1037. }
  1038. });
  1039. }
  1040. function imgPathFun(imgPath, type) {
  1041. var defImgPath = "";
  1042. var jobPng = "../../../../assets/images/icon/job.png";
  1043. var facilityPng = "../../../../assets/images/icon/facility.png";
  1044. if (type == "1") {
  1045. defImgPath = facilityPng;
  1046. } else {
  1047. defImgPath = jobPng;
  1048. }
  1049. if (imgPath == null || imgPath == "") {
  1050. return defImgPath;
  1051. } else {
  1052. if (imgPath.indexOf("http:") != -1) {
  1053. defImgPath = imgPath;
  1054. } else {
  1055. defImgPath = uParas.baseUrl + imgPath;
  1056. }
  1057. }
  1058. return defImgPath;
  1059. }
  1060. function onMapClick(e) {
  1061. $(".icon-form-box").show();
  1062. $("#info").hide();
  1063. var options = e.target.options;
  1064. var data = {};
  1065. data.mapId = options.mapId;
  1066. data.riskPointId = options.riskPointId;
  1067. $("#deleteMarker").hide();
  1068. $("#deleteMarker_").show();
  1069. $("#my-marker").html('<img src="' + options.iconUrl + '"/>');
  1070. $("#markerType").html(options.type == 2 ? '作业活动' : '设备设施');
  1071. $("#riskPointName").val(options.title);
  1072. $.getJSON("/ent/riskPointMap/findMapDataById", data, function (result) {
  1073. if (result.code == 1) {
  1074. var item = result.data[0];
  1075. var index = item.dangerSourceIds;
  1076. var arr = new Array();
  1077. if (index != null) {
  1078. if (index.indexOf(',') != -1) {
  1079. arr = index.split(',');
  1080. } else {
  1081. arr = [index];
  1082. }
  1083. }
  1084. $("#riskPointPlaces").val(item.riskPointPlaces);
  1085. $("#riskPointDesc").val(item.riskPointDesc);
  1086. $("#activeEndTime").val(item.activeEndTime);
  1087. $("#activeStartTime").val(item.activeStartTime);
  1088. $("#my-marker-title").html("");
  1089. $("#my-marker-title").append(item.dangerSrcName);
  1090. $("#type").remove();
  1091. $(".my-marker-type").append('<input type="hidden" id="type" name="type" value="' + options.type + '">');
  1092. $("#riskPointId").remove();
  1093. $(".my-marker-type").append('<input type="hidden" id="riskPointId" name="riskPointId" value="' + item.riskPointId + '">');
  1094. $("#dangerSourceId").remove();
  1095. $(".my-marker-type").append('<input type="hidden" id="dangerSourceId" name="dangerSourceId" value="' + item.dangerSrcId + '">');
  1096. $("#riskPointMinLevel").remove();
  1097. $(".my-marker-type").append('<input type="hidden" id="riskPointMinLevel" name="riskPointMinLevel" value="' + item.riskPointLevel + '">');
  1098. if (arr.length > 0) {
  1099. var majorIndex = arr.indexOf(item.dangerSrcId + "");
  1100. if (majorIndex > -1) {
  1101. arr.splice(majorIndex, 1);
  1102. }
  1103. $("#dangerSourceIds").remove();
  1104. $(".my-marker-type").append('<input type="hidden" id="dangerSourceIds" name="dangerSourceIds" value="' + arr.join(',') + '">');
  1105. }
  1106. $(".my-marker-box>ul>li:not(:last-child)").remove();
  1107. var li = '';
  1108. var _lv = 4;
  1109. var dangerSourceList = layui.data(_uParas.tableName).dangerSourceList;
  1110. $.each(arr, function (i, field) {
  1111. $.each(dangerSourceList, function (index, item) {
  1112. if (item.dangerSrcId == field) {
  1113. var title = item.dangerSrcName;
  1114. var lvSon = item.dangerSourceLevel;
  1115. if (lvSon < _lv) {
  1116. _lv = lvSon;
  1117. }
  1118. var div = riskPointLevelFunc(lvSon);
  1119. var imgPath = imgPathFun(item.dangerImg, item.riskPointType);
  1120. li += '<li><img src="' + imgPath + '" id="' + field + '" lv=' + lvSon + ' ><span>x</span><p>' + title + '</p><div class="riskPointLevel">' + div + '</div></li>';
  1121. return;
  1122. }
  1123. });
  1124. });
  1125. $("#riskPointMinLevelSon").remove();
  1126. $(".my-marker-type").append('<input type="hidden" id="riskPointMinLevelSon" name="riskPointMinLevelSon" value="' + _lv + '">');
  1127. $("#myMarkerBox>ul").prepend(li);
  1128. myBmap.data.type = options.type;
  1129. $("#liableGroupIdName").val(item.groupName);
  1130. $("#liableGroupId").val(item.liableGroupId);
  1131. if (item.liableGroupId != null) {
  1132. var inGroupNumber = {
  1133. reload: function (obj) {
  1134. uParas.initFormSelects("liablePerson", uParas.baseUrl + '/admin/common/getUsersByGroupId?gId=' + obj.where.groupId, "accountRealName", "aId");
  1135. }
  1136. }
  1137. _zTree._init('/admin/common/getGroupLists', 'gId', 'groupParent', 'groupName', 'gId', 0, 'groupTree_', inGroupNumber, 'menuContent_', 'liableGroupIdName', 'liableGroupId');
  1138. uParas.initFormSelects("liablePerson", uParas.baseUrl + '/admin/common/getUsersByGroupId?gId=' + item.liableGroupId, "accountRealName", "aId", item.personList);
  1139. }
  1140. }
  1141. });
  1142. }
  1143. }
  1144. }
  1145. function iconClick(e) {
  1146. $(e).toggleClass('icon-active')
  1147. }
  1148. </script>
  1149. </body>
  1150. </html>