fix: 修复dropdown内滚动条可以无限向下滚动bug

This commit is contained in:
陈劲松
2020-04-25 11:51:11 +08:00
parent 90c9efd047
commit fa7741ec47
2 changed files with 38 additions and 4 deletions

View File

@@ -135,8 +135,8 @@
<div class="mib-browser-left">
<div class="mib-browser-tree-title">
<span>SNMP MIBs</span>
<el-dropdown trigger="click" v-scrollBar:el-dropdown="'small'" :hide-on-click="false" @command="selectModel">
<span class="mib-browser-table-op">{{$t("config.model.model") + " "}}<i class="nz-icon nz-icon-funnel"></i></span>
<el-dropdown trigger="click" v-scrollBar:el-dropdown="'small'" :hide-on-click="false" @command="selectModel" ref="modelDropdown">
<span class="mib-browser-table-op" @click="scrollbarHeightHandler">{{$t("config.model.model") + " "}}<i class="nz-icon nz-icon-funnel"></i></span>
<el-dropdown-menu slot="dropdown" class="mib-browser-model-dropdown">
<el-dropdown-item :class="{'mib-browser-model-dropdown-item-active': walkParam.models.indexOf(item.id) > -1}" :command="item" v-for="item, index in modelData" :key="index">{{item.name}}</el-dropdown-item>
</el-dropdown-menu>
@@ -326,6 +326,19 @@
}
},
methods: {
scrollbarHeightHandler() {
setTimeout(() => {
let top = '';
document.querySelector("body>.el-dropdown-menu").addEventListener("ps-y-reach-end", () => {
let yDom = document.querySelector("body>.el-dropdown-menu>.ps__rail-y");
if (top) {
yDom.style.top = top;
} else {
top = yDom.style.top;
}
});
}, 100);
},
toFileTab() {
this.$emit("toFileTab");
},
@@ -571,6 +584,7 @@
this.getWalkData();
this.getModelData();
this.getAssetData();
}
}
</script>

View File

@@ -13,7 +13,7 @@
<div class="top-tools">
<div class="top-tool-main-left">
<el-dropdown @command="panelChange" class="panel-dropdown-title" trigger="click" placement="bottom-start" v-scrollBar:el-dropdown>
<el-row :gutter="10" class="el-dropdown-link" style="">
<el-row @click.native="scrollbarHeightHandler" :gutter="10" class="el-dropdown-link" style="">
<el-col :span="21" class="panel-list-title" :title="showPanel.name">{{showPanel.name}}</el-col>
<el-col :span="3" style="padding-left:0px !important;"><i class="el-icon-arrow-down el-icon--right"></i></el-col>
</el-row>
@@ -356,7 +356,27 @@
this.$refs.addChartModal.show(true);
this.$refs.addChartModal.createData(this.showPanel.id); //初始化创建图表需要的初始数据
},
scrollbarHeightHandler() {
console.info(1)
setTimeout(() => {
let top = '';
let top2 = '';
document.querySelector("body>.el-dropdown-menu").addEventListener("ps-y-reach-end", () => {
let yDom = document.querySelector("body>.el-dropdown-menu>.ps__rail-y");
let yDom2 = document.querySelector("body>.el-dropdown-menu>.ps__rail-y>.ps__thumb-y");
if (top) {
yDom.style.top = top;
} else {
top = yDom.style.top;
}
if (top2) {
yDom2.style.top = top2;
} else {
top2 = yDom2.style.top;
}
});
}, 100);
},
// 编辑图表信息,打开编辑弹窗
editData(data) {
this.$refs.addChartModal.setTitle(this.$t("dashboard.panel.editChartTitle"));