/* empty css             *//* empty css                   *//* empty css                     *//* empty css                  *//* empty css                 *//* empty css               *//* empty css                  *//* empty css                     *//* empty css                  *//* empty css                *//* empty css                    *//* empty css                       */import{u as e}from"./useCreate-d1a919fb.js";import{u as a}from"./useShow-5d0f85e9.js";import{b as l}from"./index-de24bfa3.js";import{d as s,m as r,O as o,x as t,a9 as m,W as d,f as u,o as i,l as p,w as n,e as c,a as f,z as v,c as _,F as b,y as h,b as y,t as j,aq as g,a2 as w,a3 as V,al as x,A as k,B as q,S as C,Y as R,$ as U}from"./index-2b50ecca.js";const S={class:"flex flex-row justify-between"},P={class:"w-full"},$={class:"flex justify-end"},z=s({__name:"create",props:{primary:String|Number,api:String,hasRoles:{type:Boolean,default:!0}},emits:["close"],setup(s,{emit:z}){const A=s,B=r(!1),F=e=>{Y(e?{cp_name:e}:{})},Y=e=>{l(e).then((e=>{G.value=e.data}))},Z=[{required:!0,message:"密码必须填写"},{pattern:/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,20}$/,message:"必须包含大小写字母和数字的组合，可以使用特殊字符，长度在6-20之间"}];A.primary&&Z.shift();const{formData:D,form:I,loading:J,submitForm:N,close:O}=e(A.api,A.primary);A.primary&&a(A.api,A.primary,D),O((()=>z("close")));const W=r(),X=r(),E=r(),G=r();return o((()=>D.value.roles),((e,a)=>{var l;B.value=A.hasRoles&&(null==(l=D.value.role_identifies)?void 0:l.includes("cp"))}),{deep:!0,immediate:!0}),t((()=>{Y({}),A.hasRoles&&(m.get("permissions/departments").then((e=>{W.value=e.data.data})),m.get("permissions/jobs").then((e=>{X.value=e.data.data})),m.get("permissions/roles").then((e=>{E.value=e.data.data})))})),(e,a)=>{const l=w,r=V,o=x,t=k,m=q,z=C,Y=R,O=U;return d((i(),p(Y,{model:u(D),"label-width":"80px",ref_key:"form",ref:I,class:"pr-4"},{default:n((()=>[c("div",S,[c("div",P,[f(r,{label:"昵称",prop:"username",rules:[{required:!0,message:"昵称必须填写"}]},{default:n((()=>[f(l,{modelValue:u(D).username,"onUpdate:modelValue":a[0]||(a[0]=e=>u(D).username=e),placeholder:"请填写昵称"},null,8,["modelValue"])])),_:1}),f(r,{label:"邮箱",prop:"email",rules:[{required:!0,message:"邮箱必须填写"},{type:"email",message:"邮箱格式不正确"}]},{default:n((()=>[f(l,{modelValue:u(D).email,"onUpdate:modelValue":a[1]||(a[1]=e=>u(D).email=e),placeholder:"请填写邮箱"},null,8,["modelValue"])])),_:1}),f(r,{label:"密码",prop:"password",rules:Z},{default:n((()=>[f(l,{autocomplete:"new-password",modelValue:u(D).password,"onUpdate:modelValue":a[2]||(a[2]=e=>u(D).password=e),type:"password","show-password":"",placeholder:"请输入密码"},null,8,["modelValue"])])),_:1}),s.hasRoles?(i(),p(r,{key:0,label:"角色",prop:"roles",rules:[{required:!0,message:"请选择角色"}]},{default:n((()=>[f(o,{onChange:a[3]||(a[3]=e=>(e=>{var a;const l=g(e).filter((e=>{var a;return null==(a=D.value.roles)?void 0:a.includes(e.id)})).map((e=>e.identify));D.value.role_identifies=l,B.value=A.hasRoles&&(null==(a=D.value.role_identifies)?void 0:a.includes("cp")),B.value||(D.value.cp_name="")})(E.value)),modelValue:u(D).roles,"onUpdate:modelValue":a[4]||(a[4]=e=>u(D).roles=e),"default-expanded-keys":u(D).roles,data:E.value,"value-key":"id","check-strictly":"",class:"w-full",props:{label:"role_name",value:"id"},clearable:"",multiple:"","show-checkbox":""},null,8,["modelValue","default-expanded-keys","data"])])),_:1})):v("",!0),B.value?(i(),p(r,{key:1,label:"CP方",prop:"cp_name",rules:[{required:!0,message:"请选择CP方"}]},{default:n((()=>[f(m,{modelValue:u(D).cp_name,"onUpdate:modelValue":a[5]||(a[5]=e=>u(D).cp_name=e),remote:"",filterable:"","remote-method":F,clearable:"",placeholder:"选择CP方"},{default:n((()=>[(i(!0),_(b,null,h(G.value,(e=>(i(),p(t,{key:e.cp_id,label:e.cp_name,value:e.cp_name},null,8,["label","value"])))),128))])),_:1},8,["modelValue"])])),_:1})):v("",!0)])]),c("div",$,[f(z,{type:"primary",onClick:a[6]||(a[6]=e=>u(N)(u(I)))},{default:n((()=>[y(j(e.$t("system.confirm")),1)])),_:1})])])),_:1},8,["model"])),[[O,u(J)]])}}});export{z as _};
