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

@@ -104,31 +104,6 @@
<artifactId>aspectjtools</artifactId>
</dependency>
<!--elasticsearch-->
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.plugin</groupId>
<artifactId>transport-netty4-client</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.plugin</groupId>
<artifactId>reindex-client</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>

View File

@@ -3,6 +3,7 @@ package com.zyplayer.doc.elasticsearch.controller;
import com.zyplayer.doc.core.json.DocResponseJson;
import com.zyplayer.doc.core.json.ResponseJson;
import com.zyplayer.doc.data.service.elasticsearch.support.ElasticSearchUtil;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.GetMappingsRequest;
@@ -12,6 +13,7 @@ import org.elasticsearch.common.unit.TimeValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -37,15 +39,22 @@ public class EsMappingController {
@Resource
ElasticSearchUtil elasticSearchUtil;
@GetMapping("/mappings")
public ResponseJson<Object> mappings() throws IOException {
@PostMapping("/mappings")
public ResponseJson<Object> mappings(String index) throws IOException {
GetMappingsRequest request = new GetMappingsRequest();
request.setMasterTimeout(TimeValue.timeValueMinutes(1));
RestHighLevelClient client = elasticSearchUtil.getEsClient("127.0.0.1:9200", "http");
GetMappingsResponse getMappingResponse = client.indices().getMapping(request, RequestOptions.DEFAULT);
Map<String, MappingMetaData> allMappings = getMappingResponse.mappings();
return DocResponseJson.ok(allMappings);
if (StringUtils.isNotBlank(index)) {
request.indices(index);
}
try {
RestHighLevelClient client = elasticSearchUtil.getEsClient("127.0.0.1:9200", "http");
GetMappingsResponse getMappingResponse = client.indices().getMapping(request, RequestOptions.DEFAULT);
Map<String, MappingMetaData> allMappings = getMappingResponse.mappings();
return DocResponseJson.ok(allMappings);
} catch (Exception e) {
e.printStackTrace();
}
return DocResponseJson.warn("获取文档失败");
}
@GetMapping("/list")

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
!function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var r=window.webpackJsonp;window.webpackJsonp=function(t,a,c){for(var u,i,f,l=0,s=[];l<t.length;l++)i=t[l],o[i]&&s.push(o[i][0]),o[i]=0;for(u in a)Object.prototype.hasOwnProperty.call(a,u)&&(e[u]=a[u]);for(r&&r(t,a,c);s.length;)s.shift()();if(c)for(l=0;l<c.length;l++)f=n(n.s=c[l]);return f};var t={},o={2:0};n.e=function(e){function r(){u.onerror=u.onload=null,clearTimeout(i);var n=o[e];0!==n&&(n&&n[1](new Error("Loading chunk "+e+" failed.")),o[e]=void 0)}var t=o[e];if(0===t)return new Promise(function(e){e()});if(t)return t[2];var a=new Promise(function(n,r){t=o[e]=[n,r]});t[2]=a;var c=document.getElementsByTagName("head")[0],u=document.createElement("script");u.type="text/javascript",u.charset="utf-8",u.async=!0,u.timeout=12e4,n.nc&&u.setAttribute("nonce",n.nc),u.src=n.p+""+e+".js?"+{0:"31474664fb42f0a39af3",1:"1d7b81f64deeacaf0960"}[e];var i=setTimeout(r,12e4);return u.onerror=u.onload=r,c.appendChild(u),a},n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:t})},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="",n.oe=function(e){throw console.error(e),e}}([]);
//# sourceMappingURL=doc-es-manifest.js.map?b055a21e8924d72bdfc6

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,14 @@
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>ES文档管理</title>
</head>
<body>
<div id="app"></div>
<script type="text/javascript" src="doc-es-manifest.js?b055a21e8924d72bdfc6"></script><script type="text/javascript" src="doc-es-vendor.js?31474664fb42f0a39af3"></script><script type="text/javascript" src="doc-es-index.js?1d7b81f64deeacaf0960"></script></body>
</html>

View File

@@ -39,4 +39,10 @@ public class DocSystemController {
public ModelAndView dubbo() {
return new ModelAndView("/doc-dubbo.html");
}
@AuthMan
@GetMapping("/doc-es")
public ModelAndView es() {
return new ModelAndView("/doc-es.html");
}
}

View File

@@ -8,6 +8,7 @@
-- 从1.0.2版本升级:
CREATE TABLE `db_datasource` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键自增ID',
`name` varchar(50) DEFAULT NULL COMMENT '数据源名称',
`driver_class_name` varchar(50) DEFAULT NULL COMMENT '数据源驱动类',
`source_url` varchar(512) DEFAULT NULL COMMENT '数据源地址',
`source_name` varchar(50) DEFAULT NULL COMMENT '数据源用户名',
@@ -28,6 +29,8 @@ where a.user_no='zyplayer' and b.auth_name='DB_DATASOURCE_MANAGE';
ALTER TABLE `wiki_page_content` MODIFY COLUMN `preview` varchar(16000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '预览内容';
-- alter table `db_datasource` add `name` varchar(50) DEFAULT NULL COMMENT '数据源名称';
-- ------------------------全新的库:------------------------

File diff suppressed because one or more lines are too long

View File

@@ -1,2 +1,2 @@
!function(e){function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}var n=window.webpackJsonp;window.webpackJsonp=function(t,c,u){for(var i,a,f,l=0,s=[];l<t.length;l++)a=t[l],o[a]&&s.push(o[a][0]),o[a]=0;for(i in c)Object.prototype.hasOwnProperty.call(c,i)&&(e[i]=c[i]);for(n&&n(t,c,u);s.length;)s.shift()();if(u)for(l=0;l<u.length;l++)f=r(r.s=u[l]);return f};var t={},o={2:0};r.e=function(e){function n(){u.onerror=u.onload=null,clearTimeout(i);var r=o[e];0!==r&&(r&&r[1](new Error("Loading chunk "+e+" failed.")),o[e]=void 0)}if(0===o[e])return Promise.resolve();if(o[e])return o[e][2];var t=new Promise(function(r,n){o[e]=[r,n]});o[e][2]=t;var c=document.getElementsByTagName("head")[0],u=document.createElement("script");u.type="text/javascript",u.charset="utf-8",u.async=!0,u.timeout=12e4,r.nc&&u.setAttribute("nonce",r.nc),u.src=r.p+""+e+".js?"+{0:"c79cfa48fc4f362296bb",1:"f8a7b3851b18330ded63"}[e];var i=setTimeout(n,12e4);return u.onerror=u.onload=n,c.appendChild(u),t},r.m=e,r.c=t,r.i=function(e){return e},r.d=function(e,n,t){r.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:t})},r.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(n,"a",n),n},r.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},r.p="",r.oe=function(e){throw console.error(e),e}}([]);
//# sourceMappingURL=doc-console-manifest.js.map?698ea1ff6484393ba8c7
!function(e){function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}var n=window.webpackJsonp;window.webpackJsonp=function(t,c,u){for(var i,a,f,l=0,s=[];l<t.length;l++)a=t[l],o[a]&&s.push(o[a][0]),o[a]=0;for(i in c)Object.prototype.hasOwnProperty.call(c,i)&&(e[i]=c[i]);for(n&&n(t,c,u);s.length;)s.shift()();if(u)for(l=0;l<u.length;l++)f=r(r.s=u[l]);return f};var t={},o={2:0};r.e=function(e){function n(){u.onerror=u.onload=null,clearTimeout(i);var r=o[e];0!==r&&(r&&r[1](new Error("Loading chunk "+e+" failed.")),o[e]=void 0)}if(0===o[e])return Promise.resolve();if(o[e])return o[e][2];var t=new Promise(function(r,n){o[e]=[r,n]});o[e][2]=t;var c=document.getElementsByTagName("head")[0],u=document.createElement("script");u.type="text/javascript",u.charset="utf-8",u.async=!0,u.timeout=12e4,r.nc&&u.setAttribute("nonce",r.nc),u.src=r.p+""+e+".js?"+{0:"c79cfa48fc4f362296bb",1:"879f5c24852c7f29a4fd"}[e];var i=setTimeout(n,12e4);return u.onerror=u.onload=n,c.appendChild(u),t},r.m=e,r.c=t,r.i=function(e){return e},r.d=function(e,n,t){r.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:t})},r.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(n,"a",n),n},r.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},r.p="",r.oe=function(e){throw console.error(e),e}}([]);
//# sourceMappingURL=doc-console-manifest.js.map?d6ae4354f2d1ad24a8d6

View File

@@ -8,7 +8,7 @@
<body>
<div id="app"></div>
<script type="text/javascript" src="doc-console-manifest.js?698ea1ff6484393ba8c7"></script><script type="text/javascript" src="doc-console-vendor.js?c79cfa48fc4f362296bb"></script><script type="text/javascript" src="doc-console-index.js?f8a7b3851b18330ded63"></script></body>
<script type="text/javascript" src="doc-console-manifest.js?d6ae4354f2d1ad24a8d6"></script><script type="text/javascript" src="doc-console-vendor.js?c79cfa48fc4f362296bb"></script><script type="text/javascript" src="doc-console-index.js?879f5c24852c7f29a4fd"></script></body>
</html>

View File

@@ -24,6 +24,10 @@
<div class="logo-img"><img src="../../assets/img/dubbo.png"></div>
<div>dubbo文档</div>
</div>
<div class="item" v-on:click="jumpToDocPage('doc-es')">
<div class="logo-text text1">ES</div>
<div>es文档</div>
</div>
<el-tooltip effect="dark" content="不成熟欢迎完善" placement="top-start">
<div class="item disabled">
<div class="logo-text text4">GRPC</div>

View File

@@ -1,5 +1,5 @@
{
"name": "element-starter",
"name": "console-ui",
"requires": true,
"lockfileVersion": 1,
"dependencies": {
@@ -2014,7 +2014,7 @@
},
"deepmerge": {
"version": "1.5.2",
"resolved": "http://registry.npm.taobao.org/deepmerge/download/deepmerge-1.5.2.tgz",
"resolved": "https://registry.npm.taobao.org/deepmerge/download/deepmerge-1.5.2.tgz",
"integrity": "sha1-EEmdhohEza1P7ghC34x/bwyVp1M="
},
"define-properties": {
@@ -2237,9 +2237,9 @@
"dev": true
},
"element-ui": {
"version": "2.8.2",
"resolved": "https://registry.npm.taobao.org/element-ui/download/element-ui-2.8.2.tgz",
"integrity": "sha1-Iaeky5Jhaw+LddTU5jfToc2MCd4=",
"version": "2.10.1",
"resolved": "https://registry.npm.taobao.org/element-ui/download/element-ui-2.10.1.tgz?cache=0&sync_timestamp=1562053824530&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Felement-ui%2Fdownload%2Felement-ui-2.10.1.tgz",
"integrity": "sha1-EBEBblDnb12ub7+chuU7blP8ues=",
"requires": {
"async-validator": "~1.8.1",
"babel-helper-vue-jsx-merge-props": "^2.0.0",
@@ -2770,7 +2770,8 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"aproba": {
"version": "1.2.0",
@@ -3185,7 +3186,8 @@
"safe-buffer": {
"version": "5.1.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"safer-buffer": {
"version": "2.1.2",
@@ -3241,6 +3243,7 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@@ -3284,12 +3287,14 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"yallist": {
"version": "3.0.3",
"bundled": true,
"dev": true
"dev": true,
"optional": true
}
}
},

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>