/* 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-4cdcc37e.js";import{u as a}from"./useShow-897a1bd7.js";import{b as l}from"./index-5037de6e.js";import{d as s,q as r,P as o,z as t,ac as m,Z as d,f as u,o as i,l as p,w as n,e as c,a as f,A as v,c as _,F as h,p as b,b as y,t as j,aq as g,a5 as w,a6 as V,am as k,B as x,D as q,X as C,a0 as R,a2 as U}from"./index-545c1a76.js";const P={class:"flex flex-row justify-between"},z={class:"w-full"},A={class:"flex justify-end"},F=s({__name:"create",props:{primary:String|Number,api:String,hasRoles:{type:Boolean,default:!0}},emits:["close"],setup(s,{emit:F}){const S=s,$=r(!1),B=e=>{D(e?{cp_name:e}:{})},D=e=>{l(e).then((e=>{L.value=e.data}))},Z=[{required:!0,message:"密码必须填写"},{pattern:/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,20}$/,message:"必须包含大小写字母和数字的组合，可以使用特殊字符，长度在6-20之间"}];S.primary&&Z.shift();const{formData:G,form:N,loading:X,submitForm:E,close:H}=e(S.api,S.primary);S.primary&&a(S.api,S.primary,G),H((()=>F("close")));const I=r(),J=r(),K=r(),L=r();return o((()=>G.value.roles),((e,a)=>{var l;$.value=S.hasRoles&&(null==(l=G.value.role_identifies)?void 0:l.includes("cp"))}),{deep:!0,immediate:!0}),t((()=>{D({}),S.hasRoles&&(m.get("permissions/departments").then((e=>{I.value=e.data.data})),m.get("permissions/jobs").then((e=>{J.value=e.data.data})),m.get("permissions/roles").then((e=>{K.value=e.data.data})))})),(e,a)=>{const l=w,r=V,o=k,t=x,m=q,F=C,D=R,H=U;return d((i(),p(D,{model:u(G),"label-width":"80px",ref_key:"form",ref:N,class:"pr-4"},{default:n((()=>[c("div",P,[c("div",z,[f(r,{label:"昵称",prop:"username",rules:[{required:!0,message:"昵称必须填写"}]},{default:n((()=>[f(l,{modelValue:u(G).username,"onUpdate:modelValue":a[0]||(a[0]=e=>u(G).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(G).email,"onUpdate:modelValue":a[1]||(a[1]=e=>u(G).email=e),placeholder:"请填写邮箱"},null,8,["modelValue"])])),_:1}),f(r,{label:"密码",prop:"password",rules:Z},{default:n((()=>[f(l,{autocomplete:"new-password",modelValue:u(G).password,"onUpdate:modelValue":a[2]||(a[2]=e=>u(G).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=G.value.roles)?void 0:a.includes(e.id)})).map((e=>e.identify));G.value.role_identifies=l,$.value=S.hasRoles&&(null==(a=G.value.role_identifies)?void 0:a.includes("cp")),$.value||(G.value.cp_name="")})(K.value)),modelValue:u(G).roles,"onUpdate:modelValue":a[4]||(a[4]=e=>u(G).roles=e),"default-expanded-keys":u(G).roles,data:K.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),$.value?(i(),p(r,{key:1,label:"CP方",prop:"cp_name",rules:[{required:!0,message:"请选择CP方"}]},{default:n((()=>[f(m,{modelValue:u(G).cp_name,"onUpdate:modelValue":a[5]||(a[5]=e=>u(G).cp_name=e),remote:"",filterable:"","remote-method":B,clearable:"",placeholder:"选择CP方"},{default:n((()=>[(i(!0),_(h,null,b(L.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",A,[f(F,{type:"primary",onClick:a[6]||(a[6]=e=>u(E)(u(N)))},{default:n((()=>[y(j(e.$t("system.confirm")),1)])),_:1})])])),_:1},8,["model"])),[[H,u(X)]])}}});export{F as _};
