|
|
<!DOCTYPE html>
|
|
|
<html lang="en">
|
|
|
|
|
|
<head>
|
|
|
<meta charset="UTF-8">
|
|
|
<title></title>
|
|
|
<link rel="stylesheet" href="../../../component/pear/css/pear.css" />
|
|
|
<style>
|
|
|
.require-star {
|
|
|
position: absolute;
|
|
|
width: 3px;
|
|
|
height: 14px;
|
|
|
background-color: #ea4335;
|
|
|
top: 12px;
|
|
|
right: 8px;
|
|
|
border-radius: 1.5px;
|
|
|
}
|
|
|
|
|
|
.input-width {
|
|
|
max-width: 455px
|
|
|
}
|
|
|
|
|
|
.layui-form-select {
|
|
|
width: 455px;
|
|
|
}
|
|
|
|
|
|
.layui-btn-container .layui-btn {
|
|
|
margin-right: 10px;
|
|
|
margin-top: 4px;
|
|
|
word-spacing: normal;
|
|
|
}
|
|
|
|
|
|
.layui-table-view .layui-table th {
|
|
|
padding: 0;
|
|
|
border-top: 1px solid #EEEEEE !important;
|
|
|
/* border-left: 1px solid #EEEEEE !important; */
|
|
|
}
|
|
|
</style>
|
|
|
</head>
|
|
|
|
|
|
<body>
|
|
|
<form class="layui-form" action="">
|
|
|
<div class="mainBox">
|
|
|
<div class="main-container">
|
|
|
<div class="layui-form-item">
|
|
|
<label class="layui-form-label" style="width: 100px !important;"><span
|
|
|
class="require-star"></span>系统名称</label>
|
|
|
<div class="layui-input-block">
|
|
|
<input type="text" id="system_name" name="system_name" lay-verify="required|sn"
|
|
|
autocomplete="off" placeholder="请输入系统名称" class="layui-input input-width">
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
|
|
|
<div class="layui-form-item">
|
|
|
<label class="layui-form-label" style="width: 100px !important;">IP</label>
|
|
|
<div class="layui-input-block">
|
|
|
<div class="layui-btn-container tag" lay-filter="ipTag" lay-allowclose="true" lay-newTag="true"
|
|
|
id="tag">
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<script type="text/html" id="ipScript">
|
|
|
{{# layui.each(d, function(index, item){ }}
|
|
|
<button type="button" class="tag-item layui-btn layui-btn-primary layui-btn-sm layui-btn-radius">{{ item }}</button>
|
|
|
{{# }); }}
|
|
|
</script>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
|
|
|
<div class="bottom">
|
|
|
<div class="button-container">
|
|
|
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="save">
|
|
|
<i class="layui-icon layui-icon-ok"></i>
|
|
|
提交
|
|
|
</button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</form>
|
|
|
<script src="../../../component/layui/layui.js"></script>
|
|
|
<script src="../../../component/pear/pear.js"></script>
|
|
|
<script src="./js/tableSelect.js"></script>
|
|
|
|
|
|
<script>
|
|
|
layui.use(['form', 'jquery', 'tag', 'laytpl'], function () {
|
|
|
var form = layui.form;
|
|
|
var $ = layui.jquery;
|
|
|
var tag = layui.tag;
|
|
|
var laytpl = layui.laytpl;
|
|
|
|
|
|
|
|
|
var systemId = GetQueryString("system_id");
|
|
|
|
|
|
// 自定义验证
|
|
|
form.verify({
|
|
|
sn: [/^[\u4e00-\u9fa5a-zA-Z0-9]{2,16}$/, '内容长度限制2-16位']
|
|
|
});
|
|
|
|
|
|
$.ajax({
|
|
|
type: "GET",
|
|
|
async: false,
|
|
|
url: "/dsBase/dataShare/getSystemById?system_id=" + systemId,
|
|
|
success: function (res) {
|
|
|
$("#system_name").val(res.system_name);
|
|
|
var ipArr = res.ip.split(',');
|
|
|
|
|
|
|
|
|
var ipTpl = ipScript.innerHTML,
|
|
|
ipView = document.getElementById('tag');
|
|
|
laytpl(ipTpl).render(ipArr, function (html) {
|
|
|
ipView.innerHTML = html;
|
|
|
tag.render("ipTag", {
|
|
|
skin: 'layui-btn layui-btn-primary layui-btn-sm layui-btn-radius', //标签样式
|
|
|
tagText: '<i class="layui-icon layui-icon-add-1" id="addTag"></i>添加IP' //标签添加按钮提示文本
|
|
|
});
|
|
|
form.render()
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
form.on('submit(save)', function (data) {
|
|
|
//获取标签信息
|
|
|
var buttons = $('#tag button:not(.button-new-tag)');
|
|
|
var ipArray = [];
|
|
|
buttons.each(function () {
|
|
|
var _ip = $(this).html().replace(/<i[^>]*>.*<\/i>/g, '');
|
|
|
if (!isIPorDomain(_ip)) {
|
|
|
layer.msg("IP或域名格式不正确!", {
|
|
|
icon: 2,
|
|
|
time: 2000
|
|
|
});
|
|
|
return false;
|
|
|
}
|
|
|
ipArray.push(_ip);
|
|
|
});
|
|
|
var ip = ipArray.join(',');
|
|
|
data.field['ip'] = ip;
|
|
|
data.field['system_id'] = systemId;
|
|
|
|
|
|
$.ajax({
|
|
|
url: '/dsBase/dataShare/updateSystem',
|
|
|
data: data.field,
|
|
|
type: 'post',
|
|
|
success: function (result) {
|
|
|
if (result.success) {
|
|
|
layer.msg("修改成功!", {
|
|
|
icon: 1,
|
|
|
time: 1300
|
|
|
}, function () {
|
|
|
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
|
|
parent.layui.table.reload("data-table");
|
|
|
});
|
|
|
} else {
|
|
|
layer.msg(result.message, {
|
|
|
icon: 2,
|
|
|
time: 2000
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
return false;
|
|
|
});
|
|
|
|
|
|
|
|
|
function GetQueryString(name, istop) {
|
|
|
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
|
|
var r = window.location.search.substr(1).match(reg);
|
|
|
if (typeof (istop) != "undefined") r = top.location.search.substr(1).match(reg);
|
|
|
|
|
|
if (r != null) return unescape(r[2]);
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
//判断字符串是否为IP或域名
|
|
|
function isIPorDomain(str) {
|
|
|
var reg = /^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$|^([a-zA-Z0-9]+(-[a-zA-Z0-9]+)*\.)+[a-zA-Z]{2,}$/;
|
|
|
return reg.test(str);
|
|
|
}
|
|
|
|
|
|
});
|
|
|
</script>
|
|
|
|
|
|
</body>
|
|
|
|
|
|
</html> |