useCrudSchemas-68789bb8.js 3.2 KB

1
  1. import{h as I,e as A,e5 as v,b8 as C,aP as H,__tla as M}from"./index-2eab2d23.js";import{e as S,t as g,f as x}from"./tree-fd3a041e.js";import{d as D,a as N,g as j,__tla as k}from"./dict-1ad71b6f.js";import{_ as q,__tla as z}from"./DictTag.vue_vue_type_script_lang-cb1e47ff.js";let E,B=Promise.all([(()=>{try{return M}catch{}})(),(()=>{try{return k}catch{}})(),(()=>{try{return z}catch{}})()]).then(async()=>{let y,T,w,F,P,_;({t:y}=I()),E=l=>{const o=A({searchSchema:[],tableColumns:[],formSchema:[],detailSchema:[]}),a=T(l,o);o.searchSchema=a||[];const s=w(l);o.tableColumns=s||[];const t=F(l,o);o.formSchema=t;const r=P(l);return o.detailSchema=r,{allSchemas:o}},T=(l,o)=>{const a=[],s=[];S(l,t=>{var r,m,e,p;if(t!=null&&t.isSearch||(r=t.search)!=null&&r.show){let u=((m=t==null?void 0:t.search)==null?void 0:m.component)||"Input";const h=[];let f={};if(t.dictType){const i={label:"\u5168\u90E8",value:""};h.push(i),D(t.dictType).forEach(c=>{h.push(c)}),f={options:h},(e=t.search)!=null&&e.component||(u="Select")}const d=v({component:u,...t.search,field:t.field,label:((p=t.search)==null?void 0:p.label)||t.label},{componentProps:f});d.api&&s.push(async()=>{var c;const i=await d.api();if(i){const n=C(o.searchSchema,b=>b.field===d.field);n!==-1&&(o.searchSchema[n].componentProps.options=_(i,(c=d.componentProps.optionsAlias)==null?void 0:c.labelField))}}),delete d.show,a.push(d)}});for(const t of s)t();return a},w=l=>{const o=g(l,{conversion:a=>{var s;if((a==null?void 0:a.isTable)!==!1&&((s=a==null?void 0:a.table)==null?void 0:s.show)!==!1)return!a.formatter&&a.dictType&&(a.formatter=(t,r,m)=>H(q,{type:a.dictType,value:m})),{...a.table,...a}}});return x(o,a=>(a.children===void 0&&delete a.children,!!a.field))},F=(l,o)=>{const a=[],s=[];S(l,t=>{var r,m,e,p,u;if((t==null?void 0:t.isForm)!==!1&&((r=t==null?void 0:t.form)==null?void 0:r.show)!==!1){let h=((m=t==null?void 0:t.form)==null?void 0:m.component)||"Input",f="";(e=t.form)!=null&&e.value?f=(p=t.form)==null?void 0:p.value:h==="InputNumber"&&(f=0);let d={};if(t.dictType){const c=[];t.dictClass&&t.dictClass==="number"?N(t.dictType).forEach(n=>{c.push(n)}):t.dictClass&&t.dictClass==="boolean"?j(t.dictType).forEach(n=>{c.push(n)}):D(t.dictType).forEach(n=>{c.push(n)}),d={options:c},t.form&&t.form.component||(h="Select")}const i=v({component:h,value:f,...t.form,field:t.field,label:((u=t.form)==null?void 0:u.label)||t.label},{componentProps:d});i.api&&s.push(async()=>{var n;const c=await i.api();if(c){const b=C(o.formSchema,Y=>Y.field===i.field);b!==-1&&(o.formSchema[b].componentProps.options=_(c,(n=i.componentProps.optionsAlias)==null?void 0:n.labelField))}}),delete i.show,a.push(i)}});for(const t of s)t();return a},P=l=>{const o=[];return S(l,a=>{var s,t,r,m,e;if((a==null?void 0:a.isDetail)!==!1&&((s=a.detail)==null?void 0:s.show)!==!1){const p={...a.detail,field:a.field,label:((t=a.detail)==null?void 0:t.label)||a.label};a.dictType&&(p.dictType=a.dictType),((r=a.detail)!=null&&r.dateFormat||a.formatter=="formatDate")&&(p.dateFormat=(m=a==null?void 0:a.detail)!=null&&m.dateFormat?(e=a==null?void 0:a.detail)==null?void 0:e.dateFormat:"YYYY-MM-DD HH:mm:ss"),delete p.show,o.push(p)}}),o},_=(l,o)=>l==null?void 0:l.map(a=>(o?a.labelField=y(a.labelField):a.label=y(a.label),a))});export{B as __tla,E as u};