import{M as J,K as R,a9 as L,a5 as A,r as D,F as E,cD as I}from"./index.17037962789732.js";import"./index.1703796278973318.js";import"./index.170379627897318.js";import"./index.170379627897319.js";import"./index.170379627897316.js";import"./index.170379627897317.js";import"./index.170379627897315.js";import{a0 as M,a1 as U}from"./instance.1703796278973.js";import{u as V}from"./instance.17037962789732.js";import{d as T,k as v,v as q,w as z,p as K,r as P,o as i,c as y,a as o,z as k,b as _,t as h,u,x as S,F as j,h as w,A as $,a5 as G}from"./vue.1703796278973.js";const H={style:{display:"flex","justify-content":"space-between","align-items":"center"}},re=T({__name:"Save",emits:["close","save"],setup(Q,{emit:g}){const p=v(),s=q({}),b=v([]),m=V(),d=v([]);z(()=>{var e;const a=((e=m.current)==null?void 0:e.relations)||[];d.value=a,a.map(t=>{s[t.relation]=[...((t==null?void 0:t.related)||[]).map(n=>JSON.stringify(n))]})}),K(()=>{M().then(a=>{a.status===200&&(b.value=a.result.map(e=>({...e,label:e.name,value:JSON.stringify({id:e.id,name:e.name})})))})});const N=()=>{g("close"),p.value.resetFields()},x=()=>{p.value.validate().then(async()=>{const a=G(s);if(Object.keys(a).length>0){const e=[];Object.keys(a).forEach(t=>{const n=d.value.find(r=>r.relation===t),f=(a[t]||[]).map(r=>JSON.parse(r));n&&e.push({relatedType:"user",relation:n.relation,description:"",related:[...f]})}),e.length&&m.current.id&&(await U(m.current.id,e)).status===200&&(J.success("操作成功！"),g("save"),p.value.resetFields())}})};return(a,e)=>{const t=P("AIcon"),n=R,f=L,r=A,C=D,O=E,B=I;return i(),y(B,{placement:"right",closable:!1,visible:!0},{title:o(()=>[k("div",H,[k("span",null,[_(t,{type:"CloseOutlined",style:{"margin-right":"5px"},onClick:N}),h("编辑")]),_(n,{type:"primary",onClick:x},{default:o(()=>[h("保存")]),_:1})])]),default:o(()=>[_(O,{layout:"vertical",ref_key:"formRef",ref:p,model:u(s)},{default:o(()=>[(i(!0),S(j,null,w(u(d),(l,F)=>(i(),y(C,{name:l.relation,label:l.relationName,key:F},{default:o(()=>[_(r,{showSearch:"",mode:"multiple",value:u(s)[l.relation],"onUpdate:value":c=>u(s)[l.relation]=c,placeholder:`请选择${l.relationName}`},{default:o(()=>[(i(!0),S(j,null,w(u(b),c=>(i(),y(f,{value:c.value,key:c.id},{default:o(()=>[h($(c.name),1)]),_:2},1032,["value"]))),128))]),_:2},1032,["value","onUpdate:value","placeholder"])]),_:2},1032,["name","label"]))),128))]),_:1},8,["model"])]),_:1})}}});export{re as _};
