@jecloud/func
Version:
JECloud 功能库
1 lines • 2.32 kB
JavaScript
var e=this&&this.__assign||function(){return e=Object.assign||function(e){for(var l,o=1,n=arguments.length;o<n;o++)for(var t in l=arguments[o])Object.prototype.hasOwnProperty.call(l,t)&&(e[t]=l[t]);return e},e.apply(this,arguments)};import{mergeProps as l,createTextVNode as o,Fragment as n,createVNode as t}from"vue";import{ref as i}from"vue";import{Form as r,Modal as a}from"@jecloud/ui";import{FuncFieldTypeEnum as u}from"../../../data/enum";import{useInjectFunc as d}from"../../../func/src/context";import{useFuncFieldConfig as f}from"../../../func-config/hooks/use-func-config";import{useFormField as c}from"./use-func-field";export function useFuncFormItem(m){var s,p,v,b,h,g,y,F=m.props,x=m.context,j=x.slots,C=x.attrs,D=u.getComponent(null===(s=F.field)||void 0===s?void 0:s.xtype),$=d(),I=$.getFuncData().info.formOptions,k=f({$func:$}).labelDblclick,w=function(){var e=F.field,l=e.help,o=e.label;a.window({title:"【"+o+"】帮助提示",width:l.width,height:l.height,content:function(){return l.html?t("div",{innerHTML:l.message},null):l.message}})},E=i();F.field&&(null===(v=null===(p=F.form)||void 0===p?void 0:p.addFields4Ref)||void 0===v||v.call(p,F.field.name,E));var L={"data-code":null===(b=F.field)||void 0===b?void 0:b.name,"data-func":null===(h=F.form)||void 0===h?void 0:h.funcCode,"data-anchor":(null===(g=F.field)||void 0===g?void 0:g.anchor)||void 0};return[u.FIELDSET.type].includes(null===(y=F.field)||void 0===y?void 0:y.xtype)&&(L.style={padding:"10px"}),{itemSlot:function(){var i;if(D){var a=F.field,d=F.model,f=F.type,m=F.form,s=c({field:a,model:d,type:f,slots:j,$form:m,$func:$,$field:E,labelDblclick:k});if(a.isFormItem()){var p={};a.label&&!a.labelHidden&&(p.label=function(){return t(n,null,[a.help.enable?t("i",{class:"je-form-func-item-help jeicon jeicon-doubt-s",onClick:w},null):null,a.required?t("span",{class:"je-form-func-item-required"},[o("*")]):null,t("span",{style:{color:a.labelColor||I.labelColor},onDblclick:function(){k(a)}},[a.label])])});var v=[u.FUNC_CHILD_FIELD.type].includes(a.xtype);return t(r.Item,l({name:a.name,rules:a.getRules({model:d,$form:m,$func:$,$field:E}),colon:!1,htmlFor:"",labelText:a.label,labelAlign:a.labelAlign,hiddenErrors:v},C),e({default:function(){return[s]}},p))}return s}return null===(i=j.default)||void 0===i?void 0:i.call(j)},itemAttrs:L}}