import{_ as O,d as T,m as U,n as c,Q as B,ck as z,w as S,q as R,r as s,aw as H,B as I,o as E,A as y,y as u,h as t,H as k,a as Q,cm as A}from"./index.js";import{d as $,e as G}from"./index.f80be860.js";const J=T({__name:"addEdit",props:{itemId:{type:String,default:""},showModel:{type:Boolean,default:!1},isDetails:{type:String,default:"add"},sitem:{type:Object}},emits:["cancel","refresh"],setup(V,{emit:x}){const{logout:h}=U(),C=c("default"),F=c(),b=V,i=c(!1),D=x,o=c("add"),a=B({...{id:"",nickname:"",mobile:""}}),M=B({nickname:[{required:!0,message:"\u8BF7\u8F93\u5165\u771F\u5B9E\u59D3\u540D",trigger:"blur"},{min:2,max:12,message:"\u957F\u5EA6\u5728 2 \u5230 12 \u4E2A\u5B57\u7B26",trigger:"blur"}],mobile:[{required:!0,validator:(n,e,l)=>{e===""?l(new Error("\u624B\u673A\u53F7\u4E0D\u80FD\u4E3A\u7A7A\uFF01")):z(e)?l():l(new Error("\u624B\u673A\u53F7\u683C\u5F0F\u4E0D\u6B63\u786E\uFF01"))},trigger:"blur"}],email:[{required:!1,message:"\u8BF7\u8F93\u5165\u90AE\u7BB1",trigger:"change"}]}),j=async n=>{if(!n)return;const{id:e,...l}=Object.assign({},a);await n.validate(async(r,v)=>{if(r){const _=Object.assign({},a),{code:d,message:g}=o.value==="add"?await $(l):await G(_);p.value=!1,d===0?(A.success(f.value+"\u6210\u529F\uFF01"),i.value=!1,D("refresh")):d>100&&d<140?(i.value=!1,h()):A.error(g)}})},w=()=>{i.value=!1,p.value=!1,D("cancel")},p=c(!1),f=c("");return S(()=>b.showModel,()=>{const{showModel:n,isDetails:e,sitem:l}=b;o.value=e,o.value==="add"?f.value="\u65B0\u5EFA\u8FD0\u8425\u8D26\u53F7":o.value==="view"?f.value="\u8FD0\u8425\u8D26\u53F7\u8BE6\u60C5":f.value="\u4FEE\u6539\u8FD0\u8425\u8D26\u53F7",i.value=n,a.nickname=l.nickname,a.mobile=l.mobile,a.id=l.id,R(()=>Object.keys(a).forEach(r=>F.value.clearValidate(r)))}),(n,e)=>{const l=s("el-input"),r=s("el-form-item"),v=s("el-col"),_=s("el-row"),d=s("el-button"),g=s("el-form"),q=s("el-dialog"),N=H("loading");return I((E(),y(q,{"close-on-click-modal":!1,"close-on-press-escape":!1,modelValue:i.value,"onUpdate:modelValue":e[3]||(e[3]=m=>i.value=m),"append-to-body":"",width:"900px",center:"",title:f.value,onClose:w},{default:u(()=>[t(g,{ref_key:"ruleFormRef",ref:F,model:a,rules:M,"label-width":"90px",class:"demo-ruleForm",size:C.value,"status-icon":""},{default:u(()=>[t(_,null,{default:u(()=>[t(v,{span:24},{default:u(()=>[t(r,{label:"\u771F\u5B9E\u59D3\u540D",prop:"nickname"},{default:u(()=>[t(l,{modelValue:a.nickname,"onUpdate:modelValue":e[0]||(e[0]=m=>a.nickname=m),disabled:o.value==="view",placeholder:"\u771F\u5B9E\u59D3\u540D"},null,8,["modelValue","disabled"])]),_:1})]),_:1}),t(v,{span:24},{default:u(()=>[t(r,{label:"\u624B\u673A\u53F7",prop:"mobile"},{default:u(()=>[t(l,{modelValue:a.mobile,"onUpdate:modelValue":e[1]||(e[1]=m=>a.mobile=m),disabled:o.value==="view",maxlength:11,placeholder:"\u624B\u673A\u53F7"},null,8,["modelValue","disabled"])]),_:1})]),_:1})]),_:1}),t(v,{span:24,class:"clear"},{default:u(()=>[o.value==="add"||o.value==="edit"?(E(),y(d,{key:0,type:"primary",class:"fr",loading:p.value,style:{margin:"0 0 0 16px"},onClick:e[2]||(e[2]=m=>j(F.value))},{default:u(()=>e[4]||(e[4]=[k("\u4FDD\u5B58")])),_:1},8,["loading"])):Q("v-if",!0),t(d,{class:"fr",style:{margin:"0 0 0 16px"},onClick:w},{default:u(()=>e[5]||(e[5]=[k("\u5173\u95ED")])),_:1})]),_:1})]),_:1},8,["model","rules","size"])]),_:1},8,["modelValue","title"])),[[N,p.value]])}}});var W=O(J,[["__file","D:/work/jiesuan/settle-vue3/src/views/system/account/addEdit.vue"]]);export{W as default};
