sql执行器增加上下布局拖拽

This commit is contained in:
diant
2023-06-01 21:37:26 +08:00
parent 76c8b83284
commit 6e4b226a46
14 changed files with 147 additions and 43 deletions

View File

@@ -51,7 +51,7 @@
left join ( left join (
select s.owner, s.table_name, s.column_name,s.POSITION, cons.constraint_type from all_cons_columns s select s.owner, s.table_name, s.column_name,s.POSITION, cons.constraint_type from all_cons_columns s
join all_constraints cons on s.owner = cons.owner and join all_constraints cons on s.owner = cons.owner and
s.constraint_name = cons.constraint_name where cons.constraint_type in ('P', 'U', 'R') s.constraint_name = cons.constraint_name where cons.constraint_type in ('P', 'U', 'R')--只选择constraint_type为'P'(主键)、'U'(唯一键)和'R'(外键)的约束类型
)cons on t.owner = cons.owner and t.table_name = cons.table_name and t.column_name = cons.column_name )cons on t.owner = cons.owner and t.table_name = cons.table_name and t.column_name = cons.column_name
left join ( left join (
select comments.owner, comments.table_name, comments.column_name, comments.comments select comments.owner, comments.table_name, comments.column_name, comments.comments

View File

@@ -51,7 +51,7 @@
left join ( left join (
select s.owner, s.table_name, s.column_name,s.POSITION, cons.constraint_type from all_cons_columns s select s.owner, s.table_name, s.column_name,s.POSITION, cons.constraint_type from all_cons_columns s
join all_constraints cons on s.owner = cons.owner and join all_constraints cons on s.owner = cons.owner and
s.constraint_name = cons.constraint_name where cons.constraint_type in ('P', 'U', 'R') s.constraint_name = cons.constraint_name where cons.constraint_type in ('P', 'U', 'R')--只选择constraint_type为'P'(主键)、'U'(唯一键)和'R'(外键)的约束类型
)cons on t.owner = cons.owner and t.table_name = cons.table_name and t.column_name = cons.column_name )cons on t.owner = cons.owner and t.table_name = cons.table_name and t.column_name = cons.column_name
left join ( left join (
select comments.owner, comments.table_name, comments.column_name, comments.comments select comments.owner, comments.table_name, comments.column_name, comments.comments

View File

@@ -44,9 +44,8 @@ public class DmServiceImpl extends DbBaseService {
public String getQueryPageSql(DataViewParam dataViewParam) { public String getQueryPageSql(DataViewParam dataViewParam) {
String queryColumns = StringUtils.defaultIfBlank(dataViewParam.getRetainColumn(), "*"); String queryColumns = StringUtils.defaultIfBlank(dataViewParam.getRetainColumn(), "*");
if(!Objects.equals(queryColumns, "*")){ if(!Objects.equals(queryColumns, "*")){
queryColumns = Arrays.stream(queryColumns.split(",")) //给字段加上双引号,解决关键字问题
.map(word -> "\"" + word + "\"") queryColumns = Arrays.stream(queryColumns.split(",")).map(word -> "\"" + word + "\"").collect(Collectors.joining(","));
.collect(Collectors.joining(","));
} }
StringBuilder sqlSb = new StringBuilder(); StringBuilder sqlSb = new StringBuilder();
sqlSb.append(String.format("select %s from %s.%s", queryColumns, dataViewParam.getDbName(), dataViewParam.getTableName())); sqlSb.append(String.format("select %s from %s.%s", queryColumns, dataViewParam.getDbName(), dataViewParam.getTableName()));

View File

@@ -53,9 +53,8 @@ public class OracleServiceImpl extends DbBaseService {
public String getQueryPageSql(DataViewParam dataViewParam) { public String getQueryPageSql(DataViewParam dataViewParam) {
String queryColumns = StringUtils.defaultIfBlank(dataViewParam.getRetainColumn(), "*"); String queryColumns = StringUtils.defaultIfBlank(dataViewParam.getRetainColumn(), "*");
if(!Objects.equals(queryColumns, "*")){ if(!Objects.equals(queryColumns, "*")){
queryColumns = Arrays.stream(queryColumns.split(",")) //给字段加上双引号,解决关键字问题
.map(word -> "\"" + word + "\"") queryColumns = Arrays.stream(queryColumns.split(",")).map(word -> "\"" + word + "\"").collect(Collectors.joining(","));
.collect(Collectors.joining(","));
} }
StringBuilder sqlSb = new StringBuilder(); StringBuilder sqlSb = new StringBuilder();
sqlSb.append(String.format("select %s from %s.%s", queryColumns, dataViewParam.getDbName(), dataViewParam.getTableName())); sqlSb.append(String.format("select %s from %s.%s", queryColumns, dataViewParam.getDbName(), dataViewParam.getTableName()));

View File

@@ -90,9 +90,8 @@ public class SqlserverServiceImpl extends DbBaseService {
public String getQueryPageSql(DataViewParam dataViewParam) { public String getQueryPageSql(DataViewParam dataViewParam) {
String queryColumns = StringUtils.defaultIfBlank(dataViewParam.getRetainColumn(), "*"); String queryColumns = StringUtils.defaultIfBlank(dataViewParam.getRetainColumn(), "*");
if(!Objects.equals(queryColumns, "*")){ if(!Objects.equals(queryColumns, "*")){
queryColumns = Arrays.stream(queryColumns.split(",")) //给字段加上双引号,解决关键字问题
.map(word -> "\"" + word + "\"") queryColumns = Arrays.stream(queryColumns.split(",")).map(word -> "\"" + word + "\"").collect(Collectors.joining(","));
.collect(Collectors.joining(","));
} }
Integer pageNum = dataViewParam.getPageNum(); Integer pageNum = dataViewParam.getPageNum();
Integer pageSize = dataViewParam.getPageSize(); Integer pageSize = dataViewParam.getPageSize();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="favicon-db.png"><title>数据库文档管理</title><link href="css/chunk-vendors.2fa4c9b3.css" rel="preload" as="style"><link href="css/index.88462938.css" rel="preload" as="style"><link href="js/chunk-vendors.6270548d.js" rel="preload" as="script"><link href="js/index.dada83b9.js" rel="preload" as="script"><link href="css/chunk-vendors.2fa4c9b3.css" rel="stylesheet"><link href="css/index.88462938.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but zyplayer-db-ui doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/chunk-vendors.6270548d.js"></script><script src="js/index.dada83b9.js"></script></body></html> <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="favicon-db.png"><title>数据库文档管理</title><link href="css/chunk-vendors.2fa4c9b3.css" rel="preload" as="style"><link href="css/index.4edbcddf.css" rel="preload" as="style"><link href="js/chunk-vendors.6270548d.js" rel="preload" as="script"><link href="js/index.8babff14.js" rel="preload" as="script"><link href="css/chunk-vendors.2fa4c9b3.css" rel="stylesheet"><link href="css/index.4edbcddf.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but zyplayer-db-ui doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/chunk-vendors.6270548d.js"></script><script src="js/index.8babff14.js"></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -349,6 +349,7 @@
border-radius: 5px; border-radius: 5px;
background: #ccc; background: #ccc;
color: #888; color: #888;
text-align: center;
} }
::-webkit-scrollbar-track { ::-webkit-scrollbar-track {
background: rgba(0, 0, 0, 0.1); background: rgba(0, 0, 0, 0.1);

View File

@@ -52,6 +52,8 @@ export default {
height: function () { height: function () {
this.$nextTick(function () { this.$nextTick(function () {
this.editor.resize() this.editor.resize()
//更新编辑器高度
document.getElementById("aceEditorId").style.height = this.height + "px";;
}) })
}, },
width: function () { width: function () {

View File

@@ -300,7 +300,9 @@ export default {
</script> </script>
<style scoped> <style scoped>
/deep/ .el-tabs--card > .el-tabs__header { /deep/ .el-tabs, .el-tabs--card, .el-tabs--top{
height: 30px;
font-size: 12px;
margin: 0 0 5px; margin: 0 0 5px;
} }
@@ -310,16 +312,6 @@ export default {
font-size: 12px; font-size: 12px;
} }
/deep/ .el-tabs__nav-next {
line-height: 33px;
font-size: 20px;
}
/deep/ .el-tabs__nav-prev {
line-height: 33px;
font-size: 20px;
}
.contextmenu { .contextmenu {
width: 100px; width: 100px;
margin: 0; margin: 0;

View File

@@ -1,12 +1,13 @@
<template> <template>
<div class="data-executor-vue"> <div class="data-executor-vue" :style="{ height: rightBodyHeight + 'px' }">
<div style="padding: 0 10px 10px;height: 100%;box-sizing: border-box;"> <div style="padding: 0 10px 10px;height: 100%;box-sizing: border-box;">
<el-card style="margin-bottom: 5px;"> <el-card id="maintopcard" :style="{ height: rightBodyTopHeight + 'px' }">
<ace-editor v-model="sqlExecutorContent" ref="sqlEditor" @init="sqlExecutorInit" lang="sql" <ace-editor id="aceEditorId" v-model="sqlExecutorContent" ref="sqlEditor" @init="sqlExecutorInit"
lang="sql"
theme="monokai" theme="monokai"
width="100%" height="20" :options="sqlEditorConfig" :source="executorSource" width="100%" :height="aceEditorHeight" :options="sqlEditorConfig" :source="executorSource"
@cursorSelection="cursorSelection" style="margin-bottom: 5px;"></ace-editor> @cursorSelection="cursorSelection"></ace-editor>
<div> <div style="margin-top: 5px;">
<el-button v-if="sqlExecuting" v-on:click="cancelExecutorSql" type="primary" plain size="mini" <el-button v-if="sqlExecuting" v-on:click="cancelExecutorSql" type="primary" plain size="mini"
icon="el-icon-video-pause">取消执行 icon="el-icon-video-pause">取消执行
</el-button> </el-button>
@@ -37,7 +38,10 @@
</el-input> </el-input>
</div> </div>
</el-card> </el-card>
<el-card> <div ref="topResize" class="top-resize">
<i ref="topResizeBar">. . .</i>
</div>
<el-card :style="{ height: rightBodyButtomHeight + 'px' }">
<div style="position: relative;"> <div style="position: relative;">
<div style="position: absolute;right: 0;z-index: 1;"> <div style="position: absolute;right: 0;z-index: 1;">
<!-- 复制选中行 --> <!-- 复制选中行 -->
@@ -53,9 +57,11 @@
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</div> </div>
<el-tabs v-model="executeShowTable" type="border-card" @tab-click="tabHandleClick"> <el-tabs :style="{ height: rightBodyButtomTabsHeight + 'px' }" v-model="executeShowTable"
type="border-card" @tab-click="tabHandleClick">
<el-tab-pane label="执行历史" name="tabHistory"> <el-tab-pane label="执行历史" name="tabHistory">
<el-table :data="myHistoryListList" stripe border style="width: 100%; margin-bottom: 5px;"> <el-table :data="myHistoryListList" stripe border
:style="{ height: rightBodyButtomTabsContentHeight + 'px',overflow: 'auto' }">
<el-table-column prop="createTime" label="执行时间" width="160px"></el-table-column> <el-table-column prop="createTime" label="执行时间" width="160px"></el-table-column>
<el-table-column prop="content" label="SQL"> <el-table-column prop="content" label="SQL">
<template slot-scope="scope"> <template slot-scope="scope">
@@ -76,7 +82,8 @@
</el-table> </el-table>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="我的收藏" name="tabFavorite"> <el-tab-pane label="我的收藏" name="tabFavorite">
<el-table :data="myFavoriteList" stripe border style="width: 100%; margin-bottom: 5px;" <el-table :data="myFavoriteList" stripe border
:style="{ height: rightBodyButtomTabsContentHeight + 'px',overflow: 'auto' }"
v-infinite-scroll> v-infinite-scroll>
<el-table-column prop="createTime" label="执行时间" width="160px"></el-table-column> <el-table-column prop="createTime" label="执行时间" width="160px"></el-table-column>
<el-table-column prop="content" label="SQL"> <el-table-column prop="content" label="SQL">
@@ -99,7 +106,10 @@
</el-table> </el-table>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="信息" name="tabInfo" v-if="!!executeResultInfo"> <el-tab-pane label="信息" name="tabInfo" v-if="!!executeResultInfo">
<pre class="execute-result-info">{{ executeResultInfo }}</pre> <pre class="execute-result-info"
:style="{ height: rightBodyButtomTabsContentHeight + 'px',overflow: 'auto' }">{{
executeResultInfo
}}</pre>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="错误" name="tabError" v-if="!!executeError"> <el-tab-pane label="错误" name="tabError" v-if="!!executeError">
<div style="color: #f00;">{{ executeError }}</div> <div style="color: #f00;">{{ executeError }}</div>
@@ -195,6 +205,12 @@ export default {
directives: {Clickoutside}, directives: {Clickoutside},
data() { data() {
return { return {
rightBodyHeight: 0,
rightBodyTopHeight: 0,
rightBodyButtomHeight: 0,
aceEditorHeight: 0,
rightBodyButtomTabsHeight: 0,
rightBodyButtomTabsContentHeight: 0,
//遮罩层 //遮罩层
loadingAll: false, loadingAll: false,
@@ -231,7 +247,7 @@ export default {
myHistoryListList: [], myHistoryListList: [],
// 选择复制 // 选择复制
choiceResultObj: {}, choiceResultObj: {},
//
exportConditionVisible: false, exportConditionVisible: false,
conditionDataCols: [], conditionDataCols: [],
conditionDataColsChoice: [], conditionDataColsChoice: [],
@@ -245,8 +261,6 @@ export default {
enableBasicAutocompletion: true, enableBasicAutocompletion: true,
enableSnippets: true, enableSnippets: true,
enableLiveAutocompletion: true, enableLiveAutocompletion: true,
minLines: 15,
maxLines: 15,
}, },
executorSource: {}, executorSource: {},
// sql参数 // sql参数
@@ -259,8 +273,17 @@ export default {
'ace-editor': aceEditor 'ace-editor': aceEditor
}, },
mounted: function () { mounted: function () {
this.height = 190;
this.loadDatasourceList(); this.loadDatasourceList();
this.dragChangeTopHeight();
//计算高度
this.elementHeightCalculation();
setTimeout(() => {
//主体上半部分高度
let bodyTopHeight = document.getElementById('maintopcard').offsetHeight;
this.aceEditorHeight = bodyTopHeight - 50;
}, 100)
}, },
activated() { activated() {
this.loadDatasourceList(); this.loadDatasourceList();
@@ -289,6 +312,9 @@ export default {
paramArr.forEach(item => { paramArr.forEach(item => {
this.sqlParams.push({key: item, value: this.sqlParamHistory[item] || ''}); this.sqlParams.push({key: item, value: this.sqlParamHistory[item] || ''});
}); });
if (this.sqlParams.length > 0) {
}
this.sqlParamWaiting = false; this.sqlParamWaiting = false;
}, 300); }, 300);
} }
@@ -474,7 +500,7 @@ export default {
resIndex++; resIndex++;
//动态设置表格高度,尽量避免出现滚动条 //动态设置表格高度,尽量避免出现滚动条
if (result.selectCount) { if (result.selectCount) {
this.height = 170; this.height = this.rightBodyButtomTabsContentHeight - 40;
} }
}); });
//多个结果情况下,且点击分页 //多个结果情况下,且点击分页
@@ -581,7 +607,9 @@ export default {
resIndex++; resIndex++;
//动态设置表格高度,尽量避免出现滚动条 //动态设置表格高度,尽量避免出现滚动条
if (result.selectCount) { if (result.selectCount) {
this.height = 170; this.height = this.rightBodyButtomTabsContentHeight -40;
}else{
this.height = this.rightBodyButtomTabsContentHeight -20;
} }
}); });
//多个结果情况下,且点击分页 //多个结果情况下,且点击分页
@@ -775,6 +803,69 @@ export default {
this.uxGridCell.style.border = 'none' this.uxGridCell.style.border = 'none'
} }
}, },
dragChangeTopHeight: function () {
// 保留this引用
let resize = this.$refs.topResize;
let resizeBar = this.$refs.topResizeBar;
resize.onmousedown = e => {
let startY = e.clientY;
// 颜色改变提醒
resize.style.background = "#ccc";
resizeBar.style.background = "#aaa";
resize.left = resize.offsetLeft;
document.onmousemove = e2 => {
// 计算并应用位移量
let endY = e2.clientY;
let moveLen = startY - endY;
if ((moveLen < 0 && this.rightBodyTopHeight < 450) || (moveLen > 0 && this.rightBodyTopHeight > 100)) {
startY = endY;
this.rightBodyTopHeight -= moveLen;
if (this.rightBodyTopHeight < 100) {
this.rightBodyTopHeight = 100;
}
if (this.rightBodyTopHeight > 450) {
this.rightBodyTopHeight = 450;
}
//浏览器页面高度
let winHeight = window.innerHeight;
//主体高度
let bodyHeight = winHeight - 82;
this.rightBodyHeight = bodyHeight;
let bodyButtomHeight = bodyHeight - this.rightBodyTopHeight - 10;
this.rightBodyButtomHeight = bodyButtomHeight;
this.rightBodyButtomTabsHeight = bodyButtomHeight - 20;
this.rightBodyButtomTabsContentHeight = this.rightBodyButtomTabsHeight - 50
//虚拟表格高度
this.height = this.rightBodyButtomTabsContentHeight-40;
//触发编辑器高度变化监听
this.aceEditorHeight = this.rightBodyTopHeight - 50;
}
};
document.onmouseup = () => {
// 颜色恢复
resize.style.background = "#fafafa";
resizeBar.style.background = "#ccc";
document.onmousemove = null;
document.onmouseup = null;
};
return false;
};
},
elementHeightCalculation(){
//浏览器页面高度
let winHeight = window.innerHeight;
//主体高度
let bodyHeight = winHeight - 82;
this.rightBodyHeight = bodyHeight;
let bodyTopHeight = bodyHeight * 0.55;
this.rightBodyTopHeight = bodyTopHeight;
let bodyButtomHeight = bodyHeight - bodyTopHeight - 10;
this.rightBodyButtomHeight = bodyButtomHeight;
this.rightBodyButtomTabsHeight = bodyButtomHeight - 20;
this.rightBodyButtomTabsContentHeight = this.rightBodyButtomTabsHeight - 50;
//虚拟表格高度
this.height = this.rightBodyButtomTabsContentHeight;
}
} }
} }
</script> </script>
@@ -838,7 +929,8 @@ export default {
overflow: auto; overflow: auto;
background: #263238; background: #263238;
color: #fff; color: #fff;
padding: 10px; padding: 0 10px;
margin: 0;
border-radius: 6px; border-radius: 6px;
} }
@@ -887,4 +979,24 @@ export default {
/deep/ .elx-table .elx-body--column.col--ellipsis > .elx-cell::-webkit-scrollbar { /deep/ .elx-table .elx-body--column.col--ellipsis > .elx-cell::-webkit-scrollbar {
display: none; display: none;
} }
.top-resize {
width: 100%;
height: 5px;
cursor: s-resize;
background: #fafafa;
display: flex;
}
.top-resize i {
width: 35px;
height: 5px;
display: inline-block;
line-height: 0px;
border-radius: 5px;
background: #ccc;
color: #888;
text-align: center;
margin: auto;
}
</style> </style>