增加sql美化功能,界面优化
This commit is contained in:
@@ -314,6 +314,7 @@ public class DatabaseDocController {
|
|||||||
excelWriter.finish();
|
excelWriter.finish();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
return DocDbResponseJson.error("导出失败:" + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return DocDbResponseJson.ok();
|
return DocDbResponseJson.ok();
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,2 +1,2 @@
|
|||||||
!function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var r=window.webpackJsonp;window.webpackJsonp=function(t,c,a){for(var u,i,f,l=0,s=[];l<t.length;l++)i=t[l],o[i]&&s.push(o[i][0]),o[i]=0;for(u in c)Object.prototype.hasOwnProperty.call(c,u)&&(e[u]=c[u]);for(r&&r(t,c,a);s.length;)s.shift()();if(a)for(l=0;l<a.length;l++)f=n(n.s=a[l]);return f};var t={},o={2:0};n.e=function(e){function r(){u.onerror=u.onload=null,clearTimeout(i);var n=o[e];0!==n&&(n&&n[1](new Error("Loading chunk "+e+" failed.")),o[e]=void 0)}var t=o[e];if(0===t)return new Promise(function(e){e()});if(t)return t[2];var c=new Promise(function(n,r){t=o[e]=[n,r]});t[2]=c;var a=document.getElementsByTagName("head")[0],u=document.createElement("script");u.type="text/javascript",u.charset="utf-8",u.async=!0,u.timeout=12e4,n.nc&&u.setAttribute("nonce",n.nc),u.src=n.p+""+e+".js?"+{0:"979d218e1203f1aad53a",1:"cc6310ae19e08e383d4b"}[e];var i=setTimeout(r,12e4);return u.onerror=u.onload=r,a.appendChild(u),c},n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:t})},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="",n.oe=function(e){throw console.error(e),e}}([]);
|
!function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var r=window.webpackJsonp;window.webpackJsonp=function(t,c,u){for(var i,a,f,l=0,s=[];l<t.length;l++)a=t[l],o[a]&&s.push(o[a][0]),o[a]=0;for(i in c)Object.prototype.hasOwnProperty.call(c,i)&&(e[i]=c[i]);for(r&&r(t,c,u);s.length;)s.shift()();if(u)for(l=0;l<u.length;l++)f=n(n.s=u[l]);return f};var t={},o={2:0};n.e=function(e){function r(){i.onerror=i.onload=null,clearTimeout(a);var n=o[e];0!==n&&(n&&n[1](new Error("Loading chunk "+e+" failed.")),o[e]=void 0)}var t=o[e];if(0===t)return new Promise(function(e){e()});if(t)return t[2];var c=new Promise(function(n,r){t=o[e]=[n,r]});t[2]=c;var u=document.getElementsByTagName("head")[0],i=document.createElement("script");i.type="text/javascript",i.charset="utf-8",i.async=!0,i.timeout=12e4,n.nc&&i.setAttribute("nonce",n.nc),i.src=n.p+""+e+".js?"+{0:"816b76cc3007c7726f16",1:"1ecabc6d379552a7c3f7"}[e];var a=setTimeout(r,12e4);return i.onerror=i.onload=r,u.appendChild(i),c},n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:t})},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="",n.oe=function(e){throw console.error(e),e}}([]);
|
||||||
//# sourceMappingURL=doc-db-manifest.js.map?a71aaf68ea572bbceb8b
|
//# sourceMappingURL=doc-db-manifest.js.map?11ddea231a2159bfc0e8
|
||||||
File diff suppressed because one or more lines are too long
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<script type="text/javascript" src="doc-db-manifest.js?a71aaf68ea572bbceb8b"></script><script type="text/javascript" src="doc-db-vendor.js?cc6310ae19e08e383d4b"></script><script type="text/javascript" src="doc-db-index.js?979d218e1203f1aad53a"></script></body>
|
<script type="text/javascript" src="doc-db-manifest.js?11ddea231a2159bfc0e8"></script><script type="text/javascript" src="doc-db-vendor.js?1ecabc6d379552a7c3f7"></script><script type="text/javascript" src="doc-db-index.js?816b76cc3007c7726f16"></script></body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|||||||
19
zyplayer-doc-ui/db-ui/package-lock.json
generated
19
zyplayer-doc-ui/db-ui/package-lock.json
generated
@@ -239,7 +239,7 @@
|
|||||||
},
|
},
|
||||||
"async-validator": {
|
"async-validator": {
|
||||||
"version": "1.8.5",
|
"version": "1.8.5",
|
||||||
"resolved": "https://registry.npm.taobao.org/async-validator/download/async-validator-1.8.5.tgz?cache=0&sync_timestamp=1565685468183&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fasync-validator%2Fdownload%2Fasync-validator-1.8.5.tgz",
|
"resolved": "https://registry.npm.taobao.org/async-validator/download/async-validator-1.8.5.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fasync-validator%2Fdownload%2Fasync-validator-1.8.5.tgz",
|
||||||
"integrity": "sha1-3D4I7B/Q3dtn5ghC8CwM0c7G1/A=",
|
"integrity": "sha1-3D4I7B/Q3dtn5ghC8CwM0c7G1/A=",
|
||||||
"requires": {
|
"requires": {
|
||||||
"babel-runtime": "6.x"
|
"babel-runtime": "6.x"
|
||||||
@@ -2238,7 +2238,7 @@
|
|||||||
},
|
},
|
||||||
"element-ui": {
|
"element-ui": {
|
||||||
"version": "2.11.1",
|
"version": "2.11.1",
|
||||||
"resolved": "https://registry.npm.taobao.org/element-ui/download/element-ui-2.11.1.tgz",
|
"resolved": "https://registry.npm.taobao.org/element-ui/download/element-ui-2.11.1.tgz?cache=0&sync_timestamp=1564126738326&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Felement-ui%2Fdownload%2Felement-ui-2.11.1.tgz",
|
||||||
"integrity": "sha1-K2f57uPtouaISHPBxYnL4w2anWA=",
|
"integrity": "sha1-K2f57uPtouaISHPBxYnL4w2anWA=",
|
||||||
"requires": {
|
"requires": {
|
||||||
"async-validator": "~1.8.1",
|
"async-validator": "~1.8.1",
|
||||||
@@ -4164,8 +4164,7 @@
|
|||||||
"lodash": {
|
"lodash": {
|
||||||
"version": "4.17.11",
|
"version": "4.17.11",
|
||||||
"resolved": "http://registry.npm.taobao.org/lodash/download/lodash-4.17.11.tgz",
|
"resolved": "http://registry.npm.taobao.org/lodash/download/lodash-4.17.11.tgz",
|
||||||
"integrity": "sha1-s56mIp72B+zYniyN8SU2iRysm40=",
|
"integrity": "sha1-s56mIp72B+zYniyN8SU2iRysm40="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"lodash.camelcase": {
|
"lodash.camelcase": {
|
||||||
"version": "4.3.0",
|
"version": "4.3.0",
|
||||||
@@ -4647,7 +4646,7 @@
|
|||||||
},
|
},
|
||||||
"normalize-wheel": {
|
"normalize-wheel": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npm.taobao.org/normalize-wheel/download/normalize-wheel-1.0.1.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fnormalize-wheel%2Fdownload%2Fnormalize-wheel-1.0.1.tgz",
|
"resolved": "http://registry.npm.taobao.org/normalize-wheel/download/normalize-wheel-1.0.1.tgz",
|
||||||
"integrity": "sha1-rsiGr/2wRQcNhWRH32Ls+GFG7EU="
|
"integrity": "sha1-rsiGr/2wRQcNhWRH32Ls+GFG7EU="
|
||||||
},
|
},
|
||||||
"nth-check": {
|
"nth-check": {
|
||||||
@@ -6042,7 +6041,7 @@
|
|||||||
},
|
},
|
||||||
"resize-observer-polyfill": {
|
"resize-observer-polyfill": {
|
||||||
"version": "1.5.1",
|
"version": "1.5.1",
|
||||||
"resolved": "https://registry.npm.taobao.org/resize-observer-polyfill/download/resize-observer-polyfill-1.5.1.tgz",
|
"resolved": "http://registry.npm.taobao.org/resize-observer-polyfill/download/resize-observer-polyfill-1.5.1.tgz",
|
||||||
"integrity": "sha1-DpAg3T0hAkRY1OvSfiPkAmmBBGQ="
|
"integrity": "sha1-DpAg3T0hAkRY1OvSfiPkAmmBBGQ="
|
||||||
},
|
},
|
||||||
"resolve": {
|
"resolve": {
|
||||||
@@ -6570,6 +6569,14 @@
|
|||||||
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
|
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"sql-formatter": {
|
||||||
|
"version": "2.3.3",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/sql-formatter/download/sql-formatter-2.3.3.tgz",
|
||||||
|
"integrity": "sha1-kQ70hPu5iKXlEL6kFhFX47gLL2I=",
|
||||||
|
"requires": {
|
||||||
|
"lodash": "^4.16.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"static-extend": {
|
"static-extend": {
|
||||||
"version": "0.1.2",
|
"version": "0.1.2",
|
||||||
"resolved": "http://registry.npm.taobao.org/static-extend/download/static-extend-0.1.2.tgz",
|
"resolved": "http://registry.npm.taobao.org/static-extend/download/static-extend-0.1.2.tgz",
|
||||||
|
|||||||
@@ -10,11 +10,12 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.18.0",
|
"axios": "^0.18.0",
|
||||||
"element-ui": "^2.10.0",
|
"element-ui": "^2.10.0",
|
||||||
|
"sql-formatter": "^2.3.3",
|
||||||
"vue": "^2.5.16",
|
"vue": "^2.5.16",
|
||||||
"vue-axios": "^2.1.4",
|
"vue-axios": "^2.1.4",
|
||||||
|
"vue-hljs": "^1.1.2",
|
||||||
"vue-router": "^3.0.6",
|
"vue-router": "^3.0.6",
|
||||||
"vuex": "^3.3.0",
|
"vuex": "^3.3.0",
|
||||||
"vue-hljs": "^1.1.2",
|
|
||||||
"wangeditor": "^3.1.1"
|
"wangeditor": "^3.1.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
@@ -8,7 +8,8 @@
|
|||||||
<el-tooltip v-else effect="dark" content="Ctrl+R、Ctrl+Enter" placement="top">
|
<el-tooltip v-else effect="dark" content="Ctrl+R、Ctrl+Enter" placement="top">
|
||||||
<el-button v-on:click="doExecutorClick" type="primary" plain size="small" icon="el-icon-video-play">执行</el-button>
|
<el-button v-on:click="doExecutorClick" type="primary" plain size="small" icon="el-icon-video-play">执行</el-button>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<el-button size="small" @click="refreshData">重置</el-button>
|
<el-button icon="el-icon-brush" size="small" @click="formatterSql">SQL美化</el-button>
|
||||||
|
<el-button icon="el-icon-refresh-left" size="small" @click="refreshData">重置</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
<el-card>
|
<el-card>
|
||||||
@@ -67,7 +68,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
</div>
|
</div>
|
||||||
<span id="widthCalculate" style="visibility: hidden; white-space: nowrap;"></span>
|
<span id="widthCalculate" style="visibility: hidden; white-space: nowrap;position: fixed;"></span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -79,6 +80,8 @@
|
|||||||
import '../../common/lib/ace/snippets/sql'
|
import '../../common/lib/ace/snippets/sql'
|
||||||
import global from '../../common/config/global'
|
import global from '../../common/config/global'
|
||||||
import {queryExecuteSql} from '../../common/api/datasource'
|
import {queryExecuteSql} from '../../common/api/datasource'
|
||||||
|
import sqlFormatter from "sql-formatter";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -142,6 +145,20 @@
|
|||||||
this.currentPage = 1;
|
this.currentPage = 1;
|
||||||
this.doExecutorSql();
|
this.doExecutorSql();
|
||||||
},
|
},
|
||||||
|
formatterSql() {
|
||||||
|
let dataSql = this.sqlExecutorEditor.getSelectedText();
|
||||||
|
if (!!dataSql) {
|
||||||
|
let range = this.sqlExecutorEditor.getSelectionRange();
|
||||||
|
this.sqlExecutorEditor.remove(range);
|
||||||
|
} else {
|
||||||
|
dataSql = this.sqlExecutorEditor.getValue();
|
||||||
|
this.sqlExecutorEditor.setValue('', 1);
|
||||||
|
}
|
||||||
|
if (!!dataSql) {
|
||||||
|
dataSql = sqlFormatter.format(dataSql);
|
||||||
|
this.sqlExecutorEditor.insert(dataSql);
|
||||||
|
}
|
||||||
|
},
|
||||||
cancelExecutorSql() {
|
cancelExecutorSql() {
|
||||||
let that = this;
|
let that = this;
|
||||||
this.common.post(this.apilist1.executeSqlCancel, {executeId: this.nowExecutorId}, function (json) {
|
this.common.post(this.apilist1.executeSqlCancel, {executeId: this.nowExecutorId}, function (json) {
|
||||||
@@ -288,7 +305,7 @@
|
|||||||
enableSnippets: true,
|
enableSnippets: true,
|
||||||
enableLiveAutocompletion: true,
|
enableLiveAutocompletion: true,
|
||||||
minLines: minLines,
|
minLines: minLines,
|
||||||
maxLines: 50,
|
maxLines: 30,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="data-executor-vue">
|
<div class="data-executor-vue">
|
||||||
<div style="padding: 0 10px;height: 100%;box-sizing: border-box;">
|
<div style="padding: 0 10px 10px;height: 100%;box-sizing: border-box;">
|
||||||
<el-card style="margin-bottom: 10px;">
|
<el-card style="margin-bottom: 10px;">
|
||||||
<pre id="sqlExecutorEditor" style="width: 100%;height: 500px;margin-top: 0;"></pre>
|
<pre id="sqlExecutorEditor" style="width: 100%;height: 500px;margin-top: 0;"></pre>
|
||||||
<div>
|
<div>
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
<el-tooltip v-else effect="dark" content="Ctrl+R、Ctrl+Enter" placement="top">
|
<el-tooltip v-else effect="dark" content="Ctrl+R、Ctrl+Enter" placement="top">
|
||||||
<el-button v-on:click="doExecutorSql" type="primary" plain size="small" icon="el-icon-video-play">执行</el-button>
|
<el-button v-on:click="doExecutorSql" type="primary" plain size="small" icon="el-icon-video-play">执行</el-button>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
|
<el-button icon="el-icon-brush" size="small" @click="formatterSql">SQL美化</el-button>
|
||||||
<el-button v-on:click="addFavorite('')" plain size="small" icon="el-icon-star-off">收藏</el-button>
|
<el-button v-on:click="addFavorite('')" plain size="small" icon="el-icon-star-off">收藏</el-button>
|
||||||
<el-button v-on:click="loadHistoryAndFavoriteList" plain size="small" icon="el-icon-tickets">收藏及历史</el-button>
|
<el-button v-on:click="loadHistoryAndFavoriteList" plain size="small" icon="el-icon-tickets">收藏及历史</el-button>
|
||||||
<div style="float: right;margin-top: -5px;">
|
<div style="float: right;margin-top: -5px;">
|
||||||
@@ -75,7 +76,7 @@
|
|||||||
</el-tabs>
|
</el-tabs>
|
||||||
</div>
|
</div>
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
<span id="widthCalculate" style="visibility: hidden; white-space: nowrap;"></span>
|
<span id="widthCalculate" style="visibility: hidden; white-space: nowrap;position: fixed;"></span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -85,7 +86,7 @@
|
|||||||
import '../../common/lib/ace/mode-sql'
|
import '../../common/lib/ace/mode-sql'
|
||||||
import '../../common/lib/ace/ext-language_tools'
|
import '../../common/lib/ace/ext-language_tools'
|
||||||
import '../../common/lib/ace/snippets/sql'
|
import '../../common/lib/ace/snippets/sql'
|
||||||
var app;
|
import sqlFormatter from "sql-formatter"
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -111,17 +112,17 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
app = this;
|
|
||||||
this.loadDatasourceList();
|
this.loadDatasourceList();
|
||||||
// 下面两行先后顺序不能改
|
// 下面两行先后顺序不能改
|
||||||
this.addEditorCompleter();
|
this.addEditorCompleter();
|
||||||
this.sqlExecutorEditor = this.initAceEditor("sqlExecutorEditor", 15);
|
this.sqlExecutorEditor = this.initAceEditor("sqlExecutorEditor", 15);
|
||||||
this.sqlExecutorEditor.setFontSize(18);
|
this.sqlExecutorEditor.setFontSize(18);
|
||||||
|
let that = this;
|
||||||
this.sqlExecutorEditor.commands.addCommand({
|
this.sqlExecutorEditor.commands.addCommand({
|
||||||
name: "execute-sql",
|
name: "execute-sql",
|
||||||
bindKey: {win: "Ctrl-R|Ctrl-Shift-R|Ctrl-Enter", mac: "Command-R|Command-Shift-R|Command-Enter"},
|
bindKey: {win: "Ctrl-R|Ctrl-Shift-R|Ctrl-Enter", mac: "Command-R|Command-Shift-R|Command-Enter"},
|
||||||
exec: function (editor) {
|
exec: function (editor) {
|
||||||
app.doExecutorSql();
|
that.doExecutorSql();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -136,12 +137,13 @@
|
|||||||
enableSnippets: true,
|
enableSnippets: true,
|
||||||
enableLiveAutocompletion: true,
|
enableLiveAutocompletion: true,
|
||||||
minLines: minLines,
|
minLines: minLines,
|
||||||
maxLines: 50,
|
maxLines: 30,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
cancelExecutorSql() {
|
cancelExecutorSql() {
|
||||||
|
let that = this;
|
||||||
this.common.post(this.apilist1.executeSqlCancel, {executeId: this.nowExecutorId}, function (json) {
|
this.common.post(this.apilist1.executeSqlCancel, {executeId: this.nowExecutorId}, function (json) {
|
||||||
app.$message.success("取消成功");
|
that.$message.success("取消成功");
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
loadHistoryAndFavoriteList() {
|
loadHistoryAndFavoriteList() {
|
||||||
@@ -150,13 +152,15 @@
|
|||||||
this.loadFavoriteList();
|
this.loadFavoriteList();
|
||||||
},
|
},
|
||||||
loadFavoriteList() {
|
loadFavoriteList() {
|
||||||
|
let that = this;
|
||||||
this.common.post(this.apilist1.favoriteList, {sourceId: this.choiceDatasourceId}, function (json) {
|
this.common.post(this.apilist1.favoriteList, {sourceId: this.choiceDatasourceId}, function (json) {
|
||||||
app.myFavoriteList = json.data || [];
|
that.myFavoriteList = json.data || [];
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
loadHistoryList() {
|
loadHistoryList() {
|
||||||
|
let that = this;
|
||||||
this.common.post(this.apilist1.historyList, {sourceId: this.choiceDatasourceId}, function (json) {
|
this.common.post(this.apilist1.historyList, {sourceId: this.choiceDatasourceId}, function (json) {
|
||||||
app.myHistoryListList = json.data || [];
|
that.myHistoryListList = json.data || [];
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
addFavorite(sqlValue) {
|
addFavorite(sqlValue) {
|
||||||
@@ -166,31 +170,47 @@
|
|||||||
sqlValue = this.sqlExecutorEditor.getValue();
|
sqlValue = this.sqlExecutorEditor.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let that = this;
|
||||||
var param = {name: '我的收藏', content: sqlValue, datasourceId: this.choiceDatasourceId};
|
var param = {name: '我的收藏', content: sqlValue, datasourceId: this.choiceDatasourceId};
|
||||||
this.common.post(this.apilist1.updateFavorite, param, function (json) {
|
this.common.post(this.apilist1.updateFavorite, param, function (json) {
|
||||||
app.$message.success("收藏成功");
|
that.$message.success("收藏成功");
|
||||||
app.loadFavoriteList();
|
that.loadFavoriteList();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
delFavorite(row) {
|
delFavorite(row) {
|
||||||
|
let that = this;
|
||||||
var param = {id: row.id, yn: 0};
|
var param = {id: row.id, yn: 0};
|
||||||
this.common.post(this.apilist1.updateFavorite, param, function (json) {
|
this.common.post(this.apilist1.updateFavorite, param, function (json) {
|
||||||
app.$message.success("删除成功");
|
that.$message.success("删除成功");
|
||||||
app.loadFavoriteList();
|
that.loadFavoriteList();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
inputFavoriteSql(content) {
|
inputFavoriteSql(content) {
|
||||||
this.sqlExecutorEditor.setValue(content, 1);
|
this.sqlExecutorEditor.setValue(content, 1);
|
||||||
this.historyDrawerVisible = false;
|
this.historyDrawerVisible = false;
|
||||||
},
|
},
|
||||||
|
formatterSql() {
|
||||||
|
let dataSql = this.sqlExecutorEditor.getSelectedText();
|
||||||
|
if (!!dataSql) {
|
||||||
|
let range = this.sqlExecutorEditor.getSelectionRange();
|
||||||
|
this.sqlExecutorEditor.remove(range);
|
||||||
|
} else {
|
||||||
|
dataSql = this.sqlExecutorEditor.getValue();
|
||||||
|
this.sqlExecutorEditor.setValue('', 1);
|
||||||
|
}
|
||||||
|
if (!!dataSql) {
|
||||||
|
dataSql = sqlFormatter.format(dataSql);
|
||||||
|
this.sqlExecutorEditor.insert(dataSql);
|
||||||
|
}
|
||||||
|
},
|
||||||
doExecutorSql() {
|
doExecutorSql() {
|
||||||
if (!this.choiceDatasourceId) {
|
if (!this.choiceDatasourceId) {
|
||||||
app.$message.error("请先选择数据源");
|
this.$message.error("请先选择数据源");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
app.executeError = "";
|
this.executeError = "";
|
||||||
app.executeUseTime = "";
|
this.executeUseTime = "";
|
||||||
app.executeResultList = [];
|
this.executeResultList = [];
|
||||||
|
|
||||||
this.nowExecutorId = (new Date()).getTime() + Math.ceil(Math.random() * 1000);
|
this.nowExecutorId = (new Date()).getTime() + Math.ceil(Math.random() * 1000);
|
||||||
var sqlValue = this.sqlExecutorEditor.getSelectedText();
|
var sqlValue = this.sqlExecutorEditor.getSelectedText();
|
||||||
@@ -198,15 +218,16 @@
|
|||||||
sqlValue = this.sqlExecutorEditor.getValue();
|
sqlValue = this.sqlExecutorEditor.getValue();
|
||||||
}
|
}
|
||||||
this.sqlExecuting = true;
|
this.sqlExecuting = true;
|
||||||
|
let that = this;
|
||||||
this.common.postNonCheck(this.apilist1.executeSql, {
|
this.common.postNonCheck(this.apilist1.executeSql, {
|
||||||
sourceId: this.choiceDatasourceId,
|
sourceId: this.choiceDatasourceId,
|
||||||
executeId: this.nowExecutorId,
|
executeId: this.nowExecutorId,
|
||||||
sql: sqlValue,
|
sql: sqlValue,
|
||||||
params: '',
|
params: '',
|
||||||
}, function (json) {
|
}, function (json) {
|
||||||
app.sqlExecuting = false;
|
that.sqlExecuting = false;
|
||||||
if (json.errCode != 200) {
|
if (json.errCode != 200) {
|
||||||
app.executeError = json.errMsg;
|
that.executeError = json.errMsg;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var resultList = json.data || [];
|
var resultList = json.data || [];
|
||||||
@@ -214,34 +235,36 @@
|
|||||||
var executeResultInfo = "", itemIndex = 1;
|
var executeResultInfo = "", itemIndex = 1;
|
||||||
for (var i = 0; i < resultList.length; i++) {
|
for (var i = 0; i < resultList.length; i++) {
|
||||||
var objItem = JSON.parse(resultList[i]);
|
var objItem = JSON.parse(resultList[i]);
|
||||||
executeResultInfo += app.getExecuteInfoStr(objItem);
|
executeResultInfo += that.getExecuteInfoStr(objItem);
|
||||||
var resultItem = app.dealExecuteResult(objItem);
|
var resultItem = that.dealExecuteResult(objItem);
|
||||||
if (resultItem.updateCount < 0) {
|
if (resultItem.updateCount < 0) {
|
||||||
resultItem.index = itemIndex;
|
resultItem.index = itemIndex;
|
||||||
itemIndex++;
|
itemIndex++;
|
||||||
}
|
}
|
||||||
executeResultList.push(resultItem);
|
executeResultList.push(resultItem);
|
||||||
}
|
}
|
||||||
app.executeShowTable = (itemIndex === 1) ? "table0" : "table1";
|
that.executeShowTable = (itemIndex === 1) ? "table0" : "table1";
|
||||||
app.executeResultInfo = executeResultInfo;
|
that.executeResultInfo = executeResultInfo;
|
||||||
app.executeResultList = executeResultList;
|
that.executeResultList = executeResultList;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
loadDatasourceList() {
|
loadDatasourceList() {
|
||||||
|
let that = this;
|
||||||
this.common.post(this.apilist1.datasourceList, {}, function (json) {
|
this.common.post(this.apilist1.datasourceList, {}, function (json) {
|
||||||
app.datasourceList = json.data || [];
|
that.datasourceList = json.data || [];
|
||||||
if (app.datasourceList.length > 0) {
|
if (that.datasourceList.length > 0) {
|
||||||
app.choiceDatasourceId = app.datasourceList[0].id;
|
that.choiceDatasourceId = that.datasourceList[0].id;
|
||||||
app.loadEditorData();
|
that.loadEditorData();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
loadEditorData() {
|
loadEditorData() {
|
||||||
|
let that = this;
|
||||||
this.common.post(this.apilist1.getEditorData, {sourceId: this.choiceDatasourceId}, function (json) {
|
this.common.post(this.apilist1.getEditorData, {sourceId: this.choiceDatasourceId}, function (json) {
|
||||||
var data = json.data || {};
|
var data = json.data || {};
|
||||||
app.editorDbInfo = data.db || [];
|
that.editorDbInfo = data.db || [];
|
||||||
app.editorDbTableInfo = data.table || {};
|
that.editorDbTableInfo = data.table || {};
|
||||||
app.editorColumnInfo = data.column || {};
|
that.editorColumnInfo = data.column || {};
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
datasourceChangeEvents() {
|
datasourceChangeEvents() {
|
||||||
@@ -292,6 +315,7 @@
|
|||||||
return resultObj;
|
return resultObj;
|
||||||
},
|
},
|
||||||
addEditorCompleter() {
|
addEditorCompleter() {
|
||||||
|
let that = this;
|
||||||
var languageTools = ace.require("ace/ext/language_tools");
|
var languageTools = ace.require("ace/ext/language_tools");
|
||||||
languageTools.addCompleter({
|
languageTools.addCompleter({
|
||||||
needDestory: true, // 一定得加上这个参数~不然页面生命周期内页面的切换,编辑器会有多个相同的completer
|
needDestory: true, // 一定得加上这个参数~不然页面生命周期内页面的切换,编辑器会有多个相同的completer
|
||||||
@@ -301,12 +325,12 @@
|
|||||||
var lineStr = session.getLine(pos.row).substring(0, pos.column - 1);
|
var lineStr = session.getLine(pos.row).substring(0, pos.column - 1);
|
||||||
if (lineStr.endsWith("from ") || lineStr.endsWith("join ")) {
|
if (lineStr.endsWith("from ") || lineStr.endsWith("join ")) {
|
||||||
// 库
|
// 库
|
||||||
for (var i = 0; i < app.editorDbInfo.length; i++) {
|
for (var i = 0; i < that.editorDbInfo.length; i++) {
|
||||||
callbackArr.push({caption: app.editorDbInfo[i].dbName, snippet: app.editorDbInfo[i].dbName, meta: "database", type: "snippet", score : 1000});
|
callbackArr.push({caption: that.editorDbInfo[i].dbName, snippet: that.editorDbInfo[i].dbName, meta: "database", type: "snippet", score : 1000});
|
||||||
}
|
}
|
||||||
// 所有表
|
// 所有表
|
||||||
for (var key in app.editorDbTableInfo) {
|
for (var key in that.editorDbTableInfo) {
|
||||||
var tableInfo = app.editorDbTableInfo[key];
|
var tableInfo = that.editorDbTableInfo[key];
|
||||||
for (var i = 0; i < tableInfo.length; i++) {
|
for (var i = 0; i < tableInfo.length; i++) {
|
||||||
var caption = (!!tableInfo[i].tableComment) ? tableInfo[i].tableName + "-" + tableInfo[i].tableComment : tableInfo[i].tableName;
|
var caption = (!!tableInfo[i].tableComment) ? tableInfo[i].tableName + "-" + tableInfo[i].tableComment : tableInfo[i].tableName;
|
||||||
callbackArr.push({caption: caption, snippet: tableInfo[i].tableName, meta: "table", type: "snippet", score : 1000});
|
callbackArr.push({caption: caption, snippet: tableInfo[i].tableName, meta: "table", type: "snippet", score : 1000});
|
||||||
@@ -315,9 +339,9 @@
|
|||||||
callback(null, callbackArr);
|
callback(null, callbackArr);
|
||||||
} else if (lineStr.endsWith(".")) {
|
} else if (lineStr.endsWith(".")) {
|
||||||
// 匹配 库名. 搜索表名
|
// 匹配 库名. 搜索表名
|
||||||
for (var i = 0; i < app.editorDbInfo.length; i++) {
|
for (var i = 0; i < that.editorDbInfo.length; i++) {
|
||||||
if (lineStr.endsWith(app.editorDbInfo[i].dbName + ".")) {
|
if (lineStr.endsWith(that.editorDbInfo[i].dbName + ".")) {
|
||||||
var tableInfo = app.editorDbTableInfo[app.editorDbInfo[i].dbName];
|
var tableInfo = that.editorDbTableInfo[that.editorDbInfo[i].dbName];
|
||||||
if (!!tableInfo) {
|
if (!!tableInfo) {
|
||||||
for (var j = 0; j < tableInfo.length; j++) {
|
for (var j = 0; j < tableInfo.length; j++) {
|
||||||
var caption = (!!tableInfo[j].tableComment) ? tableInfo[j].tableName + "-" + tableInfo[j].tableComment : tableInfo[j].tableName;
|
var caption = (!!tableInfo[j].tableComment) ? tableInfo[j].tableName + "-" + tableInfo[j].tableComment : tableInfo[j].tableName;
|
||||||
@@ -329,11 +353,11 @@
|
|||||||
}
|
}
|
||||||
// 未找到,匹配 表名. 搜索字段名
|
// 未找到,匹配 表名. 搜索字段名
|
||||||
if (!isFound) {
|
if (!isFound) {
|
||||||
for (var key in app.editorColumnInfo) {
|
for (var key in that.editorColumnInfo) {
|
||||||
if (!lineStr.endsWith(key + ".")) {
|
if (!lineStr.endsWith(key + ".")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var columnInfo = app.editorColumnInfo[key];
|
var columnInfo = that.editorColumnInfo[key];
|
||||||
if (!!columnInfo) {
|
if (!!columnInfo) {
|
||||||
for (var i = 0; i < columnInfo.length; i++) {
|
for (var i = 0; i < columnInfo.length; i++) {
|
||||||
var caption = (!!columnInfo[i].description) ? columnInfo[i].name + "-" + columnInfo[i].description : columnInfo[i].name;
|
var caption = (!!columnInfo[i].description) ? columnInfo[i].name + "-" + columnInfo[i].description : columnInfo[i].name;
|
||||||
@@ -363,13 +387,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 所有表,找下面的字段列表
|
// 所有表,找下面的字段列表
|
||||||
for (var key in app.editorDbTableInfo) {
|
for (var key in that.editorDbTableInfo) {
|
||||||
var tableInfo = app.editorDbTableInfo[key];
|
var tableInfo = that.editorDbTableInfo[key];
|
||||||
for (var i = 0; i < tableInfo.length; i++) {
|
for (var i = 0; i < tableInfo.length; i++) {
|
||||||
if (queryText.indexOf(tableInfo[i].tableName) < 0) {
|
if (queryText.indexOf(tableInfo[i].tableName) < 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var columnInfo = app.editorColumnInfo[tableInfo[i].tableName];
|
var columnInfo = that.editorColumnInfo[tableInfo[i].tableName];
|
||||||
if (!!columnInfo) {
|
if (!!columnInfo) {
|
||||||
for (var j = 0; j < columnInfo.length; j++) {
|
for (var j = 0; j < columnInfo.length; j++) {
|
||||||
var caption = (!!columnInfo[j].description) ? columnInfo[j].name + "-" + columnInfo[j].description : columnInfo[j].name;
|
var caption = (!!columnInfo[j].description) ? columnInfo[j].name + "-" + columnInfo[j].description : columnInfo[j].name;
|
||||||
|
|||||||
Reference in New Issue
Block a user