index.CgSD74y2.js 2.8 KB

1
  1. import{l as U,U as L,A as q}from"./api.DXSIyw8u.js";import{I as B,p as N}from"./index.Dzkftxcu.js";import{w as O,D as c,af as V,O as T,aF as m,a0 as j,y as z,G as t,a1 as d,a8 as l,a5 as b,a6 as A}from"./vue.Bi2Y_N79.js";import{_ as I}from"./_plugin-vue_export-helper.DlAUqK2U.js";const M=O({__name:"index",props:{initFormData:{default:()=>null},treeData:{default:()=>[]},cacheData:{default:()=>[]}},emits:["drawerClose"],setup(w,{emit:F}){const g={children:"children",label:"name",value:"id",isLeaf:(o,a)=>!a?.data.hasChild},u=c(),k=V({name:[{required:!0,message:"部门名称必填",trigger:"blur"}],key:[{required:!0,message:"部门标识必填",trigger:"blur"}]}),r=w,v=F;let _=c([]),e=V({key:"",parent:"",name:"",owner:"",description:""}),p=c(!1);const h=()=>{r.initFormData?.id&&(e.id=r.initFormData?.id,e.key=r.initFormData.key||"",e.parent=r.initFormData.parent||"",e.name=r.initFormData.name||"",e.owner=r.initFormData.owner||"",e.description=r.initFormData.description||"")},C=(o,a)=>{o.level!==0&&U({parent:o.data.id}).then(f=>{a(f.data)})},x=()=>{u.value?.validate(async o=>{if(o)try{let a;p.value=!0,e.id?a=await L(e):a=await q(e),a?.code===2e3&&(N(a.msg),y("submit"))}finally{p.value=!1}})},y=(o="")=>{v("drawerClose",o),u.value?.resetFields()};return T(async()=>{r.treeData.map(o=>{_.value.push(o)}),h()}),(o,a)=>{const f=m("el-tree-select"),i=m("el-form-item"),s=m("el-input"),D=m("el-button");return z(),j(t(B),{ref_key:"formRef",ref:u,rules:k,model:t(e),"label-width":"100px","label-position":"right",class:"dept-form-com"},{default:d(()=>[l(i,{label:"父级部门",prop:"parent"},{default:d(()=>[l(f,{modelValue:t(e).parent,"onUpdate:modelValue":a[0]||(a[0]=n=>t(e).parent=n),props:g,data:t(_),"cache-data":r.cacheData,lazy:"","check-strictly":"",load:C,style:{width:"100%"}},null,8,["modelValue","data","cache-data"])]),_:1}),l(i,{required:"",label:"部门名称",prop:"name"},{default:d(()=>[l(s,{modelValue:t(e).name,"onUpdate:modelValue":a[1]||(a[1]=n=>t(e).name=n)},null,8,["modelValue"])]),_:1}),l(i,{required:"",label:"部门标识",prop:"key"},{default:d(()=>[l(s,{modelValue:t(e).key,"onUpdate:modelValue":a[2]||(a[2]=n=>t(e).key=n)},null,8,["modelValue"])]),_:1}),l(i,{label:"负责人"},{default:d(()=>[l(s,{modelValue:t(e).owner,"onUpdate:modelValue":a[3]||(a[3]=n=>t(e).owner=n),placeholder:"请输入"},null,8,["modelValue"])]),_:1}),l(i,{label:"备注"},{default:d(()=>[l(s,{modelValue:t(e).description,"onUpdate:modelValue":a[4]||(a[4]=n=>t(e).description=n),maxlength:"200","show-word-limit":"",type:"textarea"},null,8,["modelValue"])]),_:1}),l(i,null,{default:d(()=>[l(D,{onClick:x,type:"primary",loading:t(p)},{default:d(()=>[b(A(t(e).id?"保存":"新增"),1)]),_:1},8,["loading"]),l(D,{onClick:y},{default:d(()=>a[5]||(a[5]=[b("取消 ")])),_:1,__:[5]})]),_:1})]),_:1},8,["rules","model"])}}}),S=I(M,[["__scopeId","data-v-aa6a357a"]]);export{S as default};