import{_ as U,d as z,v as O,w as m,Z as E,aL as T,z as q,y as S,r as t,aC as R,H as G,o as B,G as y,C as u,j as o,M as k,a as H,aN as A}from"./index.js";import{b as I,c as L}from"./index.b45d915f.js";const Z=z({__name:"addEdit",props:{itemId:{type:String,default:""},showModel:{type:Boolean,default:!1},isDetails:{type:String,default:"add"},sitem:{type:Object}},emits:["cancel","refresh"],setup(h,{emit:b}){const D=h,{logout:V}=O(),x=m("default"),_=m(),i=m(!1),s=m("add"),a=E({...{id:"",nickname:"",mobile:""}}),C=E({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")):T(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"}]}),M=async n=>{if(!n)return;const{id:e,...l}=Object.assign({},a);await n.validate(async(r,v)=>{if(r){const F=Object.assign({},a),{code:d,message:g}=s.value==="add"?await I(l):await L(F);p.value=!1,d===0?(A.success(f.value+"\u6210\u529F\uFF01"),i.value=!1,b("refresh")):d>100&&d<140?(i.value=!1,V()):A.error(g)}})},w=()=>{i.value=!1,p.value=!1,b("cancel")},p=m(!1),f=m("");return q(()=>D.showModel,()=>{const{showModel:n,isDetails:e,sitem:l}=D;s.value=e,s.value==="add"?f.value="\u65B0\u5EFA\u8FD0\u8425\u8D26\u53F7":s.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,S(()=>Object.keys(a).forEach(r=>_.value.clearValidate(r)))}),(n,e)=>{const l=t("el-input"),r=t("el-form-item"),v=t("el-col"),F=t("el-row"),d=t("el-button"),g=t("el-form"),j=t("el-dialog"),N=R("loading");return G((B(),y(j,{"close-on-click-modal":!1,"close-on-press-escape":!1,modelValue:i.value,"onUpdate:modelValue":e[3]||(e[3]=c=>i.value=c),"append-to-body":"",width:"900px",center:"",title:f.value,onClose:w},{default:u(()=>[o(g,{ref_key:"ruleFormRef",ref:_,model:a,rules:C,"label-width":"90px",class:"demo-ruleForm",size:x.value,"status-icon":""},{default:u(()=>[o(F,null,{default:u(()=>[o(v,{span:24},{default:u(()=>[o(r,{label:"\u771F\u5B9E\u59D3\u540D",prop:"nickname"},{default:u(()=>[o(l,{modelValue:a.nickname,"onUpdate:modelValue":e[0]||(e[0]=c=>a.nickname=c),disabled:s.value==="view",placeholder:"\u771F\u5B9E\u59D3\u540D"},null,8,["modelValue","disabled"])]),_:1})]),_:1}),o(v,{span:24},{default:u(()=>[o(r,{label:"\u624B\u673A\u53F7",prop:"mobile"},{default:u(()=>[o(l,{modelValue:a.mobile,"onUpdate:modelValue":e[1]||(e[1]=c=>a.mobile=c),disabled:s.value==="view",maxlength:11,placeholder:"\u624B\u673A\u53F7"},null,8,["modelValue","disabled"])]),_:1})]),_:1})]),_:1}),o(v,{span:24,class:"clear"},{default:u(()=>[s.value==="add"||s.value==="edit"?(B(),y(d,{key:0,type:"primary",class:"fr",loading:p.value,style:{margin:"0 0 0 16px"},onClick:e[2]||(e[2]=c=>M(_.value))},{default:u(()=>[k("\u4FDD\u5B58")]),_:1},8,["loading"])):H("v-if",!0),o(d,{class:"fr",style:{margin:"0 0 0 16px"},onClick:w},{default:u(()=>[k("\u5173\u95ED")]),_:1})]),_:1})]),_:1},8,["model","rules","size"])]),_:1},8,["modelValue","title"])),[[N,p.value]])}}});var P=U(Z,[["__file","C:/Users/Administrator/Desktop/projects/purchase-vue3/src/views/system/operationAccount/addEdit.vue"]]);export{P as default};
