departEdit.5ee9eb94.js 4.9 KB

123
  1. import{D as u}from"./department.e6e0ec1d.js";import{r as Z}from"./ruleReg.a279d0a6.js";import{E as d}from"./index.27cf50e8.js";import{M as y,j as G,a3 as H,am as i,o as c,a as _,_ as o,U as a,b as V,Y as p,Z as f,T as x,X as D,F as J,ad as K}from"./vue.aade88c7.js";const O={key:0},P={class:"dialog-footer"},Q=y({name:"underlyingDeptDialog"}),ae=y({...Q,emits:["refresh"],setup(W,{expose:v,emit:k}){const C=G(),e=H({id:0,ruleForm:{parent_id:0,name:"",admin_ids:[],valid:1},dialog:{isShowDialog:!1,type:"",title:"",submitTxt:""},departmentList:[],roleList:[],adminList:[],isLoad:!0}),S=l=>{console.log("e",l),e.ruleForm.parent_id=l[l.length-1],console.log("state.ruleForm.department_id",e.ruleForm.parent_id)},E=async()=>{let l=await u.detail(e.id);if(l.code!=0)return d.error(l.msg);let t=[];l.data.mainAdmin.forEach(n=>{t.push(n.id)}),e.ruleForm={parent_id:l.data.parent_id,name:l.data.name,admin_ids:t,valid:l.data.valid}},T=(l,t)=>{e.dialog.type=l,l==="edit"?(e.id=t.id,e.dialog.title="部门编辑038",e.dialog.submitTxt="修 改",E()):(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,z()},g=()=>{e.dialog.isShowDialog=!1},U=()=>{g()},B=async()=>{if(console.log("state.ruleForm.parent_id",e.ruleForm.parent_id),!Z.emptyReg(e.ruleForm.name))return d.warning("请输入部门名称");if(e.ruleForm.admin_ids.length<=0)return d.warning("请选择负责人");let l=null;if(e.dialog.type=="edit"){if(e.ruleForm.id=e.id,l=await u.edit(e.ruleForm),l.code!=0)return d.error(l.msg)}else if(l=await u.add(e.ruleForm),l.code!=0)return d.error(l.msg);d.success(l.msg),g(),k("refresh")},F=l=>{l.forEach((t,n)=>{t.parent_id==0&&t.id==e.id&&(console.log("indexDel1",n),l.splice(n,1)),t.children&&t.children.length>0&&(t.children.forEach((m,s)=>{m.id==e.id&&(console.log("indexDel2",n,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 u.initAdmin();if(l.code!=0)return d.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 u.init();if(l.code!=0)return d.error(l.msg);e.adminList=l.data.adminList,await N(),e.isLoad=!0},z=()=>{R()};return v({openDialog:T}),(l,t)=>{const n=i("el-cascader"),m=i("el-form-item"),s=i("el-col"),A=i("el-input"),M=i("el-option"),q=i("el-select"),b=i("el-radio"),j=i("el-radio-group"),I=i("el-row"),X=i("el-form"),L=i("el-button"),Y=i("el-dialog");return c(),_("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(()=>[V("span",P,[o(L,{onClick:U,size:"default"},{default:a(()=>[p("取 消")]),_:1}),o(L,{type:"primary",onClick:B,size:"default"},{default:a(()=>[p(f(e.dialog.submitTxt),1)]),_:1})])]),default:a(()=>[e.isLoad?(c(),x(X,{key:0,ref_key:"deptDialogFormRef",ref:C,model:e.ruleForm,size:"default","label-width":"90px"},{default:a(()=>[o(I,{gutter:35},{default:a(()=>[o(s,{xs:24,sm:12,md:12,lg:12,xl:12,class:"mb20"},{default:a(()=>[o(m,{label:"上级部门"},{default:a(()=>[o(n,{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:S},{default:a(({node:r,data:w})=>[V("span",null,f(w.name),1),r.isLeaf?D("",!0):(c(),_("span",O," ("+f(w.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(A,{modelValue:e.ruleForm.name,"onUpdate:modelValue":t[1]||(t[1]=r=>e.ruleForm.name=r),placeholder:"请输入部门名称",clearable:""},null,8,["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.admin_ids,"onUpdate:modelValue":t[2]||(t[2]=r=>e.ruleForm.admin_ids=r),placeholder:"请选择负责人",multiple:""},{default:a(()=>[(c(!0),_(J,null,K(e.adminList,r=>(c(),x(M,{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(j,{modelValue:e.ruleForm.valid,"onUpdate:modelValue":t[3]||(t[3]=r=>e.ruleForm.valid=r)},{default:a(()=>[o(b,{label:1},{default:a(()=>[p("启用")]),_:1}),o(b,{label:0},{default:a(()=>[p("禁用")]),_:1})]),_:1},8,["modelValue"])]),_:1})]),_:1})]),_:1})]),_:1},8,["model"])):D("",!0)]),_:1},8,["title","modelValue"])])}}});export{ae as default};
  2. //# sourceMappingURL=departEdit.5ee9eb94.js.map