UNPKG

@jecloud/func

Version:

JECloud 功能库

1 lines 2.17 kB
var e=this&&this.__assign||function(){return e=Object.assign||function(e){for(var n,t=1,l=arguments.length;t<l;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},e.apply(this,arguments)};import{mergeProps as n,isVNode as t,createVNode as l}from"vue";import{Tree as r,Toolbar as c,Switch as o,Panel as u}from"@jecloud/ui";import{nextTick as a,watch as i}from"vue";function s(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!t(e)}export function useRenderer(t){var f=t.props,d=t.context,h=t.$tree,p=d.attrs,v=d.slots,b=h.multiple,g=h.$plugin,j=h.search,k=h.async,m=h.store,y=h.singleMode,S=h.searchSelect,M=u.useInjectPanel();i((function(){return y.value}),(function(){y.value&&a((function(){b.value=!1}))}));var C=function(){var e=[];f.enableSelectMode&&e.push(l(o,{checked:b.value,"onUpdate:checked":function(e){return b.value=e},disabled:y.value,"checked-children":"多选","un-checked-children":"多选"},null)),f.enableSearchMode&&e.push(l(o,{checked:y.value,"onUpdate:checked":function(e){return y.value=e},"checked-children":"检索","un-checked-children":"检索"},null));var n=[];return f.helpMessage&&n.push(l("div",{class:"je-func-help-message"},[l("div",{class:"content"},[f.helpMessage])])),e.length&&n.push(l(c,{class:"je-tree-bbar",justify:"center"},s(e)?e:{default:function(){return[e]}})),n},O=function(){return f.title?l(c,{class:"je-tree-tbar",space:4},{default:function(){return[l("span",null,[f.title]),l(c.Fill,null,null),l(c.Tool,{icon:"fal fa-chevron-left",title:"收起",onClick:function(){var e;null===(e=M.getPanelItem("left"))||void 0===e||e.setExpand(!1)}},null),l(c.Tool,{icon:"fal fa-chevron-up",title:"收起",onClick:function(){h.setAllTreeExpand(!1)}},null),l(c.Tool,{icon:"fal fa-sync",title:"刷新",onClick:function(){h.reload()}},null)]}}):null};return{treeSlot:function(){return l(r,n({class:"je-tree-func"},p,{ref:g,search:function(e,n){j(e).then(n)},onSearchSelect:S,treeConfig:e(e({},f.treeConfig),{lazy:k.value,loadMethod:function(e){var n=e.row;return m.loadNode(n)}}),multiple:b.value,allowDeselect:!0,store:m}),e(e({},v),{bbar:C,tbar:O}))}}}