add.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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/formSelects/formSelects-v4.css"/>
  10. <link rel="stylesheet" href="../../../assets/module/admin.css?v=312"/>
  11. <link rel="stylesheet" href="../../../assets/css/editormap.css?v=312"/>
  12. <style>
  13. .layui-form-item {
  14. margin-bottom: 0;
  15. margin-top: 20px;
  16. }
  17. .layui-form-item .layui-inline {
  18. margin-bottom: 25px;
  19. margin-right: 0;
  20. }
  21. .form-group-bottom {
  22. position: fixed;
  23. bottom: 0;
  24. left: 0;
  25. right: 0;
  26. background-color: #fff;
  27. padding: 10px 20px;
  28. box-shadow: 0 -1px 2px 0 rgba(0, 0, 0, .05);
  29. }
  30. .menuContent {
  31. display: none;
  32. position: absolute;
  33. top: 33px;
  34. /*left: 15px;*/
  35. background-color: #fff;
  36. z-index: 2000;
  37. border: 1px solid #ccc;
  38. }
  39. /**
  40. * 弹出框需要 不要删除
  41. */
  42. .layui-layer-content {
  43. overflow: auto !important;
  44. }
  45. </style>
  46. </head>
  47. <body>
  48. <!-- 加载动画 -->
  49. <div class="page-loading">
  50. <div class="ball-loader">
  51. <span></span><span></span><span></span><span></span>
  52. </div>
  53. </div>
  54. <!-- 正文开始 -->
  55. <div class="layui-fluid">
  56. <div class="layui-card">
  57. <div class="layui-card-body">
  58. <div class="layui-card-header">
  59. 添加风险点
  60. <div class="layui-inline pull-right">
  61. <button onclick="history.back()" class="layui-btn layui-btn-sm layui-btn-radius layui-btn-normal"><i
  62. class="layui-icon">&#xe65c;</i>返回
  63. </button>
  64. </div>
  65. </div>
  66. <form class="layui-form" lay-filter="layuiForm">
  67. <div class="layui-form-item layui-row">
  68. <label class="layui-form-label">风险点名称:</label>
  69. <div class="layui-input-block">
  70. <input name="riskPointName" type="text" placeholder="请输入风险点名称" class="layui-input"
  71. lay-verType="tips" required lay-verify="riskPointName">
  72. </div>
  73. </div>
  74. <div class="layui-form-item layui-row">
  75. <label class="layui-form-label">责任部门:</label>
  76. <div class="layui-input-block">
  77. <input type="text" id="liableGroupIdName" class="layui-input" name="liableGroupIdName"
  78. value=""
  79. placeholder="点击选择责任部门"
  80. class="form-control" readonly>
  81. <input type="hidden" id="gId" name="gId" readonly>
  82. <div id="menuContentMap" class="menuContent">
  83. <ul id="groupTree" class="ztree" style="margin-top:0;"></ul>
  84. </div>
  85. </div>
  86. </div>
  87. <div class="layui-form-item layui-row">
  88. <label class="layui-form-label">责任人:</label>
  89. <div class="layui-input-block">
  90. <select id="aId" name="aId" lay-verType="tips" class="layui-input-block" xm-select="aId"
  91. xm-select-search>
  92. <option value="">直接选择责任人或搜索选择责任人</option>
  93. </select>
  94. </div>
  95. </div>
  96. <!-- <div class="layui-form-item layui-row">-->
  97. <!-- <label class="layui-form-label">站点:</label>-->
  98. <!-- <div class="my-marker-box" id="myMarkerBox">-->
  99. <!-- <ul style="overflow-y: auto">-->
  100. <!-- <li class="add-subIcon" id="addMarker">+</li>-->
  101. <!-- </ul>-->
  102. <!-- </div>-->
  103. <!-- </div>-->
  104. <div class="form-group-bottom text-right">
  105. <button class="layui-btn" lay-filter="formSubmit" lay-submit>&emsp;提交&emsp;</button>
  106. <button type="reset" class="layui-btn layui-btn-primary">&emsp;重置&emsp;</button>
  107. </div>
  108. </form>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. <!-- js部分 -->
  114. <script type="text/javascript" src="../../../assets/libs/layui/layui.js"></script>
  115. <script type="text/javascript" src="../../../assets/js/common.js?v=312"></script>
  116. <script>
  117. var resultData;
  118. layui.use(['layer', 'form', 'table', 'util', 'zTree', 'admin', 'uParas', 'laydate', 'upload', 'formSelects'], function () {
  119. var $ = layui.jquery;
  120. var layer = layui.layer;
  121. var form = layui.form;
  122. var util = layui.util;
  123. var admin = layui.admin;
  124. var uParas = layui.uParas;
  125. var laydate = layui.laydate, upload = layui.upload, formSelects = layui.formSelects;
  126. var url = uParas.baseUrl + "/ent/parkConf/query?limit=1000";
  127. $.getJSON(url, function (result) {
  128. resultData = result;
  129. uParas.cache("dangerSourceList", result.data);
  130. });
  131. uParas.initFormSelects("checkedTable_", "/ent/bizCheckDef/getList?page=1&limit=1000", "checkDefName", "checkDefId");
  132. $("#addMarker").click(function () {
  133. layerOpen();
  134. });
  135. $.extend(window, {
  136. iconClick: function (e) {
  137. $(e).toggleClass('icon-active')
  138. }
  139. });
  140. $(".my-marker-box>ul").on('click', 'span', function (e) {
  141. $(e.target).parent().remove();
  142. var eles = $(".my-marker-box>ul>li");
  143. var ids = '';
  144. var lv = 4;
  145. $.each(eles, function (index, item) {
  146. var id = $(item).find('img').attr('id');
  147. var lvSon = $(item).find('img').attr('lv');
  148. if (id != undefined) {
  149. ids += id + ",";
  150. if (Number(lvSon) < Number(lv)) {
  151. lv = lvSon;
  152. }
  153. }
  154. });
  155. $("#dangerSourceIds").remove();
  156. $("#riskPointMinLevelSon").remove();
  157. $(".layui-form").append('<input type="hidden" id="dangerSourceIds" name="dangerSourceIds" value="' + ids + '">');
  158. })
  159. function layerOpen() {
  160. var outIds = $("#dangerSourceId").val();
  161. if ($("#dangerSourceIds").val() != undefined) {
  162. outIds += "," + $("#dangerSourceIds").val();
  163. }
  164. if (outIds == undefined) {
  165. outIds = new Array();
  166. }
  167. var defImgPath = "../../../assets/images/icon/facility.png";
  168. //var dangerSourceList = layui.data(uParas.tableName).dangerSourceList;
  169. var html = '<div class="">';
  170. html += '<div class="danger-src-date popup-icon-box" style="width: 550px;float: left;margin-left: 20px;"><ul>';
  171. $.each(resultData.data, function (i, field) {
  172. var type = field.riskPointType;
  173. var imgPath = field.dangerImg;
  174. if (imgPath == null || imgPath == "") {
  175. imgPath = defImgPath;
  176. } else {
  177. imgPath = imgPath;
  178. }
  179. var id = field.dangerSrcId;
  180. if (field.parkParentId == 0) {
  181. if (outIds.indexOf(id) == -1) {
  182. // if (field.parentDangerSrcId == -1) {
  183. if (field.parkParentId == 0) {
  184. html += '<li class="iconCategory_">' + field.parkName + '</li>';
  185. html += `<li onclick="iconClick(this)"><a href="javascript:;" id="${field.parkId}" class="marker-icon"><span style='font-size: 18px;margin-top: 10px;'>✦ </span>
  186. <img src="${imgPath}" id="${field.parkId}" type="${type}" lv="${field.dangerSourceLevel}" name="${field.parkName}" style='width: 25px;height: 25px;'></a>
  187. <span style="margin-left: 10px;color: #0c5df1;">${field.parkName}</span></li>`;
  188. } else {
  189. html += '<li class="iconCategory_">' + field.parkName + '</li>';
  190. }
  191. // } else {
  192. // html += `<li onclick="iconClick(this)"><a href="javascript:;" id="${field.parkId}" class="marker-icon"><span style='font-size: 18px;margin-top: 10px;'>✦ </span>
  193. // <img src="${imgPath}" id="${field.parkId}" type="${type}" lv="${field.dangerSourceLevel}" name="${field.parkName}" style='width: 25px;height: 25px;'></a>
  194. // <span style="margin-left: 10px;color: #0c5df1;">${field.parkName}</span></li>`;
  195. // }
  196. }
  197. }
  198. });
  199. html += '</ul></div></div>';
  200. layer.open({
  201. title: '站点信息',
  202. btn: ['确定', '取消'],
  203. type: 1,
  204. area: ['600px', '60%'], //宽高
  205. content: html,
  206. yes: yes
  207. });
  208. }
  209. function yes(index) {
  210. var eles = $(".popup-icon-box>ul>li");
  211. var li = '';
  212. var ids = '';
  213. var lv = 4;
  214. $.each(eles, function (index, item) {
  215. if ($(item).hasClass('icon-active')) {
  216. var imgSrc = $(item).find('img').attr('src');
  217. var id = $(item).find('img').attr('id');
  218. var title = $(item).find('img').attr('name');
  219. var div = $(item).find('div').html();
  220. var lvSon = $(item).find('img').attr('lv');
  221. li += '<li><img src="' + imgSrc + '" id="' + id + '"lv=' + lvSon + ' ><span>x</span><p>' + title + '</p></li>';
  222. if (id != undefined) {
  223. ids += id + ",";
  224. if (Number(lvSon) < lv) {
  225. lv = lvSon;
  226. }
  227. }
  228. }
  229. });
  230. $("#myMarkerBox>ul").prepend(li);
  231. if ($("#dangerSourceIds").val() != undefined) {
  232. ids += $("#dangerSourceIds").val();
  233. }
  234. $("#dangerSourceIds").remove();
  235. $("#riskPointMinLevelSon").remove();
  236. $(".layui-form").append('<input type="hidden" id="riskPointMinLevelSon" name="riskPointMinLevelSon" value="' + lv + '">');
  237. $(".layui-form").append('<input type="hidden" id="dangerSourceIds" name="dangerSourceIds" value="' + ids + '">');
  238. layer.close(index);
  239. }
  240. date = new Date();
  241. // 渲染laydate
  242. laydate.render({
  243. elem: '#activeStartTime', format: 'yyyy-MM-dd HH:mm:ss', type: 'datetime', min: 'date'
  244. });
  245. laydate.render({
  246. elem: '#activeEndTime', format: 'yyyy-MM-dd HH:mm:ss', type: 'datetime', min: 'date'
  247. });
  248. /**
  249. * @Author: NanKeYang
  250. * @Description: 自定义验证规则
  251. * @Data: 2020/1/6 14:54
  252. */
  253. form.verify({
  254. riskPointName: function (value) {
  255. if (value.length < 1) {
  256. return '请填写风险点名称';
  257. }
  258. }
  259. });
  260. // 监听表单提交
  261. form.on('submit(formSubmit)', function (data) {
  262. // 表格选择的数据放到data.field中
  263. var obj = data.field;
  264. if (obj.dangerSourceId == null && obj.dangerSourceIds != null) {
  265. var dSIds = obj.dangerSourceIds.split(",");
  266. obj.dangerSourceId = dSIds[0];
  267. }
  268. console.log(obj);
  269. admin.req(uParas.baseUrl + '/ent/riskPointMap/saveDangerSourceMap', obj, function (resp) {
  270. // if (resp.code == 1) {
  271. // location.href = "./index.html";
  272. // } else {
  273. // layer.msg(resp.msg)
  274. // }
  275. }, 'POST');
  276. return false;
  277. });
  278. /**
  279. * ztree 文本下拉
  280. */
  281. admin.req(uParas.baseUrl + '/admin/common/getGroupLists', null, function (res) {
  282. if (res.code == 1) {
  283. $.fn.zTree.init($('#groupTree'), settingMAP, res.data);
  284. $.fn.zTree.getZTreeObj("groupTree").expandAll(true);
  285. layer.closeAll('loading');
  286. hideMenuMap();
  287. }
  288. }, 'get');
  289. $("#liableGroupIdName").click(function () {
  290. $("#menuContentMap").slideDown("fast");
  291. $("body").bind("mousedown", onBodyDown);
  292. });
  293. function onBodyDown(event) {
  294. if (!(event.target.id === "groupIdName" || event.target.id === "menuContentMap" || $(event.target).parents("#menuContentMap").length > 0)) {
  295. hideMenuMap();
  296. }
  297. }
  298. var settingMAP = {
  299. check: {
  300. enable: false,
  301. chkboxType: {"Y": "", "N": ""}
  302. },
  303. view: {
  304. dblClickExpand: false
  305. },
  306. data: {
  307. simpleData: {
  308. enable: true,
  309. idKey: "gId",
  310. pIdKey: "groupParent",
  311. rootPId: null
  312. },
  313. key: {
  314. name: "groupName"
  315. }
  316. },
  317. callback: {
  318. onClick: onClickMap
  319. }
  320. };
  321. function onClickMap(event, treeId, treeNode, clickFlag) {
  322. var zTree = $.fn.zTree.getZTreeObj("groupTree"),
  323. nodes = zTree.getSelectedNodes(),
  324. v = "", idlist = "";
  325. for (var i = 0, l = nodes.length; i < l; i++) {
  326. v += nodes[i].groupName + ",";
  327. idlist += nodes[i].gId + ",";
  328. }
  329. if (v.length > 0) {
  330. v = v.substring(0, v.length - 1);
  331. idlist = idlist.substring(0, idlist.length - 1);
  332. }
  333. var cityObj = $("#liableGroupIdName");
  334. if (cityObj.val() == v) {
  335. cityObj.attr("value", "");
  336. $("#gId").attr("value", "");
  337. } else {
  338. $("#liableGroupIdName").val(v);
  339. $("#gId").attr("value", idlist);
  340. }
  341. hideMenuMap();
  342. var groupId = idlist;
  343. if (groupId != "-1") {
  344. uParas.initFormSelects("aId", "/ent/groupAccount/queryAccounts?gId=" + groupId, "accountRealName", "aId");
  345. }
  346. }
  347. function hideMenuMap() {
  348. $("#menuContentMap").fadeOut("fast");
  349. $("body").unbind("mousedown", onBodyDown);
  350. }
  351. });
  352. </script>
  353. </body>
  354. </html>