2019-08-21 20:39:43 +08:00
|
|
|
|
<template>
|
2023-02-07 15:35:34 +08:00
|
|
|
|
<div class="data-executor-vue">
|
|
|
|
|
|
<div style="padding: 0 10px 10px;height: 100%;box-sizing: border-box;">
|
2023-05-16 18:38:42 +08:00
|
|
|
|
<el-card style="margin-bottom: 5px;">
|
2023-02-22 19:16:31 +08:00
|
|
|
|
<ace-editor v-model="sqlExecutorContent" ref="sqlEditor" @init="sqlExecutorInit" lang="sql" theme="monokai"
|
2023-05-16 18:38:42 +08:00
|
|
|
|
width="100%" height="20" :options="sqlEditorConfig" :source="executorSource"
|
|
|
|
|
|
@cursorSelection="cursorSelection" style="margin-bottom: 5px;"></ace-editor>
|
2023-02-07 15:35:34 +08:00
|
|
|
|
<div>
|
2023-05-16 18:38:42 +08:00
|
|
|
|
<el-button v-if="sqlExecuting" v-on:click="cancelExecutorSql" type="primary" plain size="mini"
|
2023-02-22 19:16:31 +08:00
|
|
|
|
icon="el-icon-video-pause">取消执行
|
|
|
|
|
|
</el-button>
|
2023-02-07 15:35:34 +08:00
|
|
|
|
<el-tooltip v-else effect="dark" content="Ctrl+R、Ctrl+Enter" placement="top">
|
2023-05-16 18:38:42 +08:00
|
|
|
|
<el-button v-on:click="doExecutorSql" type="primary" plain size="mini" icon="el-icon-video-play">{{executeButtonText}}
|
2023-02-22 19:16:31 +08:00
|
|
|
|
</el-button>
|
2023-02-07 15:35:34 +08:00
|
|
|
|
</el-tooltip>
|
2023-05-16 18:38:42 +08:00
|
|
|
|
<el-button icon="el-icon-brush" size="mini" @click="formatterSql">SQL美化</el-button>
|
|
|
|
|
|
<el-button v-on:click="addFavorite('')" plain size="mini" icon="el-icon-star-off">收藏</el-button>
|
2023-02-07 15:35:34 +08:00
|
|
|
|
<div style="float: right;">
|
2023-05-16 18:38:42 +08:00
|
|
|
|
<el-select v-model="choiceDatasourceId" @change="datasourceChangeEvents" size="mini" filterable
|
2023-02-22 19:16:31 +08:00
|
|
|
|
placeholder="请选择数据源" style="width: 300px;margin-left: 10px;">
|
|
|
|
|
|
<el-option v-for="item in datasourceOptions" :key="item.id" :label="item.name"
|
|
|
|
|
|
:value="item.id"></el-option>
|
2023-02-07 15:35:34 +08:00
|
|
|
|
</el-select>
|
2023-05-16 18:38:42 +08:00
|
|
|
|
<el-select v-model="choiceDatabase" @change="databaseChangeEvents" size="mini" filterable
|
2023-02-22 19:16:31 +08:00
|
|
|
|
placeholder="请选择数据库" style="width: 200px;margin-left: 10px;">
|
|
|
|
|
|
<el-option v-for="item in databaseList" :key="item.dbName" :label="item.dbName"
|
|
|
|
|
|
:value="item.dbName"></el-option>
|
2023-02-07 15:35:34 +08:00
|
|
|
|
</el-select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2021-06-27 22:45:30 +08:00
|
|
|
|
<div v-if="sqlParams.length > 0" class="sql-params">
|
2023-05-17 23:48:26 +08:00
|
|
|
|
<el-input :placeholder="'请输入'+param.key+'的值'" v-model="param.value" v-for="(param,index) in sqlParams" :key="index">
|
2023-02-07 15:35:34 +08:00
|
|
|
|
<template slot="prepend">{{ param.key }}</template>
|
2021-06-27 22:45:30 +08:00
|
|
|
|
</el-input>
|
|
|
|
|
|
</div>
|
2023-02-07 15:35:34 +08:00
|
|
|
|
</el-card>
|
|
|
|
|
|
<el-card>
|
|
|
|
|
|
<div style="position: relative;">
|
2021-05-24 22:42:01 +08:00
|
|
|
|
<div style="position: absolute;right: 0;z-index: 1;">
|
|
|
|
|
|
<!-- 复制选中行 -->
|
2023-02-22 19:16:31 +08:00
|
|
|
|
<el-dropdown @command="handleCopyCheckLineCommand"
|
|
|
|
|
|
v-show="this.choiceResultObj[this.executeShowTable] && this.choiceResultObj[this.executeShowTable].length > 0">
|
2021-06-05 16:38:27 +08:00
|
|
|
|
<el-button type="primary" size="small" icon="el-icon-document-copy">
|
2021-05-24 22:42:01 +08:00
|
|
|
|
复制选中行<i class="el-icon-arrow-down el-icon--right"></i>
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
<el-dropdown-menu slot="dropdown">
|
|
|
|
|
|
<el-dropdown-item command="insert">SQL Inserts</el-dropdown-item>
|
|
|
|
|
|
<el-dropdown-item command="update">SQL Updates</el-dropdown-item>
|
|
|
|
|
|
<el-dropdown-item command="json">JSON</el-dropdown-item>
|
|
|
|
|
|
</el-dropdown-menu>
|
|
|
|
|
|
</el-dropdown>
|
|
|
|
|
|
</div>
|
2023-05-16 18:38:42 +08:00
|
|
|
|
<el-tabs v-model="executeShowTable" type="border-card" @tab-click="tabHandleClick">
|
2023-02-07 15:35:34 +08:00
|
|
|
|
<el-tab-pane label="执行历史" name="tabHistory">
|
2021-06-27 22:45:30 +08:00
|
|
|
|
<el-table :data="myHistoryListList" stripe border style="width: 100%; margin-bottom: 5px;">
|
|
|
|
|
|
<el-table-column prop="createTime" label="执行时间" width="160px"></el-table-column>
|
|
|
|
|
|
<el-table-column prop="content" label="SQL">
|
|
|
|
|
|
<template slot-scope="scope">
|
2023-02-22 19:16:31 +08:00
|
|
|
|
<pre class="sql-content-line" @dblclick="inputFavoriteSql(scope.row)"
|
|
|
|
|
|
:title="scope.row.content">{{ scope.row.content }}</pre>
|
2021-06-27 22:45:30 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column label="操作" width="160px">
|
|
|
|
|
|
<template slot-scope="scope">
|
2021-07-17 12:22:51 +08:00
|
|
|
|
<el-button size="mini" type="primary" @click="inputFavoriteSql(scope.row)">输入</el-button>
|
2023-02-22 19:16:31 +08:00
|
|
|
|
<el-button size="mini" type="success" @click="addFavorite(scope.row.content)"
|
|
|
|
|
|
style="margin-left: 10px;">收藏
|
|
|
|
|
|
</el-button>
|
2021-06-27 22:45:30 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</el-table>
|
2023-02-07 15:35:34 +08:00
|
|
|
|
</el-tab-pane>
|
|
|
|
|
|
<el-tab-pane label="我的收藏" name="tabFavorite">
|
2021-06-27 22:45:30 +08:00
|
|
|
|
<el-table :data="myFavoriteList" stripe border style="width: 100%; margin-bottom: 5px;" v-infinite-scroll>
|
|
|
|
|
|
<el-table-column prop="createTime" label="执行时间" width="160px"></el-table-column>
|
|
|
|
|
|
<el-table-column prop="content" label="SQL">
|
|
|
|
|
|
<template slot-scope="scope">
|
2023-02-22 19:16:31 +08:00
|
|
|
|
<pre class="sql-content-line" @dblclick="inputFavoriteSql(scope.row)"
|
|
|
|
|
|
:title="scope.row.content">{{ scope.row.content }}</pre>
|
2021-06-27 22:45:30 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column label="操作" width="160px">
|
|
|
|
|
|
<template slot-scope="scope">
|
2021-07-17 12:22:51 +08:00
|
|
|
|
<el-button size="mini" type="primary" v-on:click="inputFavoriteSql(scope.row)">输入</el-button>
|
2023-02-22 19:16:31 +08:00
|
|
|
|
<el-button size="mini" type="danger" v-on:click="delFavorite(scope.row)" style="margin-left: 10px;">
|
|
|
|
|
|
删除
|
|
|
|
|
|
</el-button>
|
2021-06-27 22:45:30 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</el-table>
|
2023-02-07 15:35:34 +08:00
|
|
|
|
</el-tab-pane>
|
|
|
|
|
|
<el-tab-pane label="信息" name="tabInfo" v-if="!!executeResultInfo">
|
2023-02-15 20:35:34 +08:00
|
|
|
|
<pre class="execute-result-info">{{ executeResultInfo }}</pre>
|
2023-02-07 15:35:34 +08:00
|
|
|
|
</el-tab-pane>
|
|
|
|
|
|
<el-tab-pane label="错误" name="tabError" v-if="!!executeError">
|
|
|
|
|
|
<div style="color: #f00;">{{ executeError }}</div>
|
|
|
|
|
|
</el-tab-pane>
|
2021-06-27 22:45:30 +08:00
|
|
|
|
<template v-else>
|
2023-05-17 23:48:26 +08:00
|
|
|
|
<el-tab-pane :label="resultItem.label" :name="resultItem.name" v-for="(resultItem,index) in executeResultList" :key="index"
|
2023-02-22 19:16:31 +08:00
|
|
|
|
lazy>
|
2023-02-07 15:35:34 +08:00
|
|
|
|
<div v-if="!!resultItem.errMsg" style="color: #f00;">{{ resultItem.errMsg }}</div>
|
2023-05-17 23:48:26 +08:00
|
|
|
|
<ux-grid v-else
|
|
|
|
|
|
v-clickoutside="handleClickOutside"
|
|
|
|
|
|
:data="resultItem.dataList"
|
2023-02-22 19:16:31 +08:00
|
|
|
|
@table-body-scroll="scroll"
|
|
|
|
|
|
@selection-change="handleSelectionChange"
|
2023-05-16 18:38:42 +08:00
|
|
|
|
@cell-click="mouseOnFocus"
|
|
|
|
|
|
@cell-mouse-leave="mouseLeave"
|
2023-02-22 19:16:31 +08:00
|
|
|
|
:checkboxConfig="{checkMethod: selectable, highlight: true}"
|
|
|
|
|
|
stripe border :height="height" max-height="600"
|
|
|
|
|
|
style="width: 100%; margin-bottom: 5px;" class="execute-result-table">
|
2023-02-07 15:35:34 +08:00
|
|
|
|
<ux-table-column type="checkbox" width="55"></ux-table-column>
|
2023-05-17 23:48:26 +08:00
|
|
|
|
<ux-table-column type="index" width="55" title=" "></ux-table-column>
|
|
|
|
|
|
<ux-table-column v-for="(item,index) in resultItem.dataCols" :key="index" :prop="item.prop" :title="item.label"
|
2023-02-22 19:16:31 +08:00
|
|
|
|
:width="item.width">
|
2021-06-27 22:45:30 +08:00
|
|
|
|
<template slot-scope="scope">
|
2023-05-17 23:48:26 +08:00
|
|
|
|
<textarea readonly :value="scope.row[item.prop]" class="el-textarea__inner" rows="1"></textarea>
|
2021-06-27 22:45:30 +08:00
|
|
|
|
</template>
|
2023-02-07 15:35:34 +08:00
|
|
|
|
</ux-table-column>
|
|
|
|
|
|
</ux-grid>
|
2023-02-22 19:16:31 +08:00
|
|
|
|
<el-pagination
|
|
|
|
|
|
v-if="resultItem.selectCount"
|
|
|
|
|
|
@current-change="handleCurrentChange"
|
|
|
|
|
|
:current-page="currentPage"
|
|
|
|
|
|
:page-size="pageSize"
|
|
|
|
|
|
:page-sizes="[1000]"
|
|
|
|
|
|
layout="total, sizes, prev, pager, next, jumper"
|
|
|
|
|
|
:total="resultItem.selectCount">
|
|
|
|
|
|
</el-pagination>
|
2023-05-17 23:48:26 +08:00
|
|
|
|
<div v-if="resultItem.selectCount" style="position: absolute;right: 5px;bottom: 5px;">
|
|
|
|
|
|
<el-button type="primary" plain v-on:click="viewAllData()">查看所有</el-button>
|
|
|
|
|
|
</div>
|
2023-05-18 17:06:20 +08:00
|
|
|
|
<div v-if="!resultItem.selectCount" style="height: 20px;font-size: 13px;font-weight: 400;color: #606266;padding-left: 5px;">
|
|
|
|
|
|
共 {{resultItem.totalCount}} 条
|
|
|
|
|
|
</div>
|
2021-06-27 22:45:30 +08:00
|
|
|
|
</el-tab-pane>
|
|
|
|
|
|
</template>
|
2023-05-17 23:48:26 +08:00
|
|
|
|
<el-main v-loading="loadingAll"
|
|
|
|
|
|
v-show="loadingAll"
|
|
|
|
|
|
element-loading-text="正在加载中"
|
|
|
|
|
|
element-loading-spinner="el-icon-loading"
|
2023-05-18 17:06:20 +08:00
|
|
|
|
style="height: 175px;">
|
2023-05-17 23:48:26 +08:00
|
|
|
|
</el-main>
|
2023-02-07 15:35:34 +08:00
|
|
|
|
</el-tabs>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-card>
|
|
|
|
|
|
</div>
|
2021-05-29 22:18:15 +08:00
|
|
|
|
<!--选择导出为update的条件列弹窗-->
|
|
|
|
|
|
<el-dialog :visible.sync="exportConditionVisible" width="500px" title="选择更新语句条件">
|
|
|
|
|
|
<div>
|
|
|
|
|
|
更新条件列:
|
|
|
|
|
|
<el-select v-model="conditionDataColsChoice" multiple placeholder="请选择" style="width: 370px;">
|
2023-02-22 19:16:31 +08:00
|
|
|
|
<el-option v-for="item in conditionDataCols" :key="item.prop" :label="item.label"
|
|
|
|
|
|
:value="item.prop"></el-option>
|
2021-05-29 22:18:15 +08:00
|
|
|
|
</el-select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<span slot="footer" class="dialog-footer">
|
|
|
|
|
|
<el-button @click="exportConditionVisible = false">取 消</el-button>
|
|
|
|
|
|
<el-button type="primary" @click="doCopyCheckLineUpdate">确 定</el-button>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</el-dialog>
|
2023-02-07 15:35:34 +08:00
|
|
|
|
<span id="widthCalculate" style="visibility: hidden; white-space: nowrap;position: fixed;"></span>
|
|
|
|
|
|
</div>
|
2019-08-21 20:39:43 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2023-02-07 15:35:34 +08:00
|
|
|
|
import copyFormatter from './copy/index'
|
|
|
|
|
|
import sqlFormatter from "sql-formatter"
|
|
|
|
|
|
import datasourceApi from '../../common/api/datasource'
|
|
|
|
|
|
import aceEditor from "../../common/lib/ace-editor";
|
|
|
|
|
|
import sqlParser from "./parser/SqlParser";
|
2023-05-22 18:32:42 +08:00
|
|
|
|
import Clickoutside from 'element-ui/src/utils/clickoutside';
|
|
|
|
|
|
import merge from 'webpack-merge';
|
2020-05-23 12:21:23 +08:00
|
|
|
|
|
2023-02-07 15:35:34 +08:00
|
|
|
|
export default {
|
2023-05-17 23:48:26 +08:00
|
|
|
|
directives: { Clickoutside },
|
2023-02-07 15:35:34 +08:00
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
2023-05-17 23:48:26 +08:00
|
|
|
|
//遮罩层
|
|
|
|
|
|
loadingAll: false,
|
|
|
|
|
|
|
2023-02-07 15:35:34 +08:00
|
|
|
|
height: 0,
|
|
|
|
|
|
scrollTop: 0,
|
|
|
|
|
|
datasourceList: [],
|
|
|
|
|
|
choiceDatasourceId: "",
|
|
|
|
|
|
datasourceOptions: [],
|
|
|
|
|
|
datasourceGroupList: [],
|
|
|
|
|
|
choiceDatasourceGroup: "",
|
2020-05-24 13:00:43 +08:00
|
|
|
|
|
2023-02-07 15:35:34 +08:00
|
|
|
|
databaseList: [],
|
|
|
|
|
|
choiceDatabase: "",
|
|
|
|
|
|
editorDbProduct: "",
|
|
|
|
|
|
editorDbInfo: [],
|
|
|
|
|
|
editorDbTableInfo: {},
|
|
|
|
|
|
editorColumnInfo: {},
|
2019-08-21 20:39:43 +08:00
|
|
|
|
|
2023-05-16 18:38:42 +08:00
|
|
|
|
//选中的单元格
|
|
|
|
|
|
uxGridCell: "",
|
|
|
|
|
|
|
2023-02-22 19:16:31 +08:00
|
|
|
|
pageSize: 1000,
|
|
|
|
|
|
currentPage: 1,
|
|
|
|
|
|
|
2023-02-07 15:35:34 +08:00
|
|
|
|
sqlExecuting: false,
|
|
|
|
|
|
executeResultList: [],
|
|
|
|
|
|
executeResultInfo: "",
|
|
|
|
|
|
executeShowTable: "tabHistory",
|
|
|
|
|
|
sqlExecutorEditor: {},
|
|
|
|
|
|
nowExecutorId: 1,
|
|
|
|
|
|
executeError: "",
|
|
|
|
|
|
// 收藏及历史
|
|
|
|
|
|
myFavoriteList: [],
|
|
|
|
|
|
myHistoryListList: [],
|
|
|
|
|
|
// 选择复制
|
|
|
|
|
|
choiceResultObj: {},
|
|
|
|
|
|
//
|
|
|
|
|
|
exportConditionVisible: false,
|
|
|
|
|
|
conditionDataCols: [],
|
|
|
|
|
|
conditionDataColsChoice: [],
|
2023-05-16 18:38:42 +08:00
|
|
|
|
//执行按钮文本
|
|
|
|
|
|
executeButtonText: '执行',
|
2023-02-07 15:35:34 +08:00
|
|
|
|
// 编辑器
|
|
|
|
|
|
sqlExecutorContent: '',
|
|
|
|
|
|
sqlEditorConfig: {
|
|
|
|
|
|
wrap: true,
|
|
|
|
|
|
autoScrollEditorIntoView: true,
|
|
|
|
|
|
enableBasicAutocompletion: true,
|
|
|
|
|
|
enableSnippets: true,
|
|
|
|
|
|
enableLiveAutocompletion: true,
|
2023-05-16 18:38:42 +08:00
|
|
|
|
minLines: 15,
|
|
|
|
|
|
maxLines: 15,
|
2021-06-20 00:41:28 +08:00
|
|
|
|
},
|
2023-02-07 15:35:34 +08:00
|
|
|
|
executorSource: {},
|
|
|
|
|
|
// sql参数
|
|
|
|
|
|
sqlParams: [],
|
|
|
|
|
|
sqlParamWaiting: false,
|
|
|
|
|
|
sqlParamHistory: {},
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
components: {
|
|
|
|
|
|
'ace-editor': aceEditor
|
|
|
|
|
|
},
|
|
|
|
|
|
mounted: function () {
|
2023-05-18 17:06:20 +08:00
|
|
|
|
this.height = 190;
|
2023-02-07 15:35:34 +08:00
|
|
|
|
this.loadDatasourceList();
|
|
|
|
|
|
},
|
2023-05-22 18:32:42 +08:00
|
|
|
|
activated(){
|
|
|
|
|
|
this.loadDatasourceList();
|
|
|
|
|
|
},
|
2023-02-07 15:35:34 +08:00
|
|
|
|
methods: {
|
|
|
|
|
|
sqlExecutorInit(editor) {
|
|
|
|
|
|
this.sqlExecutorEditor = editor;
|
|
|
|
|
|
this.sqlExecutorEditor.setFontSize(16);
|
|
|
|
|
|
let that = this;
|
|
|
|
|
|
this.sqlExecutorEditor.commands.addCommand({
|
|
|
|
|
|
name: "execute-sql",
|
|
|
|
|
|
bindKey: {win: "Ctrl-R|Ctrl-Shift-R|Ctrl-Enter", mac: "Command-R|Command-Shift-R|Command-Enter"},
|
|
|
|
|
|
exec: function (editor) {
|
|
|
|
|
|
that.doExecutorSql();
|
2021-07-17 12:22:51 +08:00
|
|
|
|
}
|
2023-02-07 15:35:34 +08:00
|
|
|
|
});
|
|
|
|
|
|
editor.on('change', () => {
|
|
|
|
|
|
if (!this.sqlParamWaiting) {
|
|
|
|
|
|
this.sqlParamWaiting = true;
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
let content = editor.getValue();
|
|
|
|
|
|
let paramArr = sqlParser.parserArr(content, [
|
|
|
|
|
|
{start: '${', end: '}'}, {start: '#{', end: '}'}
|
|
|
|
|
|
]);
|
|
|
|
|
|
this.sqlParams = [];
|
|
|
|
|
|
paramArr.forEach(item => {
|
|
|
|
|
|
this.sqlParams.push({key: item, value: this.sqlParamHistory[item] || ''});
|
|
|
|
|
|
});
|
|
|
|
|
|
this.sqlParamWaiting = false;
|
|
|
|
|
|
}, 300);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
2023-05-16 18:38:42 +08:00
|
|
|
|
cursorSelection(sqlValue){
|
|
|
|
|
|
if(sqlValue){
|
|
|
|
|
|
this.executeButtonText = '执行已选择的'
|
|
|
|
|
|
}else{
|
|
|
|
|
|
this.executeButtonText = '执行'
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2023-02-22 19:16:31 +08:00
|
|
|
|
scroll({scrollTop, scrollLeft}) {
|
|
|
|
|
|
this.scrollTop = scrollTop
|
|
|
|
|
|
},
|
|
|
|
|
|
selectable({row}) {
|
|
|
|
|
|
return row.id !== 2
|
|
|
|
|
|
},
|
2023-02-07 15:35:34 +08:00
|
|
|
|
cancelExecutorSql() {
|
|
|
|
|
|
datasourceApi.executeSqlCancel({executeId: this.nowExecutorId}).then(() => {
|
|
|
|
|
|
this.$message.success("取消成功");
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
loadHistoryAndFavoriteList() {
|
|
|
|
|
|
this.loadHistoryList();
|
|
|
|
|
|
this.loadFavoriteList();
|
|
|
|
|
|
},
|
|
|
|
|
|
loadFavoriteList() {
|
|
|
|
|
|
datasourceApi.favoriteList({sourceId: this.choiceDatasourceId}).then(json => {
|
|
|
|
|
|
this.myFavoriteList = json.data || [];
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
loadHistoryList() {
|
|
|
|
|
|
datasourceApi.historyList({sourceId: this.choiceDatasourceId}).then(json => {
|
|
|
|
|
|
this.myHistoryListList = json.data || [];
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
addFavorite(sqlValue) {
|
|
|
|
|
|
if (!sqlValue) {
|
|
|
|
|
|
sqlValue = this.sqlExecutorEditor.getSelectedText();
|
|
|
|
|
|
if (!sqlValue) {
|
|
|
|
|
|
sqlValue = this.sqlExecutorEditor.getValue();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
let sqlParamObj = {};
|
|
|
|
|
|
this.sqlParams.forEach(item => {
|
|
|
|
|
|
if (!!item.value) {
|
|
|
|
|
|
sqlParamObj[item.key] = item.value;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
let param = {
|
|
|
|
|
|
name: '我的收藏',
|
|
|
|
|
|
content: sqlValue,
|
|
|
|
|
|
paramJson: JSON.stringify(sqlParamObj),
|
|
|
|
|
|
datasourceId: this.choiceDatasourceId
|
|
|
|
|
|
};
|
|
|
|
|
|
datasourceApi.updateFavorite(param).then(() => {
|
|
|
|
|
|
this.$message.success("收藏成功");
|
|
|
|
|
|
this.loadFavoriteList();
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
delFavorite(row) {
|
|
|
|
|
|
datasourceApi.updateFavorite({id: row.id, yn: 0}).then(() => {
|
|
|
|
|
|
this.$message.success("删除成功");
|
|
|
|
|
|
this.loadFavoriteList();
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
inputFavoriteSql(item) {
|
|
|
|
|
|
this.sqlExecutorEditor.setValue(item.content, 1);
|
|
|
|
|
|
if (!!item.paramJson) {
|
|
|
|
|
|
let paramJson = JSON.parse(item.paramJson);
|
|
|
|
|
|
for (let key in paramJson) {
|
|
|
|
|
|
this.sqlParamHistory[key] = paramJson[key];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2023-02-24 18:12:04 +08:00
|
|
|
|
doExecutorSql(init) {
|
2023-02-07 15:35:34 +08:00
|
|
|
|
if (!this.choiceDatasourceId) {
|
|
|
|
|
|
this.$message.error("请先选择数据源");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2023-05-23 14:00:00 +08:00
|
|
|
|
if(!this.choiceDatabase){
|
|
|
|
|
|
this.$message.error("请先选择数据库");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2023-02-07 15:35:34 +08:00
|
|
|
|
this.executeError = "";
|
|
|
|
|
|
this.executeUseTime = "";
|
|
|
|
|
|
this.executeResultList = [];
|
|
|
|
|
|
let sqlParamObj = {};
|
|
|
|
|
|
this.sqlParams.forEach(item => {
|
|
|
|
|
|
if (!!item.value) {
|
|
|
|
|
|
sqlParamObj[item.key] = item.value;
|
|
|
|
|
|
this.sqlParamHistory[item.key] = item.value;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
this.nowExecutorId = (new Date()).getTime() + Math.ceil(Math.random() * 1000);
|
|
|
|
|
|
let sqlValue = this.sqlExecutorEditor.getSelectedText();
|
|
|
|
|
|
if (!sqlValue) {
|
|
|
|
|
|
sqlValue = this.sqlExecutorEditor.getValue();
|
|
|
|
|
|
}
|
|
|
|
|
|
this.sqlExecuting = true;
|
|
|
|
|
|
datasourceApi.queryExecuteSql({
|
|
|
|
|
|
sourceId: this.choiceDatasourceId,
|
|
|
|
|
|
dbName: this.choiceDatabase,
|
|
|
|
|
|
executeId: this.nowExecutorId,
|
2023-02-22 19:16:31 +08:00
|
|
|
|
pageNum: this.currentPage,
|
|
|
|
|
|
pageSize: this.pageSize,
|
2023-02-07 15:35:34 +08:00
|
|
|
|
sql: sqlValue,
|
|
|
|
|
|
params: JSON.stringify(sqlParamObj),
|
2023-02-15 20:35:34 +08:00
|
|
|
|
}).then(response => {
|
2023-02-07 15:35:34 +08:00
|
|
|
|
this.sqlExecuting = false;
|
2023-02-24 18:12:04 +08:00
|
|
|
|
if (response.errCode != 200) {
|
|
|
|
|
|
this.executeShowTable = 'tabError';
|
|
|
|
|
|
this.executeError = response.errMsg;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2023-02-15 20:35:34 +08:00
|
|
|
|
let resIndex = 1;
|
2023-02-07 15:35:34 +08:00
|
|
|
|
let executeResultList = [];
|
2023-02-15 20:35:34 +08:00
|
|
|
|
let resData = response.data || [];
|
|
|
|
|
|
let executeResultInfo = "";
|
|
|
|
|
|
resData.forEach(result => {
|
|
|
|
|
|
let dataListRes = [];
|
|
|
|
|
|
let previewColumns = [];
|
|
|
|
|
|
executeResultInfo += this.getExecuteInfoStr(result);
|
|
|
|
|
|
if (result.errCode === 0) {
|
|
|
|
|
|
let dataListTemp = result.data || [];
|
|
|
|
|
|
let headerList = result.header || [];
|
|
|
|
|
|
// 组装表头
|
|
|
|
|
|
let columnSet = {};
|
|
|
|
|
|
if (headerList.length > 0) {
|
|
|
|
|
|
let headerIndex = 0;
|
|
|
|
|
|
headerList.forEach(item => {
|
|
|
|
|
|
let key = 'value_' + (headerIndex++);
|
|
|
|
|
|
columnSet[key] = item;
|
|
|
|
|
|
previewColumns.push({prop: key, label: item});
|
|
|
|
|
|
});
|
|
|
|
|
|
dataListTemp.forEach(item => {
|
|
|
|
|
|
let dataItem = {}, dataIndex = 0;
|
|
|
|
|
|
previewColumns.forEach(column => {
|
|
|
|
|
|
let key = column.prop;
|
|
|
|
|
|
dataItem[key] = item[dataIndex++];
|
|
|
|
|
|
if ((dataItem[key] + '').length > columnSet[key].length) {
|
|
|
|
|
|
columnSet[key] = dataItem[key] + '';
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
dataListRes.push(dataItem);
|
|
|
|
|
|
});
|
|
|
|
|
|
previewColumns.forEach(item => {
|
|
|
|
|
|
// 动态计算宽度~自己想的一个方法,666
|
|
|
|
|
|
document.getElementById("widthCalculate").innerText = columnSet[item.prop];
|
|
|
|
|
|
let width = document.getElementById("widthCalculate").offsetWidth;
|
|
|
|
|
|
width = width + (columnSet[item.prop] === item.label ? 35 : 55);
|
|
|
|
|
|
width = (width < 50) ? 50 : width;
|
|
|
|
|
|
item.width = (width > 200) ? 200 : width;
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2020-05-24 13:00:43 +08:00
|
|
|
|
}
|
2023-02-15 20:35:34 +08:00
|
|
|
|
executeResultList.push({
|
|
|
|
|
|
label: '结果' + resIndex,
|
|
|
|
|
|
name: 'result_' + resIndex,
|
|
|
|
|
|
errMsg: result.errMsg,
|
|
|
|
|
|
errCode: result.errCode,
|
|
|
|
|
|
queryTime: result.queryTime,
|
2023-02-22 19:16:31 +08:00
|
|
|
|
selectCount: result.selectCount,
|
2023-05-18 17:06:20 +08:00
|
|
|
|
totalCount: dataListRes.length,
|
2023-02-15 20:35:34 +08:00
|
|
|
|
dataCols: previewColumns,
|
|
|
|
|
|
dataList: dataListRes
|
|
|
|
|
|
});
|
|
|
|
|
|
resIndex++;
|
2023-02-24 18:12:04 +08:00
|
|
|
|
//动态设置表格高度,尽量避免出现滚动条
|
|
|
|
|
|
if(result.selectCount){
|
2023-05-16 18:38:42 +08:00
|
|
|
|
this.height = 170;
|
2023-02-24 18:12:04 +08:00
|
|
|
|
}
|
2023-02-15 20:35:34 +08:00
|
|
|
|
});
|
2023-02-24 18:12:04 +08:00
|
|
|
|
//多个结果情况下,且点击分页
|
|
|
|
|
|
if(init!=1){
|
|
|
|
|
|
this.executeShowTable = (resIndex === 1) ? "tabInfo" : "result_1";
|
|
|
|
|
|
}
|
2023-02-07 15:35:34 +08:00
|
|
|
|
this.executeResultInfo = executeResultInfo;
|
|
|
|
|
|
this.executeResultList = executeResultList;
|
|
|
|
|
|
this.loadHistoryList();
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
2023-05-17 23:48:26 +08:00
|
|
|
|
//查看所有数据
|
|
|
|
|
|
viewAllData(init){
|
|
|
|
|
|
this.loadingAll = true;
|
|
|
|
|
|
if (!this.choiceDatasourceId) {
|
|
|
|
|
|
this.$message.error("请先选择数据源");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.executeError = "";
|
|
|
|
|
|
this.executeUseTime = "";
|
|
|
|
|
|
this.executeResultList = [];
|
|
|
|
|
|
let sqlParamObj = {};
|
|
|
|
|
|
this.sqlParams.forEach(item => {
|
|
|
|
|
|
if (!!item.value) {
|
|
|
|
|
|
sqlParamObj[item.key] = item.value;
|
|
|
|
|
|
this.sqlParamHistory[item.key] = item.value;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
this.nowExecutorId = (new Date()).getTime() + Math.ceil(Math.random() * 1000);
|
|
|
|
|
|
let sqlValue = this.sqlExecutorEditor.getSelectedText();
|
|
|
|
|
|
if (!sqlValue) {
|
|
|
|
|
|
sqlValue = this.sqlExecutorEditor.getValue();
|
|
|
|
|
|
}
|
|
|
|
|
|
this.sqlExecuting = true;
|
|
|
|
|
|
datasourceApi.queryExecuteSql({
|
|
|
|
|
|
sourceId: this.choiceDatasourceId,
|
|
|
|
|
|
dbName: this.choiceDatabase,
|
|
|
|
|
|
executeId: this.nowExecutorId,
|
|
|
|
|
|
pageNum: this.currentPage,
|
|
|
|
|
|
pageSize: this.pageSize,
|
|
|
|
|
|
sql: sqlValue,
|
|
|
|
|
|
type: 'noPage',
|
|
|
|
|
|
params: JSON.stringify(sqlParamObj),
|
|
|
|
|
|
}).then(response => {
|
|
|
|
|
|
this.sqlExecuting = false;
|
|
|
|
|
|
this.loadingAll = false;
|
|
|
|
|
|
if (response.errCode != 200) {
|
|
|
|
|
|
this.executeShowTable = 'tabError';
|
|
|
|
|
|
this.executeError = response.errMsg;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
let resIndex = 1;
|
|
|
|
|
|
let executeResultList = [];
|
|
|
|
|
|
let resData = response.data || [];
|
|
|
|
|
|
let executeResultInfo = "";
|
|
|
|
|
|
resData.forEach(result => {
|
|
|
|
|
|
let dataListRes = [];
|
|
|
|
|
|
let previewColumns = [];
|
|
|
|
|
|
executeResultInfo += this.getExecuteInfoStr(result);
|
|
|
|
|
|
if (result.errCode === 0) {
|
|
|
|
|
|
let dataListTemp = result.data || [];
|
|
|
|
|
|
let headerList = result.header || [];
|
|
|
|
|
|
// 组装表头
|
|
|
|
|
|
let columnSet = {};
|
|
|
|
|
|
if (headerList.length > 0) {
|
|
|
|
|
|
let headerIndex = 0;
|
|
|
|
|
|
headerList.forEach(item => {
|
|
|
|
|
|
let key = 'value_' + (headerIndex++);
|
|
|
|
|
|
columnSet[key] = item;
|
|
|
|
|
|
previewColumns.push({prop: key, label: item});
|
|
|
|
|
|
});
|
|
|
|
|
|
dataListTemp.forEach(item => {
|
|
|
|
|
|
let dataItem = {}, dataIndex = 0;
|
|
|
|
|
|
previewColumns.forEach(column => {
|
|
|
|
|
|
let key = column.prop;
|
|
|
|
|
|
dataItem[key] = item[dataIndex++];
|
|
|
|
|
|
if ((dataItem[key] + '').length > columnSet[key].length) {
|
|
|
|
|
|
columnSet[key] = dataItem[key] + '';
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
dataListRes.push(dataItem);
|
|
|
|
|
|
});
|
|
|
|
|
|
previewColumns.forEach(item => {
|
|
|
|
|
|
// 动态计算宽度~自己想的一个方法,666
|
|
|
|
|
|
document.getElementById("widthCalculate").innerText = columnSet[item.prop];
|
|
|
|
|
|
let width = document.getElementById("widthCalculate").offsetWidth;
|
|
|
|
|
|
width = width + (columnSet[item.prop] === item.label ? 35 : 55);
|
|
|
|
|
|
width = (width < 50) ? 50 : width;
|
|
|
|
|
|
item.width = (width > 200) ? 200 : width;
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
executeResultList.push({
|
|
|
|
|
|
label: '结果' + resIndex,
|
|
|
|
|
|
name: 'result_' + resIndex,
|
|
|
|
|
|
errMsg: result.errMsg,
|
|
|
|
|
|
errCode: result.errCode,
|
|
|
|
|
|
queryTime: result.queryTime,
|
|
|
|
|
|
selectCount: result.selectCount,
|
2023-05-18 17:06:20 +08:00
|
|
|
|
totalCount: dataListRes.length,
|
2023-05-17 23:48:26 +08:00
|
|
|
|
dataCols: previewColumns,
|
|
|
|
|
|
dataList: dataListRes
|
|
|
|
|
|
});
|
|
|
|
|
|
resIndex++;
|
|
|
|
|
|
//动态设置表格高度,尽量避免出现滚动条
|
|
|
|
|
|
if(result.selectCount){
|
|
|
|
|
|
this.height = 170;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
//多个结果情况下,且点击分页
|
|
|
|
|
|
if(init!=1){
|
|
|
|
|
|
this.executeShowTable = (resIndex === 1) ? "tabInfo" : "result_1";
|
|
|
|
|
|
}
|
|
|
|
|
|
this.executeResultInfo = executeResultInfo;
|
|
|
|
|
|
this.executeResultList = executeResultList;
|
|
|
|
|
|
this.loadHistoryList();
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
2023-02-22 19:16:31 +08:00
|
|
|
|
handleCurrentChange(to) {
|
|
|
|
|
|
this.currentPage = to;
|
2023-02-24 18:12:04 +08:00
|
|
|
|
let init = 1;
|
|
|
|
|
|
this.doExecutorSql(init);
|
2023-02-22 19:16:31 +08:00
|
|
|
|
},
|
2023-02-07 15:35:34 +08:00
|
|
|
|
loadDatasourceList() {
|
|
|
|
|
|
datasourceApi.datasourceList({}).then(json => {
|
|
|
|
|
|
this.datasourceList = json.data || [];
|
|
|
|
|
|
this.datasourceOptions = this.datasourceList;
|
2023-05-22 18:32:42 +08:00
|
|
|
|
|
|
|
|
|
|
//子组件向父组件传值
|
|
|
|
|
|
//this.$emit('listenToChildEvent',this.datasourceList);
|
|
|
|
|
|
|
2023-02-07 15:35:34 +08:00
|
|
|
|
let datasourceGroupList = [];
|
|
|
|
|
|
this.datasourceList.filter(item => !!item.groupName).forEach(item => datasourceGroupList.push(item.groupName || ''));
|
|
|
|
|
|
this.datasourceGroupList = Array.from(new Set(datasourceGroupList));
|
2023-05-22 18:32:42 +08:00
|
|
|
|
|
2023-02-07 15:35:34 +08:00
|
|
|
|
if (this.datasourceList.length > 0) {
|
|
|
|
|
|
this.choiceDatasourceId = this.datasourceList[0].id;
|
2023-05-22 18:32:42 +08:00
|
|
|
|
//初次加载根据query值设置对应数据源
|
|
|
|
|
|
if(this.$route.query.datasourceId){
|
|
|
|
|
|
this.choiceDatasourceId = parseInt(this.$route.query.datasourceId);
|
|
|
|
|
|
}
|
|
|
|
|
|
//初次加载根据query值设置对应数据库
|
|
|
|
|
|
if(this.$route.query.database){
|
|
|
|
|
|
this.choiceDatabase = this.$route.query.database;
|
|
|
|
|
|
}
|
2021-06-20 00:41:28 +08:00
|
|
|
|
this.executorSource = {sourceId: this.choiceDatasourceId};
|
2023-05-22 18:32:42 +08:00
|
|
|
|
this.loadDatabaseList(true);
|
2021-06-20 17:47:46 +08:00
|
|
|
|
this.loadSourceBaseInfo();
|
2021-06-27 22:45:30 +08:00
|
|
|
|
this.loadHistoryAndFavoriteList();
|
2021-06-01 22:34:21 +08:00
|
|
|
|
}
|
2023-02-07 15:35:34 +08:00
|
|
|
|
});
|
|
|
|
|
|
},
|
2023-05-22 18:32:42 +08:00
|
|
|
|
//initFlag: 初次加载状态
|
|
|
|
|
|
loadDatabaseList(initFlag) {
|
2023-02-07 15:35:34 +08:00
|
|
|
|
datasourceApi.databaseList({sourceId: this.choiceDatasourceId}).then(json => {
|
|
|
|
|
|
this.databaseList = json.data || [];
|
|
|
|
|
|
if (this.databaseList.length > 0) {
|
|
|
|
|
|
// 排除系统库
|
|
|
|
|
|
let sysDbName = ["information_schema", "master", "model", "msdb", "tempdb"];
|
|
|
|
|
|
let notSysDbItem = this.databaseList.find(item => sysDbName.indexOf(item.dbName) < 0);
|
2023-05-23 14:00:00 +08:00
|
|
|
|
// 非初次加载,动态改变url参数
|
2023-05-22 18:32:42 +08:00
|
|
|
|
if(!initFlag){
|
2023-05-23 14:00:00 +08:00
|
|
|
|
this.choiceDatabase = (!!notSysDbItem) ? notSysDbItem.dbName : this.databaseList[0].dbName;
|
2023-05-22 18:32:42 +08:00
|
|
|
|
this.$router.replace({ query: { datasourceId: this.choiceDatasourceId,database:this.choiceDatabase } })
|
2023-05-23 14:00:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
this.executorSource = {sourceId: this.choiceDatasourceId, dbName: this.choiceDatabase};
|
2023-02-07 15:35:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
loadSourceBaseInfo() {
|
|
|
|
|
|
datasourceApi.getSourceBaseInfo({sourceId: this.choiceDatasourceId}).then(json => {
|
|
|
|
|
|
let data = json.data || {};
|
|
|
|
|
|
this.editorDbProduct = data.product || '';
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
sourceGroupChangeEvents() {
|
|
|
|
|
|
let datasourceOptions = [];
|
|
|
|
|
|
for (let i = 0; i < this.datasourceList.length; i++) {
|
|
|
|
|
|
let item = this.datasourceList[i];
|
|
|
|
|
|
if (!this.choiceDatasourceGroup || this.choiceDatasourceGroup == item.groupName) {
|
|
|
|
|
|
datasourceOptions.push(item);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
this.datasourceOptions = datasourceOptions;
|
|
|
|
|
|
if (datasourceOptions.length > 0) {
|
|
|
|
|
|
this.choiceDatasourceId = datasourceOptions[0].id;
|
2021-06-20 00:41:28 +08:00
|
|
|
|
this.executorSource = {sourceId: this.choiceDatasourceId};
|
|
|
|
|
|
this.loadDatabaseList();
|
2021-06-20 17:47:46 +08:00
|
|
|
|
this.loadSourceBaseInfo();
|
2021-06-27 22:45:30 +08:00
|
|
|
|
this.loadHistoryAndFavoriteList();
|
2023-02-07 15:35:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
datasourceChangeEvents() {
|
|
|
|
|
|
this.executorSource = {sourceId: this.choiceDatasourceId};
|
2023-02-22 19:16:31 +08:00
|
|
|
|
this.currentPage = 1;
|
2023-02-07 15:35:34 +08:00
|
|
|
|
this.loadDatabaseList();
|
|
|
|
|
|
this.loadSourceBaseInfo();
|
|
|
|
|
|
this.loadHistoryAndFavoriteList();
|
|
|
|
|
|
},
|
|
|
|
|
|
databaseChangeEvents() {
|
2023-05-23 14:00:00 +08:00
|
|
|
|
this.$router.replace({ query: { datasourceId: this.choiceDatasourceId,database:this.choiceDatabase } })
|
2023-02-07 15:35:34 +08:00
|
|
|
|
this.executorSource = {sourceId: this.choiceDatasourceId, dbName: this.choiceDatabase};
|
2023-02-22 19:16:31 +08:00
|
|
|
|
this.currentPage = 1;
|
2023-02-07 15:35:34 +08:00
|
|
|
|
},
|
|
|
|
|
|
getExecuteInfoStr(resultData) {
|
2023-02-15 20:35:34 +08:00
|
|
|
|
var resultStr = resultData.executeSql;
|
2023-02-07 15:35:34 +08:00
|
|
|
|
resultStr += "\n> 状态:" + ((!!resultData.errMsg) ? "ERROR" : "OK");
|
|
|
|
|
|
if (resultData.updateCount >= 0) {
|
|
|
|
|
|
resultStr += "\n> 影响行数:" + resultData.updateCount;
|
|
|
|
|
|
}
|
2023-02-15 20:35:34 +08:00
|
|
|
|
resultStr += "\n> 耗时:" + (resultData.queryTime || 0) / 1000 + "s";
|
2023-02-07 15:35:34 +08:00
|
|
|
|
resultStr += "\n\n";
|
|
|
|
|
|
return resultStr;
|
|
|
|
|
|
},
|
|
|
|
|
|
dealExecuteResult(resultData) {
|
|
|
|
|
|
var dataList = resultData.result || [];
|
|
|
|
|
|
var executeResultCols = [];
|
|
|
|
|
|
if (dataList.length > 0) {
|
|
|
|
|
|
var propData = dataList[0];
|
|
|
|
|
|
for (var key in propData) {
|
|
|
|
|
|
// 动态计算宽度~自己想的一个方法,666
|
|
|
|
|
|
document.getElementById("widthCalculate").innerText = key;
|
|
|
|
|
|
var width1 = document.getElementById("widthCalculate").offsetWidth;
|
|
|
|
|
|
document.getElementById("widthCalculate").innerText = propData[key];
|
|
|
|
|
|
var width2 = document.getElementById("widthCalculate").offsetWidth;
|
|
|
|
|
|
var width = (width1 > width2) ? width1 : width2;
|
|
|
|
|
|
width = (width < 50) ? 50 : width;
|
|
|
|
|
|
width = (width > 200) ? 200 : width;
|
|
|
|
|
|
executeResultCols.push({prop: key, width: width + 25});
|
2021-05-29 22:18:15 +08:00
|
|
|
|
}
|
2023-02-07 15:35:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
var resultObj = {};
|
|
|
|
|
|
resultObj.dataList = dataList;
|
|
|
|
|
|
resultObj.dataCols = executeResultCols;
|
|
|
|
|
|
resultObj.useTime = resultData.useTime || 0;
|
|
|
|
|
|
resultObj.errMsg = resultData.errMsg || "";
|
|
|
|
|
|
resultObj.updateCount = resultData.updateCount;
|
|
|
|
|
|
return resultObj;
|
|
|
|
|
|
},
|
|
|
|
|
|
handleSelectionChange(val) {
|
|
|
|
|
|
this.$set(this.choiceResultObj, this.executeShowTable, val);
|
|
|
|
|
|
},
|
2023-02-22 19:16:31 +08:00
|
|
|
|
tabHandleClick(t){
|
2023-02-24 18:12:04 +08:00
|
|
|
|
|
2023-02-22 19:16:31 +08:00
|
|
|
|
},
|
2023-02-07 15:35:34 +08:00
|
|
|
|
doCopyCheckLineUpdate() {
|
|
|
|
|
|
let choiceData = this.choiceResultObj[this.executeShowTable] || [];
|
|
|
|
|
|
if (choiceData.length > 0) {
|
|
|
|
|
|
let dataCols = this.executeResultList.find(item => item.name === this.executeShowTable).dataCols;
|
|
|
|
|
|
let copyData = copyFormatter.format('update', this.editorDbProduct, dataCols, choiceData, this.conditionDataColsChoice);
|
|
|
|
|
|
this.conditionDataColsChoice = [];
|
|
|
|
|
|
this.exportConditionVisible = false;
|
|
|
|
|
|
this.$copyText(copyData).then(
|
|
|
|
|
|
res => this.$message.success("内容已复制到剪切板!"),
|
|
|
|
|
|
err => this.$message.error("抱歉,复制失败!")
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
handleCopyCheckLineCommand(type) {
|
|
|
|
|
|
let choiceData = this.choiceResultObj[this.executeShowTable] || [];
|
|
|
|
|
|
if (choiceData.length > 0) {
|
|
|
|
|
|
let dataCols = this.executeResultList.find(item => item.name === this.executeShowTable).dataCols;
|
|
|
|
|
|
if (type === 'update') {
|
|
|
|
|
|
// 选择更新的条件列
|
|
|
|
|
|
this.conditionDataCols = dataCols;
|
|
|
|
|
|
this.exportConditionVisible = true;
|
|
|
|
|
|
return;
|
2021-05-24 22:42:01 +08:00
|
|
|
|
}
|
2023-02-07 15:35:34 +08:00
|
|
|
|
let copyData = copyFormatter.format(type, this.editorDbProduct, dataCols, choiceData, '');
|
|
|
|
|
|
this.$copyText(copyData).then(
|
|
|
|
|
|
res => this.$message.success("内容已复制到剪切板!"),
|
|
|
|
|
|
err => this.$message.error("抱歉,复制失败!")
|
|
|
|
|
|
);
|
2021-05-24 22:42:01 +08:00
|
|
|
|
}
|
2023-05-16 18:38:42 +08:00
|
|
|
|
},
|
|
|
|
|
|
//表格单元格鼠标焦点事件
|
|
|
|
|
|
mouseOnFocus(row, column, cell, event){
|
|
|
|
|
|
if(this.uxGridCell){
|
|
|
|
|
|
this.uxGridCell.style.border = 'none'
|
|
|
|
|
|
}
|
|
|
|
|
|
cell.style.border = '2px solid #0078d7'
|
|
|
|
|
|
this.uxGridCell = cell;
|
|
|
|
|
|
},
|
|
|
|
|
|
//表格单元格 hover 退出
|
|
|
|
|
|
mouseLeave(row, column, cell, event){
|
|
|
|
|
|
// if(this.uxGridCell){
|
|
|
|
|
|
// this.uxGridCell.style.border = 'none'
|
|
|
|
|
|
// }
|
2023-05-17 23:48:26 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 点击区域外
|
|
|
|
|
|
handleClickOutside() {
|
|
|
|
|
|
if(this.uxGridCell){
|
|
|
|
|
|
this.uxGridCell.style.border = 'none'
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2021-05-24 22:42:01 +08:00
|
|
|
|
}
|
2023-02-07 15:35:34 +08:00
|
|
|
|
}
|
2019-08-21 20:39:43 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
2023-02-09 22:27:39 +08:00
|
|
|
|
<style scoped>
|
2023-02-07 15:35:34 +08:00
|
|
|
|
.data-executor-vue .ace-monokai .ace_print-margin {
|
|
|
|
|
|
display: none;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.data-executor-vue .el-card__body {
|
2023-05-16 18:38:42 +08:00
|
|
|
|
padding: 5px;
|
2023-02-07 15:35:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.data-executor-vue .sql-params {
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.data-executor-vue .sql-params .el-input-group {
|
|
|
|
|
|
width: auto;
|
|
|
|
|
|
margin: 10px 10px 0 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.data-executor-vue .sql-params .el-input__inner {
|
|
|
|
|
|
width: 200px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.data-executor-vue .el-table td, .el-table th {
|
|
|
|
|
|
padding: 6px 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.data-executor-vue .execute-result-table .el-input__inner {
|
|
|
|
|
|
height: 25px;
|
|
|
|
|
|
line-height: 25px;
|
|
|
|
|
|
padding: 0 5px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.data-executor-vue .execute-result-table .el-textarea__inner {
|
2023-05-17 23:48:26 +08:00
|
|
|
|
height: 26px;
|
|
|
|
|
|
min-height: 26px;
|
|
|
|
|
|
line-height: 26px;
|
|
|
|
|
|
padding: 0;
|
2023-02-07 15:35:34 +08:00
|
|
|
|
resize: none;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.data-executor-vue .sql-content-line {
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
display: -webkit-box;
|
|
|
|
|
|
-webkit-line-clamp: 2;
|
|
|
|
|
|
-webkit-box-orient: vertical;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.data-executor-vue .execute-use-time {
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
margin-right: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-02-15 20:35:34 +08:00
|
|
|
|
.data-executor-vue .execute-result-info {
|
|
|
|
|
|
white-space: pre-wrap;
|
|
|
|
|
|
max-height: 400px;
|
|
|
|
|
|
overflow: auto;
|
|
|
|
|
|
background: #263238;
|
|
|
|
|
|
color: #fff;
|
|
|
|
|
|
padding: 10px;
|
|
|
|
|
|
border-radius: 6px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-02-07 15:35:34 +08:00
|
|
|
|
.data-executor-vue-out .el-tabs__nav-scroll {
|
|
|
|
|
|
padding-left: 20px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.data-executor-vue-out .el-button + .el-button {
|
|
|
|
|
|
margin-left: 0px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.data-executor-vue-out .el-table__body-wrapper {
|
|
|
|
|
|
height: calc(100vh - 180px);
|
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
|
}
|
2023-02-09 22:27:39 +08:00
|
|
|
|
|
|
|
|
|
|
/deep/ .elx-table .elx-body--column.col--ellipsis {
|
2023-05-17 23:48:26 +08:00
|
|
|
|
height: 30px;
|
2023-02-09 22:27:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/deep/ .elx-table .elx-header--column.col--ellipsis {
|
2023-05-17 23:48:26 +08:00
|
|
|
|
height: 30px;
|
|
|
|
|
|
//padding-left: 5px;
|
2023-05-16 18:38:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
.el-textarea__inner{
|
|
|
|
|
|
border: none;
|
|
|
|
|
|
background-color: #f0f8ff00;
|
2023-02-09 22:27:39 +08:00
|
|
|
|
}
|
2023-05-12 18:13:59 +08:00
|
|
|
|
.el-textarea__inner::-webkit-scrollbar {
|
|
|
|
|
|
display: none;
|
|
|
|
|
|
}
|
2023-05-16 18:38:42 +08:00
|
|
|
|
/deep/ .el-tabs--border-card>.el-tabs__content {
|
|
|
|
|
|
padding: 5px;
|
|
|
|
|
|
}
|
2023-05-17 23:48:26 +08:00
|
|
|
|
/deep/ .elx-table .elx-body--column.col--ellipsis>.elx-cell,
|
|
|
|
|
|
.elx-table .elx-footer--column.col--ellipsis>.elx-cell,
|
|
|
|
|
|
.elx-table .elx-header--column.col--ellipsis>.elx-cell{
|
|
|
|
|
|
overflow: auto;
|
|
|
|
|
|
text-overflow: unset;
|
|
|
|
|
|
}
|
|
|
|
|
|
/deep/ .elx-table .elx-body--column.col--ellipsis>.elx-cell::-webkit-scrollbar {
|
|
|
|
|
|
display: none;
|
|
|
|
|
|
}
|
2019-08-21 20:39:43 +08:00
|
|
|
|
</style>
|