import{$ as k,C as y,B as R,v as U,t as N,D as I}from"./element-plus.ae8e286c.js";import{d as S,a as T,b as q,c as M}from"./department.d0876fbc.js";import{P}from"./index.a9e38e26.js";import{a as $}from"./useDictOptions.40b26c73.js";import{d as J,s as E,r as K,b as O,_ as Q,o as f,c as j,T as l,K as s,J as z,u as _,Q as G,a as F}from"./@vue.108c970a.js";const H={class:"edit-popup"},L=F("div",{class:"form-tips"},"\u9ED8\u8BA4\u4E3A0\uFF0C \u6570\u503C\u8D8A\u5927\u8D8A\u6392\u524D",-1),te=J({__name:"edit",emits:["success","close"],setup(W,{expose:D,emit:i}){const m=E(),d=E(),r=K("add"),B=O(()=>r.value=="edit"?"\u7F16\u8F91\u90E8\u95E8":"\u65B0\u589E\u90E8\u95E8"),u=Q({id:"",pid:"",name:"",leader:"",mobile:"",sort:0,status:1}),b={pid:[{required:!0,message:"\u8BF7\u9009\u62E9\u4E0A\u7EA7\u90E8\u95E8",trigger:["change"]}],name:[{required:!0,message:"\u8BF7\u8F93\u5165\u90E8\u95E8\u540D\u79F0",trigger:["blur"]}],mobile:[{validator:(t,e,n)=>{if(e){const a=/^[1][3,4,5,6,7,8,9][0-9]{9}$/;if(console.log(a.test(e)),a.test(e))n();else return n(new Error("\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u624B\u673A\u53F7"))}else return n()},trigger:["blur"]}]},{optionsData:V}=$({dept:{api:S}}),v=async()=>{var t,e;await((t=m.value)==null?void 0:t.validate()),r.value=="edit"?await T(u):await q(u),(e=d.value)==null||e.close(),i("success")},A=(t="add")=>{var e;r.value=t,(e=d.value)==null||e.open()},c=t=>{for(const e in u)t[e]!=null&&t[e]!=null&&(u[e]=t[e])},g=async t=>{const e=await M({id:t.id});c(e)},w=()=>{i("close")};return D({open:A,setFormData:c,getDetail:g}),(t,e)=>{const n=k,a=y,p=R,C=U,x=N,h=I;return f(),j("div",H,[l(P,{ref_key:"popupRef",ref:d,title:_(B),async:!0,width:"550px",onConfirm:v,onClose:w},{default:s(()=>[l(h,{ref_key:"formRef",ref:m,model:u,"label-width":"84px",rules:b},{default:s(()=>[u.pid!==0?(f(),z(a,{key:0,label:"\u4E0A\u7EA7\u90E8\u95E8",prop:"pid"},{default:s(()=>[l(n,{class:"flex-1",modelValue:u.pid,"onUpdate:modelValue":e[0]||(e[0]=o=>u.pid=o),data:_(V).dept,clearable:"","node-key":"id",props:{value:"id",label:"name"},"check-strictly":"","default-expand-all":!0,placeholder:"\u8BF7\u9009\u62E9\u4E0A\u7EA7\u90E8\u95E8"},null,8,["modelValue","data"])]),_:1})):G("",!0),l(a,{label:"\u90E8\u95E8\u540D\u79F0",prop:"name"},{default:s(()=>[l(p,{modelValue:u.name,"onUpdate:modelValue":e[1]||(e[1]=o=>u.name=o),placeholder:"\u8BF7\u8F93\u5165\u90E8\u95E8\u540D\u79F0",maxlength:100},null,8,["modelValue"])]),_:1}),l(a,{label:"\u8D1F\u8D23\u4EBA",prop:"leader"},{default:s(()=>[l(p,{modelValue:u.leader,"onUpdate:modelValue":e[2]||(e[2]=o=>u.leader=o),placeholder:"\u8BF7\u8F93\u5165\u8D1F\u8D23\u4EBA\u59D3\u540D",maxlength:30},null,8,["modelValue"])]),_:1}),l(a,{label:"\u8054\u7CFB\u7535\u8BDD",prop:"mobile"},{default:s(()=>[l(p,{modelValue:u.mobile,"onUpdate:modelValue":e[3]||(e[3]=o=>u.mobile=o),placeholder:"\u8BF7\u8F93\u5165\u8054\u7CFB\u7535\u8BDD"},null,8,["modelValue"])]),_:1}),l(a,{label:"\u6392\u5E8F",prop:"sort"},{default:s(()=>[F("div",null,[l(C,{modelValue:u.sort,"onUpdate:modelValue":e[4]||(e[4]=o=>u.sort=o),min:0,max:9999},null,8,["modelValue"]),L])]),_:1}),l(a,{label:"\u90E8\u95E8\u72B6\u6001"},{default:s(()=>[l(x,{modelValue:u.status,"onUpdate:modelValue":e[5]||(e[5]=o=>u.status=o),"active-value":1,"inactive-value":0},null,8,["modelValue"])]),_:1})]),_:1},8,["model"])]),_:1},8,["title"])])}}});export{te as _};
