Commit 24b36f98 by zhengxiaokui
parents 0d397ab6 4e730c01
......@@ -21,7 +21,7 @@
<ul>
<li
:class="{ 'sug-selected': item.selected }"
v-for="(item, idx) in searchResult"
v-for="(item, idx) in searchResultForLis"
:key="idx"
@mouseover="liOverEvent(idx)"
@mouseup.left="searchEvent(item.text)"
......@@ -41,6 +41,7 @@ export default {
return {
searchContent: "",
searchResult: [],
searchResultForLis: [],
selectedIndex: 0,
resultDisplay: false,
// 鼠标选择结果集的状态
......@@ -53,6 +54,7 @@ export default {
// console.log(val, oldVal);
if (val.trim() === "") {
this.searchResult = [];
this.searchResultForLis = [];
this.resultDisplay = false;
return;
}
......@@ -87,21 +89,23 @@ export default {
console.log("query data ..." + new Date().toLocaleString());
// this.shuffle(testData);
// const res = testData;
const res = testData
.filter((d) => d.text.indexOf(this.searchContent) > -1)
.map((d) =>
Object.assign(d, {
text: d.text.replace(
this.searchContent,
"<em>" + this.searchContent + "</em>"
),
})
);
const res = testData.filter(
(d) => d.text.indexOf(this.searchContent) > -1
);
if (res && res.length > 0) {
this.resultDisplay = true;
this.searchResultForLis = res.map((d) => {
const o = Object.assign({}, d);
o.text = d.text.replace(
this.searchContent,
"<em>" + this.searchContent + "</em>"
);
return o;
});
this.searchResult = res;
this.resultDisplay = true;
} else {
this.searchResult = [];
this.searchResultForLis = [];
this.resultDisplay = false;
}
},
......
......@@ -2,7 +2,7 @@
<div class="eibs-toolbar">
<el-popover
placement="left-start"
trigger="hover"
trigger="click"
:offset="150"
popper-class="toolbars-popover"
>
......@@ -32,7 +32,33 @@
</template>
<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>
<style>
......@@ -46,7 +72,7 @@ export default {};
right: 0;
}
.toolbars-popover {
padding: 0!important;
padding: 0 !important;
}
.toolbar-core {
background: var(--themecolor);
......
......@@ -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