UNPKG

@jecloud/func

Version:

JECloud 功能库

1 lines 1.6 kB
import{isPromise as e,toTemplate as n,execScript4Return as o,isNotEmpty as i}from"@jecloud/utils";import{doEvents4Sync as c}from"../event-action";import{useWatchActiveBean as t}from"../../hooks/use-func-active-bean";export function useFieldExps(e){var n=e.$func;(0,t({$func:n}).watchBean4Exps)()}export function useChildFuncExps(e){var n=e.$func,o=e.children;(0,t({$func:n}).watchBean4ChildrenExps)({children:o})}export function doFormFieldExps(e){var n,o,c=e.$func,t=c.getFuncData(),r=c.getFuncForm(),l=c.store;t.fields.exps.forEach((function(e){var n=t.basic.fields.get(e);Object.keys(n.exps).forEach((function(o){var i=n.exps[o];doFormFieldExp({$func:c,exp:i,model:l.activeBean}).then((function(n){switch(o){case"data":l.activeBean[e]=n;break;case"visible":null==r||r.setVisible(e,n);break;case"readOnly":null==r||r.setReadOnly(e,n);break;case"required":null==r||r.setRequired(e,n)}}))}))})),(null!==(n=null==r?void 0:r.getButtons())&&void 0!==n?n:[]).forEach((function(e){i(e.visibleExp)&&doFormFieldExp({$func:c,exp:{exp:e.visibleExp},model:l.activeBean}).then((function(n){e.hidden=!n}))}));var u=null!==(o=null==r?void 0:r.getChilds())&&void 0!==o?o:{},d=function(e){var n=u[e];i(n.visibleExp)&&doFormFieldExp({$func:c,exp:{exp:n.visibleExp},model:l.activeBean}).then((function(e){n.hidden=!e}))};for(var a in u)d(a)}export function doFormFieldExp(n){var o=doFormFieldExp4Sync({$func:n.$func,model:n.model,exp:n.exp});return e(o)?o:Promise.resolve(o)}export function doFormFieldExp4Sync(e){var i=e.$func,t=e.model,r=e.exp;return r.fn?c({$func:i,code:r.fn,eventOptions:{model:t}}):o(n(r.exp,t))}