import{a as z,b as S,_ as G}from"./index-c87bcfde-1782468512657v=1.0.0.js";import{g as H,a as P,b as Q,c as T,e as X}from"./role-d87c2313-1782468512657v=1.0.0.js";import{E as D}from"./eleVendor-12a75a9a-1782468512657v=1.0.0.js";import{x as J,r as p,X as E,c as K,h as W,k as Y,al as n,y as m,H as V,I as u,A as k,Q as l,z as Z,P as $,a4 as ee,M as R}from"./vendor-27e23c1b-1782468512657v=1.0.0.js";const oe={class:"form-section clearfix"},le={class:"form-section--bd clearfix"},te=J({__name:"BaseInfo",props:{role_id:{}},emits:["addRole"],setup(C,{emit:x}){const c=C,f=x,I=z(),w=S(),F=p(),t=E({mp_id:"",role_name:"",role_desc:"",role_id:"",role_status:1}),s=E({}),g=p([]),r=p(!1),h={role_status:[{required:!0,message:"\u8BF7\u9009\u62E9\u89D2\u8272\u72B6\u6001",trigger:"change"}],mp_id:[{required:!0,message:"\u8BF7\u9009\u62E9\u6240\u5C5E\u5E94\u7528",trigger:"change"}],role_name:[{required:!0,message:"\u8BF7\u8F93\u5165\u89D2\u8272\u540D\u79F0",trigger:"change"}]},A=K(()=>!!c.role_id||!!s.post_mp_id);W(()=>c.role_id,o=>{o&&y(o)}),Y(()=>{var i;const{copy_role_id:o,copy_mp_id:e}=I.query;o&&e&&Object.assign(s,{mp_id:e,post_mp_id:e,role_id:o});const d=c.role_id||((i=s.role_id)!=null?i:"");d&&y(d),j()});const j=async()=>{const o={page:1,size:99},{data:e}=await H(o);g.value=e.list},y=async o=>{const{data:e}=await P({role_id:o});Object.keys(s).length&&(e.role_level="",e.role_pid="",e.company_id="",e.role_id=""),Object.assign(t,e)},O=()=>{F.value.validate(o=>{o&&(r.value=!0,Object.keys(s).length||!c.role_id?q():L())})},q=async()=>{try{r.value=!0;const o=Object.keys(s).length?Q:T,{data:e}=await o({...t,...s});D.success("\u89D2\u8272\u6DFB\u52A0\u6210\u529F\uFF01"),f("addRole",{mp_id:t.mp_id,role_id:e.role_id.toString(),position:"1"})}finally{r.value=!1}},L=async()=>{try{r.value=!0;const{data:o}=await X(t);D.success("\u89D2\u8272\u7F16\u8F91\u6210\u529F\uFF01"),f("addRole",{mp_id:t.mp_id,role_id:o.role_id.toString(),position:"1"})}finally{r.value=!1}},M=()=>{w.go(-1)};return(o,e)=>{const d=n("el-option"),i=n("el-select"),_=n("el-form-item"),b=n("el-input"),v=n("el-button"),B=n("el-col"),U=n("el-form");return m(),V(U,{ref_key:"ruleFormRef",ref:F,model:t,rules:h,"label-width":"120px",class:"demo-ruleForm"},{default:u(()=>[k("div",oe,[l(B,{span:24},{default:u(()=>[k("div",le,[l(B,{span:12},{default:u(()=>[l(_,{label:"\u6240\u5C5E\u5E94\u7528",prop:"mp_id"},{default:u(()=>[l(i,{modelValue:t.mp_id,"onUpdate:modelValue":e[0]||(e[0]=a=>t.mp_id=a),placeholder:"\u8BF7\u9009\u62E9\u5E94\u7528",disabled:A.value},{default:u(()=>[(m(!0),Z($,null,ee(g.value,(a,N)=>(m(),V(d,{key:N,label:a.mp_name,value:a.mp_id},null,8,["label","value"]))),128))]),_:1},8,["modelValue","disabled"])]),_:1}),l(_,{label:"\u89D2\u8272\u72B6\u6001",prop:"role_status"},{default:u(()=>[l(i,{modelValue:t.role_status,"onUpdate:modelValue":e[1]||(e[1]=a=>t.role_status=a),placeholder:"\u8BF7\u9009\u62E9\u5E94\u7528"},{default:u(()=>[l(d,{label:"\u6709\u6548",value:1}),l(d,{label:"\u65E0\u6548",value:0})]),_:1},8,["modelValue"])]),_:1}),l(_,{label:"\u89D2\u8272\u540D\u79F0",prop:"role_name"},{default:u(()=>[l(b,{modelValue:t.role_name,"onUpdate:modelValue":e[2]||(e[2]=a=>t.role_name=a),placeholder:"\u8BF7\u8F93\u5165\u89D2\u8272\u540D\u79F0"},null,8,["modelValue"])]),_:1}),l(_,{label:"\u89D2\u8272\u63CF\u8FF0",prop:"role_desc"},{default:u(()=>[l(b,{modelValue:t.role_desc,"onUpdate:modelValue":e[3]||(e[3]=a=>t.role_desc=a),placeholder:"\u8BF7\u8F93\u5165\u89D2\u8272\u63CF\u8FF0"},null,8,["modelValue"])]),_:1}),l(_,null,{default:u(()=>[l(v,{onClick:M},{default:u(()=>e[4]||(e[4]=[R("\u53D6\u6D88",-1)])),_:1,__:[4]}),l(v,{type:"primary",loading:r.value,onClick:O},{default:u(()=>e[5]||(e[5]=[R("\u786E\u5B9A",-1)])),_:1,__:[5]},8,["loading"])]),_:1})]),_:1})])]),_:1})])]),_:1},8,["model"])}}});const re=G(te,[["__scopeId","data-v-3e0b1d84"]]);export{re as default};
