import{M as D,j as Z,a3 as G,am as i,o as u,a as f,_ as o,U as a,b as y,Y as _,Z as g,T as w,X as c,F as H,ad as J}from"./vue.60d2ee98.js";import{D as p}from"./department.73be3d58.js";import{r as K}from"./ruleReg.ec1cc1f0.js";import{E as n,_ as O}from"./index.beaea096.js";const P={key:0},Q={class:"dialog-footer"},W=D({name:"underlyingDeptDialog"}),$=D({...W,emits:["refresh"],setup(ee,{expose:V,emit:k}){const C=Z(),e=G({id:0,ruleForm:{parent_id:0,name:"",admin_ids:[],valid:1},dialog:{isShowDialog:!1,type:"",title:"",submitTxt:""},departmentList:[],roleList:[],adminList:[],isLoad:!0}),E=l=>{console.log("e",l),e.ruleForm.parent_id=l[l.length-1],console.log("state.ruleForm.department_id",e.ruleForm.parent_id)},S=async()=>{let l=await p.detail(e.id);if(l.code!=0)return n.error(l.msg);let t=[];l.data.mainAdmin.forEach(d=>{t.push(d.id)}),e.ruleForm={parent_id:l.data.parent_id,name:l.data.name,admin_ids:t,valid:l.data.valid}},U=(l,t)=>{e.dialog.type=l,l==="edit"?(e.id=t.id,e.dialog.title="部门编辑038",e.dialog.submitTxt="修 改",S()):(e.id=0,e.ruleForm={parent_id:0,name:"",admin_ids:[],valid:1},e.dialog.title="部门添加037",e.dialog.submitTxt="保 存"),e.departmentList=[],e.roleList=[],e.dialog.isShowDialog=!0,j()},b=()=>{e.dialog.isShowDialog=!1},T=()=>{b()},B=async()=>{if(console.log("state.ruleForm.parent_id",e.ruleForm.parent_id),!K.emptyReg(e.ruleForm.name))return n.warning("请输入部门名称");if(e.ruleForm.admin_ids.length<=0)return n.warning("请选择负责人");let l=null;if(e.dialog.type=="edit"){if(e.ruleForm.id=e.id,l=await p.edit(e.ruleForm),l.code!=0)return n.error(l.msg)}else if(l=await p.add(e.ruleForm),l.code!=0)return n.error(l.msg);n.success(l.msg),b(),k("refresh")},F=l=>{l.forEach((t,d)=>{t.parent_id==0&&t.id==e.id&&(console.log("indexDel1",d),l.splice(d,1)),t.children&&t.children.length>0&&(t.children.forEach((m,s)=>{m.id==e.id&&(console.log("indexDel2",d,s),t.children.splice(s,1))}),F(t.children))})},h=l=>{l.forEach(t=>{t.valid!=1&&(t.disabled=!0),t.children&&h(t.children)})},N=async()=>{console.log("初始化下拉列表");let l=await p.initAdmin();if(l.code!=0)return n.error(l.msg);F(l.data.departmentList),h(l.data.departmentList),e.departmentList=l.data.departmentList,e.roleList=l.data.roleList},R=async()=>{console.log("初始化人员列表"),e.isLoad=!1;let l=await p.init();if(l.code!=0)return n.error(l.msg);e.adminList=l.data.adminList,await N(),e.isLoad=!0},j=()=>{R()};return V({openDialog:U}),(l,t)=>{const d=i("el-cascader"),m=i("el-form-item"),s=i("el-col"),q=i("el-input"),z=i("el-option"),A=i("el-select"),v=i("el-radio"),M=i("el-radio-group"),I=i("el-row"),X=i("el-form"),x=i("el-button"),Y=i("el-dialog");return u(),f("div",null,[o(Y,{title:e.dialog.title,modelValue:e.dialog.isShowDialog,"onUpdate:modelValue":t[4]||(t[4]=r=>e.dialog.isShowDialog=r),width:"769px"},{footer:a(()=>[y("span",Q,[o(x,{onClick:T,size:"default"},{default:a(()=>[_("取 消")]),_:1}),o(x,{type:"primary",onClick:B,size:"default"},{default:a(()=>[_(g(e.dialog.submitTxt),1)]),_:1})])]),default:a(()=>[e.isLoad?(u(),w(X,{key:0,ref_key:"deptDialogFormRef",ref:C,model:e.ruleForm,size:"default","label-width":"90px"},{default:a(()=>[o(I,{gutter:35},{default:a(()=>[c(`
`),c(` :rules="[{ required: true, message: '上级部门不能为空' }]"
clearable `),o(s,{xs:24,sm:12,md:12,lg:12,xl:12,class:"mb20"},{default:a(()=>[o(m,{label:"上级部门"},{default:a(()=>[o(d,{options:e.departmentList,props:{checkStrictly:!0,value:"id",label:"name"},placeholder:"请选择上级部门",class:"w100",modelValue:e.ruleForm.parent_id,"onUpdate:modelValue":t[0]||(t[0]=r=>e.ruleForm.parent_id=r),onChange:E},{default:a(({node:r,data:L})=>[y("span",null,g(L.name),1),r.isLeaf?c("v-if",!0):(u(),f("span",P," ("+g(L.children.length)+") ",1))]),_:1},8,["options","modelValue"])]),_:1})]),_:1}),o(s,{xs:24,sm:12,md:12,lg:12,xl:12,class:"mb20"},{default:a(()=>[o(m,{label:"部门名称",rules:[{required:!0,message:"部门名称不能为空"}]},{default:a(()=>[o(q,{modelValue:e.ruleForm.name,"onUpdate:modelValue":t[1]||(t[1]=r=>e.ruleForm.name=r),placeholder:"请输入部门名称",clearable:""},null,8,["modelValue"])]),_:1})]),_:1}),c(`
`),o(s,{xs:24,sm:12,md:12,lg:12,xl:12,class:"mb20"},{default:a(()=>[o(m,{label:"负 责 人",rules:[{required:!0,message:"负责人不能为空"}]},{default:a(()=>[o(A,{modelValue:e.ruleForm.admin_ids,"onUpdate:modelValue":t[2]||(t[2]=r=>e.ruleForm.admin_ids=r),placeholder:"请选择负责人",multiple:""},{default:a(()=>[(u(!0),f(H,null,J(e.adminList,r=>(u(),w(z,{key:r.id,label:r.name,value:r.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1})]),_:1}),o(s,{xs:24,sm:12,md:12,lg:12,xl:12,class:"mb20"},{default:a(()=>[o(m,{label:"状 态"},{default:a(()=>[o(M,{modelValue:e.ruleForm.valid,"onUpdate:modelValue":t[3]||(t[3]=r=>e.ruleForm.valid=r)},{default:a(()=>[o(v,{label:1},{default:a(()=>[_("启用")]),_:1}),o(v,{label:0},{default:a(()=>[_("禁用")]),_:1})]),_:1},8,["modelValue"])]),_:1})]),_:1})]),_:1})]),_:1},8,["model"])):c("v-if",!0)]),_:1},8,["title","modelValue"])])}}}),re=O($,[["__file","C:/Users/89282/Desktop/xmgl_yjy/project-manager/h5/src/views/underlying/department/departEdit.vue"]]);export{re as default};
//# sourceMappingURL=departEdit.79cd776b.js.map