@jecloud/ui
Version:
JECloud UI库,基于ant-design-vue封装
1 lines • 1.48 kB
JavaScript
var e=this&&this.__assign||function(){return e=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},e.apply(this,arguments)};import{computed as t,onMounted as o,nextTick as r,watch as n}from"vue";import{pick as l,omit as i}from"@jecloud/utils";import{useRowDD as s}from"../../../grid/src/plugins/sortablejs";import{useTable as a}from"../../../grid/src/table";import{useSearch as u}from"../hooks/use-search";import{useAction as c}from"../hooks/use-action";export function useTree(p){var f=p.props,d=p.context,m=a({props:f,context:d,tree:!0}),h=m.$table,b=(m.$plugin,m.tableCompEvents),g=m.tableCompProps,v=m.tableCompSlots,C=d.slots,w=t((function(){var e=l(g.value,Object.keys(g.value));return f.multiple?(Object.assign(e.checkboxConfig,{labelField:"text"}),e.rowConfig.isCurrent=!1):(e.checkboxConfig=null,e.rowConfig.isCurrent=!0),e.showHeader=!1,e})),x=i(v,["default"]),j={action:c(h),nodeIcon:C.nodeIcon,default:C.nodeDefault},k=function(e){return{treeNode:!0,type:e?"checkbox":"",showOverflow:"title",width:"auto",field:"text",rowField:"id",slots:j}};n((function(){return f.multiple}),(function(e){h.clearSelectedRecords(),h.loadColumn([k(e)])}),{immediate:!0});var y=k(f.multiple);o((function(){r((function(){h.loadColumn([y])}))})),w.value.draggable&&s(e(e({},h),{delay:50}));var O=u(h).searchSlot;return e(e({},m),{treeProps:w,treeSlots:x,treeEvents:b,searchSlot:O})}