UNPKG

element-ui-el-table-draggable

Version:
1 lines 2.17 kB
var ElementUiElTableDraggable=function(e,t){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;var n=function(e,t,n,a,i,r,o,l,d,s){"boolean"!=typeof o&&(d=l,l=o,o=!1);var c,u="function"==typeof n?n.options:n;if(e&&e.render&&(u.render=e.render,u.staticRenderFns=e.staticRenderFns,u._compiled=!0,i&&(u.functional=!0)),a&&(u._scopeId=a),r?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,d(e)),e&&e._registeredComponents&&e._registeredComponents.add(r)},u._ssrRegister=c):t&&(c=o?function(){t.call(this,s(this.$root.$options.shadowRoot))}:function(e){t.call(this,l(e))}),c)if(u.functional){var f=u.render;u.render=function(e,t){return c.call(t),f(e,t)}}else{var p=u.beforeCreate;u.beforeCreate=p?[].concat(p,c):[c]}return n}({render:function(){var e=this.$createElement,t=this._self._c||e;return t("div",{ref:"wrapper"},[t("div",{key:this.tableKey},[this._t("default")],2)])},staticRenderFns:[]},void 0,{name:"ElementUiElTableDraggable",props:{handle:{type:String,default:""},animate:{type:Number,default:100}},data:function(){return{tableKey:0}},methods:{makeTableSortAble:function(){var e=this,n=this.$children[0].$el.querySelector(".el-table__body-wrapper tbody");t.create(n,{handle:this.handle,animation:this.animate,onStart:function(){e.$emit("drag")},onEnd:function(t){var n=t.newIndex,a=t.oldIndex;e.keepWrapperHeight(!0),e.tableKey=Math.random();var i=e.$children[0].data,r=i.splice(a,1)[0];i.splice(n,0,r),e.$emit("drop",{targetObject:r,list:i})}})},keepWrapperHeight:function(e){var t=this.$refs.wrapper;t.style.minHeight=e?t.clientHeight+"px":"auto"}},mounted:function(){this.makeTableSortAble()},watch:{tableKey:function(){var e=this;this.$nextTick(function(){e.makeTableSortAble(),e.keepWrapperHeight(!1)})}}},void 0,!1,void 0,void 0,void 0);function a(e){a.installed||(a.installed=!0,e.component("ElementUiElTableDraggable",n))}var i={install:a},r=null;return"undefined"!=typeof window?r=window.Vue:"undefined"!=typeof global&&(r=global.Vue),r&&r.use(i),n.install=a,e.default=n,e}({},sortable);