addEdit.e8ac3a1a.js 3.4 KB

1
  1. import{_ as O,d as T,D as U,E as m,a7 as w,aT as S,H as q,G as z,x as s,aA as R,O as G,o as B,N as y,K as u,y as o,a as H,W as k,aS as h}from"./index.1417328f.js";import{d as I,e as K}from"./index.4a42eaee.js";const P=k("\u4FDD\u5B58"),W=k("\u5173\u95ED"),$=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(x,{emit:D}){const b=x,{logout:A}=U(),V=m("default"),_=m(),i=m(!1),t=m("add"),a=w({...{id:"",nickname:"",mobile:""}}),C=w({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")):S(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}=t.value==="add"?await I(l):await K(F);p.value=!1,d===0?(h.success(f.value+"\u6210\u529F\uFF01"),i.value=!1,D("refresh")):d>100&&d<140?(i.value=!1,A()):h.error(g)}})},E=()=>{i.value=!1,p.value=!1,D("cancel")},p=m(!1),f=m("");return q(()=>b.showModel,()=>{const{showModel:n,isDetails:e,sitem:l}=b;t.value=e,t.value==="add"?f.value="\u65B0\u5EFA\u8FD0\u8425\u8D26\u53F7":t.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,z(()=>Object.keys(a).forEach(r=>_.value.clearValidate(r)))}),(n,e)=>{const l=s("el-input"),r=s("el-form-item"),v=s("el-col"),F=s("el-row"),d=s("el-button"),g=s("el-form"),j=s("el-dialog"),N=R("loading");return G((B(),y(j,{"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:E},{default:u(()=>[o(g,{ref_key:"ruleFormRef",ref:_,model:a,rules:C,"label-width":"90px",class:"demo-ruleForm",size:V.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:t.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:t.value==="view",maxlength:11,placeholder:"\u624B\u673A\u53F7"},null,8,["modelValue","disabled"])]),_:1})]),_:1})]),_:1}),o(v,{span:24,class:"clear"},{default:u(()=>[t.value==="add"||t.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(()=>[P]),_:1},8,["loading"])):H("v-if",!0),o(d,{class:"fr",style:{margin:"0 0 0 16px"},onClick:E},{default:u(()=>[W]),_:1})]),_:1})]),_:1},8,["model","rules","size"])]),_:1},8,["modelValue","title"])),[[N,p.value]])}}});var X=O($,[["__file","/Users/apple/Desktop/Company Projects/accout-vue3-ui/src/views/system/account/addEdit.vue"]]);export{X as default};