vxe-table
Version:
一个基于 vue 的 PC 端表格组件,支持增删改查、虚拟滚动、懒加载、快捷菜单、数据校验、树形结构、打印导出、表单渲染、数据分页、虚拟列表、模态窗口、自定义模板、渲染器、贼灵活的配置项、扩展接口等...
1 lines • 4.42 kB
JavaScript
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _conf=_interopRequireDefault(require("../../v-x-e-table/src/conf")),_size=_interopRequireDefault(require("../../mixins/size")),_tools=require("../../tools");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:"VxePulldown",mixins:[_size.default],props:{disabled:Boolean,placement:String,size:{type:String,default:function(){return _conf.default.size}},destroyOnClose:Boolean,transfer:Boolean},data:function(){return{inited:!1,panelIndex:0,panelStyle:null,panelPlacement:null,currentValue:null,visiblePanel:!1,animatVisible:!1,isActivated:!1}},created:function(){_tools.GlobalEvent.on(this,"mousewheel",this.handleGlobalMousewheelEvent),_tools.GlobalEvent.on(this,"mousedown",this.handleGlobalMousedownEvent),_tools.GlobalEvent.on(this,"blur",this.handleGlobalBlurEvent)},beforeDestroy:function(){var e=this.$refs.panel;e&&e.parentNode&&e.parentNode.removeChild(e)},destroyed:function(){_tools.GlobalEvent.off(this,"mousewheel"),_tools.GlobalEvent.off(this,"mousedown"),_tools.GlobalEvent.off(this,"blur")},render:function(e){var t=this.$scopedSlots,i=this.inited,n=this.vSize,l=this.destroyOnClose,o=this.transfer,s=this.isActivated,a=this.disabled,r=this.animatVisible,d=this.visiblePanel,u=this.panelStyle,h=this.panelPlacement,f=t.default,c=t.dropdown;return e("div",{class:["vxe-pulldown",(_defineProperty(t={},"size--".concat(n),n),_defineProperty(t,"is--visivle",d),_defineProperty(t,"is--disabled",a),_defineProperty(t,"is--active",s),t)]},[e("div",{ref:"content",class:"vxe-pulldown--content"},f?f.call(this,{$pulldown:this},e):[]),e("div",{ref:"panel",class:["vxe-table--ignore-clear vxe-pulldown--panel",(_defineProperty(f={},"size--".concat(n),n),_defineProperty(f,"is--transfer",o),_defineProperty(f,"animat--leave",r),_defineProperty(f,"animat--enter",d),f)],attrs:{placement:h},style:u},!c||!i||l&&!d&&!r?[]:c.call(this,{$pulldown:this},e))])},methods:{handleGlobalMousewheelEvent:function(e){var t=this.$refs,i=this.disabled,n=this.visiblePanel;i||n&&(_tools.DomTools.getEventTargetNode(e,t.panel).flag?this.updatePlacement():(this.hidePanel(),this.$emit("hide-panel",{$event:e})))},handleGlobalMousedownEvent:function(e){var t=this.$refs,i=this.$el,n=this.disabled,l=this.visiblePanel;n||(this.isActivated=_tools.DomTools.getEventTargetNode(e,i).flag||_tools.DomTools.getEventTargetNode(e,t.panel).flag,l&&!this.isActivated&&(this.hidePanel(),this.$emit("hide-panel",{$event:e})))},handleGlobalBlurEvent:function(e){this.visiblePanel&&(this.hidePanel(),this.$emit("hide-panel",{$event:e}))},updateZindex:function(){this.panelIndex<_tools.UtilTools.getLastZIndex()&&(this.panelIndex=_tools.UtilTools.nextZIndex())},isPanelVisible:function(){return this.visiblePanel},togglePanel:function(){return this.visiblePanel?this.hidePanel():this.showPanel()},showPanel:function(){var t=this;return this.inited||(this.inited=!0,this.transfer&&document.body.appendChild(this.$refs.panel)),new Promise(function(e){t.disabled?e(t.$nextTick()):(clearTimeout(t.hidePanelTimeout),t.isActivated=!0,t.animatVisible=!0,setTimeout(function(){t.visiblePanel=!0,t.updatePlacement(),setTimeout(function(){e(t.updatePlacement())},40)},10),t.updateZindex())})},hidePanel:function(){var t=this;return this.visiblePanel=!1,new Promise(function(e){t.animatVisible?t.hidePanelTimeout=setTimeout(function(){t.animatVisible=!1,e(t.$nextTick())},350):e(t.$nextTick())})},updatePlacement:function(){var f=this;return this.$nextTick().then(function(){var e,t,i,n,l,o,s,a,r=f.$refs,d=f.transfer,u=f.placement,h=f.panelIndex;return f.visiblePanel&&(a=r.panel,o=r.content,a&&o&&(e=o.offsetHeight,t=o.offsetWidth,i=a.offsetHeight,n=a.offsetWidth,l={zIndex:h},r=(s=_tools.DomTools.getAbsolutePos(o)).boundingTop,a=s.boundingLeft,h=s.visibleHeight,o=s.visibleWidth,s="bottom",d?(d=r+e,"top"===u?(s="top",d=r-i):u||(h<d+i+5&&(s="top",d=r-i),d<5&&(s="bottom",d=r+e)),o<(a=a)+n+5&&(a-=a+n+5-o),a<5&&(a=5),Object.assign(l,{left:"".concat(a,"px"),top:"".concat(d,"px"),minWidth:"".concat(t,"px")})):"top"===u?(s="top",l.bottom="".concat(e,"px")):u||h<r+e+i&&5<r-e-i&&(s="top",l.bottom="".concat(e,"px")),f.panelStyle=l,f.panelPlacement=s)),f.$nextTick()})}}};exports.default=_default2;