UNPKG

element-ui-el-table-draggable

Version:
2 lines (1 loc) 2.07 kB
import e from"sortablejs";var t=function(e,t,n,i,r,a,o,l,d,s){"boolean"!=typeof o&&(d=l,l=o,o=!1);var c,p="function"==typeof n?n.options:n;if(e&&e.render&&(p.render=e.render,p.staticRenderFns=e.staticRenderFns,p._compiled=!0,r&&(p.functional=!0)),i&&(p._scopeId=i),a?(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(a)},p._ssrRegister=c):t&&(c=o?function(){t.call(this,s(this.$root.$options.shadowRoot))}:function(e){t.call(this,l(e))}),c)if(p.functional){var f=p.render;p.render=function(e,t){return c.call(t),f(e,t)}}else{var u=p.beforeCreate;p.beforeCreate=u?[].concat(u,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 t=this,n=this.$children[0].$el.querySelector(".el-table__body-wrapper tbody");e.create(n,{handle:this.handle,animation:this.animate,onStart:function(){t.$emit("drag")},onEnd:function(e){var n=e.newIndex,i=e.oldIndex;t.keepWrapperHeight(!0),t.tableKey=Math.random();var r=t.$children[0].data,a=r.splice(i,1)[0];r.splice(n,0,a),t.$emit("drop",{targetObject:a,list:r})}})},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 n(e){n.installed||(n.installed=!0,e.component("ElementUiElTableDraggable",t))}var i={install:n},r=null;"undefined"!=typeof window?r=window.Vue:"undefined"!=typeof global&&(r=global.Vue),r&&r.use(i),t.install=n;export default t;