表数据查看排序,tab标签页优化
This commit is contained in:
@@ -3,19 +3,24 @@
|
||||
<div style="padding: 0 10px;height: 100%;box-sizing: border-box;">
|
||||
<el-card>
|
||||
<div v-if="!!executeError" style="color: #f00;">{{executeError}}</div>
|
||||
<div v-else-if="executeResultList.length <= 0" v-loading="sqlExecuting">暂无数据</div>
|
||||
<div v-else-if="sqlExecuting" v-loading="sqlExecuting" style="padding: 20px 0;">暂无数据</div>
|
||||
<div v-else>
|
||||
<el-button size="small" @click="refreshData" style="position: absolute;right: 30px;z-index: 1;">刷新</el-button>
|
||||
<el-tabs :value="executeShowTable">
|
||||
<el-tab-pane label="信息" name="table0">
|
||||
<pre>{{executeResultInfo}}</pre>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="'结果'+resultItem.index" :name="'table'+resultItem.index" v-for="resultItem in executeResultList" v-if="!!resultItem.index">
|
||||
<div v-if="!!resultItem.errMsg" style="color: #f00;">{{resultItem.errMsg}}</div>
|
||||
<el-table v-else :data="resultItem.dataList" stripe border style="width: 100%; margin-bottom: 5px;" class="execute-result-table" max-height="600">
|
||||
<el-table v-else :data="resultItem.dataList" stripe border
|
||||
style="width: 100%; margin-bottom: 5px;"
|
||||
class="execute-result-table" :max-height="tableMaxHeight"
|
||||
@sort-change="tableSortChange"
|
||||
:default-sort="tableSort">
|
||||
<el-table-column width="60px" v-if="resultItem.dataCols.length > 0">
|
||||
<template slot-scope="scope">{{scope.row._index}}</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-for="item in resultItem.dataCols" :prop="item.prop" :label="item.prop" :width="item.width">
|
||||
<el-table-column sortable v-for="item in resultItem.dataCols" :prop="item.prop" :label="item.prop" :width="item.width">
|
||||
<template slot-scope="scope">
|
||||
<el-input type="textarea" :rows="1" :value="scope.row[item.prop]" :readonly="true" resize="none"></el-input>
|
||||
</template>
|
||||
@@ -61,24 +66,22 @@
|
||||
pageSize: 50,
|
||||
currentPage: 1,
|
||||
tableTotalCount: 0,
|
||||
tableSort: {},
|
||||
tableMaxHeight: 600,
|
||||
}
|
||||
},
|
||||
beforeRouteUpdate(to, from, next) {
|
||||
this.initQueryParam(to);
|
||||
next();
|
||||
},
|
||||
mounted: function () {
|
||||
activated: function () {
|
||||
this.initQueryParam(this.$route);
|
||||
this.doExecutorSql();
|
||||
// 延迟设置展开的目录,edit比app先初始化
|
||||
setTimeout(()=> {
|
||||
this.doExecutorSql();
|
||||
global.vue.$app.initLoadDataList(this.vueQueryParam.sourceId, this.vueQueryParam.host, this.vueQueryParam.dbName);
|
||||
}, 500);
|
||||
},
|
||||
methods: {
|
||||
initQueryParam(to) {
|
||||
this.vueQueryParam = to.query;
|
||||
let newName = {key: this.$route.fullPath, val: this.vueQueryParam.tableName + '-数据'};
|
||||
let newName = {key: this.$route.fullPath, val: '数据-'+this.vueQueryParam.tableName};
|
||||
this.$store.commit('global/addTableName', newName);
|
||||
},
|
||||
handleCurrentChange(to) {
|
||||
@@ -89,6 +92,16 @@
|
||||
this.pageSize = to;
|
||||
this.doExecutorSql();
|
||||
},
|
||||
tableSortChange(sort) {
|
||||
if (this.tableSort.prop === sort.prop && this.tableSort.order === sort.order) return;
|
||||
this.tableSort = {prop: sort.prop, order: sort.order};
|
||||
this.doExecutorSql();
|
||||
},
|
||||
refreshData() {
|
||||
this.tableSort = {};
|
||||
this.currentPage = 1;
|
||||
this.doExecutorSql();
|
||||
},
|
||||
cancelExecutorSql() {
|
||||
let that = this;
|
||||
this.common.post(this.apilist1.executeSqlCancel, {executeId: this.nowExecutorId}, function (json) {
|
||||
@@ -104,6 +117,7 @@
|
||||
this.executeError = "";
|
||||
this.executeUseTime = "";
|
||||
this.executeResultList = [];
|
||||
this.tableMaxHeight = document.body.offsetHeight - 240;
|
||||
|
||||
this.nowExecutorId = (new Date()).getTime() + Math.ceil(Math.random() * 1000);
|
||||
this.sqlExecuting = true;
|
||||
@@ -149,7 +163,12 @@
|
||||
},
|
||||
getExecuteSql() {
|
||||
if (this.vueQueryParam.dbType == 'mysql') {
|
||||
let tableSort = ' ';
|
||||
if (!!this.tableSort.prop && !!this.tableSort.order) {
|
||||
tableSort = ' order by ' + this.tableSort.prop + ' ' + (this.tableSort.order === 'ascending' ? 'asc' : 'desc');
|
||||
}
|
||||
return 'select * from ' + this.vueQueryParam.dbName + '.' + this.vueQueryParam.tableName
|
||||
+ tableSort
|
||||
+ ' limit ' + this.pageSize + ' offset ' + ((this.currentPage - 1) * this.pageSize);
|
||||
}
|
||||
this.$message.error("暂未支持的数据库类型表数据预览");
|
||||
@@ -185,7 +204,7 @@
|
||||
var width = (width1 > width2) ? width1 : width2;
|
||||
width = (width < 50) ? 50 : width;
|
||||
width = (width > 200) ? 200 : width;
|
||||
executeResultCols.push({prop: key, width: width + 25});
|
||||
executeResultCols.push({prop: key, width: width + 50});
|
||||
}
|
||||
for (var i = 0; i < dataList.length; i++) {
|
||||
dataList[i]._index = i + 1;
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
|
||||
<script>
|
||||
import global from '../../common/config/global'
|
||||
var app;
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@@ -39,28 +38,26 @@
|
||||
keyword: '',
|
||||
};
|
||||
},
|
||||
beforeRouteUpdate(to, from, next) {
|
||||
this.initQueryParam(to);
|
||||
next();
|
||||
},
|
||||
mounted: function () {
|
||||
app = this;
|
||||
activated: function () {
|
||||
this.initQueryParam(this.$route);
|
||||
// 延迟设置展开的目录,edit比app先初始化
|
||||
setTimeout(function () {
|
||||
global.vue.$app.initLoadDataList(app.vueQueryParam.sourceId, app.vueQueryParam.host, app.vueQueryParam.dbName);
|
||||
setTimeout(() => {
|
||||
global.vue.$app.initLoadDataList(this.vueQueryParam.sourceId, this.vueQueryParam.host, this.vueQueryParam.dbName);
|
||||
}, 500);
|
||||
},
|
||||
methods: {
|
||||
initQueryParam(to) {
|
||||
this.vueQueryParam = to.query;
|
||||
let newName = {key: this.$route.fullPath, val: '库-' + this.vueQueryParam.dbName};
|
||||
this.$store.commit('global/addTableName', newName);
|
||||
},
|
||||
searchSubmit() {
|
||||
let that = this;
|
||||
this.columnListLoading = true;
|
||||
this.vueQueryParam.searchText = this.keyword;
|
||||
this.common.post(this.apilist1.tableAndColumnBySearch, this.vueQueryParam, function (json) {
|
||||
app.columnList = json.data || [];
|
||||
app.columnListLoading = false;
|
||||
that.columnList = json.data || [];
|
||||
that.columnListLoading = false;
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
</el-row>
|
||||
<el-row class="status-info-row">
|
||||
<el-col :span="6"><span class="label">数据库:</span>{{vueQueryParam.dbName}}</el-col>
|
||||
<el-col :span="6"><span class="label">数据表:</span>{{vueQueryParam.tableName}}</el-col>
|
||||
<el-col :span="6"><span class="label">数据表:</span>{{tableStatusInfo.name}}</el-col>
|
||||
<el-col :span="6"><span class="label">引擎:</span>{{tableStatusInfo.engine}}</el-col>
|
||||
</el-row>
|
||||
<el-row class="status-info-row">
|
||||
@@ -88,14 +88,10 @@
|
||||
vueQueryParam: {},
|
||||
tableStatusInfo: {},
|
||||
columnList: [],
|
||||
tableInfo: [],
|
||||
tableInfo: {},
|
||||
};
|
||||
},
|
||||
beforeRouteUpdate(to, from, next) {
|
||||
this.initQueryParam(to);
|
||||
next();
|
||||
},
|
||||
mounted: function () {
|
||||
activated: function () {
|
||||
this.initQueryParam(this.$route);
|
||||
// 延迟设置展开的目录,edit比app先初始化
|
||||
setTimeout(()=> {
|
||||
@@ -104,6 +100,9 @@
|
||||
},
|
||||
methods: {
|
||||
initQueryParam(to) {
|
||||
if (this.columnListLoading) {
|
||||
return;
|
||||
}
|
||||
let that = this;
|
||||
this.columnListLoading = true;
|
||||
this.vueQueryParam = to.query;
|
||||
@@ -118,9 +117,9 @@
|
||||
tableInfo.inEdit = 0;
|
||||
tableInfo.newDesc = tableInfo.description;
|
||||
that.tableInfo = tableInfo;
|
||||
that.columnListLoading = false;
|
||||
var newName = {key: that.$route.fullPath, val: tableInfo.tableName};
|
||||
var newName = {key: that.$route.fullPath, val: '表-' + tableInfo.tableName};
|
||||
that.$store.commit('global/addTableName', newName);
|
||||
that.columnListLoading = false;
|
||||
});
|
||||
this.common.post(this.apilist1.tableStatus, this.vueQueryParam, function (json) {
|
||||
that.tableStatusInfo = json.data || {};
|
||||
|
||||
Reference in New Issue
Block a user