UNPKG

tfp

Version:

A Web UI framework for TaskBuilder

79 lines (70 loc) 2.14 kB
import { FormInput } from "../controller.js"; /** * 滑块组件 * @param {[type]} dataModel [description] */ export default class Progress extends FormInput { constructor(__tfp, dataModel, parent, inputType) { if (inputType) { super(__tfp, inputType, dataModel, parent); } else { super(__tfp, "Progress", dataModel, parent); } } get value() { return this.dataModel.value || 0; } set value(value) { let val = value; if (isNull(value)) { val = 0; } this.dataModel.value = val; if (this._jqObj ) { this._jqObj.find('.tfp-progress-bar__inner').css('width', val + "%") this._jqObj.find('.tfp-progress__text').text(val+ "%"); } if (!this._tfp.isDesigning) { this.valueOnChange(); this.exeEventHandler("onChange", value); } } get dataType() { if (!this.dataModel.dataType) this.dataModel.dataType = "text"; return this.dataModel.dataType; } set dataType(value) { this.dataModel.dataType = value; if (this._jqObj ) { switch (value) { case 'success': this._jqObj.find('.tfp-progress-bar__inner') .css('background-color', '#67c23a') .css('width','100%') this._jqObj.find('.tfp-progress__text').text(100+ "%"); break; case 'warning': this._jqObj.find('.tfp-progress-bar__inner') .css('background-color', '#e6a23c') .css('width','50%') this._jqObj.find('.tfp-progress__text').text(50+ "%"); break; case 'exception': this._jqObj.find('.tfp-progress-bar__inner') .css('background-color', '#f56c6c') .css('width','50%') this._jqObj.find('.tfp-progress__text').text(50+ "%"); break; default: break; } } if (!this._tfp.isDesigning) { // this.valueOnChange(); this.exeEventHandler("onDatatypeChange", value); } } initRuntime() { // this._jqObj.mousedown(onMousedown.bind(this)); } }