一种百分比的动态显示方式(进度)
先看效果1. 引入资源文件jqc.js到全局或者使用页面
2. 活字格内部设置
a. 说明:
i. 为了能够实时监听到值的变化,我们使用活字格内置的“文本框“类型单元格来作为展示模板
ii. 在页面上拉出一个“文本框”,并且命名为"progress"
iii. 为“文本框”progress配置代码
代码:
const p = Forguncy.Page
const progessValue = parseFloat(p.getCell('progress').getValue())
const width = $("").css("width").split("px")
const height = $("").css("height").split("px")
$(":last").css("text-align", "right")
if ($("")) {
$(":last").html((progessValue * 100) + "%")
//$(":last").css(initial)
$(":last").animate({
"width": (progessValue * width) + "px",
"backgroundColor": getColor(progessValue),
"border-radius": (height / 2) + "px",
"color": "white",
"line-height": height + "px",
"padding-right": "4px"
}, 800)
} else {
$("").after($("").clone())
$(":last").empty()
$(":last").html((progessValue * 100) + "%")
$(":last").css("width", "0px")
//$(":last").css(initial)
$(":last").animate({
"width": (progessValue * width) + "px",
"backgroundColor": getColor(progessValue),
"border-radius": (height / 2) + "px",
"color": "white",
"line-height": height + "px",
"padding-right": "4px"
}, 400)
}
function getColor(value) {
let color = null
if (value <= 0.25) {
color = '#f63a0f'
} else {
if (value <= 0.5) {
color = "#f2b01e"
} else {
if (value <= 0.75) {
color = "#f2d31b"
} else {
color = "#86e01e"
}
}
}
return color
} iv. 为“文本框”progress赋值(为了动态展示,我们使用绑定字段的方式为其赋值)
谢谢老板分享~ 本帖最后由 夏雪冬阳 于 2019-11-20 17:54 编辑
举个例子,用在什么场景下,类似于那种加载进度条吗 蟹老板威武:lol:lol:lol
让我们继续活在你的影子里 老蟹威武:lol :hjyzw:谢总威武 厅长V587:D 必须的~ Simon.hu 发表于 2019-11-21 19:15
必须的~
谢总威武 :hjyzw:
页:
[1]