You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

357 lines
14 KiB

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="../../../component/pear/css/pear.css" />
<style>
.woo-tool-text-delimiter {
width: 1px;
height: 12px;
background: #EEEEEE;
display: inline-block;
margin: 0 6px 0 4px;
}
.woo-theme-color {
color: #2d8cf0 !important;
}
.woo-tool-span {
margin: 0 3px;
position: relative;
top: -1px;
cursor: pointer;
}
.layui-table-tool-temp {
padding-right: 0;
}
</style>
</head>
<body class="pear-container layui-form">
<div class="layui-card">
<div class="layui-card-body">
<table id="data-table"></table>
</div>
</div>
<script type="text/html" id="table-toolbar">
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="batchSub">
<i class="layui-icon layui-icon-add-1"></i>
批量订阅
</button>
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="batchCancelSub">
<i class="layui-icon layui-icon-add-1"></i>
批量取消订阅
</button>
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="refreshTable">
<i class="layui-icon layui-icon-refresh"></i>
刷新表
</button>
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="return" style="float: right;">
<i class="layui-icon layui-icon-return"></i>
返回
</button>
</script>
<script type="text/html" id="table-bar">
{{# if(d.subscrib_system_id > 0){ }}
<span class="woo-tool-span woo-tool-text-span" lay-event="sub"><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="cancelSub"><a
class="woo-theme-color">取消订阅</a></span>
{{# } else { }}
<span class="woo-tool-span woo-tool-text-span" lay-event="sub"><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="updateMemo"><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="viewTableStructure"><a
class="woo-theme-color">查看表结构</a></span>
</script>
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>
<script>
layui.use(['table', 'form', 'jquery', 'common', 'laytpl'], function () {
var table = layui.table;
var form = layui.form;
var $ = layui.jquery;
var common = layui.common;
var laytpl = layui.laytpl;
var subscribSystemId = GetQueryString("subscrib_system_id");
var publishSystemId = GetQueryString("publish_system_id");
tableRender();
function tableRender() {
table.render({
elem: '#data-table',
url: '/dsBase/dataShare/getPublishSystemAllTable',
where: {
keyword: $("#system_name").val(),
subscrib_system_id: subscribSystemId,
publish_system_id: publishSystemId
},
height: 'full-60',
page: {
limit: 15
, layout: ['count', 'prev', 'page', 'next', 'skip']
, prev: "上一页"
, next: "下一页"
},
cols: [[
{ type: 'checkbox', width: "5%" },
{ title: '序号', align: 'center', width: "10%", type: 'numbers' },
{ title: '表名', field: 'table_name', align: 'center' },
{ title: '表描述', field: 'memo', align: 'center' },
{ title: '状态', field: 'status_name', align: 'center' },
{ title: '订阅范围', field: 'sub_scope', align: 'center' },
{ title: '操作', toolbar: '#table-bar', align: 'center', width: "25%" }
]],
skin: 'line',
toolbar: '#table-toolbar',
defaultToolbar: [],
parseData: function (res) {
var array = res.data;
for (var i = 0; i < array.length; i++) {
if (array[i].subscrib_system_id > 0) {
res.data[i].status_name = '已订阅';
} else {
res.data[i].status_name = '未订阅';
}
switch (array[i].type_id) {
case 0:
res.data[i].sub_scope = '全部';
break;
case 1:
res.data[i].sub_scope = '本市';
break;
case 2:
res.data[i].sub_scope = '本区(县)';
break;
case 3:
res.data[i].sub_scope = '本单位(校)';
break;
default:
res.data[i].sub_scope = '--';
break;
}
}
return res;
}
});
}
table.on('tool(data-table)', function (obj) {
if (obj.event === 'sub') {
window.sub(obj);
} else if (obj.event === 'cancelSub') {
window.cancelSub(obj);
} else if (obj.event === 'updateMemo') {
window.updateMemo(obj);
} else if (obj.event === 'viewTableStructure') {
window.viewTableStructure(obj);
}
});
table.on('toolbar(data-table)', function (obj) {
if (obj.event === 'batchSub') {
window.batchSub(obj);
} else if (obj.event === 'batchCancelSub') {
window.batchCancelSub(obj);
} else if (obj.event === 'refreshTable') {
window.refreshTable();
} else if (obj.event === 'return') {
parent.layer.close(parent.layer.getFrameIndex(window.name));
parent.layui.table.reload("data-table");
}
});
window.sub = function (obj) {
layer.open({
type: 2,
title: '设置数据范围',
shade: 0.1,
area: ['650px', '220px'],
content: './specified_range.html?system_id=' + subscribSystemId + "&tables_name=" + obj.data.table_name
});
}
window.batchSub = function (obj) {
var tablesName = common.checkField(obj, 'table_name');
if (tablesName === "") {
layer.msg("请选择要批量订阅的数据!", {
icon: 2,
time: 2000
});
return false;
}
layer.open({
type: 2,
title: '设置数据范围',
shade: 0.1,
area: ['650px', '220px'],
content: './specified_range.html?system_id=' + subscribSystemId + "&tables_name=" + tablesName
});
}
window.cancelSub = function (obj) {
layer.confirm('确定要取消订阅吗?', {
icon: 3,
title: '提示'
}, function (index) {
layer.close(index);
$.ajax({
url: "/dsBase/dataShare/delSubscribTable",
data: { subscrib_system_id: subscribSystemId, table_names: obj.data.table_name },
type: 'post',
success: function (result) {
if (result.success) {
layer.msg('取消订阅成功!', {
icon: 1,
time: 1000
}, function () {
table.reload('data-table');
});
} else {
layer.msg(result.message, {
icon: 2,
time: 1000
});
}
},
error: function (xhr, status, error) {
layer.close(loading);
console.log('请求出错:' + error + ',' + status);
}
});
});
}
window.batchCancelSub = function (obj) {
var tablesName = common.checkField(obj, 'table_name');
if (tablesName === "") {
layer.msg("请选择要批量取消订阅的数据!", {
icon: 2,
time: 2000
});
return false;
}
layer.confirm('确定要取消订阅吗?', {
icon: 3,
title: '提示'
}, function (index) {
layer.close(index);
$.ajax({
url: "/dsBase/dataShare/delSubscribTable",
data: { subscrib_system_id: subscribSystemId, table_names: tablesName },
type: 'post',
success: function (result) {
if (result.success) {
layer.msg('取消订阅成功!', {
icon: 1,
time: 1000
}, function () {
table.reload('data-table');
});
} else {
layer.msg(result.message, {
icon: 2,
time: 1000
});
}
},
error: function (xhr, status, error) {
layer.close(loading);
console.log('请求出错:' + error + ',' + status);
}
});
});
}
window.updateMemo = function (obj) {
layer.open({
type: 2,
title: '修改表描述',
shade: 0.1,
area: ['650px', '180px'],
content: './update_memo.html?table_name=' + obj.data.table_name
});
}
window.viewTableStructure = function (obj) {
layer.open({
type: 2,
title: '查看表结构',
shade: 0.1,
area: ['800px', '500px'],
content: './view_table_structure.html?table_name=' + obj.data.table_name
});
}
window.refreshTable = function () {
$.ajax({
url: "/dsBase/dataShare/refreshTable",
type: 'post',
success: function (result) {
if (result.success) {
layer.msg('刷新成功!', {
icon: 1,
time: 1000
}, function () {
table.reload('data-table');
});
} else {
layer.msg(result.message, {
icon: 2,
time: 1000
});
}
},
error: function (xhr, status, error) {
layer.close(loading);
console.log('请求出错:' + error + ',' + status);
}
});
}
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>