增加了elasticsearch全局搜索和文章内搜索
This commit is contained in:
@@ -20,8 +20,8 @@
|
||||
<div align="center">
|
||||
<el-button v-on:click="createWiki" icon="el-icon-plus" style="width: 100%;">创建文档</el-button>
|
||||
</div>
|
||||
<el-input v-model="searchKeywords" @keyup.enter.native="searchByKeywords" placeholder="搜索文档" style="margin: 10px 0;">
|
||||
<el-button slot="append" icon="el-icon-search" v-on:click="searchByKeywords"></el-button>
|
||||
<el-input v-model="searchKeywords" @input="searchByKeywords" @keyup.enter.native="searchByKeywords" placeholder="搜索文档" style="margin: 10px 0;">
|
||||
<el-button slot="append" icon="el-icon-search" v-on:click="searchByKeywordsNewPage"></el-button>
|
||||
</el-input>
|
||||
<el-tree :props="defaultProps" :data="wikiPageList" @node-click="handleNodeClick"
|
||||
@node-expand="handleNodeExpand" draggable @node-drop="handlePageDrop"
|
||||
@@ -207,6 +207,10 @@
|
||||
searchByKeywords() {
|
||||
this.$refs.wikiPageTree.filter(app.searchKeywords);
|
||||
},
|
||||
searchByKeywordsNewPage() {
|
||||
var routeUrl = this.$router.resolve({path: '/page/search', query: {keywords: app.searchKeywords}});
|
||||
window.open(routeUrl.href, '_blank');
|
||||
},
|
||||
handleNodeClick(data) {
|
||||
console.log("点击节点:", data);
|
||||
this.nowClickPath = {spaceId: this.nowClickPath.spaceId, pageId: data.id, parentId: data.id, path: data.path};
|
||||
|
||||
@@ -9,6 +9,7 @@ var URL = {
|
||||
pageDetail: '/zyplayer-doc-wiki/page/detail',
|
||||
pageDelete: '/zyplayer-doc-wiki/page/delete',
|
||||
pageNews: '/zyplayer-doc-wiki/page/news',
|
||||
pageSearchByEs: '/zyplayer-doc-wiki/page/searchByEs',
|
||||
pageLock: '/zyplayer-doc-wiki/page/lock',
|
||||
pageUnlock: '/zyplayer-doc-wiki/page/unlock',
|
||||
spaceList: '/zyplayer-doc-wiki/space/list',
|
||||
|
||||
@@ -106,5 +106,25 @@ export default {
|
||||
isNotEmpty(str) {
|
||||
return !isEmpty(str);
|
||||
},
|
||||
/**
|
||||
* param 将要转为URL参数字符串的对象
|
||||
* key URL参数字符串的前缀
|
||||
* encode true/false 是否进行URL编码,默认为true
|
||||
* return URL参数字符串
|
||||
*/
|
||||
objUrlEncode(param, key, encode) {
|
||||
if (param == null) return '';
|
||||
var paramStr = '';
|
||||
var t = typeof (param);
|
||||
if (t == 'string' || t == 'number' || t == 'boolean') {
|
||||
paramStr += '&' + key + '=' + ((encode == null || encode) ? encodeURIComponent(param) : param);
|
||||
} else {
|
||||
for (var i in param) {
|
||||
var k = key == null ? i : key + (param instanceof Array ? '[' + i + ']' : '.' + i);
|
||||
paramStr += urlEncode(param[i], k, encode);
|
||||
}
|
||||
}
|
||||
return paramStr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import UserRouterView from './views/user/RouterView.vue'
|
||||
|
||||
import PageShow from './views/page/Show.vue'
|
||||
import PageEdit from './views/page/Edit.vue'
|
||||
import PageSearch from './views/page/Search.vue'
|
||||
import PageRouterView from './views/page/RouterView.vue'
|
||||
|
||||
import CommonNoAuth from './views/common/NoAuth.vue'
|
||||
@@ -33,6 +34,7 @@ let routes = [
|
||||
children: [
|
||||
{path: 'show', name: '页面内容展示',component: PageShow},
|
||||
{path: 'edit', name: '编辑内容',component: PageEdit},
|
||||
{path: 'search', name: '全局搜索',component: PageSearch, meta: {fullscreen: true}},
|
||||
]
|
||||
}, {
|
||||
path: '/common',
|
||||
|
||||
122
zyplayer-doc-ui/wiki-ui/src/views/page/Search.vue
Normal file
122
zyplayer-doc-ui/wiki-ui/src/views/page/Search.vue
Normal file
@@ -0,0 +1,122 @@
|
||||
<template>
|
||||
<div style="background: #f1f1f1;min-height: 100%;">
|
||||
<div style="max-width: 1200px;margin: 0 auto;background: #fff;padding: 20px;min-height: 100%;box-sizing: border-box;">
|
||||
<div style="margin-bottom: 20px;">
|
||||
<el-row :gutter="20" style="max-width: 700px; margin: 0 auto;">
|
||||
<el-col :span="20">
|
||||
<el-input v-model="searchParam.keywords" @keyup.enter.native="getSpacePageNews" placeholder="" style="width: 100%;"></el-input>
|
||||
</el-col>
|
||||
<el-col :span="4">
|
||||
<el-button type="primary" @click="getSpacePageNews" icon="el-icon-search">搜索一下</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
<div v-if="spacePageNews.length <= 0" class="empty-news">暂无数据</div>
|
||||
<div v-else class="line-box" v-for="item in spacePageNews">
|
||||
<div class="line-title">
|
||||
<span class="text-link">{{item.createUserName}}</span> 发布于 <span class="text-link">{{item.spaceName}}</span>
|
||||
</div>
|
||||
<div class="page-preview-box">
|
||||
<div class="page-preview-title" v-on:click="showPageDetail(item)">{{item.pageTitle}}</div>
|
||||
<div class="page-preview-content">{{item.previewContent}}</div>
|
||||
<div>
|
||||
<span><img src="../../assets/img/zan.png" class="zan-img"> {{item.zanNum}} </span>
|
||||
<span><i class="el-icon-view view-img"></i> {{item.viewNum}} </span>
|
||||
<span>{{item.updateTime||item.createTime}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="page-info-box">
|
||||
<el-pagination
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
:page-sizes="[20, 50, 100]"
|
||||
:page-size="20"
|
||||
:current-page="searchParam.pageNum"
|
||||
layout="prev, pager, next, jumper, sizes, total"
|
||||
:total="totalCount"
|
||||
>
|
||||
</el-pagination>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import toast from '../../common/lib/common/toast'
|
||||
import global from '../../common/config/global'
|
||||
|
||||
var app;
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
totalCount: 0,
|
||||
searchParam: {
|
||||
spaceId: '',
|
||||
keywords: '',
|
||||
newsType: 1,
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
},
|
||||
spacePageNews:[],
|
||||
};
|
||||
},
|
||||
beforeRouteUpdate(to, from, next) {
|
||||
this.initQueryParam(to);
|
||||
next();
|
||||
},
|
||||
mounted: function () {
|
||||
this.initQueryParam(this.$route);
|
||||
app = this;
|
||||
},
|
||||
methods: {
|
||||
getSpacePageNews() {
|
||||
this.common.post(this.apilist1.pageSearchByEs, this.searchParam, function (json) {
|
||||
app.spacePageNews = json.data || [];
|
||||
app.totalCount = json.total;
|
||||
});
|
||||
},
|
||||
handleSizeChange(val) {
|
||||
this.searchParam.pageSize = val;
|
||||
this.getSpacePageNews();
|
||||
},
|
||||
showPageDetail(row) {
|
||||
window.open('#/page/show?spaceId=' + row.spaceId + "&pageId=" + row.pageId);
|
||||
},
|
||||
handleCurrentChange(val) {
|
||||
this.searchParam.pageNum = val;
|
||||
this.getSpacePageNews();
|
||||
},
|
||||
initQueryParam(to) {
|
||||
this.searchParam = {
|
||||
keywords: to.query.keywords,
|
||||
spaceId: to.query.spaceId,
|
||||
newsType: 1,
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
};
|
||||
this.getSpacePageNews();
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.empty-news{text-align: center;padding: 100px;}
|
||||
|
||||
.text-link {
|
||||
color: #444;
|
||||
/*cursor: pointer;*/
|
||||
/*font-weight: bold;*/
|
||||
}
|
||||
.line-box{color: #666;border-bottom: 1px solid #eee;padding: 20px 0;}
|
||||
.line-title{font-size: 14px;}
|
||||
.page-preview-box{}
|
||||
.page-preview-title{font-size: 18px;margin: 10px 0 5px 0;color: #3a8ee6;cursor: pointer;}
|
||||
.page-preview-content{font-size: 16px;margin-bottom: 5px;}
|
||||
.zan-img{vertical-align: middle;margin-top: -3px;}
|
||||
.view-img{font-size: 16px;color: #666;}
|
||||
|
||||
.page-info-box{text-align: right;margin: 20px 0 50px 0;}
|
||||
</style>
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
<el-form :model="loginParam" :rules="loginRules" ref="loginParam" label-position="left" label-width="0px"
|
||||
class="demo-ruleForm login-container">
|
||||
<h3 class="title">系统登录</h3>
|
||||
<el-form-item prop="username">
|
||||
<el-form-item>
|
||||
<el-input type="text" v-model="loginParam.username" auto-complete="off" placeholder="账号"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="password">
|
||||
<el-form-item>
|
||||
<el-input type="password" v-model="loginParam.password" auto-complete="off" placeholder="密码"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item style="width:100%;">
|
||||
|
||||
Reference in New Issue
Block a user