From 1d9cdc7a7ed1a810b6ea8bc1ece03c415dc521ee Mon Sep 17 00:00:00 2001 From: WangHao <43278047@qq.com> Date: Sat, 14 Nov 2020 16:07:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=90=9C=E7=B4=A2=E9=AB=98?= =?UTF-8?q?=E4=BA=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/BookmarkList/index.vue | 65 +++++++++++++++- .../src/views/bookmark/bookmark/index.vue | 78 ++++--------------- 2 files changed, 77 insertions(+), 66 deletions(-) diff --git a/ruoyi-ui/src/components/BookmarkList/index.vue b/ruoyi-ui/src/components/BookmarkList/index.vue index 77d119d67..3a65ac43e 100644 --- a/ruoyi-ui/src/components/BookmarkList/index.vue +++ b/ruoyi-ui/src/components/BookmarkList/index.vue @@ -4,12 +4,16 @@
+ - {{bm.title}} + {{bm.title}}
{{bm.createTime|changeTime}}
- {{bm.description}} + + + + {{bm.description}}
@@ -43,6 +47,8 @@ props: { bookmarkList: Array, property: null, + highlighted: null,//搜索是否高亮 + sousuo:null }, data: function () { return { @@ -98,7 +104,60 @@ } - } + }, + + /**搜索高亮 开始**/ + highLight(item, highLight) { + return this.highLightTableMsg(item, highLight) + }, + highLightTableMsg(msg, highLightStr) { + if (msg == null) { + msg = '' + } + if (highLightStr == null) { + highLightStr = '' + } + if (msg instanceof Object) { + msg = JSON.stringify(msg) + } + if (highLightStr instanceof Object) { + highLightStr = JSON.stringify(highLightStr) + } + if (!(msg instanceof String)) { + msg = msg.toString() + } + if (!(highLightStr instanceof String)) { + highLightStr = highLightStr.toString() + } + var htmlStr = '' + if (highLightStr.length > 0) { + if (msg.toLowerCase().indexOf(highLightStr) !== -1) { + assemblyStr(msg, highLightStr) + + } else { + htmlStr = '' + msg + '' + } + } else { + htmlStr = '' + msg + '' + } + + function assemblyStr(msgAssembly, highLightAssembly) { + var isend=highLightAssembly.length; + if (msgAssembly.toLowerCase().indexOf(highLightAssembly) !== -1) { + var length = highLightAssembly.length + + var start = msgAssembly.toLowerCase().indexOf(highLightAssembly) + htmlStr = htmlStr + '' + msgAssembly.substring(0, start) + '' + '' + msgAssembly.substring(start, start+isend) + '' + msgAssembly = msgAssembly.substring(start + length, msgAssembly.length) + assemblyStr(msgAssembly, highLightAssembly) + } else { + htmlStr = htmlStr + '' + msgAssembly + '' + } + } + + return htmlStr; + }, + /**搜索高亮 结束**/ } } diff --git a/ruoyi-ui/src/views/bookmark/bookmark/index.vue b/ruoyi-ui/src/views/bookmark/bookmark/index.vue index a1452d95b..3d5d16c4e 100644 --- a/ruoyi-ui/src/views/bookmark/bookmark/index.vue +++ b/ruoyi-ui/src/views/bookmark/bookmark/index.vue @@ -119,7 +119,7 @@
- 共为您找到约{{total}}个结果 + "{{sousuo}}"共为您找到约{{total}}个结果
@@ -199,7 +199,7 @@
- +

加载中...

没有更多了

@@ -486,6 +486,7 @@ //搜索值 if (sousuo != null && sousuo != undefined && sousuo != '') { this.queryParams.sousuo = sousuo; + this.sousuo=sousuo } @@ -505,7 +506,7 @@ //自动获取高度 window.addEventListener('resize', this.getHeight); this.getHeight() - + }, mounted() { @@ -836,6 +837,7 @@ }, /**查询书签 滚动加载分页拼接*/ getListConcat(){ + var that=this; this.loading = true; selectBymenuIdUserID(this.queryParams).then(response => { if (response.code == 200) { @@ -908,67 +910,17 @@ window.open(this.gourl); }, - /**搜索高亮 开始**/ - highLight(item, highLight) { - return this.highLightTableMsg(item, highLight) - }, - highLightTableMsg(msg, highLightStr) { - if (msg == null) { - msg = '' - } - if (highLightStr == null) { - highLightStr = '' - } - if (msg instanceof Object) { - msg = JSON.stringify(msg) - } - if (highLightStr instanceof Object) { - highLightStr = JSON.stringify(highLightStr) - } - if (!(msg instanceof String)) { - msg = msg.toString() - } - if (!(highLightStr instanceof String)) { - highLightStr = highLightStr.toString() - } - var htmlStr = '' - if (highLightStr.length > 0) { - if (msg.indexOf(highLightStr) !== -1) { - assemblyStr(msg, highLightStr) - } else { - htmlStr = '' + msg + '' - } - } else { - htmlStr = '' + msg + '' - } - - function assemblyStr(msgAssembly, highLightAssembly) { - if (msgAssembly.indexOf(highLightAssembly) !== -1) { - var length = highLightAssembly.length - // alert(length) - var start = msgAssembly.indexOf(highLightAssembly) - htmlStr = htmlStr + '' + msgAssembly.substring(0, start) + '' + '' + highLightAssembly + '' - msgAssembly = msgAssembly.substring(start + length, msgAssembly.length) - assemblyStr(msgAssembly, highLightAssembly) - } else { - htmlStr = htmlStr + '' + msgAssembly + '' - } - } - - return htmlStr; - }, - /**搜索高亮 结束**/ /**搜索功能**/ gosousuo() { var that = this; - // that.$router.push({ - // path: "/content", - // query: { - // sousuo: this.sousuo, - // t:Date.now(), - // } - // }) + that.$router.push({ + path: "/content", + query: { + sousuo: this.sousuo, + t:Date.now(), + } + }) }, /** 查询部门下拉树结构 */ @@ -1352,7 +1304,7 @@ .bookmark { height: 70px; /*border-bottom: 1px solid #D9D9D9;*/ - + } .bookmark2 { @@ -1478,9 +1430,9 @@ } .sousou-left { - + margin-left: 12px; - + } .isBookmarkAside{ padding: 0px;