SQL执行的动态参数保存,数据预览列表头移上去展示列说明

This commit is contained in:
暮光:城中城
2021-07-17 12:22:51 +08:00
parent eda81c36bc
commit 1d5c57d516
15 changed files with 84 additions and 27 deletions

View File

@@ -45,6 +45,11 @@
<el-table-column type="selection" width="55"></el-table-column>
<el-table-column type="index" width="50"></el-table-column>
<el-table-column sortable v-for="item in resultItem.dataCols" :prop="item.prop" :label="item.prop" :width="item.width">
<template slot="header" slot-scope="scope">
<el-tooltip effect="dark" :content="item.desc" placement="top">
<span>{{item.prop}}</span>
</el-tooltip>
</template>
<template slot-scope="scope">
<textarea readonly :value="scope.row[item.prop]" class="el-textarea__inner" rows="1"></textarea>
</template>
@@ -170,7 +175,8 @@
minLines: 3,
maxLines: 3,
},
executorSource: {}
executorSource: {},
columnMap: {},
}
},
components: {
@@ -188,12 +194,15 @@
// }, 500);
},
methods: {
init(param) {
init(param, columnList) {
if (this.pageParam.sourceId == param.sourceId) {
return;
}
this.pageParam = param;
this.executorSource = {sourceId: param.sourceId, dbName: param.dbName, tableName: param.tableName};
let columnMap = {};
columnList.forEach(item => columnMap[item.name] = item);
this.columnMap = columnMap;
this.doExecutorSqlCommon();
// this.vueQueryParam = to.query;
// let newName = {key: this.$route.fullPath, val: '数据-'+this.vueQueryParam.tableName};
@@ -328,7 +337,8 @@
var width = (width1 > width2) ? width1 : width2;
width = (width < 50) ? 50 : width;
width = (width > 200) ? 200 : width;
executeResultCols.push({prop: key, width: width + 50});
let column = this.columnMap[key] || {};
executeResultCols.push({prop: key, width: width + 50, desc: (column.description || key)});
}
}
var resultObj = {};

View File

@@ -46,12 +46,12 @@
<el-table-column prop="createTime" label="执行时间" width="160px"></el-table-column>
<el-table-column prop="content" label="SQL">
<template slot-scope="scope">
<pre class="sql-content-line" @dblclick="inputFavoriteSql(scope.row.content)" :title="scope.row.content">{{scope.row.content}}</pre>
<pre class="sql-content-line" @dblclick="inputFavoriteSql(scope.row)" :title="scope.row.content">{{scope.row.content}}</pre>
</template>
</el-table-column>
<el-table-column label="操作" width="160px">
<template slot-scope="scope">
<el-button size="mini" type="primary" @click="inputFavoriteSql(scope.row.content)">输入</el-button>
<el-button size="mini" type="primary" @click="inputFavoriteSql(scope.row)">输入</el-button>
<el-button size="mini" type="success" @click="addFavorite(scope.row.content)" style="margin-left: 10px;">收藏</el-button>
</template>
</el-table-column>
@@ -62,12 +62,12 @@
<el-table-column prop="createTime" label="执行时间" width="160px"></el-table-column>
<el-table-column prop="content" label="SQL">
<template slot-scope="scope">
<pre class="sql-content-line" @dblclick="inputFavoriteSql(scope.row.content)" :title="scope.row.content">{{scope.row.content}}</pre>
<pre class="sql-content-line" @dblclick="inputFavoriteSql(scope.row)" :title="scope.row.content">{{scope.row.content}}</pre>
</template>
</el-table-column>
<el-table-column label="操作" width="160px">
<template slot-scope="scope">
<el-button size="mini" type="primary" v-on:click="inputFavoriteSql(scope.row.content)">输入</el-button>
<el-button size="mini" type="primary" v-on:click="inputFavoriteSql(scope.row)">输入</el-button>
<el-button size="mini" type="danger" v-on:click="delFavorite(scope.row)" style="margin-left: 10px;">删除</el-button>
</template>
</el-table-column>
@@ -234,11 +234,22 @@
sqlValue = this.sqlExecutorEditor.getValue();
}
}
let param = {name: '我的收藏', content: sqlValue, datasourceId: this.choiceDatasourceId};
datasourceApi.updateFavorite(param).then(() => {
this.$message.success("收藏成功");
this.loadFavoriteList();
});
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(() => {
@@ -246,9 +257,15 @@
this.loadFavoriteList();
});
},
inputFavoriteSql(content) {
this.sqlExecutorEditor.setValue(content, 1);
},
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) {