Commit 24b36f98 by zhengxiaokui
parents 0d397ab6 4e730c01
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<ul> <ul>
<li <li
:class="{ 'sug-selected': item.selected }" :class="{ 'sug-selected': item.selected }"
v-for="(item, idx) in searchResult" v-for="(item, idx) in searchResultForLis"
:key="idx" :key="idx"
@mouseover="liOverEvent(idx)" @mouseover="liOverEvent(idx)"
@mouseup.left="searchEvent(item.text)" @mouseup.left="searchEvent(item.text)"
...@@ -41,6 +41,7 @@ export default { ...@@ -41,6 +41,7 @@ export default {
return { return {
searchContent: "", searchContent: "",
searchResult: [], searchResult: [],
searchResultForLis: [],
selectedIndex: 0, selectedIndex: 0,
resultDisplay: false, resultDisplay: false,
// 鼠标选择结果集的状态 // 鼠标选择结果集的状态
...@@ -53,6 +54,7 @@ export default { ...@@ -53,6 +54,7 @@ export default {
// console.log(val, oldVal); // console.log(val, oldVal);
if (val.trim() === "") { if (val.trim() === "") {
this.searchResult = []; this.searchResult = [];
this.searchResultForLis = [];
this.resultDisplay = false; this.resultDisplay = false;
return; return;
} }
...@@ -87,21 +89,23 @@ export default { ...@@ -87,21 +89,23 @@ export default {
console.log("query data ..." + new Date().toLocaleString()); console.log("query data ..." + new Date().toLocaleString());
// this.shuffle(testData); // this.shuffle(testData);
// const res = testData; // const res = testData;
const res = testData const res = testData.filter(
.filter((d) => d.text.indexOf(this.searchContent) > -1) (d) => d.text.indexOf(this.searchContent) > -1
.map((d) => );
Object.assign(d, { if (res && res.length > 0) {
text: d.text.replace( this.searchResultForLis = res.map((d) => {
const o = Object.assign({}, d);
o.text = d.text.replace(
this.searchContent, this.searchContent,
"<em>" + this.searchContent + "</em>" "<em>" + this.searchContent + "</em>"
),
})
); );
if (res && res.length > 0) { return o;
this.resultDisplay = true; });
this.searchResult = res; this.searchResult = res;
this.resultDisplay = true;
} else { } else {
this.searchResult = []; this.searchResult = [];
this.searchResultForLis = [];
this.resultDisplay = false; this.resultDisplay = false;
} }
}, },
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="eibs-toolbar"> <div class="eibs-toolbar">
<el-popover <el-popover
placement="left-start" placement="left-start"
trigger="hover" trigger="click"
:offset="150" :offset="150"
popper-class="toolbars-popover" popper-class="toolbars-popover"
> >
...@@ -32,7 +32,33 @@ ...@@ -32,7 +32,33 @@
</template> </template>
<script> <script>
export default {}; export default {
data() {
return {};
},
mounted() {
const that = this;
const dom = this.$el;
const minTop = 60,
maxTop = document.body.clientHeight - dom.offsetHeight - 40;
dom.onmousedown = (e) => {
const disY = e.clientY - dom.offsetTop;
document.onmousemove = function(e) {
let top = e.clientY - disY;
if (top > maxTop) {
top = maxTop;
} else if (top < minTop) {
top = minTop;
}
dom.style.top = top + "px";
};
document.onmouseup = function(e) {
document.onmousemove = null;
document.onmouseup = null;
};
};
},
};
</script> </script>
<style> <style>
...@@ -46,7 +72,7 @@ export default {}; ...@@ -46,7 +72,7 @@ export default {};
right: 0; right: 0;
} }
.toolbars-popover { .toolbars-popover {
padding: 0!important; padding: 0 !important;
} }
.toolbar-core { .toolbar-core {
background: var(--themecolor); background: var(--themecolor);
......
...@@ -56,7 +56,7 @@ export default { ...@@ -56,7 +56,7 @@ export default {
"盛世饮料", "盛世饮料",
"中国华润总公司", "中国华润总公司",
"东风汽车公司", "东风汽车公司",
"恒大集团", "万科",
"万康食品", "万康食品",
], ],
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment