@jecloud/func
Version:
JECloud 功能库
1 lines • 3.34 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{withDirectives as t,mergeProps as o,resolveDirective as r,isVNode as n,createVNode as l}from"vue";import{defineComponent as i,nextTick as u,onMounted as a,ref as f,watch as c}from"vue";import{Form as s,Fieldset as d,Panel as p,Loading as m}from"@jecloud/ui";import{pick as y,omit as v}from"@jecloud/utils";import h from"./form-item";import{useFormToolbar as g}from"./hooks/use-form-toolbar";import{useForm as w}from"./hooks/use-form";import b from"../../func-children";import{FuncFieldTypeEnum as j}from"../../data/enum";import S from"./form-anchor";import{useWorkflowHistory as C}from"../../func-workflow/use-workflow-history";function O(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!n(e)}export default i({name:"JeFuncForm",inheritAttrs:!1,props:{fields:{type:Array,default:function(){return[]}},cols:{type:Number,default:3},labelCol:{type:Object,default:function(){return{style:{width:"140px"}}}},wrapperCol:{type:Object,default:function(){return{span:24}}},loading:Boolean,type:{type:String,default:"func",validator:function(e){return["func","query","custom"].includes(e)}},funcCode:String,model:Object,readOnly:Boolean},emits:["model-change"],setup:function(n,i){var x=i.attrs,F=i.slots,k=i.emit,D=f(),E=w({props:n,context:i}),$=E.$form,I=E.$func,N=E.fields,P=E.cols,B=E.$plugin,_=E.formProps,A=E.anchorOptions,H=g({$form:$}).tbarSlot,L=f(),M=C(I).workflowHistorySlot,V=function(e,t){void 0===e&&(e=[]);var o,r=[];return(null==t?void 0:t.xtype)===j.FIELDSET.type&&t.otherConfig.titleWidth&&(o={style:{width:t.otherConfig.titleWidth+"px"}}),e.forEach((function(e){var t;if(e.xtype===j.FUNC_CHILD.type)r.push(l(b,{funcCode:n.funcCode,field:e,colSpan:P.value},null));else{var i=(null===(t=e.children)||void 0===t?void 0:t.length)?V(e.children,e):[];r.push(l(h,{field:e,model:n.model,labelCol:o,colSpan:e.colSpan,hidden:e.hidden,form:$},O(i)?i:{default:function(){return[i]}}))}})),r},W=f(!0);return a((function(){u((function(){W.value=!1,!n.readOnly&&I.getFuncData().getFormEditPerm()||$.setReadOnly(!0),I&&I.store.activeBeanEmitter++}))})),c((function(){return n.model}),(function(e,t){k("model-change",{newModel:e,oldModel:t})}),{deep:!0}),function(){var i;return W.value?l(m,{loading:W.value},null):l(p,o({class:{"je-form-func":!0,"is--loading":n.loading},ref:D},y(x,["style","class"])),e({default:function(){return[l(p.Item,{region:"tbar",class:"je-form-func-tbar-wrapper"},O(i=H())?i:{default:function(){return[i]}}),l(p.Item,{class:"je-form-func-body-wrapper"},{default:function(){return[l("div",{class:"je-form-func-wrapper",style:_.mainStyle},[t(l(s,o({ref:B},v(x,["style","class"]),y(n,["labelCol","wrapperCol","model"]),v(_,["wrapperStyle","mainStyle"])),{default:function(){return[l(d,{ref:L,simple:!0,cols:P.value,class:"je-form-wrapper",style:_.wrapperStyle},{default:function(){var e,t;return[null!==(t=null===(e=F.default)||void 0===e?void 0:e.call(F))&&void 0!==t?t:V(N.value),M({colSpan:P.value})]}})]}}),[[r("loading"),n.loading]])]),A.length?l(S,{target:function(){return L.value.$el},options:A},null):null]}})]}},y(F,p.Config.slots)))}}});