首页 分享 el

el

来源:花匠小妙招 时间:2024-11-03 05:41

在当前操作的表格组件标签上写入代码(这里使用的是element ui组件)
:row-class-name="tableRowClassName" @cell-mouse-enter="enterSelectionRows" @cell-mouse-leave="leaveSelectionRows"

这里使用row-class-name属性是参考了element ui组件库中el-table的带状态表格,来实现高亮色凸显表格数据异常信息行。

然后使用cell-mouse-enter和cell-mouse-leave属性来实现tooltips展示数据异常的标注信息

tableRowClassName({ row, rowIndex }) {

if (row.rowSign == "fail") {

return "warning-row";

} else {

return "";

}

},

enterSelectionRows(row, column, cell, event) {

if (!row.hasAuth) {

if (row.rowSign == "fail") {

this.createTips(event, row, "数据异常");

}

return;

}

},

leaveSelectionRows(row) {

if (row.rowSign == "fail") {

this.removeTips(row);

}

},

createTips(el, row, value) {

const { id } = row;

const tooltipDom = document.createElement("div");

tooltipDom.style.cssText = `

display: inline-block;

width: 68px;

height: 30px;

position: fixed;

top: ${el.clientY}px;

left: ${el.clientX}px;

padding:5px 10px;

overflow: auto;

font-size: 12px;

font-family: PingFangSC-Regular, PingFang SC;

font-weight: 400;

color: #fff;

background: black;

border-radius: 5px;

z-index: 19999;

box-shadow: 0 4px 12px 1px #ccc;

`;

tooltipDom.innerHTML = value;

tooltipDom.setAttribute("id", `tooltip-${id}`);

document.body.appendChild(tooltipDom);

},

removeTips(row) {

const { id } = row;

const tooltipDomLeave = document.querySelectorAll(`#tooltip-${id}`);

if (tooltipDomLeave.length) {

tooltipDomLeave.forEach((dom) => {

document.body.removeChild(dom);

});

}

},

closeTooltip() {

let scrollTop =

window.pageYOffset ||

document.documentElement.scrollTop ||

document.body.scrollTop;

if (scrollTop) {

let list = document.getElementsByClassName("el-tooltip__popper");

if (list.length > 0) {

list[list.length - 1].style.display = "none";

}

}

},

.el-table .warning-row {

background: rgb(252, 235, 235);

}

这样我们就实现了el-table高亮色凸显和tooltips展示表格数据异常信息。

但是在使用时出现bug

就是视图上超过三条异常信息tooltips就会错位,之后将定位的absolute改为fixed就好了。因为之前是根据视口定位,当鼠标滚轮滚动后就会导致定位不准确,错位。

相关知识

拟南芥光周期开花路径的建模与分析
西班牙人为什么会选择这七种花献给逝去的亲友?
观赏植物五种花期控制技术.pdf
园艺学院学术报告:园艺作物的耐盐和耐旱研究
鲜花酒店(Hotel Florido)预订价格,联系电话位置地址【携程酒店】
玫瑰精油:香薰疗法的魔法 el
粉红色的开花植物
冬花
家庭养花入门,电子书下载,txt,chm,pdf,epub,mobi下载
‎植物识别

网址: el https://www.huajiangbk.com/newsview338899.html

所属分类:花卉
上一篇: 探索MATLAB支持向量机分类:
下一篇: 火焰紫荆简介 火焰紫荆的形态特征

推荐分享