UNPKG

vhb-table

Version:

一个基于 vue 的 PC 端表格组件,支持增删改查、虚拟列表、虚拟树、懒加载、快捷菜单、数据校验、树形结构、打印导出、表单渲染、数据分页、弹窗、自定义模板、渲染器、贼灵活的配置项、扩展接口等...

1 lines 2.78 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _utils=require("../../tools/utils"),_conf=_interopRequireDefault(require("../../v-h-b-table/src/conf")),_size=_interopRequireDefault(require("../../mixins/size")),_dom=require("../../tools/dom");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _defineProperty(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}var _default2={name:"VhbSwitch",mixins:[_size.default],props:{value:[String,Number,Boolean],disabled:Boolean,className:String,size:{type:String,default:function(){return _conf.default.switch.size||_conf.default.size}},openLabel:String,closeLabel:String,openValue:{type:[String,Number,Boolean],default:!0},closeValue:{type:[String,Number,Boolean],default:!1},openIcon:String,closeIcon:String},data:function(){return{isActivated:!1,hasAnimat:!1,offsetLeft:0}},computed:{isChecked:function(){return this.value===this.openValue},onShowLabel:function(){return(0,_utils.getFuncText)(this.openLabel)},offShowLabel:function(){return(0,_utils.getFuncText)(this.closeLabel)},styles:function(){return _dom.browse.msie&&this.isChecked?{left:"".concat(this.offsetLeft,"px")}:null}},created:function(){var e=this;_dom.browse.msie&&this.$nextTick(function(){return e.updateStyle()})},render:function(e){var t,i=this.isChecked,s=this.vSize,n=this.className,o=this.disabled,l=this.openIcon,a=this.closeIcon;return e("div",{class:["vhb-switch",n,i?"is--on":"is--off",(t={},_defineProperty(t,"size--".concat(s),s),_defineProperty(t,"is--disabled",o),_defineProperty(t,"is--animat",this.hasAnimat),t)]},[e("button",{ref:"btn",class:"vhb-switch--button",attrs:{type:"button",disabled:o},on:{click:this.clickEvent,focus:this.focusEvent,blur:this.blurEvent}},[e("span",{class:"vhb-switch--label vhb-switch--label-on"},[l?e("i",{class:["vhb-switch--label-icon",l]}):null,this.onShowLabel]),e("span",{class:"vhb-switch--label vhb-switch--label-off"},[a?e("i",{class:["vhb-switch--label-icon",a]}):null,this.offShowLabel]),e("span",{class:"vhb-switch--icon",style:this.styles})])])},methods:{updateStyle:function(){this.hasAnimat=!0,this.offsetLeft=this.$refs.btn.offsetWidth},clickEvent:function(e){var t=this;if(!this.disabled){clearTimeout(this.activeTimeout);var i=this.isChecked?this.closeValue:this.openValue;this.hasAnimat=!0,_dom.browse.msie&&this.updateStyle(),this.$emit("input",i),this.$emit("change",{value:i,$event:e}),this.activeTimeout=setTimeout(function(){t.hasAnimat=!1},400)}},focusEvent:function(e){this.isActivated=!0,this.$emit("focus",{value:this.value,$event:e})},blurEvent:function(e){this.isActivated=!1,this.$emit("blur",{value:this.value,$event:e})}}};exports.default=_default2;