var _=(c,b,n)=>new Promise((g,u)=>{var d=a=>{try{m(n.next(a))}catch(v){u(v)}},s=a=>{try{m(n.throw(a))}catch(v){u(v)}},m=a=>a.done?g(a.value):Promise.resolve(a.value).then(d,s);m((n=n.apply(c,b)).next())});import{B as I}from"./BasicForm.948b0243.js";import{B as x,a as G}from"./index.4b403226.js";import{aH as j,r as l,a as q,aJ as C,o as H,aK as J,p as K,i as W,j as z,b6 as L,x as Q}from"./index.bde7963b.js";import{u as M,t as X}from"./tree.36c6ae32.js";import{a as E,b as O}from"./common.201fe4f0.js";import"./index.0103b3aa.js";import"./index.3289c967.js";import"./_baseIteratee.34b68bfe.js";import"./index.9b1e5ec7.js";import"./index.dcd3d2b7.js";import"./index.18602d99.js";import"./index.bfd670f8.js";import"./index.13318916.js";import"./index.ce7c5e55.js";import"./index.b75cc0a1.js";import"./uniqBy.3333e3da.js";import"./download.dc299cb5.js";import"./useWindowSizeFn.ada338ad.js";const A=l(null),T=l(""),k=l(""),D=l(""),P=l(""),Y=q({components:{BasicForm:I,BasicModal:x},emits:["reload","register"],setup(c,{emit:b}){const n=l("\u6DFB\u52A0\u8BB0\u5F55"),g=l(""),u=l(""),d=l(""),s=l("insert"),m=[],[a,{closeModal:v}]=G(e=>_(this,null,function*(){u.value=e.column,d.value=e.value,g.value=e.table,T.value=e.selectUrl,k.value=e.insertUrl,D.value=e.updateUrl,P.value=e.schemaUrl,u.value?(s.value="edit",n.value="\u7F16\u8F91\u8BB0\u5F55"):(s.value="insert",n.value="\u63D2\u5165\u8BB0\u5F55");const o=yield E(P.value),r=o.forms,B=o.columns,p={};for(let t of B)p[t.field]=t;const f=A.value;if(!f)return;yield f.resetSchema([]);const i={};i[u.value]=d.value;const w=s.value=="edit"?yield E(T.value,i):{},F=s.value=="edit"&&w.items.length?w.items[0]:{};for(let t of r){if(!t.form_show)continue;let[h,U,y]=R(t,F[t.field]);t.field=="password"&&(y="",s.value=="edit"&&(U={placeholder:"\u4E0D\u66F4\u65B0\u5BC6\u7801\u8BF7\u7559\u7A7A"})),f.appendSchemaByField({field:t.field,component:h,label:t.comment||t.field,colProps:{span:24},required:s.value=="edit"&&t.field=="password"?!1:!p[t.field].nullable,componentProps:U,defaultValue:y},"")}})),{createMessage:$}=Q(),{success:N}=$;function R(e,o){o=S(o);let r={disabled:s.value=="edit"?!1:e.readonly};if(e.control=="Switch"&&(o=!!o),e.control=="DatePicker"&&(r.showTime=!0),(e.control=="ApiTreeSelect"||e.control=="ApiTree")&&(r.resultField="list",o&&r.multiple&&typeof o!="number"&&(o=o.split(","))),e.control_args)for(let B of e.control_args.split(";")){let p=B.indexOf(":");if(p==-1)continue;let f=B.substring(0,p).trim(),i=B.substring(p+1).trim();if(e.control=="Upload"&&f==="url"){r.api=M(i);continue}if((e.control=="ApiTreeSelect"||e.control=="ApiTree")&&f==="url"){r.api=X(i);continue}if(p=i.indexOf(":"),p!==-1){let w=i.split(",");i=[];for(let F of w){let[t,h]=F.split(":");i.push({value:t,label:h})}}r[f]=S(i)}return e.control=="Upload"&&(o?(o=o.split(","),r.value=o):r.value=[],r.api||(r.api=M())),[e.control,r,o]}function S(e){return e==="true"?!0:e==="false"?!1:String(Number(e))===e?Number(e):e}return{formElRef:A,handleSubmit:()=>_(this,null,function*(){try{const e=A.value;if(!e)return;const o=yield e.validate();s.value=="edit"?yield O(D.value,{column:u.value,value:d.value,data:o}):yield O(k.value,{data:o}),v(),N("\u64CD\u4F5C\u6210\u529F"),b("reload")}catch(e){console.log(e)}}),schemas:m,register:a,title:n}}}),Z={class:"mt-3"};function V(c,b,n,g,u,d){const s=C("BasicForm"),m=C("BasicModal");return H(),J(m,L(c.$attrs,{destroyOnClose:"",onRegister:c.register,title:c.title,onOk:c.handleSubmit}),{default:K(()=>[W("div",Z,[z(s,{schemas:c.schemas,ref:"formElRef",labelWidth:75,showActionButtonGroup:!1},null,8,["schemas"])])]),_:1},16,["onRegister","title","onOk"])}var Fe=j(Y,[["render",V]]);export{Fe as default};
