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