<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
+ path + "/";
request.setAttribute("basePath", basePath);
%>
var basePath = '${basePath}';
.likequery {
font-size: 12px;
height: 32px;
background-color: #E0ECFF;
border-radius: 5px;
outline: none;
}
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-thumb {
background-color: rgba(18, 160, 236, 0.4);
border-radius: 4px;
}
::-webkit-scrollbar:horizontal {
height: 8px;
}
.aaa:HOVER {
cursor: pointer;
background-color: #eee;
width: 100%;
border-radius: 2px;
}
.aaa {
list-style: none;
font-size: 14px;
width: 100%;
}
.ul {
margin: 0;
padding: 0;
}
.rightBtnClass>.menu-line {
display: none;
}
.selectoption {
cursor: pointer;
}
.easyui-tabs {
width: 100%;
height: 100%;
}
onkeyup="likequery()" type="text" placeholder="搜索表名..."
style="width: 100%;margin-top: 20px;padding-left: 5px">
style="overflow:auto;height: 66%;margin-top: 10px;">
style="position:absolute;display:none;background: silver;z-index: 999;">提示
data-options="" closed="true"
style="width:200px;height:100px;padding:15 10 10 10">
target='_blank'
id="exportExcel" href="javascript:void(0)" class="easyui-linkbutton" style="margin-left: 20" onclick="downloadMore('excelMore')">导出EXCEL
data-options="" closed="true"
style="width:200px;height:100px;padding:15 10 10 10">
class="easyui-linkbutton" target='_blank'>导入CSV id="importExcel" href="javascript:void(0)" class="easyui-linkbutton" style="margin-left: 20">导入EXCEL
data-options="modal:true,closed:true"
style="width: 500px; height: 200px; padding: 10px;">
data-options="top:100,border:false,modal:true,closed:true"
style="width: 800px; height: 400px; padding: 0px;">
data-options="" closed="true"
style="width:500px;height:300px;padding:10 10 10 10">
function errorMsg(msg) {
$("#errorMsgId").html(msg);
$(".easyui-dialog").dialog('close');
$("#errorMsgId").dialog('open');
}
function dataExport() {
$(".easyui-dialog").dialog('close');
$('#exporttype').dialog('open');
}
function dialogOpen() {
$("#downloading").dialog('open');
}
function dialogClose() {
$("#downloading").dialog('close');
}
function downloadMore(url) {
var tableName = $("#rightBtn").attr("table");
var dataBase = $("#test").combobox('getValue');
$(".easyui-dialog").dialog('close');
$("#downloading").dialog('open');
$.ajax({
type : "POST",
url : "${basePath}export/" + url,
data : {
tableName : tableName,
dataBase : dataBase
},
dataType : "text",
success : function(data) {
$("#downloading").dialog('close');
var fileType = "CSV";
if (url.indexOf("excelMore") >= 0) {
fileType = "EXCEL";
}
window.open("${basePath}export/downloadFile?filename=" + data + "&fileType=" + fileType);
}
});
}
function dataImport() {
$(".easyui-dialog").dialog('close');
$('#importtype').dialog('open');
var tableName = $("#rightBtn").attr("table");
var dataBase = $("#test").combobox('getValue');
$("#importCsv").attr("tableName", dataBase + "." + tableName);
$("#ucsvTname")[0].value = dataBase + "." + tableName;
}
/* 刷新左侧 */
function refresh1() {
showdbn();
}
function refreshover(img){
$("#refreshimg").attr("src","${basePath}p_w_picpaths/"+img);
}
/* 获取数据库 */
var orgCount = 0;
function showdbn() {
$("#test").combobox({
url : '${basePath}index/showdatabase',
textField : 'database_name',
valueField : 'database_name',
editable : false,
panelHeight : 'auto',
onLoadSuccess : function(data) {
orgCount = data.length;
var showtable = $('#test').combobox('getData');
if (showtable.length > 0) {
$('#test').combobox('select', showtable[0].database_name);
}
},
onSelect : function(record) {
var showtable = $('#test').combobox('getValue');
change();
},
onShowPanel : function() {
// 动态调整高度
if (orgCount > 10) {
$(this).combobox('panel').height(305);
}
}
});
}
$(function() {
showdbn();
ttttt();
});
var showtable;
/* 选择库展示表 */
function change() {
$("#couponprice").html("loading...");
$("#liketable").val("");
var showtable = $("#test").combobox('getValue');
$.ajax({
type : "POST",
url : "${basePath}index/likesql",
data : "databasename=" + showtable,
dataType : "text",
success : function(data) {
if (data != null && data.length != 2) {
var list = eval(data);
var count = list.length;
var name = "";
for (i = 0; i < count; i++) {
name += "
}
$("#couponprice").html(name);
$("#liketable").css('display', 'block');
} else {
$("#couponprice").html("当前库没有表...");
$("#liketable").css('display', 'none');
}
$(".aaa").tooltip({
deltaX : -40,
deltaY : -5,
showDelay : 1000
});
$(".aaa").bind('contextmenu', function(e) {
e.preventDefault();
$('#rightBtn').menu('show', {
left : e.pageX - 10,
top : e.pageY - 10
});
$("#rightBtn").attr("table", $(e.currentTarget).html());
});
}
});
}
/* 中文提示 */
function over(e) {
var tb = e.innerHTML;
var dbn = $("#test").combobox('getValue');
$.ajax({
type : "POST",
url : "${basePath}index/comment",
data : "databasename=" + dbn + "&tablename=" + tb,
dataType : "text",
success : function(data) {
if (data != null) {
var list = eval(data);
var name = list[0].prpt_name;
if (name.indexOf(" does not have property: comment") >= 0) {
name = "无注释";
}
$(".aaa").tooltip({
content : name,
deltaX : -40,
deltaY : -5,
showDelay : 1000
});
}
}
})
}
/* 模糊查询 */
function likequery() {
var tablename = $("#liketable").val();
var showtable = $("#test").combobox('getValue');
$.ajax({
type : "POST",
url : "${basePath}index/likesql",
data : "databasename=" + showtable + "&name=" + tablename,
dataType : "text",
success : function(data) {
if (data != null) {
var list = eval(data);
var count = list.length;
var name = "";
for (i = 0; i < count; i++) {
name += "
}
$("#couponprice").html(name);
$(".aaa").bind('contextmenu', function(e) {
e.preventDefault();
$('#rightBtn').menu('show', {
left : e.pageX - 10,
top : e.pageY - 10
});
$("#rightBtn").attr("table", $(e.currentTarget).html());
});
}
$(".aaa").tooltip({
deltaX : -40,
deltaY : -5,
showDelay : 1000
});
}
})
}
//csv import
function importCsv() {
$('#wimportCsv').window('open');
}
$('#ffimportCsv').form({
onSubmit : function() {
//console.log($("#importCsv").attr("tableName"));
},
success : function(data) {
$.messager.alert("提示", data, "info");
}
});
//右键表结构
function showTdesc(tableName) {
$('#tdesc').datagrid({
rownumbers:true,
url : basePath + 'tabledesc/desc',
method : 'post',
queryParams : {
tableName : tableName,
subject : 'datagrid'
},
columns : [ [
{
field : 'col_name',
title : '列名',
width : 100
},
{
field : 'data_type',
title : '字段类型',
width : 100
},
{
field : 'comment',
title : '备注'
}
] ]
});
$('#tdesc').datagrid('autoSizeColumn', 'comment');
}
/* function showTdesc(tableName) {
$('#tdesc').datagrid({
rownumbers:true,
url : basePath + 'tabledesc/desc',
method : 'post',
queryParams : {
tableName : tableName,
subject : 'datagrid'
},
columns : [ [
{
field : 'col_name',
title : '列名',
width : 100
},
{
field : 'data_type',
title : '字段类型',
width : 100
},
{
field : 'comment',
title : '备注'
}
] ]
});
$('#tdesc').datagrid('autoSizeColumn', 'comment');
} */
function showTprop(tableName) {
$.ajax({
type : "POST",
url : basePath + 'tabledesc/property',
data : {
"tableName" : tableName
},
dataType : "json",
success : function(data) {
//console.log(data);
if (data.error) {
$.messager.alert("提示", data.error, "error");
//alert(data.error);
$('#w').window('close');
} else {
var tfDesc = fuck(data.tfDesc);
var tCSentence = showCreateSentence(data.tCSentence);
tfDesc = tfDesc.concat(tCSentence);
//console.log(tfDesc);
$('#tfdesc').datagrid({
rownumbers:true,
fitColumns : false,
columns : [ [
{
field : 'col_name',
title : '属性名',
width : 100
},
{
field : 'data_type',
title : '值'
},
] ]
});
$('#tfdesc').datagrid('loadData', tfDesc);
}
}
});
}
function ttttt() {
$('#tt').tabs({
onSelect : function(title) {
if (title == '属性') {
setTimeout(function() {
$('#tfdesc').datagrid('autoSizeColumn', 'data_type');
}, 500);
}
}
});
}
function tableDesc(tableName) {
if (tableName) {
$('#w').window('open');
showTdesc(tableName);
setTimeout(function() {
showTprop(tableName);
}, 1000);
} else {
//alert("请选中表名!");
$.messager.alert("提示", "请选中表名!", "info");
}
}
;
function fuck(tfDesc) {
//console.log(111);
var resultTFD = [];
var enTfd = [ 'Database:', 'Owner:', 'CreateTime:', 'LastAccessTime:', 'Location:', 'InputFormat:', 'OutputFormat:', 'Compressed:' ];
var chTfd = [ '数据库:', '拥有者:', '创建日期:', '最后访问日期:', '位置:', '输入格式:', '输出格式:', '压缩格式:' ];
for (var int = 0; int < tfDesc.length; int++) {
var tfDesc_ele = tfDesc[int];
for (var int2 = 0; int2 < enTfd.length; int2++) {
var enTfd_ele = enTfd[int2];
if (tfDesc_ele.col_name.replace(/\s+/g, "") == enTfd_ele) {
tfDesc_ele.col_name = chTfd[int2];
resultTFD.push(tfDesc_ele);
}
}
}
//console.log(resultTFD);
return (resultTFD);
}
//建表语句
function showCreateSentence(data) {
var tCSentence = data;
var createSentence = "";
for (var i = 0; i < tCSentence.length; i++) {
//console.log(tCSentence[i].createtab_stmt);
createSentence += tCSentence[i].createtab_stmt;
}
//console.log(createSentence);
return ({
col_name : '建表语句',
data_type : createSentence
});
}
//biao jie gou end
function callTableDesc() {
var tableName = $("#rightBtn").attr("table");
var dataBase = $("#test").combobox('getValue');
tableDesc(dataBase + "." + tableName);
}
function openWindowDate() {
var tableName = $("#rightBtn").attr("table");
var dataBase = $("#test").combobox('getValue');
var url = "${basePath}DataInstance/DataInstanceInfo?tableName=" + tableName + "&dataBase=" + dataBase;
openWindow(url, "数据实例", 400, 800);
}