数据源管理页面-新增与修改页面:增加智能填入功能
sql执行器页面刷新记住数据源,可同时存在多个数据源执行器页面
This commit is contained in:
@@ -18,4 +18,9 @@ public interface DbDatasourceService extends IService<DbDatasource> {
|
||||
* @return List<DbDatasource>
|
||||
*/
|
||||
List<DbDatasource> getDataSourceList();
|
||||
|
||||
/**
|
||||
* 获取数据源
|
||||
*/
|
||||
DbDatasource getDataSource(Long sourceId);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.zyplayer.doc.data.repository.support.consts.DocSysModuleType;
|
||||
import com.zyplayer.doc.data.repository.support.consts.DocSysType;
|
||||
import com.zyplayer.doc.data.service.manage.DbDatasourceService;
|
||||
import com.zyplayer.doc.data.service.manage.UserAuthService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -33,6 +34,9 @@ public class DbDatasourceServiceImpl extends ServiceImpl<DbDatasourceMapper, DbD
|
||||
@Resource
|
||||
UserAuthService userAuthService;
|
||||
|
||||
@Autowired
|
||||
private DbDatasourceMapper dbDatasourceMapper;
|
||||
|
||||
@Override
|
||||
public List<DbDatasource> getDataSourceList() {
|
||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||
@@ -55,6 +59,36 @@ public class DbDatasourceServiceImpl extends ServiceImpl<DbDatasourceMapper, DbD
|
||||
wrapper.in("id", userAuthDbIds);
|
||||
}
|
||||
wrapper.select("id", "name", "group_name");
|
||||
|
||||
return list(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据源
|
||||
*/
|
||||
@Override
|
||||
public DbDatasource getDataSource(Long sourceId){
|
||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||
QueryWrapper<DbDatasource> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("yn", 1);
|
||||
wrapper.eq("id", sourceId);
|
||||
// 没管理权限只返回有权限的数据源
|
||||
if (!DocUserUtil.haveAuth(DocAuthConst.DB_DATASOURCE_MANAGE)) {
|
||||
QueryWrapper<UserAuth> updateWrapper = new QueryWrapper<>();
|
||||
updateWrapper.eq("sys_type", DocSysType.DB.getType());
|
||||
updateWrapper.eq("sys_module_type", DocSysModuleType.Db.DATASOURCE.getType());
|
||||
updateWrapper.eq("del_flag", 0);
|
||||
updateWrapper.eq("user_id", currentUser.getUserId());
|
||||
List<UserAuth> userAuthList = userAuthService.list(updateWrapper);
|
||||
if (userAuthList == null || userAuthList.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
List<Long> userAuthDbIds = userAuthList.stream()
|
||||
.map(UserAuth::getSysModuleId)
|
||||
.collect(Collectors.toList());
|
||||
wrapper.in("id", userAuthDbIds);
|
||||
}
|
||||
wrapper.select("id", "name", "group_name");
|
||||
return dbDatasourceMapper.selectOne(wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,15 @@ public class DatabaseDocController {
|
||||
return DocDbResponseJson.ok(dataSourceList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据源
|
||||
*/
|
||||
@PostMapping("/getDataSource")
|
||||
public DocDbResponseJson getDataSource(Long sourceId) {
|
||||
DbDatasource dataSource = dbDatasourceService.getDataSource(sourceId);
|
||||
return DocDbResponseJson.ok(dataSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据源基本信息
|
||||
*
|
||||
|
||||
1
zyplayer-doc-db/src/main/resources/dist/css/index.7acc9f77.css
vendored
Normal file
1
zyplayer-doc-db/src/main/resources/dist/css/index.7acc9f77.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="favicon-db.png"><title>数据库文档管理</title><link href="css/chunk-vendors.2fa4c9b3.css" rel="preload" as="style"><link href="css/index.9ecc4b23.css" rel="preload" as="style"><link href="js/chunk-vendors.3d6daf5c.js" rel="preload" as="script"><link href="js/index.c49d7fe4.js" rel="preload" as="script"><link href="css/chunk-vendors.2fa4c9b3.css" rel="stylesheet"><link href="css/index.9ecc4b23.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but zyplayer-db-ui doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/chunk-vendors.3d6daf5c.js"></script><script src="js/index.c49d7fe4.js"></script></body></html>
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="favicon-db.png"><title>数据库文档管理</title><link href="css/chunk-vendors.2fa4c9b3.css" rel="preload" as="style"><link href="css/index.7acc9f77.css" rel="preload" as="style"><link href="js/chunk-vendors.efca7909.js" rel="preload" as="script"><link href="js/index.ccb56003.js" rel="preload" as="script"><link href="css/chunk-vendors.2fa4c9b3.css" rel="stylesheet"><link href="css/index.7acc9f77.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but zyplayer-db-ui doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/chunk-vendors.efca7909.js"></script><script src="js/index.ccb56003.js"></script></body></html>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
zyplayer-doc-db/src/main/resources/dist/js/index.ccb56003.js
vendored
Normal file
1
zyplayer-doc-db/src/main/resources/dist/js/index.ccb56003.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -62,7 +62,7 @@
|
||||
<el-header>
|
||||
<span class="header-right-user-name">{{userSelfInfo.userName}}</span>
|
||||
<el-dropdown @command="userSettingDropdown" trigger="click">
|
||||
<i class="el-icon-setting" style="margin-right: 15px; font-size: 16px;cursor: pointer;color: #fff;"> </i>
|
||||
<i class="el-icon-setting" style="margin-right: 15px; font-size: 12px;cursor: pointer;color: #fff;"> </i>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item command="console">控制台</el-dropdown-item>
|
||||
<el-dropdown-item command="aboutDoc" divided>关于</el-dropdown-item>
|
||||
@@ -323,7 +323,8 @@
|
||||
overflow: unset;
|
||||
}
|
||||
.header-right-user-name{color: #fff;padding-right: 5px;}
|
||||
.el-menu-vertical{border-right: 0;background: #fafafa;}
|
||||
.el-menu-vertical{border-right: 0;background: #fafafa}
|
||||
.el-menu-item, .el-submenu__title{font-size: 12px;}
|
||||
.el-menu-vertical .el-menu{background: #fafafa;}
|
||||
.el-header {background-color: #409EFF; color: #333; line-height: 40px; text-align: right;height: 40px !important;}
|
||||
|
||||
|
||||
@@ -14,6 +14,9 @@ export default {
|
||||
datasourceList: data => {
|
||||
return request({url: '/zyplayer-doc-db/doc-db/getDataSourceList', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
datasource: data => {
|
||||
return request({url: '/zyplayer-doc-db/doc-db/getDataSource', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
databaseList: data => {
|
||||
return request({url: '/zyplayer-doc-db/doc-db/getDatabaseList', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
|
||||
@@ -4,13 +4,15 @@
|
||||
<el-tab-pane :label="pageTabNameMap[item.fullPath]||item.name" :name="getRouteRealPath(item)" :fullPath="item.fullPath" :key="item.fullPath" v-for="item in pageList"/>
|
||||
</el-tabs>
|
||||
<keep-alive>
|
||||
<router-view :key="$route.fullPath" @initLoadDataList="initLoadDataList" @loadDatasourceList="loadDatasourceList"/>
|
||||
<router-view v-on:listenToChildEvent = "getDatafromChild" :key="$route.fullPath" @initLoadDataList="initLoadDataList" @loadDatasourceList="loadDatasourceList"/>
|
||||
</keep-alive>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
import datasourceApi from "@/common/api/datasource";
|
||||
|
||||
export default {
|
||||
name: 'PageTableView',
|
||||
components: {},
|
||||
data() {
|
||||
@@ -18,6 +20,7 @@
|
||||
pageList: [],
|
||||
linkList: [],
|
||||
activePage: '',
|
||||
datasourceList: [],
|
||||
multiPage: true,
|
||||
ignoreParamPath: [
|
||||
"/data/export",
|
||||
@@ -31,11 +34,31 @@
|
||||
},
|
||||
created() {
|
||||
let {name, path, fullPath} = this.$route;
|
||||
this.pageList.push({name, path, fullPath});
|
||||
let activePage = this.getRouteRealPath(this.$route);
|
||||
this.linkList.push(activePage);
|
||||
this.activePage = activePage;
|
||||
this.$router.push(this.$route.fullPath);
|
||||
//sql执行器tab页名称动态变化
|
||||
if(path === '/data/executor'){
|
||||
let database = this.$route.query.database;
|
||||
let datasourceId = this.$route.query.datasourceId;
|
||||
if(datasourceId){
|
||||
datasourceApi.datasource({sourceId: datasourceId}).then(json => {
|
||||
let dataname = json.data.name;
|
||||
let groupName = json.data.name;
|
||||
if(dataname){
|
||||
name = name+"("+dataname+")"
|
||||
}
|
||||
this.pageList.push({name, path, fullPath});
|
||||
let activePage = this.getRouteRealPath(this.$route);
|
||||
this.linkList.push(activePage);
|
||||
this.activePage = activePage;
|
||||
this.$router.push(this.$route.fullPath);
|
||||
})
|
||||
return false;
|
||||
}
|
||||
}
|
||||
this.pageList.push({name, path, fullPath});
|
||||
let activePage = this.getRouteRealPath(this.$route);
|
||||
this.linkList.push(activePage);
|
||||
this.activePage = activePage;
|
||||
this.$router.push(this.$route.fullPath);
|
||||
},
|
||||
watch: {
|
||||
'$route': function (newRoute, oldRoute) {
|
||||
@@ -44,13 +67,36 @@
|
||||
if (this.linkList.indexOf(activePage) < 0) {
|
||||
this.linkList.push(activePage);
|
||||
let {name, path, fullPath} = newRoute;
|
||||
this.pageList.push({name, path, fullPath});
|
||||
|
||||
//sql执行器tab页名称动态变化
|
||||
if(path === '/data/executor'){
|
||||
let database = newRoute.query.database;
|
||||
let datasourceId = newRoute.query.datasourceId;
|
||||
if(datasourceId) {
|
||||
datasourceApi.datasource({sourceId: datasourceId}).then(json => {
|
||||
let dataname = json.data.name;
|
||||
let groupName = json.data.name;
|
||||
if (dataname) {
|
||||
name = name + "(" + dataname + ")"
|
||||
}
|
||||
this.pageList.push({name, path, fullPath});
|
||||
})
|
||||
}else{
|
||||
this.pageList.push({name, path, fullPath});
|
||||
}
|
||||
}else{
|
||||
this.pageList.push({name, path, fullPath});
|
||||
}
|
||||
|
||||
}
|
||||
let pageRoute = this.pageList.find(item => this.getRouteRealPath(item) === activePage);
|
||||
pageRoute.fullPath = newRoute.fullPath;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getDatafromChild(data){
|
||||
this.datasourceList = data;
|
||||
},
|
||||
initLoadDataList(param) {
|
||||
this.$emit('initLoadDataList', param);
|
||||
},
|
||||
@@ -66,6 +112,7 @@
|
||||
changePage(tab) {
|
||||
this.activePage = tab.name;
|
||||
this.$router.push(tab.$attrs.fullPath);
|
||||
|
||||
},
|
||||
editPage(key, action) {
|
||||
this[action](key);
|
||||
|
||||
@@ -61,7 +61,9 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="数据源URL:">
|
||||
<el-input v-model="newDatasource.sourceUrl" :placeholder="urlPlaceholder"></el-input>
|
||||
<el-input v-model="newDatasource.sourceUrl" :placeholder="urlPlaceholder" :disabled="sourceUrlDisabled&&!newDatasource.id>0">
|
||||
<el-button slot="append" @click="autoFillDialog" :disabled="sourceUrlDisabled&&!newDatasource.id>0">智能填入</el-button>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="账号:">
|
||||
<el-input v-model="newDatasource.sourceName" placeholder="账号"></el-input>
|
||||
@@ -96,12 +98,12 @@
|
||||
<el-table-column prop="userName" label="用户" width="150"></el-table-column>
|
||||
<el-table-column label="权限">
|
||||
<template slot-scope="scope">
|
||||
<el-select v-model="scope.row.executeAuth" placeholder="选择权限" style="width: 150px;margin-right: 10px;">
|
||||
<el-option value="">无权限</el-option>
|
||||
<el-option :value="1" label="库表查看权"></el-option>
|
||||
<el-option :value="2" label="数据查询权"></el-option>
|
||||
<el-option :value="3" label="所有权限"></el-option>
|
||||
</el-select>
|
||||
<el-select v-model="scope.row.executeAuth" placeholder="选择权限" style="width: 150px;margin-right: 10px;">
|
||||
<el-option value="">无权限</el-option>
|
||||
<el-option :value="1" label="库表查看权"></el-option>
|
||||
<el-option :value="2" label="数据查询权"></el-option>
|
||||
<el-option :value="3" label="所有权限"></el-option>
|
||||
</el-select>
|
||||
<el-checkbox :true-label="1" :false-label="0" v-model="scope.row.descEditAuth">表字段注释修改权</el-checkbox>
|
||||
<el-checkbox :true-label="1" :false-label="0" v-model="scope.row.procEditAuth">函数修改权</el-checkbox>
|
||||
</template>
|
||||
@@ -122,6 +124,43 @@
|
||||
<pre><code v-html="testDatasourceErrInfo"></code></pre>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!--数据源url地址自动输入弹窗-->
|
||||
<el-dialog
|
||||
title="智能填入"
|
||||
:visible.sync="autoFillDialogVisible"
|
||||
width="30%" :close-on-click-modal="false">
|
||||
<el-form :model="autoFillForm" :rules="rules" label-width="90px" ref="autoFillForm">
|
||||
<el-form-item label="主机地址" prop="hostIp">
|
||||
<el-input v-model="autoFillForm.hostIp" placeholder="请输入主机地址" ></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="端口号" prop="port">
|
||||
<el-input v-model="autoFillForm.port" placeholder="请输入数据库端口号" ></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="服务名" prop="serverName" v-if="oracleServerNameShow" >
|
||||
<template slot="label">
|
||||
<span>服务名
|
||||
<el-tooltip class="item" effect="dark" placement="right">
|
||||
<i class="el-icon-question" style="font-size: 16px; vertical-align: middle;"></i>
|
||||
<div slot="content">
|
||||
<p>oracle数据库服务名默认为ORCL</p>
|
||||
<p>可使用下面的命令来查看服务名</p>
|
||||
<p>select global_name from global_name;</p>
|
||||
</div>
|
||||
</el-tooltip>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<el-input v-model="autoFillForm.serverName" placeholder="请输入服务名" ></el-input>
|
||||
<el-tooltip class="item" effect="dark" content="Top Left 提示文字" placement="top-start">
|
||||
<i class="el-icon-question-solid" />
|
||||
</el-tooltip>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="autoFillDialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="autoFill('autoFillForm')">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -132,15 +171,16 @@
|
||||
data() {
|
||||
return {
|
||||
loadDataListLoading: false,
|
||||
datasourceDialogVisible: false,
|
||||
datasourceList: [],
|
||||
searchParam: {
|
||||
name: '',
|
||||
groupName: ''
|
||||
},
|
||||
pageSize: 30,
|
||||
currentPage: 1,
|
||||
tableTotalCount: 0,
|
||||
datasourceDialogVisible: false,
|
||||
autoFillDialogVisible: false,
|
||||
datasourceList: [],
|
||||
searchParam: {
|
||||
name: '',
|
||||
groupName: ''
|
||||
},
|
||||
pageSize: 30,
|
||||
currentPage: 1,
|
||||
tableTotalCount: 0,
|
||||
newDatasource: {},
|
||||
urlPlaceholder: "数据源URL",
|
||||
|
||||
@@ -153,8 +193,32 @@
|
||||
testDatasourceErrInfo: "",
|
||||
testDatasourceErrVisible: false,
|
||||
testDatasourceErrLoading: false,
|
||||
// 数据源分组
|
||||
datasourceGroupList: [],
|
||||
// 数据源分组
|
||||
datasourceGroupList: [],
|
||||
|
||||
sourceUrlDisabled: true,
|
||||
|
||||
//自动填入参数
|
||||
autoFillForm: {
|
||||
hostIp: null,
|
||||
port: null,
|
||||
serverName: null,
|
||||
},
|
||||
//oracle数据库服务名是否显示
|
||||
oracleServerNameShow: false,
|
||||
|
||||
rules: {
|
||||
hostIp: [
|
||||
{ required: true, message: '请输入主机地址', trigger: 'blur' }
|
||||
],
|
||||
port: [
|
||||
{ required: true, message: '请输入数据库端口号', trigger: 'blur' }
|
||||
],
|
||||
serverName: [
|
||||
{ required: true, message: '请输入数据库服务名', trigger: 'blur' }
|
||||
],
|
||||
}
|
||||
|
||||
};
|
||||
},
|
||||
mounted: function () {
|
||||
@@ -178,9 +242,68 @@
|
||||
saveUserDbSourceAuth() {
|
||||
let param = {sourceId: this.newDatasource.id, authList: JSON.stringify(this.dbSourceAuthUserList)};
|
||||
datasourceApi.assignDbUserAuth(param).then(() => {
|
||||
this.$message.success("保存成功");
|
||||
this.$message.success("保存成功");
|
||||
});
|
||||
},
|
||||
|
||||
autoFillDialog(){
|
||||
this.autoFillDialogVisible = true;
|
||||
let thatClassName = this.newDatasource.driverClassName;
|
||||
if (thatClassName === 'com.mysql.jdbc.Driver') {
|
||||
//this.urlPlaceholder = "例:jdbc:mysql://127.0.0.1:3306/user_info?useUnicode=true&characterEncoding=utf8";
|
||||
this.autoFillForm.port = "3306";
|
||||
} else if (thatClassName === 'net.sourceforge.jtds.jdbc.Driver') {
|
||||
//this.urlPlaceholder = "例:jdbc:jtds:sqlserver://127.0.0.1:33434;DatabaseName=user_info;socketTimeout=60;";
|
||||
this.autoFillForm.port = "33434";
|
||||
} else if (thatClassName === 'oracle.jdbc.driver.OracleDriver') {
|
||||
//this.urlPlaceholder = "例:jdbc:oracle:thin:@127.0.0.1:1521/user_info";
|
||||
this.autoFillForm.port = "1521";
|
||||
this.oracleServerNameShow = true;
|
||||
} else if (thatClassName === 'org.postgresql.Driver') {
|
||||
//this.urlPlaceholder = "例:jdbc:postgresql://127.0.0.1:5432/user_info";
|
||||
this.autoFillForm.port = "5432";
|
||||
} else if (thatClassName === 'org.apache.hive.jdbc.HiveDriver') {
|
||||
//this.urlPlaceholder = "例:jdbc:hive2://127.0.0.1:21050/user_info;auth=noSasl";
|
||||
this.autoFillForm.port = "21050";
|
||||
} else if (thatClassName === 'dm.jdbc.driver.DmDriver'){
|
||||
//this.urlPlaceholder = "例:jdbc:dm://127.0.0.1:5236?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=utf-8";
|
||||
this.autoFillForm.port = "5236";
|
||||
}
|
||||
},
|
||||
autoFill(formName){
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
this.autoFillDialogVisible = false;
|
||||
//拼接地址
|
||||
let thatClassName = this.newDatasource.driverClassName;
|
||||
let hostIp = this.autoFillForm.hostIp;
|
||||
let port = this.autoFillForm.port;
|
||||
let serverName = this.autoFillForm.serverName;
|
||||
if (thatClassName === 'com.mysql.jdbc.Driver') {
|
||||
//this.urlPlaceholder = "例:jdbc:mysql://127.0.0.1:3306/user_info?useUnicode=true&characterEncoding=utf8";
|
||||
this.newDatasource.sourceUrl = "jdbc:mysql://"+hostIp+":"+port;
|
||||
} else if (thatClassName === 'net.sourceforge.jtds.jdbc.Driver') {
|
||||
//this.urlPlaceholder = "例:jdbc:jtds:sqlserver://127.0.0.1:33434;DatabaseName=user_info;socketTimeout=60;";
|
||||
this.newDatasource.sourceUrl = "jdbc:jtds:sqlserver://"+hostIp+":"+port;
|
||||
} else if (thatClassName === 'oracle.jdbc.driver.OracleDriver') {
|
||||
//this.urlPlaceholder = "例:jdbc:oracle:thin:@127.0.0.1:1521/user_info";
|
||||
this.newDatasource.sourceUrl = "jdbc:oracle:thin:@"+hostIp+":"+port+"/"+serverName;
|
||||
} else if (thatClassName === 'org.postgresql.Driver') {
|
||||
//this.urlPlaceholder = "例:jdbc:postgresql://127.0.0.1:5432/user_info";
|
||||
this.newDatasource.sourceUrl = "jdbc:postgresql://"+hostIp+":"+port;
|
||||
} else if (thatClassName === 'org.apache.hive.jdbc.HiveDriver') {
|
||||
//this.urlPlaceholder = "例:jdbc:hive2://127.0.0.1:21050/user_info;auth=noSasl";
|
||||
this.newDatasource.sourceUrl = "jdbc:hive2://"+hostIp+":"+port;
|
||||
} else if (thatClassName === 'dm.jdbc.driver.DmDriver'){
|
||||
//this.urlPlaceholder = "例:jdbc:dm://127.0.0.1:5236?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=utf-8";
|
||||
this.newDatasource.sourceUrl = "jdbc:dm://"+hostIp+":"+port;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
deleteUserDbSourceAuth(row) {
|
||||
var dbSourceAuthUserList = [];
|
||||
for (var i = 0; i < this.dbSourceAuthUserList.length; i++) {
|
||||
@@ -193,7 +316,7 @@
|
||||
},
|
||||
addDbSourceAuthUser() {
|
||||
if (this.dbSourceAuthNewUser.length <= 0) {
|
||||
this.$message.warning("请先选择用户");
|
||||
this.$message.warning("请先选择用户");
|
||||
return;
|
||||
}
|
||||
var userName = "";
|
||||
@@ -208,7 +331,7 @@
|
||||
userId: this.dbSourceAuthNewUser,
|
||||
executeAuth: '',
|
||||
descEditAuth: 0,
|
||||
procEditAuth: 0,
|
||||
procEditAuth: 0,
|
||||
});
|
||||
this.dbSourceAuthNewUser = "";
|
||||
},
|
||||
@@ -216,19 +339,20 @@
|
||||
if (!query) return;
|
||||
this.dbSourceAuthUserLoading = true;
|
||||
userApi.getUserBaseInfo({search: query}).then(json => {
|
||||
this.searchUserList = json.data || [];
|
||||
this.dbSourceAuthUserLoading = false;
|
||||
this.searchUserList = json.data || [];
|
||||
this.dbSourceAuthUserLoading = false;
|
||||
});
|
||||
},
|
||||
addDatasource() {
|
||||
this.datasourceDialogVisible = true;
|
||||
this.testDatasourceErrLoading = false;
|
||||
this.testDatasourceErrLoading = false;
|
||||
this.newDatasource = {name: "", driverClassName: "", sourceUrl: "", sourceName: "", sourcePassword: "", groupName: ""};
|
||||
this.sourceUrlDisabled = true;
|
||||
},
|
||||
editDatasource(row) {
|
||||
this.newDatasource = JSON.parse(JSON.stringify(row));
|
||||
this.datasourceDialogVisible = true;
|
||||
this.testDatasourceErrLoading = false;
|
||||
this.testDatasourceErrLoading = false;
|
||||
},
|
||||
deleteDatasource(row) {
|
||||
this.$confirm('确定要删除此数据源吗?', '提示', {
|
||||
@@ -239,16 +363,16 @@
|
||||
row.yn = 0;
|
||||
datasourceApi.manageUpdateDatasource(row).then(() => {
|
||||
this.$message.success("删除成功!");
|
||||
this.$emit('loadDatasourceList');
|
||||
this.$emit('loadDatasourceList');
|
||||
this.getDatasourceList();
|
||||
});
|
||||
}).catch(()=>{});
|
||||
},
|
||||
saveDatasource() {
|
||||
datasourceApi.manageUpdateDatasource(this.newDatasource).then(() => {
|
||||
this.datasourceDialogVisible = false;
|
||||
this.datasourceDialogVisible = false;
|
||||
this.$message.success("保存成功!");
|
||||
this.$emit('loadDatasourceList');
|
||||
this.$emit('loadDatasourceList');
|
||||
this.getDatasourceList();
|
||||
});
|
||||
},
|
||||
@@ -282,6 +406,8 @@
|
||||
} else if (this.newDatasource.driverClassName == 'dm.jdbc.driver.DmDriver'){
|
||||
this.urlPlaceholder = "例:jdbc:dm://127.0.0.1:5236?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=utf-8";
|
||||
}
|
||||
this.sourceUrlDisabled = false;
|
||||
this.oracleServerNameShow = false;
|
||||
},
|
||||
handleCurrentChange(to) {
|
||||
this.currentPage = to;
|
||||
@@ -314,7 +440,13 @@
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
|
||||
<style scoped>
|
||||
.demo-input-suffix{
|
||||
display: flex;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.demo-input-suffix>span{
|
||||
width: 90px;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@@ -169,7 +169,8 @@ import sqlFormatter from "sql-formatter"
|
||||
import datasourceApi from '../../common/api/datasource'
|
||||
import aceEditor from "../../common/lib/ace-editor";
|
||||
import sqlParser from "./parser/SqlParser";
|
||||
import Clickoutside from 'element-ui/src/utils/clickoutside'
|
||||
import Clickoutside from 'element-ui/src/utils/clickoutside';
|
||||
import merge from 'webpack-merge';
|
||||
|
||||
export default {
|
||||
directives: { Clickoutside },
|
||||
@@ -242,6 +243,9 @@ export default {
|
||||
this.height = 190;
|
||||
this.loadDatasourceList();
|
||||
},
|
||||
activated(){
|
||||
this.loadDatasourceList();
|
||||
},
|
||||
methods: {
|
||||
sqlExecutorInit(editor) {
|
||||
this.sqlExecutorEditor = editor;
|
||||
@@ -575,19 +579,33 @@ export default {
|
||||
datasourceApi.datasourceList({}).then(json => {
|
||||
this.datasourceList = json.data || [];
|
||||
this.datasourceOptions = this.datasourceList;
|
||||
|
||||
//子组件向父组件传值
|
||||
//this.$emit('listenToChildEvent',this.datasourceList);
|
||||
|
||||
let datasourceGroupList = [];
|
||||
this.datasourceList.filter(item => !!item.groupName).forEach(item => datasourceGroupList.push(item.groupName || ''));
|
||||
this.datasourceGroupList = Array.from(new Set(datasourceGroupList));
|
||||
|
||||
if (this.datasourceList.length > 0) {
|
||||
this.choiceDatasourceId = this.datasourceList[0].id;
|
||||
//初次加载根据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;
|
||||
}
|
||||
this.executorSource = {sourceId: this.choiceDatasourceId};
|
||||
this.loadDatabaseList();
|
||||
this.loadDatabaseList(true);
|
||||
this.loadSourceBaseInfo();
|
||||
this.loadHistoryAndFavoriteList();
|
||||
}
|
||||
});
|
||||
},
|
||||
loadDatabaseList() {
|
||||
//initFlag: 初次加载状态
|
||||
loadDatabaseList(initFlag) {
|
||||
datasourceApi.databaseList({sourceId: this.choiceDatasourceId}).then(json => {
|
||||
this.databaseList = json.data || [];
|
||||
if (this.databaseList.length > 0) {
|
||||
@@ -596,6 +614,11 @@ export default {
|
||||
let notSysDbItem = this.databaseList.find(item => sysDbName.indexOf(item.dbName) < 0);
|
||||
this.choiceDatabase = (!!notSysDbItem) ? notSysDbItem.dbName : this.databaseList[0].dbName;
|
||||
this.executorSource = {sourceId: this.choiceDatasourceId, dbName: this.choiceDatabase};
|
||||
// 非初次加载,动态改变url参数
|
||||
if(!initFlag){
|
||||
this.$router.replace({ query: { datasourceId: this.choiceDatasourceId,database:this.choiceDatabase } })
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user