main
kgdxpr 1 year ago
parent f3c2d0c21b
commit f7bb33ccb7

@ -24,7 +24,6 @@
top: -1px;
cursor: pointer;
}
</style>
</head>
@ -88,6 +87,10 @@
<script type="text/html" id="table-bar">
<span class="woo-tool-span woo-tool-text-span" lay-event="edit"><a
class="woo-theme-color">编辑</a></span>
<i class="woo-tool-text-delimiter"></i>
<span class="woo-tool-span woo-tool-text-span" lay-event="share"><a
class="woo-theme-color">共享管理</a></span>
<i class="woo-tool-text-delimiter"></i>
<span class="woo-tool-span woo-tool-text-span" lay-event="sub"><a
@ -128,7 +131,7 @@
keyword: $("#system_name").val(),
except_system_id: -1
},
height: 'full-110',
height: 'full-150',
page: {
limit: 15
, layout: ['count', 'prev', 'page', 'next', 'skip']
@ -136,13 +139,12 @@
, next: "下一页"
},
cols: [[
{ type: 'checkbox', width: "5%" },
{ title: '序号', align: 'center', width: "5%", type: 'numbers' },
{ title: '系统名称', field: 'system_name', align: 'center' },
{ title: '访问账号', field: 'prefix', align: 'center', width: "10%" },
{ title: '访问密码', field: 'prefix', align: 'center', width: "10%" },
{ title: '已订阅表个数', field: 'table_cnt', align: 'center', width: "10%" },
{ title: '操作', toolbar: '#table-bar', align: 'center', width: "15%" }
{ title: '访问账号', field: 'user_name', align: 'center', width: "15%" },
{ title: '访问密码', field: 'pwd', align: 'center', width: "15%" },
// { title: '已订阅表个数', field: 'table_cnt', align: 'center', width: "10%" },
{ title: '操作', toolbar: '#table-bar', align: 'center', width: "20%" }
]],
skin: 'line',
toolbar: '#table-toolbar',
@ -153,6 +155,8 @@
table.on('tool(data-table)', function (obj) {
if (obj.event === 'sub') {
window.sub(obj);
} else if (obj.event === 'share') {
window.share(obj);
} else if (obj.event === 'remove') {
window.remove(obj);
} else if (obj.event === 'edit') {
@ -208,12 +212,22 @@
});
}
window.share = function (obj) {
layer.open({
type: 2,
title: '共享',
shade: 0.1,
area: ['650px', '400px'],
content: './share.html?system_id=' + obj.data.system_id
});
}
window.edit = function (obj) {
layer.open({
type: 2,
title: '编辑',
shade: 0.1,
area: ['650px', '320px'],
area: ['650px', '230px'],
content: './update.html?system_id=' + obj.data.system_id
});
}

@ -0,0 +1,135 @@
<!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;">共享表:</label>
<div class="layui-input-block">
<div class="layui-btn-container tag" lay-filter="ipTag" lay-allowclose="true" lay-newTag="true"
id="tag">
</div>
</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'], function () {
var form = layui.form;
var $ = layui.jquery;
var tag = layui.tag;
var systemId = GetQueryString("system_id");
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>添加表' //标签添加按钮提示文本
});
form.on('submit(save)', function (data) {
var _data = {};
//获取标签信息
var buttons = $('#tag button:not(.button-new-tag)');
var ipArray = [];
buttons.each(function () {
var _ip = $(this).html().replace(/<i[^>]*>.*<\/i>/g, '');
ipArray.push(_ip);
});
var ip = ipArray.join(',');
_data['table_names'] = ip;
_data['system_id'] = systemId;
$.ajax({
url: '/QingLong/dataShare/share',
data: _data,
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;
}
});
</script>
</body>
</html>

@ -46,28 +46,20 @@
<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">
<input type="text" id="system_name" name="system_name" lay-verify="required" 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>
<label class="layui-form-label" style="width: 100px !important;"><span
class="require-star"></span>访问账号</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>
<input type="text" id="user_name" name="user_name" lay-verify="required" autocomplete="off"
placeholder="请输入访问账号" class="layui-input input-width" disabled>
</div>
</div>
</div>
</div>
@ -92,56 +84,20 @@
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: "/QingLong/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()
});
$("#user_name").val(res.user_name);
}
});
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: '/QingLong/dataShare/updateSystem',
data: data.field,
@ -166,7 +122,6 @@
return false;
});
function GetQueryString(name, istop) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
@ -176,12 +131,6 @@
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>

Loading…
Cancel
Save