@jecloud/func
Version:
JECloud 功能库
1 lines • 2.75 kB
JavaScript
var e=this&&this.__assign||function(){return e=Object.assign||function(e){for(var n,t=1,o=arguments.length;t<o;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{isVNode as n,mergeProps as t,createVNode as o}from"vue";import{defineComponent as r,resolveDynamicComponent as u,h as i,watch as a,computed as c}from"vue";import{useInjectFunc as l}from"../../func/src/context";import{Tabs as d,Hooks as f}from"@jecloud/ui";import{isEmpty as v}from"@jecloud/utils";import{useFuncChildren as s}from"../hooks/use-func-children";import{FuncChildrenLayoutEnum as p}from"../../data/enum";function m(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!n(e)}export default r({name:"JeFuncChildrenHorizontal",inheritAttrs:!1,props:{funcCode:String,layout:String,activeItem:String,height:Number,hiddenTabs:Boolean,form:Object,config:{type:Object,default:function(){}}},emits:["update:activeItem"],setup:function(n,r){var h,y,g=r.expose,b=r.attrs,O="je-func-children-horizontal",j=l(),x=f.useModelValue({props:n,context:r,key:"activeItem"}),I=s({props:n,context:r}),C=I.children,S=I.$child,T=I.funcComponent,k=I.computeHeight;x.value=null!==(h=x.value)&&void 0!==h?h:null===(y=C.value[0])||void 0===y?void 0:y.code;var N=c((function(){return n.hiddenTabs||p.FORM_OUTER_HORIZONTAL===n.layout&&C.value.length<=1})),R=c((function(){return!C.value.find((function(e){return!e.hidden}))}));Object.assign(S,{activeItem:x,setActiveItem:function(e){x.value=e}}),g(S),C.value.length&&(a((function(){return x.value}),(function(){C.value.find((function(e){return e.code===x.value})).rendered=!0}),{immediate:!0}),a((function(){return C.value}),(function(e){var n=e.find((function(e){return e.code===x.value&&!e.hidden}));n||(n=e.find((function(e){return!e.hidden})))&&(x.value=n.code)}),{deep:!0}));return function(){var r;return v(C.value)?null:o(d,t({activeKey:x.value,"onUpdate:activeKey":function(e){return x.value=e},class:O,style:{height:k(),display:R.value?"none":void 0},tabBarStyle:{display:N.value?"none":void 0}},b),m(r=C.value.map((function(t){return t.hidden?null:o(d.TabPane,{key:t.code},{tab:function(){return o("div",null,[o("i",{class:t.icon,style:"margin-right:5px"},null),t.title])},default:function(){return function(t){var o,r;return x.value===t.code||t.rendered?i(u(null!==(r=t.component)&&void 0!==r?r:T),e({funcCode:t.code,key:t.code,ref:S.getRefMaps(t.code),readOnly:t.readOnly,model:j.store.activeBean,class:(o={},o[O+"-single"]=1===C.value.length,o),style:{display:x.value===t.code?void 0:"none"},"data-code":t.code,"data-func":n.funcCode,"data-anchor":t.anchor||void 0},t.events)):null}(t)}})})))?r:{default:function(){return[r]}})}}});