import{a as I,b as O,c as R}from"./company.479d8ad0.js";import{r as B}from"./responseHandle.fe68d5aa.js";import{u as H}from"./useNav.5e73c372.js";import{a as M,r as d,W as P,b as c,a7 as S,Z as W,c as w,j as V,h as o,f as l,m as Y,x as h,l as Z,u as $,am as z,a_ as G}from"./index.4d061c66.js";const J={class:"flex justify-end"},ae=M({__name:"edit-dialog",emits:["reload"],setup(K,{expose:C,emit:A}){const{logout:_}=H(),p=d(!1),n=d("create"),b=d(null),i=d(!1),v=d(""),E=d(""),f={title:"",contacts:"",id:"",mobile:"",remark:""},x=(r,e,u)=>{e===""?u(new Error("\u8054\u7CFB\u65B9\u5F0F\u4E0D\u80FD\u4E3A\u7A7A\uFF01")):G(e)?u():u(new Error("\u8054\u7CFB\u65B9\u5F0F\u683C\u5F0F\u4E0D\u6B63\u786E\uFF01"))},a=d({...f}),D=P({title:[{required:!0,trigger:"bulr",message:"\u8BF7\u8F93\u5165\u4F01\u4E1A"}],contacts:[{required:!0,trigger:"bulr",message:"\u8BF7\u8F93\u5165\u8054\u7CFB\u4EBA"}],mobile:[{required:!0,validator:x,trigger:"blur"}]}),y=async()=>{const{code:r,data:e,message:u}=await I({id:E.value});B({code:r,message:u,logout:_,handler:()=>{Object.keys(a.value).forEach(t=>{a.value[t]=e[t]?e[t]+"":""})}})};async function k(r,e,u){switch(E.value=e,Object.keys(a.value).forEach(t=>{a.value[t]=f[t]?f[t]+"":""}),n.value=u,n.value){case"create":v.value="\u65B0\u5EFA\u4F01\u4E1A";break;case"edit":v.value="\u7F16\u8F91\u4F01\u4E1A";break;case"view":v.value="\u4F01\u4E1A\u8BE6\u60C5";break;default:v.value="\u65B0\u5EFA\u4F01\u4E1A"}n.value!=="create"&&await y(),p.value=!0}function U(){return{data:{...a.value},api:O}}function N(){return{data:{...a.value},api:R}}function j(){b.value.validate(async r=>{if(r){if(i.value)return;const e=n.value==="create"?N:U;i.value=!0;const{api:u,data:t}=e(),{message:m,code:F}=await u(t);i.value=!1,B({code:F,message:m,logout:_,handler:()=>{p.value=!1,A("reload")}})}})}return C({show:k}),(r,e)=>{const u=c("ElInput"),t=c("el-form-item"),m=c("el-col"),F=c("el-row"),g=c("el-button"),q=c("el-dialog"),T=S("loading");return W((w(),V(q,{modelValue:p.value,"onUpdate:modelValue":e[5]||(e[5]=s=>p.value=s),"close-on-press-escape":!1,center:"","append-to-body":"","destroy-on-close":"",width:"900px",title:v.value},{default:o(()=>[l($(z),{ref_key:"formRef",ref:b,model:a.value,rules:D,"label-width":"90px",style:{"margin-top":"-10px"},class:"demo-ruleForm","status-icon":""},{default:o(()=>[l(F,null,{default:o(()=>[l(m,{span:24},{default:o(()=>[l(t,{label:"\u4F01\u4E1A\u540D\u79F0",prop:"title"},{default:o(()=>[l(u,{placeholder:"\u4F01\u4E1A\u540D\u79F0",disabled:n.value==="view",maxlength:"50",modelValue:a.value.title,"onUpdate:modelValue":e[0]||(e[0]=s=>a.value.title=s)},null,8,["disabled","modelValue"])]),_:1})]),_:1}),l(m,{span:12},{default:o(()=>[l(t,{label:"\u8054\u7CFB\u4EBA",prop:"contacts"},{default:o(()=>[l(u,{placeholder:"\u8054\u7CFB\u4EBA",disabled:n.value==="view",maxlength:"11",modelValue:a.value.contacts,"onUpdate:modelValue":e[1]||(e[1]=s=>a.value.contacts=s)},null,8,["disabled","modelValue"])]),_:1})]),_:1}),l(m,{span:12},{default:o(()=>[l(t,{label:"\u8054\u7CFB\u65B9\u5F0F",prop:"mobile"},{default:o(()=>[l(u,{placeholder:"\u8054\u7CFB\u65B9\u5F0F",disabled:n.value==="view",maxlength:"11",modelValue:a.value.mobile,"onUpdate:modelValue":e[2]||(e[2]=s=>a.value.mobile=s)},null,8,["disabled","modelValue"])]),_:1})]),_:1}),l(m,{span:24},{default:o(()=>[l(t,{label:"\u5907\u6CE8",prop:"remark"},{default:o(()=>[l(u,{placeholder:"\u5907\u6CE8",disabled:n.value==="view",maxlength:"500",type:"textarea",modelValue:a.value.remark,"onUpdate:modelValue":e[3]||(e[3]=s=>a.value.remark=s)},null,8,["disabled","modelValue"])]),_:1})]),_:1})]),_:1}),Y("div",J,[n.value!=="view"?(w(),V(g,{key:0,loading:i.value,disabled:i.value,type:"primary",onClick:j},{default:o(()=>[h("\u4FDD\u5B58")]),_:1},8,["loading","disabled"])):Z("",!0),l(g,{onClick:e[4]||(e[4]=s=>p.value=!1)},{default:o(()=>[h("\u53D6\u6D88")]),_:1})])]),_:1},8,["model","rules"])]),_:1},8,["modelValue","title"])),[[T,i.value]])}}});export{ae as _};
