es文档开发

This commit is contained in:
暮光:城中城
2019-07-23 21:41:20 +08:00
parent 417132d25c
commit fc02414519
22 changed files with 205 additions and 356 deletions

View File

@@ -6,11 +6,6 @@
<el-container v-else>
<el-aside>
<div style="padding: 10px;height: 100%;box-sizing: border-box;background: #fafafa;">
<div style="margin-bottom: 10px;">
<el-select v-model="choiceDatasource" @change="datasourceChangeEvents" filterable placeholder="请先选择数据源" style="width: 100%;">
<el-option v-for="item in datasourceOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
</el-select>
</div>
<el-menu :router="true" class="el-menu-vertical" style="height: auto;">
<el-menu-item index="/"><i class="el-icon-s-home"></i>控制台</el-menu-item>
<el-submenu index="1">
@@ -21,14 +16,13 @@
<el-menu-item index="/data/datasourceManage"><i class="el-icon-coin"></i>数据源管理</el-menu-item>
</el-submenu>
</el-menu>
<el-tree :props="defaultProps" :data="databaseList" @node-click="handleNodeClick"
<el-tree :props="defaultProps" :data="esIndexList" @node-click="handleNodeClick"
ref="databaseTree" highlight-current draggable
:default-expanded-keys="databaseExpandedKeys"
:default-expanded-keys="esIndexExpandedKeys"
node-key="id" @node-expand="handleNodeExpand"
style="background-color: #fafafa;">
<span slot-scope="{node, data}">
<span v-if="data.needLoad"><i class="el-icon-loading"></i></span>
<span v-else>{{node.label}}</span>
<span>{{node.label}}</span>
</span>
</el-tree>
</div>
@@ -87,15 +81,10 @@
isCollapse: false,
aboutDialogVisible: false,
userSelfInfo: {},
// 数据源相关
datasourceOptions: [],
datasourceList: [],
choiceDatasource: "",
defaultProps: {children: 'children', label: 'name'},
// 页面展示相关
nowDatasourceShow: {},
databaseList: [],
databaseExpandedKeys: [],
defaultProps: {children: 'children', label: 'name'},
esIndexList: [],
esIndexExpandedKeys: [],
// 升级信息
upgradeInfo: {},
}
@@ -105,7 +94,7 @@
global.vue.$app = this;
this.getSelfUserInfo();
this.checkSystemUpgrade();
this.loadDatasourceList();
this.loadEsMappingList();
},
methods: {
userSettingDropdown(command) {
@@ -132,96 +121,36 @@
app.userSelfInfo = json.data;
});
},
datasourceChangeEvents() {
app.nowDatasourceShow = this.choiceDatasource;
app.loadDatabaseList(this.choiceDatasource);
},
handleNodeClick(node) {
console.log("点击节点:", node);
if (node.type == 1) {
this.nowClickPath = {host: node.host, dbName: node.dbName, tableName: node.tableName};
this.$router.push({path: '/table/database', query: this.nowClickPath});
} else if (node.type == 2) {
this.nowClickPath = {host: node.host, dbName: node.dbName, tableName: node.tableName};
this.$router.push({path: '/table/info', query: this.nowClickPath});
this.nowClickPath = {index: node.name};
this.$router.push({path: '/index/show', query: this.nowClickPath});
}
},
handleNodeExpand(node) {
if (node.children.length > 0 && node.children[0].needLoad) {
console.log("加载节点:", node);
if (node.type == 1) {
app.loadGetTableList(node);
}
}
},
loadGetTableList(node, callback) {
this.common.post(this.apilist1.tableList, {host: node.host, dbName: node.dbName}, function (json) {
var pathIndex = [];
var result = json.data || [];
for (var i = 0; i < result.length; i++) {
var item = {
id: node.host + "_" + node.dbName + "_" + result[i].tableName, host: node.host,
dbName: node.dbName, tableName: result[i].tableName, name: result[i].tableName, type: 2
};
// item.children = [{label: '', needLoad: true}];// 初始化一个对象,点击展开时重新查询加载
pathIndex.push(item);
loadEsMappingList() {
this.common.post(this.apilist1.esMappings, {}, function (json) {
var result = json.data || {};
var pathIndex = [], pathChildren = [];
for (var key in result) {
// var properties = result[key].sourceAsMap.properties;
// var children = [];
// for (var propertiesKey in properties) {
// var propertiesItem = properties[propertiesKey];
// var item = {
// id: key + "_" + propertiesKey, name: propertiesKey
// };
// children.push(item);
// }
pathChildren.push({id: key, name: key, type: 1});
}
node.children = pathIndex;
if (typeof callback == 'function') {
callback(pathIndex);
}
});
},
loadDatasourceList() {
this.common.post(this.apilist1.datasourceList, {}, function (json) {
app.datasourceList = json.data || [];
var datasourceOptions = [];
for (var i = 0; i < app.datasourceList.length; i++) {
datasourceOptions.push({
label: app.datasourceList[i], value: app.datasourceList[i]
});
}
app.datasourceOptions = datasourceOptions;
});
},
loadDatabaseList(host, callback) {
this.common.post(this.apilist1.databaseList, {host: host}, function (json) {
var result = json.data || [];
var pathIndex = [];
var children = [];
for (var i = 0; i < result.length; i++) {
var item = {
id: host + "_" + result[i].dbName, host: host, dbName: result[i].dbName,
name: result[i].dbName, type: 1
};
item.children = [{label: '', needLoad: true}];// 初始化一个对象,点击展开时重新查询加载
children.push(item);
}
pathIndex.push({id: host, host: host, name: host, children: children});
app.databaseList = pathIndex;
if (typeof callback == 'function') {
callback();
}
});
},
initLoadDataList(host, dbName) {
if (app.databaseList.length > 0) {
return;
}
this.loadDatabaseList(host, function () {
app.databaseExpandedKeys = [host];
// 展不开、、
// setTimeout(()=> {
// var node = app.$refs.databaseTree.getNode(host + "_" + dbName);
// if (!!node) {
// app.loadGetTableList(node.data, function (children) {
// var node = app.$refs.databaseTree.getNode(host + "_" + dbName);
// node.childNodes = children;
// app.$refs.databaseTree.updateKeyChildren(host + "_" + dbName);
// // node.setChildren(node.data);
// });
// }
// }, 500);
pathIndex.push({name: "索引列表", children: pathChildren});
app.esIndexList = pathIndex;
});
},
checkSystemUpgrade() {

View File

@@ -14,6 +14,8 @@ var URL = {
manageDatasourceList: '/zyplayer-doc-db/datasource/list',
manageUpdateDatasource: '/zyplayer-doc-db/datasource/update',
esMappings: '/zyplayer-doc-es/es-mapping/mappings',
systemUpgradeInfo: '/system/info/upgrade',
};

View File

@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>数据库文档管理</title>
<title>ES文档管理</title>
</head>
<body>

View File

@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>数据库文档管理</title>
<title>ES文档管理</title>
</head>
<body>

View File

@@ -4,13 +4,12 @@ import UserLogin from './views/user/Login.vue'
import UserMyInfo from './views/user/MyInfo.vue'
import UserRouterView from './views/user/RouterView.vue'
import TableInfo from './views/table/Info.vue'
import TableDatabase from './views/table/Database.vue'
import TableRouterView from './views/table/RouterView.vue'
import DataDatasourceManage from './views/data/DatasourceManage.vue'
import DataRouterView from './views/data/RouterView.vue'
import IndexShow from './views/index/Show.vue'
import IndexRouterView from './views/index/RouterView.vue'
import CommonNoAuth from './views/common/NoAuth.vue'
let routes = [
@@ -30,12 +29,11 @@ let routes = [
{path: 'myInfo', name: '我的信息',component: UserMyInfo},
]
}, {
path: '/table',
name: '表信息',
component: TableRouterView,
path: '/index',
name: '索引管理',
component: IndexRouterView,
children: [
{path: 'info', name: '信息',component: TableInfo},
{path: 'database', name: '库信息',component: TableDatabase},
{path: 'show', name: '索引信息',component: IndexShow},
]
}, {
path: '/data',

View File

@@ -0,0 +1,67 @@
<template>
<div class="index-show-vue">
<el-card style="margin: 10px;">
<div slot="header" class="clearfix">字段信息</div>
<div style="padding: 10px;" v-loading="indexMappingListLoading">
<el-table :data="indexMappingList" stripe border style="width: 100%; margin-bottom: 5px;">
<el-table-column prop="name" label="字段名"></el-table-column>
<el-table-column prop="type" label="类型"></el-table-column>
</el-table>
</div>
</el-card>
</div>
</template>
<script>
import global from '../../common/config/global'
var app;
export default {
data() {
return {
indexMappingListLoading: false,
vueQueryParam: {},
indexMappingList: [],
};
},
beforeRouteUpdate(to, from, next) {
this.initQueryParam(to);
next();
},
mounted: function () {
app = this;
this.initQueryParam(this.$route);
// 延迟设置展开的目录edit比app先初始化
setTimeout(function () {
//global.vue.$app.initLoadDataList(app.vueQueryParam.host, app.vueQueryParam.dbName);
}, 500);
},
methods: {
initQueryParam(to) {
this.indexMappingListLoading = true;
this.vueQueryParam = to.query;
this.common.post(this.apilist1.esMappings, this.vueQueryParam, function (json) {
var data = json.data || {};
var properties = data[app.vueQueryParam.index].sourceAsMap.properties;
var propertiesArr = [];
for (var propertiesKey in properties) {
var propertiesItem = properties[propertiesKey];
var item = {
name: propertiesKey, type: propertiesItem.type
};
propertiesArr.push(item);
}
app.indexMappingList = propertiesArr;
app.indexMappingListLoading = false;
});
},
}
}
</script>
<style>
.index-show-vue .el-form-item{margin-bottom: 5px;}
.index-show-vue .edit-table-desc{cursor: pointer; color: #409EFF;}
.index-show-vue .description{cursor: pointer;}
.index-show-vue .el-table td, .table-info-vue .el-table th{padding: 5px 0;}
</style>

View File

@@ -1,72 +0,0 @@
<template>
<div class="table-database-vue">
<el-card style="margin: 10px;" shadow="never">
<div slot="header" class="clearfix">库信息</div>
<el-form label-width="100px">
<el-form-item label="数据源:">{{vueQueryParam.host}}</el-form-item>
<el-form-item label="数据库:">{{vueQueryParam.dbName}}</el-form-item>
</el-form>
<el-form :inline="true" label-width="100px">
<el-form-item label="关键字:">
<el-input v-model="keyword" placeholder="输入字段名或注释搜索相关的表或字段信息" style="width: 500px;"></el-input>
</el-form-item>
<el-form-item>
<el-button class="search-submit" type="primary" icon="el-icon-search" @click="searchSubmit">模糊搜索</el-button>
</el-form-item>
</el-form>
</el-card>
<div style="padding: 10px;" v-loading="columnListLoading">
<el-table :data="columnList" stripe border style="width: 100%; margin-bottom: 5px;">
<el-table-column prop="tableName" label="表名" width="200"></el-table-column>
<el-table-column prop="columnName" label="字段名" width="200"></el-table-column>
<el-table-column prop="description" label="注释"></el-table-column>
</el-table>
</div>
</div>
</template>
<script>
import global from '../../common/config/global'
var app;
export default {
data() {
return {
columnListLoading: false,
vueQueryParam: {},
columnList: [],
tableInfo: [],
keyword: '',
};
},
beforeRouteUpdate(to, from, next) {
this.initQueryParam(to);
next();
},
mounted: function () {
app = this;
this.initQueryParam(this.$route);
// 延迟设置展开的目录edit比app先初始化
setTimeout(function () {
global.vue.$app.initLoadDataList(app.vueQueryParam.host, app.vueQueryParam.dbName);
}, 500);
},
methods: {
initQueryParam(to) {
this.vueQueryParam = to.query;
},
searchSubmit() {
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;
});
},
}
}
</script>
<style>
.table-database-vue .el-table td, .table-database-vue .el-table th{padding: 5px 0;}
</style>

View File

@@ -1,128 +0,0 @@
<template>
<div class="table-info-vue">
<el-card style="margin: 10px;">
<div slot="header" class="clearfix">表信息</div>
<el-form label-width="100px">
<el-form-item label="数据源:">{{vueQueryParam.host}}</el-form-item>
<el-form-item label="数据库:">{{vueQueryParam.dbName}}</el-form-item>
<el-form-item label="数据表:">{{vueQueryParam.tableName}}</el-form-item>
<el-form-item label="表注释:">
<span v-if="tableInfo.inEdit == 1" @keyup.enter="saveTableDescription">
<el-input v-model="tableInfo.newDesc" placeholder="输入表注释" v-on:blur="saveTableDescription" style="width: 500px;"></el-input>
</span>
<span v-else>{{tableInfo.description || '暂无注释'}} <i class="el-icon-edit edit-table-desc" v-on:click="tableInfo.inEdit = 1"></i></span>
</el-form-item>
</el-form>
</el-card>
<el-card style="margin: 10px;">
<div slot="header" class="clearfix">字段信息</div>
<div style="padding: 10px;" v-loading="columnListLoading">
<el-table :data="columnList" stripe border style="width: 100%; margin-bottom: 5px;">
<el-table-column prop="name" label="字段名" width="200"></el-table-column>
<el-table-column label="自增" width="50">
<template slot-scope="scope">{{scope.row.isidentity ? '是' : '否'}}</template>
</el-table-column>
<el-table-column prop="type" label="类型" width="150"></el-table-column>
<el-table-column prop="length" label="长度" width="80"></el-table-column>
<el-table-column label="NULL" width="60">
<template slot-scope="scope">{{scope.row.nullable ? '允许' : '不允许'}}</template>
</el-table-column>
<el-table-column label="主键" width="50">
<template slot-scope="scope">{{scope.row.ispramary ? '是' : '否'}}</template>
</el-table-column>
<el-table-column label="注释">
<template slot-scope="scope">
<div v-if="scope.row.inEdit == 1" @keyup.enter="saveColumnDescription(scope.row)">
<el-input v-model="scope.row.newDesc" placeholder="输入字段注释" v-on:blur="saveColumnDescription(scope.row)"></el-input>
</div>
<div v-else class="description" v-on:click="descBoxClick(scope.row)">{{scope.row.description}}</div>
</template>
</el-table-column>
</el-table>
</div>
</el-card>
</div>
</template>
<script>
import global from '../../common/config/global'
var app;
export default {
data() {
return {
columnListLoading: false,
vueQueryParam: {},
columnList: [],
tableInfo: [],
};
},
beforeRouteUpdate(to, from, next) {
this.initQueryParam(to);
next();
},
mounted: function () {
app = this;
this.initQueryParam(this.$route);
// 延迟设置展开的目录edit比app先初始化
setTimeout(function () {
global.vue.$app.initLoadDataList(app.vueQueryParam.host, app.vueQueryParam.dbName);
}, 500);
},
methods: {
initQueryParam(to) {
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++) {
columnList[i].inEdit = 0;
columnList[i].newDesc = columnList[i].description;
}
app.columnList = columnList;
var tableInfo = json.data.tableInfo || {};
tableInfo.inEdit = 0;
tableInfo.newDesc = tableInfo.description;
app.tableInfo = tableInfo;
app.columnListLoading = false;
});
},
descBoxClick(row) {
// row.newDesc = row.description;
row.inEdit = 1;
},
saveColumnDescription(row) {
if (row.inEdit == 0 || row.description == row.newDesc) {
row.inEdit = 0;
return;
}
row.inEdit = 0;
this.vueQueryParam.columnName = row.name;
this.vueQueryParam.newDesc = row.newDesc;
this.common.post(this.apilist1.updateTableColumnDesc, this.vueQueryParam, function (json) {
row.description = row.newDesc;
app.$message.success("修改成功");
});
},
saveTableDescription() {
if (this.tableInfo.inEdit == 0 || this.tableInfo.description == this.tableInfo.newDesc) {
this.tableInfo.inEdit = 0;
return;
}
this.tableInfo.inEdit = 0;
this.vueQueryParam.newDesc = this.tableInfo.newDesc;
this.common.post(this.apilist1.updateTableDesc, this.vueQueryParam, function (json) {
app.tableInfo.description = app.tableInfo.newDesc;
app.$message.success("修改成功");
});
},
}
}
</script>
<style>
.table-info-vue .el-form-item{margin-bottom: 5px;}
.table-info-vue .edit-table-desc{cursor: pointer; color: #409EFF;}
.table-info-vue .description{cursor: pointer;}
.table-info-vue .el-table td, .table-info-vue .el-table th{padding: 5px 0;}
</style>