import{a as I,b as O,c as R}from"./card.7fa38337.js";import{r as w}from"./responseHandle.fe68d5aa.js";import{u as q}from"./useNav.5e73c372.js";import{a as H,r as u,W as M,b as d,a7 as P,Z as S,c as C,j as x,h as s,f as i,m as W,x as y,l as Y,u as Z,am as $}from"./index.4d061c66.js";const z={class:"flex justify-end"},X=H({__name:"edit-dialog",emits:["reload"],setup(G,{expose:F,emit:V}){const{logout:B}=q(),c=u(!1),n=u("create"),b=u(null),r=u(!1),m=u(""),h=u(""),p={title:"",id:""},t=u({...p}),E=M({title:[{required:!0,trigger:"bulr",message:"\u8BF7\u8F93\u5165\u5361\u7C7B\u578B"}]}),D=async()=>{const{code:l,data:e,message:o}=await I({id:h.value});w({code:l,message:o,logout:B,handler:()=>{Object.keys(t.value).forEach(a=>{t.value[a]=e[a]?e[a]+"":""})}})};async function k(l,e,o){switch(h.value=e,Object.keys(t.value).forEach(a=>{t.value[a]=p[a]?p[a]+"":""}),n.value=o,n.value){case"create":m.value="\u65B0\u5EFA\u5361\u7C7B\u578B";break;case"edit":m.value="\u7F16\u8F91\u5361\u7C7B\u578B";break;case"view":m.value="\u5361\u7C7B\u578B\u8BE6\u60C5";break;default:m.value="\u65B0\u5EFA\u5361\u7C7B\u578B"}n.value!=="create"&&await D(),c.value=!0}function N(){return{data:{...t.value},api:O}}function j(){return{data:{...t.value},api:R}}function U(){b.value.validate(async l=>{if(l){if(r.value)return;const e=n.value==="create"?j:N;r.value=!0;const{api:o,data:a}=e(),{message:f,code:_}=await o(a);r.value=!1,w({code:_,message:f,logout:B,handler:()=>{c.value=!1,V("reload")}})}})}return F({show:k}),(l,e)=>{const o=d("ElInput"),a=d("el-form-item"),f=d("el-col"),_=d("el-row"),g=d("el-button"),A=d("el-dialog"),T=P("loading");return S((C(),x(A,{modelValue:c.value,"onUpdate:modelValue":e[2]||(e[2]=v=>c.value=v),"close-on-press-escape":!1,center:"","append-to-body":"","destroy-on-close":"",width:"400px",title:m.value},{default:s(()=>[i(Z($),{ref_key:"formRef",ref:b,model:t.value,rules:E,"label-width":"70px",style:{"margin-top":"-10px"},class:"demo-ruleForm","status-icon":""},{default:s(()=>[i(_,null,{default:s(()=>[i(f,{span:24},{default:s(()=>[i(a,{label:"\u5361\u7C7B\u578B",prop:"title"},{default:s(()=>[i(o,{placeholder:"\u5361\u7C7B\u578B",disabled:n.value==="view",maxlength:"50",modelValue:t.value.title,"onUpdate:modelValue":e[0]||(e[0]=v=>t.value.title=v)},null,8,["disabled","modelValue"])]),_:1})]),_:1})]),_:1}),W("div",z,[n.value!=="view"?(C(),x(g,{key:0,loading:r.value,disabled:r.value,type:"primary",onClick:U},{default:s(()=>[y("\u4FDD\u5B58")]),_:1},8,["loading","disabled"])):Y("",!0),i(g,{onClick:e[1]||(e[1]=v=>c.value=!1)},{default:s(()=>[y("\u53D6\u6D88")]),_:1})])]),_:1},8,["model","rules"])]),_:1},8,["modelValue","title"])),[[T,r.value]])}}});export{X as _};
