改为使用vue-cli打包,修改所有的请求方式,优化页面间的交互,增加数据源分组

This commit is contained in:
暮光:城中城
2020-05-23 12:21:23 +08:00
parent adadffa0cd
commit 88686f84f4
63 changed files with 8421 additions and 8773 deletions

View File

@@ -78,8 +78,7 @@
import '../../common/lib/ace/mode-sql'
import '../../common/lib/ace/ext-language_tools'
import '../../common/lib/ace/snippets/sql'
import global from '../../common/config/global'
import {queryExecuteSql} from '../../common/api/datasource'
import datasourceApi from '../../common/api/datasource'
import sqlFormatter from "sql-formatter";
export default {
@@ -112,11 +111,15 @@
that.doExecutorClick();
}
});
// 延迟设置展开的目录edit比app先初始化
setTimeout(()=> {
this.doExecutorSql();
global.vue.$app.initLoadDataList(this.vueQueryParam.sourceId, this.vueQueryParam.host, this.vueQueryParam.dbName);
}, 500);
// 延迟设置展开的目录edit比app先初始化
setTimeout(() => {
this.doExecutorSql();
this.$emit('initLoadDataList', {
sourceId: this.vueQueryParam.sourceId,
host: this.vueQueryParam.host,
dbName: this.vueQueryParam.dbName
});
}, 500);
},
activated: function () {
this.initQueryParam(this.$route);
@@ -160,9 +163,8 @@
}
},
cancelExecutorSql() {
let that = this;
this.common.post(this.apilist1.executeSqlCancel, {executeId: this.nowExecutorId}, function (json) {
that.$message.success("取消成功");
datasourceApi.executeSqlCancel({executeId: this.nowExecutorId}).then(() => {
this.$message.success("取消成功");
});
},
doExecutorClick() {
@@ -185,7 +187,6 @@
this.doExecutorSqlCommon(dataSql, countSql);
},
doExecutorSqlCommon(dataSql, countSql) {
let that = this;
if (!this.vueQueryParam.sourceId) {
this.$message.error("请先选择数据源");
return;
@@ -205,7 +206,7 @@
};
// 第一页才查询总条数
if (!!countSql && this.currentPage == 1) {
queryExecuteSql(param).then(res => {
datasourceApi.queryExecuteSql(param).then(res => {
if (res.errCode != 200 || !res.data || res.data.length <= 0) return;
let objItem = JSON.parse(res.data[0]);
if(!objItem.result || objItem.result.length <= 0) return;
@@ -213,29 +214,29 @@
});
}
param.sql = dataSql;
this.common.postNonCheck(this.apilist1.executeSql, param, function (json) {
datasourceApi.queryExecuteSql(param).then(json => {
if (json.errCode != 200) {
that.executeError = json.errMsg;
that.sqlExecuting = false;
this.executeError = json.errMsg;
this.sqlExecuting = false;
return;
}
var resultList = json.data || [];
var executeResultList = [];
var executeResultInfo = "", itemIndex = 1;
for (var i = 0; i < resultList.length; i++) {
var objItem = JSON.parse(resultList[i]);
executeResultInfo += that.getExecuteInfoStr(objItem);
var resultItem = that.dealExecuteResult(objItem);
let resultList = json.data || [];
let executeResultList = [];
let executeResultInfo = "", itemIndex = 1;
for (let i = 0; i < resultList.length; i++) {
let objItem = JSON.parse(resultList[i]);
executeResultInfo += this.getExecuteInfoStr(objItem);
let resultItem = this.dealExecuteResult(objItem);
if (resultItem.updateCount < 0) {
resultItem.index = itemIndex;
itemIndex++;
}
executeResultList.push(resultItem);
}
that.executeShowTable = (itemIndex === 1) ? "table0" : "table1";
that.executeResultInfo = executeResultInfo;
that.executeResultList = executeResultList;
that.sqlExecuting = false;
this.executeShowTable = (itemIndex === 1) ? "table0" : "table1";
this.executeResultInfo = executeResultInfo;
this.executeResultList = executeResultList;
this.sqlExecuting = false;
});
},
getExecuteSql() {

View File

@@ -8,6 +8,7 @@
</div>
<el-table :data="datasourceList" stripe border style="width: 100%; margin-bottom: 5px;">
<el-table-column prop="name" label="名字" width="100"></el-table-column>
<el-table-column prop="groupName" label="分组" width="100"></el-table-column>
<el-table-column prop="driverClassName" label="驱动类" width="200"></el-table-column>
<el-table-column prop="sourceUrl" label="数据源URL"></el-table-column>
<el-table-column prop="sourceName" label="账号"></el-table-column>
@@ -23,15 +24,15 @@
</el-card>
<!--增加数据源弹窗-->
<el-dialog :inline="true" :title="newDatasource.id>0?'编辑数据源':'新增数据源'" :visible.sync="datasourceDialogVisible" width="760px">
<!-- <el-alert-->
<!-- title="重要提醒"-->
<!-- description="请录入正确可用的数据库连接、账号、密码信息,否则初始化数据源失败将影响整个系统,有可能需要重启服务才能解决"-->
<!-- type="warning" :closable="false"-->
<!-- show-icon style="margin-bottom: 10px;">-->
<!-- </el-alert>-->
<el-form label-width="120px">
<el-form-item label="名字">
<el-input v-model="newDatasource.name" placeholder="中文名字"></el-input>
<el-form-item label="分组">
<el-select v-model="newDatasource.groupName" placeholder="分组名字" style="width: 100%" filterable allow-create>
<el-option value="">未分组</el-option>
<el-option :value="item" v-for="item in datasourceGroupList"></el-option>
</el-select>
</el-form-item>
<el-form-item label="数据源名称:">
<el-input v-model="newDatasource.name" placeholder="给数据源起个中文名称"></el-input>
</el-form-item>
<el-form-item label="驱动类:">
<el-select v-model="newDatasource.driverClassName" @change="driverClassNameChange" placeholder="驱动类" style="width: 100%">
@@ -49,7 +50,7 @@
<el-form-item label="密码:">
<el-input v-model="newDatasource.sourcePassword" placeholder="密码"></el-input>
</el-form-item>
<el-form-item label="测试:">
<el-form-item label="测试连接">
<el-button v-on:click="testDatasource" type="primary" v-loading="testDatasourceErrLoading">测试数据源</el-button>
</el-form-item>
</el-form>
@@ -103,12 +104,8 @@
</template>
<script>
import toast from '../../common/lib/common/toast'
import global from '../../common/config/global'
import {queryTestDatasource} from '../../common/api/datasource'
var app;
import datasourceApi from '../../common/api/datasource'
import userApi from '../../common/api/user'
export default {
data() {
return {
@@ -127,30 +124,31 @@
testDatasourceErrInfo: "",
testDatasourceErrVisible: false,
testDatasourceErrLoading: false,
// 数据源分组
datasourceGroupList: [],
};
},
mounted: function () {
app = this;
this.getDatasourceList();
},
methods: {
editDbAuth(row) {
this.newDatasource = JSON.parse(JSON.stringify(row));
app.dbSourceAuthDialogVisible = true;
this.dbSourceAuthDialogVisible = true;
this.loadDbAuthUserList();
},
loadDbAuthUserList() {
app.dbSourceAuthNewUser = [];
app.dbSourceAuthUserList = [];
var param = {sourceId: app.newDatasource.id};
this.common.post(this.apilist1.dbUserAuthList, param, function (json) {
app.dbSourceAuthUserList = json.data || [];
this.dbSourceAuthNewUser = [];
this.dbSourceAuthUserList = [];
let param = {sourceId: this.newDatasource.id};
datasourceApi.dbUserAuthList(param).then(json => {
this.dbSourceAuthUserList = json.data || [];
});
},
saveUserDbSourceAuth() {
var param = {sourceId: app.newDatasource.id, authList: JSON.stringify(app.dbSourceAuthUserList)};
this.common.post(this.apilist1.assignDbUserAuth, param, function (json) {
toast.success("保存成功");
let param = {sourceId: this.newDatasource.id, authList: JSON.stringify(this.dbSourceAuthUserList)};
datasourceApi.assignDbUserAuth(param).then(() => {
this.$message.success("保存成功");
});
},
deleteUserDbSourceAuth(row) {
@@ -165,7 +163,7 @@
},
addDbSourceAuthUser() {
if (this.dbSourceAuthNewUser.length <= 0) {
toast.warn("请先选择用户");
this.$message.warn("请先选择用户");
return;
}
var userName = "";
@@ -184,19 +182,16 @@
this.dbSourceAuthNewUser = "";
},
getSearchUserList(query) {
if (query == '') {
return;
}
if (!query) return;
this.dbSourceAuthUserLoading = true;
var param = {search: query};
this.common.post(this.apilist1.getUserBaseInfo, param, function (json) {
app.searchUserList = json.data || [];
app.dbSourceAuthUserLoading = false;
userApi.getUserBaseInfo({search: query}).then(json => {
this.searchUserList = json.data || [];
this.dbSourceAuthUserLoading = false;
});
},
addDatasource() {
this.datasourceDialogVisible = true;
this.newDatasource = {name: "", driverClassName: "", sourceUrl: "", sourceName: "", sourcePassword: ""};
this.newDatasource = {name: "", driverClassName: "", sourceUrl: "", sourceName: "", sourcePassword: "", groupName: ""};
},
editDatasource(row) {
this.newDatasource = JSON.parse(JSON.stringify(row));
@@ -209,25 +204,27 @@
type: 'warning'
}).then(() => {
row.yn = 0;
this.common.post(this.apilist1.manageUpdateDatasource, row, function (json) {
app.$message.success("删除成功!");
app.getDatasourceList();
datasourceApi.manageUpdateDatasource(row).then(() => {
this.$message.success("删除成功!");
this.$emit('loadDatasourceList');
this.getDatasourceList();
});
}).catch(()=>{});
},
saveDatasource() {
app.datasourceDialogVisible = false;
this.common.post(this.apilist1.manageUpdateDatasource, this.newDatasource, function (json) {
app.$message.success("保存成功!");
app.getDatasourceList();
this.datasourceDialogVisible = false;
datasourceApi.manageUpdateDatasource(this.newDatasource).then(() => {
this.$message.success("保存成功!");
this.$emit('loadDatasourceList');
this.getDatasourceList();
});
},
testDatasource() {
this.testDatasourceErrLoading = true;
queryTestDatasource(this.newDatasource).then(res => {
datasourceApi.queryTestDatasource(this.newDatasource).then(res => {
this.testDatasourceErrLoading = false;
if (res.errCode == 200) {
this.$message.success("测试成功!");
this.$message.success("连接成功!");
} else {
this.testDatasourceErrVisible = true;
this.testDatasourceErrInfo = res.errMsg || '';
@@ -245,9 +242,14 @@
},
getDatasourceList() {
this.loadDataListLoading = true;
this.common.post(this.apilist1.manageDatasourceList, {}, function (json) {
app.datasourceList = json.data || [];
setTimeout(()=>{app.loadDataListLoading = false;}, 800);
datasourceApi.manageDatasourceList({}).then(json => {
this.datasourceList = json.data || [];
let datasourceGroupList = [];
this.datasourceList.filter(item => !!item.groupName).forEach(item => datasourceGroupList.push(item.groupName));
this.datasourceGroupList = Array.from(new Set(datasourceGroupList));
setTimeout(() => {
this.loadDataListLoading = false;
}, 800);
});
},
}

View File

@@ -14,7 +14,7 @@
<div style="float: right;margin-top: -5px;">
数据源
<el-select v-model="choiceDatasourceId" @change="datasourceChangeEvents" filterable placeholder="请选择数据源" style="width: 400px;">
<el-option v-for="item in datasourceList" :key="item.id" :label="item.cnName" :value="item.id"></el-option>
<el-option v-for="item in datasourceList" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
</div>
</div>
@@ -54,21 +54,25 @@
<pre style="margin: 0;">{{scope.row.content}}</pre>
</template>
</el-table-column>
<el-table-column label="操作" width="150px">
<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="danger" v-on:click="delFavorite(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>
</el-table>
</el-tab-pane>
<el-tab-pane label="历史记录" name="history">
<el-table :data="myHistoryListList" stripe border style="width: 100%; margin-bottom: 5px;">
<el-table-column prop="content" label="SQL"></el-table-column>
<el-table-column label="操作" width="150px">
<el-table-column prop="content" label="SQL">
<template slot-scope="scope">
<pre style="margin: 0;">{{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="success" v-on:click="addFavorite(scope.row.content)">收藏</el-button>
<el-button size="mini" type="success" v-on:click="addFavorite(scope.row.content)" style="margin-left: 10px;">收藏</el-button>
</template>
</el-table-column>
</el-table>
@@ -87,6 +91,8 @@
import '../../common/lib/ace/ext-language_tools'
import '../../common/lib/ace/snippets/sql'
import sqlFormatter from "sql-formatter"
import datasourceApi from '../../common/api/datasource'
export default {
data() {
return {
@@ -141,9 +147,8 @@
});
},
cancelExecutorSql() {
let that = this;
this.common.post(this.apilist1.executeSqlCancel, {executeId: this.nowExecutorId}, function (json) {
that.$message.success("取消成功");
datasourceApi.executeSqlCancel({executeId: this.nowExecutorId}).then(() => {
this.$message.success("取消成功");
});
},
loadHistoryAndFavoriteList() {
@@ -152,15 +157,13 @@
this.loadFavoriteList();
},
loadFavoriteList() {
let that = this;
this.common.post(this.apilist1.favoriteList, {sourceId: this.choiceDatasourceId}, function (json) {
that.myFavoriteList = json.data || [];
datasourceApi.favoriteList({sourceId: this.choiceDatasourceId}).then(json => {
this.myFavoriteList = json.data || [];
});
},
loadHistoryList() {
let that = this;
this.common.post(this.apilist1.historyList, {sourceId: this.choiceDatasourceId}, function (json) {
that.myHistoryListList = json.data || [];
datasourceApi.historyList({sourceId: this.choiceDatasourceId}).then(json => {
this.myHistoryListList = json.data || [];
});
},
addFavorite(sqlValue) {
@@ -170,19 +173,16 @@
sqlValue = this.sqlExecutorEditor.getValue();
}
}
let that = this;
var param = {name: '我的收藏', content: sqlValue, datasourceId: this.choiceDatasourceId};
this.common.post(this.apilist1.updateFavorite, param, function (json) {
that.$message.success("收藏成功");
that.loadFavoriteList();
let param = {name: '我的收藏', content: sqlValue, datasourceId: this.choiceDatasourceId};
datasourceApi.updateFavorite(param).then(() => {
this.$message.success("收藏成功");
this.loadFavoriteList();
});
},
delFavorite(row) {
let that = this;
var param = {id: row.id, yn: 0};
this.common.post(this.apilist1.updateFavorite, param, function (json) {
that.$message.success("删除成功");
that.loadFavoriteList();
datasourceApi.updateFavorite({id: row.id, yn: 0}).then(() => {
this.$message.success("删除成功");
this.loadFavoriteList();
});
},
inputFavoriteSql(content) {
@@ -218,16 +218,15 @@
sqlValue = this.sqlExecutorEditor.getValue();
}
this.sqlExecuting = true;
let that = this;
this.common.postNonCheck(this.apilist1.executeSql, {
datasourceApi.queryExecuteSql({
sourceId: this.choiceDatasourceId,
executeId: this.nowExecutorId,
sql: sqlValue,
params: '',
}, function (json) {
that.sqlExecuting = false;
}).then(json => {
this.sqlExecuting = false;
if (json.errCode != 200) {
that.executeError = json.errMsg;
this.executeError = json.errMsg;
return;
}
var resultList = json.data || [];
@@ -235,43 +234,38 @@
var executeResultInfo = "", itemIndex = 1;
for (var i = 0; i < resultList.length; i++) {
var objItem = JSON.parse(resultList[i]);
executeResultInfo += that.getExecuteInfoStr(objItem);
var resultItem = that.dealExecuteResult(objItem);
executeResultInfo += this.getExecuteInfoStr(objItem);
var resultItem = this.dealExecuteResult(objItem);
if (resultItem.updateCount < 0) {
resultItem.index = itemIndex;
itemIndex++;
}
executeResultList.push(resultItem);
}
that.executeShowTable = (itemIndex === 1) ? "table0" : "table1";
that.executeResultInfo = executeResultInfo;
that.executeResultList = executeResultList;
this.executeShowTable = (itemIndex === 1) ? "table0" : "table1";
this.executeResultInfo = executeResultInfo;
this.executeResultList = executeResultList;
});
},
loadDatasourceList() {
let that = this;
this.common.post(this.apilist1.datasourceList, {}, function (json) {
that.datasourceList = json.data || [];
if (that.datasourceList.length > 0) {
that.choiceDatasourceId = that.datasourceList[0].id;
that.loadEditorData();
datasourceApi.datasourceList({}).then(json => {
this.datasourceList = json.data || [];
if (this.datasourceList.length > 0) {
this.choiceDatasourceId = this.datasourceList[0].id;
this.loadEditorData();
}
});
},
loadEditorData() {
let that = this;
this.common.post(this.apilist1.getEditorData, {sourceId: this.choiceDatasourceId}, function (json) {
var data = json.data || {};
that.editorDbInfo = data.db || [];
that.editorDbTableInfo = data.table || {};
that.editorColumnInfo = data.column || {};
datasourceApi.getEditorData({sourceId: this.choiceDatasourceId}).then(json => {
let data = json.data || {};
this.editorDbInfo = data.db || [];
this.editorDbTableInfo = data.table || {};
this.editorColumnInfo = data.column || {};
});
},
datasourceChangeEvents() {
this.loadEditorData();
// this.common.post(this.apilist1.databaseList, {sourceId: this.choiceDatasourceId}, function (json) {
// app.databaseList = json.data || [];
// });
},
databaseChangeEvents() {

View File

@@ -8,14 +8,14 @@
<el-select v-model="choiceDatasourceId" @change="datasourceChangeEvents" filterable placeholder="请选择数据源">
<el-option v-for="item in datasourceOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
</el-select>
<el-select v-model="choiceDatabase" @change="databaseChangeEvents" filterable placeholder="请选择数据库">
<el-select v-model="choiceDatabase" @change="databaseChangeEvents" filterable placeholder="请选择数据库" style="margin: 0 10px;">
<el-option v-for="item in databaseList" :key="item.dbName" :label="item.dbName" :value="item.dbName"></el-option>
</el-select>
<el-radio-group v-model="exportType">
<el-radio :label="1">HTML格式</el-radio>
<el-radio :label="2">Excel格式</el-radio>
</el-radio-group>
<el-button v-on:click="exportChoiceTable" type="primary" style="margin-left: 20px;">导出选中的表</el-button>
<el-button v-on:click="exportChoiceTable" type="primary" style="margin: 0 10px 0 20px;">导出选中的表</el-button>
<a target="_blank" title="点击查看如何使用" href="http://doc.zyplayer.com/zyplayer-doc-manage/open-wiki.html?pageId=117&space=23f3f59a60824d21af9f7c3bbc9bc3cb"><i class="el-icon-info" style="color: #999;"></i></a>
</div>
<el-table :data="tableList" stripe border @selection-change="handleSelectionChange" style="width: 100%; margin-bottom: 5px;">
@@ -28,6 +28,7 @@
</template>
<script>
import datasourceApi from '../../common/api/datasource'
var app;
export default {
@@ -77,25 +78,25 @@
+ "&tableNames=" + tableNames);
},
loadGetTableList() {
this.common.post(this.apilist1.tableList, {sourceId: this.choiceDatasourceId, dbName: this.choiceDatabase}, function (json) {
app.tableList = json.data || [];
datasourceApi.tableList({sourceId: this.choiceDatasourceId, dbName: this.choiceDatabase}).then(json => {
this.tableList = json.data || [];
});
},
loadDatasourceList() {
this.common.post(this.apilist1.datasourceList, {}, function (json) {
app.datasourceList = json.data || [];
var datasourceOptions = [];
for (var i = 0; i < app.datasourceList.length; i++) {
datasourceApi.datasourceList({}).then(json => {
this.datasourceList = json.data || [];
let datasourceOptions = [];
for (let i = 0; i < this.datasourceList.length; i++) {
datasourceOptions.push({
label: app.datasourceList[i].cnName, value: app.datasourceList[i].id
label: this.datasourceList[i].name, value: this.datasourceList[i].id
});
}
app.datasourceOptions = datasourceOptions;
this.datasourceOptions = datasourceOptions;
});
},
loadDatabaseList() {
this.common.post(this.apilist1.databaseList, {sourceId: this.choiceDatasourceId}, function (json) {
app.databaseList = json.data || [];
datasourceApi.databaseList({sourceId: this.choiceDatasourceId}).then(json => {
this.databaseList = json.data || [];
});
},
handleSelectionChange(val) {

View File

@@ -111,6 +111,7 @@
import '../../common/lib/ace/mode-sql'
import '../../common/lib/ace/ext-language_tools'
import '../../common/lib/ace/snippets/sql'
import datasourceApi from '../../common/api/datasource'
var app;
export default {
@@ -162,9 +163,9 @@
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.common.post(this.apilist1.transferUpdate, {id: id, delFlag: 1}, function (json) {
app.$message.success("删除成功");
app.loadGetTaskList();
datasourceApi.transferUpdate({id: id, delFlag: 1}).then(() => {
this.$message.success("删除成功");
this.loadGetTaskList();
});
}).catch(()=>{});
},
@@ -174,26 +175,28 @@
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.common.post(this.apilist1.transferStart, {id: id}, function (json) {
app.$message.success("任务提交成功");
datasourceApi.transferStart({id: id}).then(() => {
this.$message.success("任务提交成功");
});
}).catch(()=>{});
},
saveEditTask() {
this.taskEditInfo.querySql = app.querySqlEditor.getValue();
this.taskEditInfo.storageSql = app.storageSqlEditor.getValue();
this.common.post(this.apilist1.transferUpdate, this.taskEditInfo, function (json) {
app.$message.success("保存成功");
app.taskEditDialogVisible = false;
app.loadGetTaskList();
this.taskEditInfo.querySql = this.querySqlEditor.getValue();
this.taskEditInfo.storageSql = this.storageSqlEditor.getValue();
datasourceApi.transferUpdate(this.taskEditInfo).then(() => {
this.$message.success("保存成功");
this.taskEditDialogVisible = false;
this.loadGetTaskList();
});
},
viewTask(id) {
this.viewTaskLoading = true;
this.taskViewDialogVisible = true;
this.common.post(this.apilist1.transferDetail, {id: id}, function (json) {
app.taskEditInfo = json.data || {};
setTimeout(()=>{app.viewTaskLoading = false;}, 300);
datasourceApi.transferDetail({id: id}).then(json => {
this.taskEditInfo = json.data || {};
setTimeout(() => {
app.viewTaskLoading = false;
}, 300);
});
},
cancelTask() {
@@ -202,51 +205,54 @@
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.common.post(this.apilist1.transferCancel, {id: this.taskEditInfo.id}, function (json) {
app.$message.success("取消成功");
app.viewTask(app.taskEditInfo.id);
datasourceApi.transferCancel({id: this.taskEditInfo.id}).then(() => {
this.$message.success("取消成功");
this.viewTask(this.taskEditInfo.id);
});
}).catch(()=>{});
},
loadGetTaskList() {
this.loadDataListLoading = true;
this.common.post(this.apilist1.transferList, {}, function (json) {
app.taskList = json.data || [];
setTimeout(()=>{app.loadDataListLoading = false;}, 800);
datasourceApi.transferList({}).then(json => {
this.taskList = json.data || [];
setTimeout(()=>{this.loadDataListLoading = false;}, 800);
});
},
autoFillStorageSql() {
var sqlStr = app.querySqlEditor.getValue();
this.common.post(this.apilist1.transferSqlColumns, {sql: sqlStr}, function (json) {
var resultData = json.data || [];
let sqlStr = this.querySqlEditor.getValue();
datasourceApi.transferSqlColumns({sql: sqlStr}).then(json => {
let resultData = json.data || [];
if (resultData.length <= 0) {
app.$message.error("查询的字段不明确,不能自动填充");
this.$message.error("查询的字段不明确,不能自动填充");
return;
}
var storageSql = "\n";
let storageSql = "\n";
storageSql += "insert into TableName (\n";
for (var i = 0; i < resultData.length; i++) {
for (let i = 0; i < resultData.length; i++) {
storageSql += "\t" + ((i === 0) ? "" : ",") + resultData[i] + "\n";
}
storageSql += ") values (\n";
for (var i = 0; i < resultData.length; i++) {
for (let i = 0; i < resultData.length; i++) {
storageSql += "\t" + ((i === 0) ? "" : ",") + "#{" + resultData[i] + "}\n";
}
storageSql += ")\n\n";
app.storageSqlEditor.setValue(storageSql, 1);
this.storageSqlEditor.setValue(storageSql, 1);
});
},
loadDatasourceList() {
this.common.post(this.apilist1.datasourceList, {}, function (json) {
app.datasourceList = json.data || [];
var datasourceOptions = [], datasourceMap = {};
for (var i = 0; i < app.datasourceList.length; i++) {
datasourceMap[app.datasourceList[i].id] = app.datasourceList[i].cnName;
datasourceOptions.push({label: app.datasourceList[i].cnName, value: app.datasourceList[i].id});
datasourceApi.datasourceList({}).then(json => {
this.datasourceList = json.data || [];
let datasourceOptions = [], datasourceMap = {};
for (let i = 0; i < this.datasourceList.length; i++) {
datasourceMap[this.datasourceList[i].id] = this.datasourceList[i].name;
datasourceOptions.push({
label: this.datasourceList[i].name,
value: this.datasourceList[i].id
});
}
app.datasourceMap = datasourceMap;
app.datasourceOptions = datasourceOptions;
app.loadGetTaskList();
this.datasourceMap = datasourceMap;
this.datasourceOptions = datasourceOptions;
this.loadGetTaskList();
});
},
initAceEditor(editor, minLines) {

View File

@@ -7,9 +7,6 @@
</template>
<script>
import toast from '../../common/lib/common/toast'
import global from '../../common/config/global'
var app;
export default {

View File

@@ -26,7 +26,7 @@
</template>
<script>
import global from '../../common/config/global'
import datasourceApi from '../../common/api/datasource'
export default {
data() {
@@ -38,12 +38,18 @@
keyword: '',
};
},
mounted: function () {
// 延迟设置展开的目录edit比app先初始化
setTimeout(() => {
this.$emit('initLoadDataList', {
sourceId: this.vueQueryParam.sourceId,
host: this.vueQueryParam.host,
dbName: this.vueQueryParam.dbName
});
}, 500);
},
activated: function () {
this.initQueryParam(this.$route);
// 延迟设置展开的目录edit比app先初始化
setTimeout(() => {
global.vue.$app.initLoadDataList(this.vueQueryParam.sourceId, this.vueQueryParam.host, this.vueQueryParam.dbName);
}, 500);
},
methods: {
initQueryParam(to) {
@@ -52,12 +58,11 @@
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) {
that.columnList = json.data || [];
that.columnListLoading = false;
datasourceApi.tableAndColumnBySearch(this.vueQueryParam).then(json => {
this.columnList = json.data || [];
this.columnListLoading = false;
});
},
}

View File

@@ -88,8 +88,7 @@
</template>
<script>
import global from '../../common/config/global'
import {queryTableDdl} from '../../common/api/datasource'
import datasourceApi from '../../common/api/datasource'
export default {
data() {
@@ -104,38 +103,43 @@
tableDDLInfoDialogVisible: false,
};
},
activated: function () {
this.initQueryParam(this.$route);
// 延迟设置展开的目录edit比app先初始化
setTimeout(()=> {
global.vue.$app.initLoadDataList(this.vueQueryParam.sourceId, this.vueQueryParam.host, this.vueQueryParam.dbName);
}, 500);
},
mounted: function () {
// 延迟设置展开的目录edit比app先初始化
setTimeout(() => {
this.$emit('initLoadDataList', {
sourceId: this.vueQueryParam.sourceId,
host: this.vueQueryParam.host,
dbName: this.vueQueryParam.dbName
});
}, 500);
},
activated: function () {
this.initQueryParam(this.$route);
},
methods: {
initQueryParam(to) {
if (this.columnListLoading) {
return;
}
let that = this;
this.columnListLoading = true;
this.vueQueryParam = to.query;
this.common.post(this.apilist1.tableColumnList, this.vueQueryParam, function (json) {
var columnList = json.data.columnList || [];
for (var i = 0; i < columnList.length; i++) {
datasourceApi.tableColumnList(this.vueQueryParam).then(json => {
let columnList = json.data.columnList || [];
for (let i = 0; i < columnList.length; i++) {
columnList[i].inEdit = 0;
columnList[i].newDesc = columnList[i].description;
}
that.columnList = columnList;
var tableInfo = json.data.tableInfo || {};
this.columnList = columnList;
let tableInfo = json.data.tableInfo || {};
tableInfo.inEdit = 0;
tableInfo.newDesc = tableInfo.description;
that.tableInfo = tableInfo;
var newName = {key: that.$route.fullPath, val: '表-' + tableInfo.tableName};
that.$store.commit('global/addTableName', newName);
that.columnListLoading = false;
this.tableInfo = tableInfo;
let newName = {key: this.$route.fullPath, val: '表-' + tableInfo.tableName};
this.$store.commit('global/addTableName', newName);
this.columnListLoading = false;
});
this.common.post(this.apilist1.tableStatus, this.vueQueryParam, function (json) {
that.tableStatusInfo = json.data || {};
datasourceApi.tableStatus(this.vueQueryParam).then(json => {
this.tableStatusInfo = json.data || {};
});
},
showCreateTableDdl() {
@@ -146,7 +150,7 @@
dbName: this.vueQueryParam.dbName,
tableName: this.vueQueryParam.tableName,
};
queryTableDdl(param).then(res => {
datasourceApi.queryTableDdl(param).then(res => {
this.tableDDLInfo = res.data || '获取失败';
});
},
@@ -181,10 +185,9 @@
row.inEdit = 0;
this.vueQueryParam.columnName = row.name;
this.vueQueryParam.newDesc = row.newDesc;
let that = this;
this.common.post(this.apilist1.updateTableColumnDesc, this.vueQueryParam, function (json) {
datasourceApi.updateTableColumnDesc(this.vueQueryParam).then(() => {
row.description = row.newDesc;
that.$message.success("修改成功");
this.$message.success("修改成功");
});
},
saveTableDescription() {
@@ -194,10 +197,9 @@
}
this.tableInfo.inEdit = 0;
this.vueQueryParam.newDesc = this.tableInfo.newDesc;
let that = this;
this.common.post(this.apilist1.updateTableDesc, this.vueQueryParam, function (json) {
that.tableInfo.description = that.tableInfo.newDesc;
that.$message.success("修改成功");
datasourceApi.updateTableDesc(this.vueQueryParam).then(() => {
this.tableInfo.description = this.tableInfo.newDesc;
this.$message.success("修改成功");
});
},
}

View File

@@ -18,6 +18,7 @@
</template>
<script>
import userApi from '../../common/api/user'
export default {
data() {
return {
@@ -43,14 +44,13 @@
},
methods: {
loginSubmit() {
var that = this;
this.$refs.loginParam.validate((valid) => {
if (!valid) return;
that.common.post(that.apilist1.userLogin, that.loginParam, function (json) {
if(!!that.redirect) {
location.href = decodeURIComponent(that.redirect);
userApi.userLogin(this.loginParam).then(() => {
if (!!this.redirect) {
location.href = decodeURIComponent(this.redirect);
} else {
that.$router.back();
this.$router.back();
}
});
});

View File

@@ -21,7 +21,7 @@
</template>
<script>
var app;
import userApi from '../../common/api/user'
export default {
data() {
return {
@@ -29,13 +29,12 @@
};
},
mounted: function () {
app = this;
this.getUserInfo();
},
methods: {
getUserInfo() {
this.common.post(this.apilist1.getSelfUserInfo, this.searchParam, function (json) {
app.userInfo = json.data;
userApi.getSelfUserInfo().then(json => {
this.userInfo = json.data;
});
},
}