123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379 |
- <!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/formSelects/formSelects-v4.css"/>
- <link rel="stylesheet" href="../../../assets/module/admin.css?v=312"/>
- <link rel="stylesheet" href="../../../assets/css/editormap.css?v=312"/>
- <style>
- .layui-form-item {
- margin-bottom: 0;
- margin-top: 20px;
- }
- .layui-form-item .layui-inline {
- margin-bottom: 25px;
- margin-right: 0;
- }
- .form-group-bottom {
- position: fixed;
- bottom: 0;
- left: 0;
- right: 0;
- background-color: #fff;
- padding: 10px 20px;
- box-shadow: 0 -1px 2px 0 rgba(0, 0, 0, .05);
- }
- .menuContent {
- display: none;
- position: absolute;
- top: 33px;
- /*left: 15px;*/
- background-color: #fff;
- z-index: 2000;
- border: 1px solid #ccc;
- }
- /**
- * 弹出框需要 不要删除
- */
- .layui-layer-content {
- overflow: auto !important;
- }
- </style>
- </head>
- <body>
- <!-- 加载动画 -->
- <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-body">
- <div class="layui-card-header">
- 添加风险点
- <div class="layui-inline pull-right">
- <button onclick="history.back()" class="layui-btn layui-btn-sm layui-btn-radius layui-btn-normal"><i
- class="layui-icon"></i>返回
- </button>
- </div>
- </div>
- <form class="layui-form" lay-filter="layuiForm">
- <div class="layui-form-item layui-row">
- <label class="layui-form-label">风险点名称:</label>
- <div class="layui-input-block">
- <input name="riskPointName" type="text" placeholder="请输入风险点名称" class="layui-input"
- lay-verType="tips" required lay-verify="riskPointName">
- </div>
- </div>
- <div class="layui-form-item layui-row">
- <label class="layui-form-label">责任部门:</label>
- <div class="layui-input-block">
- <input type="text" id="liableGroupIdName" class="layui-input" name="liableGroupIdName"
- value=""
- placeholder="点击选择责任部门"
- class="form-control" readonly>
- <input type="hidden" id="gId" name="gId" readonly>
- <div id="menuContentMap" class="menuContent">
- <ul id="groupTree" class="ztree" style="margin-top:0;"></ul>
- </div>
- </div>
- </div>
- <div class="layui-form-item layui-row">
- <label class="layui-form-label">责任人:</label>
- <div class="layui-input-block">
- <select id="aId" name="aId" lay-verType="tips" class="layui-input-block" xm-select="aId"
- xm-select-search>
- <option value="">直接选择责任人或搜索选择责任人</option>
- </select>
- </div>
- </div>
- <!-- <div class="layui-form-item layui-row">-->
- <!-- <label class="layui-form-label">站点:</label>-->
- <!-- <div class="my-marker-box" id="myMarkerBox">-->
- <!-- <ul style="overflow-y: auto">-->
- <!-- <li class="add-subIcon" id="addMarker">+</li>-->
- <!-- </ul>-->
- <!-- </div>-->
- <!-- </div>-->
- <div class="form-group-bottom text-right">
- <button class="layui-btn" lay-filter="formSubmit" lay-submit> 提交 </button>
- <button type="reset" class="layui-btn layui-btn-primary"> 重置 </button>
- </div>
- </form>
- </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>
- var resultData;
- layui.use(['layer', 'form', 'table', 'util', 'zTree', 'admin', 'uParas', 'laydate', 'upload', 'formSelects'], function () {
- var $ = layui.jquery;
- var layer = layui.layer;
- var form = layui.form;
- var util = layui.util;
- var admin = layui.admin;
- var uParas = layui.uParas;
- var laydate = layui.laydate, upload = layui.upload, formSelects = layui.formSelects;
- var url = uParas.baseUrl + "/ent/parkConf/query?limit=1000";
- $.getJSON(url, function (result) {
- resultData = result;
- uParas.cache("dangerSourceList", result.data);
- });
- uParas.initFormSelects("checkedTable_", "/ent/bizCheckDef/getList?page=1&limit=1000", "checkDefName", "checkDefId");
- $("#addMarker").click(function () {
- layerOpen();
- });
- $.extend(window, {
- iconClick: function (e) {
- $(e).toggleClass('icon-active')
- }
- });
- $(".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();
- $(".layui-form").append('<input type="hidden" id="dangerSourceIds" name="dangerSourceIds" value="' + ids + '">');
- })
- function layerOpen() {
- var outIds = $("#dangerSourceId").val();
- if ($("#dangerSourceIds").val() != undefined) {
- outIds += "," + $("#dangerSourceIds").val();
- }
- if (outIds == undefined) {
- outIds = new Array();
- }
- var defImgPath = "../../../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 imgPath = field.dangerImg;
- if (imgPath == null || imgPath == "") {
- imgPath = defImgPath;
- } else {
- imgPath = imgPath;
- }
- var id = field.dangerSrcId;
- if (field.parkParentId == 0) {
- if (outIds.indexOf(id) == -1) {
- // if (field.parentDangerSrcId == -1) {
- if (field.parkParentId == 0) {
- html += '<li class="iconCategory_">' + field.parkName + '</li>';
- html += `<li onclick="iconClick(this)"><a href="javascript:;" id="${field.parkId}" class="marker-icon"><span style='font-size: 18px;margin-top: 10px;'>✦ </span>
- <img src="${imgPath}" id="${field.parkId}" type="${type}" lv="${field.dangerSourceLevel}" name="${field.parkName}" style='width: 25px;height: 25px;'></a>
- <span style="margin-left: 10px;color: #0c5df1;">${field.parkName}</span></li>`;
- } else {
- html += '<li class="iconCategory_">' + field.parkName + '</li>';
- }
- // } else {
- // html += `<li onclick="iconClick(this)"><a href="javascript:;" id="${field.parkId}" class="marker-icon"><span style='font-size: 18px;margin-top: 10px;'>✦ </span>
- // <img src="${imgPath}" id="${field.parkId}" type="${type}" lv="${field.dangerSourceLevel}" name="${field.parkName}" style='width: 25px;height: 25px;'></a>
- // <span style="margin-left: 10px;color: #0c5df1;">${field.parkName}</span></li>`;
- // }
- }
- }
- });
- html += '</ul></div></div>';
- layer.open({
- title: '站点信息',
- btn: ['确定', '取消'],
- type: 1,
- area: ['600px', '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></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();
- $(".layui-form").append('<input type="hidden" id="riskPointMinLevelSon" name="riskPointMinLevelSon" value="' + lv + '">');
- $(".layui-form").append('<input type="hidden" id="dangerSourceIds" name="dangerSourceIds" value="' + ids + '">');
- layer.close(index);
- }
- date = new Date();
- // 渲染laydate
- laydate.render({
- elem: '#activeStartTime', format: 'yyyy-MM-dd HH:mm:ss', type: 'datetime', min: 'date'
- });
- laydate.render({
- elem: '#activeEndTime', format: 'yyyy-MM-dd HH:mm:ss', type: 'datetime', min: 'date'
- });
- /**
- * @Author: NanKeYang
- * @Description: 自定义验证规则
- * @Data: 2020/1/6 14:54
- */
- form.verify({
- riskPointName: function (value) {
- if (value.length < 1) {
- return '请填写风险点名称';
- }
- }
- });
- // 监听表单提交
- form.on('submit(formSubmit)', function (data) {
- // 表格选择的数据放到data.field中
- var obj = data.field;
- if (obj.dangerSourceId == null && obj.dangerSourceIds != null) {
- var dSIds = obj.dangerSourceIds.split(",");
- obj.dangerSourceId = dSIds[0];
- }
- console.log(obj);
- admin.req(uParas.baseUrl + '/ent/riskPointMap/saveDangerSourceMap', obj, function (resp) {
- // if (resp.code == 1) {
- // location.href = "./index.html";
- // } else {
- // layer.msg(resp.msg)
- // }
- }, 'POST');
- return false;
- });
- /**
- * ztree 文本下拉
- */
- admin.req(uParas.baseUrl + '/admin/common/getGroupLists', null, function (res) {
- if (res.code == 1) {
- $.fn.zTree.init($('#groupTree'), settingMAP, res.data);
- $.fn.zTree.getZTreeObj("groupTree").expandAll(true);
- layer.closeAll('loading');
- hideMenuMap();
- }
- }, 'get');
- $("#liableGroupIdName").click(function () {
- $("#menuContentMap").slideDown("fast");
- $("body").bind("mousedown", onBodyDown);
- });
- function onBodyDown(event) {
- if (!(event.target.id === "groupIdName" || event.target.id === "menuContentMap" || $(event.target).parents("#menuContentMap").length > 0)) {
- hideMenuMap();
- }
- }
- var settingMAP = {
- check: {
- enable: false,
- chkboxType: {"Y": "", "N": ""}
- },
- view: {
- dblClickExpand: false
- },
- data: {
- simpleData: {
- enable: true,
- idKey: "gId",
- pIdKey: "groupParent",
- rootPId: null
- },
- key: {
- name: "groupName"
- }
- },
- callback: {
- onClick: onClickMap
- }
- };
- function onClickMap(event, treeId, treeNode, clickFlag) {
- var zTree = $.fn.zTree.getZTreeObj("groupTree"),
- nodes = zTree.getSelectedNodes(),
- v = "", idlist = "";
- for (var i = 0, l = nodes.length; i < l; i++) {
- v += nodes[i].groupName + ",";
- idlist += nodes[i].gId + ",";
- }
- if (v.length > 0) {
- v = v.substring(0, v.length - 1);
- idlist = idlist.substring(0, idlist.length - 1);
- }
- var cityObj = $("#liableGroupIdName");
- if (cityObj.val() == v) {
- cityObj.attr("value", "");
- $("#gId").attr("value", "");
- } else {
- $("#liableGroupIdName").val(v);
- $("#gId").attr("value", idlist);
- }
- hideMenuMap();
- var groupId = idlist;
- if (groupId != "-1") {
- uParas.initFormSelects("aId", "/ent/groupAccount/queryAccounts?gId=" + groupId, "accountRealName", "aId");
- }
- }
- function hideMenuMap() {
- $("#menuContentMap").fadeOut("fast");
- $("body").unbind("mousedown", onBodyDown);
- }
- });
- </script>
- </body>
- </html>
|