SQL工作台添加数据库表条目拖入后自动插入查询SQL语句的功能

This commit is contained in:
datagear 2019-08-06 20:02:47 +08:00
parent fd7283c4d7
commit 1c984166c7
4 changed files with 64 additions and 4 deletions

View File

@ -55,6 +55,7 @@
-----------------------------------------
新增:数据导入/导出功能支持CSV、SQL、Excel格式数据的导入导出操作
改进SQL工作台支持拖入数据库表条目后自动插入查询SQL语句
改进:主页选项卡标签右下角的更多操作区域添加明确图标标识;
改进:主页数据库更多操作菜单改为最上层显示并适当调整大小;
改进:主页数据库菜单的表、视图条目替换为更合适的图标;

View File

@ -247,7 +247,27 @@
//jstree的_append_json_data方法有“if(data.d){data = data.d;...}”的逻辑,可以用来适配数据
pagingData.d = pagingData.items;
};
po.toDraggableNode = function(tree, node)
{
var $node = tree.get_node(node.id, true);
var $anchor = $(".jstree-anchor", $node);
if($anchor.hasClass("ui-draggable"))
return;
$anchor.draggable(
{
helper: "clone",
appendTo: ".main-page-content",
classes:
{
"ui-draggable" : "table-draggable",
"ui-draggable-dragging" : "ui-widget ui-widget-content ui-corner-all ui-widget-shadow table-draggable-helper"
}
});
};
po.isSearchTable = function()
{
var $icon = po.element("#schemaSearchSwitch > .ui-icon");
@ -327,7 +347,7 @@
});
//使"#schemaOperationMenu"可以最上层展示
po.element(".ui-layout-west").css("z-index", 6);
po.element(".ui-layout-west").css("z-index", 3);
po.element("#systemSetMenu").menu(
{
@ -859,6 +879,14 @@
tree.select_node(data.node);
}
})
.bind("hover_node.jstree", function(event, data)
{
if($.enableTableNodeDraggable && po.isTableNode(data.node))
{
var tree = $(this).jstree(true);
po.toDraggableNode(tree, data.node);
}
});
po.element("#schemaSearchForm").submit(function()

View File

@ -176,6 +176,30 @@ Schema schema 数据库不允许为null
po.sqlEditor.focus();
po.sqlEditor.navigateFileEnd();
//数据库表条目拖入自动插入SQL
$.enableTableNodeDraggable = true;
po.element("#${pageId}-sql-editor").droppable(
{
accept: ".table-draggable",
drop: function(event, ui)
{
var srcText = ui.draggable.text();
if(srcText)
{
var cursor = po.sqlEditor.getCursorPosition();
if(cursor.column == 0)
srcText = "SELECT * FROM " +srcText+";";
po.sqlEditor.moveCursorToPosition(cursor);
po.sqlEditor.session.insert(cursor, srcText);
po.sqlEditor.focus();
}
}
});
//当前在执行的SQL语句数
po.executingSqlCount = -1;

View File

@ -819,8 +819,8 @@ table.dataTable tbody tr .column-check .row-data-state .ui-icon{
.main-page-content .schema-panel .schema-panel-head .schema-panel-operation .search .schema-search-switch{
display: inline-block;
float: left;
opacity: 0.6;
filter: Alpha(Opacity=60);
opacity: 0.4;
filter: Alpha(Opacity=40);
cursor: pointer;
}
.main-page-content .schema-panel .schema-panel-head .schema-panel-operation .search .keyword-input-parent{
@ -887,6 +887,13 @@ table.dataTable tbody tr .column-check .row-data-state .ui-icon{
font-weight: bold;
font-style: italic;
}
.main-page-content .table-draggable-helper{
padding: 0.5em 1em;
z-index: 6;
opacity: 0.7;
filter: Alpha(Opacity=70);
border-style: dotted;
}
.main-page-content .main-tabs{
position: absolute;
display: block;