import{_ as O,d as j,ci as z,n as w,O as L,cc as M,w as h,r,aw as H,o as v,A as N,y as s,B as Q,h as n,i as b,d5 as T,c as G,F as J,z as K,e as P,H as W,ak as X,cm as y}from"./index.js";import{h as Y,d as Z,b as $}from"./index.3dd3ee5a.js";const ee={class:"w-full flex justify-end"},oe=j({__name:"role-copy",props:{companyNo:{type:String,required:!0},roleName:{type:String,required:!0},visible:{type:Boolean,required:!0},roleId:{type:String,required:!0}},emits:["refresh"],setup(R,{emit:I}){const f=R,V=I,d=z(f,"visible"),F=w(null),{currentCompany:C}=L(),D=w([]),c=M(!1),B={name:"",companyNo:"",sourceRoleId:"",sourceCompanyNo:""},o=w({...B});h(()=>C.value,()=>o.value.companyNo=C.value.companyNo);async function k(u){c.value=!0;const{code:e,data:l,message:t}=await Y({size:1e3,level:"2",companyNo:u});if(e===0){const{list:m,count:i}=l;D.value=m}c.value=!1}h(()=>o.value.sourceCompanyNo,u=>{D.value=[],o.value.sourceRoleId="",o.value.sourceCompanyNo&&k(o.value.sourceCompanyNo)},{immediate:!0});const q={sourceCompanyNo:[{required:!0,message:"\u8BF7\u9009\u62E9\u6765\u6E90\u4E1A\u52A1\u516C\u53F8",trigger:"change"}],sourceRoleId:[{required:!0,message:"\u8BF7\u9009\u62E9\u6765\u6E90\u89D2\u8272",trigger:"change"}]};function A(){o.value={...B},d.value=!1}async function S(){try{const{sourceCompanyNo:u,sourceRoleId:e}=o.value,{data:l,code:t}=await Z({companyNo:u,roleid:e});if(t===0)return l;throw new Error("\u8BFB\u53D6\u89D2\u8272\u5931\u8D25..")}catch{throw new Error("\u8BFB\u53D6\u89D2\u8272\u5931\u8D25..")}}async function x(u={}){try{const{data:e,code:l}=await $(u);if(l!==0)throw new Error("\u590D\u5236\u89D2\u8272\u5931\u8D25..")}catch{throw new Error("\u590D\u5236\u89D2\u8272\u5931\u8D25..")}}async function U(){try{c.value=!0,await F.value.validate();const{sourceCompanyNo:u,sourceRoleId:e,companyNo:l,name:t}=o.value;y.info("\u6B63\u5728\u8BFB\u53D6\u6765\u6E90\u89D2\u8272\u4FE1\u606F(1/3)...");const m=await S();y.info("\u8BFB\u53D6\u89D2\u8272\u4FE1\u606F\u6210\u529F,\u6B63\u5728\u590D\u5236\u89D2\u8272(2/3)...");const{action:i,private_data:p,role_name:g}=m,E={level:2,roleid:f.roleId,role_name:f.roleName,companyNo:f.companyNo,action:Array.isArray(i)?i:i.split(","),private_data:(Array.isArray(p)?p:p.split(",")).filter(_=>!!_)};await x(E),c.value=!1,y.success("\u89D2\u8272\u590D\u5236\u6210\u529F(3/3)..."),V("refresh"),d.value=!1}catch(u){y.warning(u),c.value=!1}}return(u,e)=>{const l=r("ElInput"),t=r("ElFormItem"),m=r("ElOption"),i=r("ElSelect"),p=r("ElButton"),g=r("ElForm"),E=r("ElDialog"),_=H("loading");return v(),N(E,{title:"\u590D\u5236\u89D2\u8272",center:"",modelValue:b(d),"onUpdate:modelValue":e[2]||(e[2]=a=>X(d)?d.value=a:null),onClose:A,"close-on-click-modal":!1,"close-on-press-escape":!1},{default:s(()=>[Q((v(),N(g,{model:o.value,rules:q,ref_key:"formRef",ref:F,"label-width":"80px"},{default:s(()=>[n(t,{prop:"name",label:"\u89D2\u8272\u540D\u79F0"},{default:s(()=>[n(l,{modelValue:u.roleName,placeholder:"\u89D2\u8272\u540D\u79F0",disabled:""},null,8,["modelValue"])]),_:1}),n(t,{prop:"sourceCompanyNo",label:"\u6765\u6E90\u516C\u53F8"},{default:s(()=>[n(b(T),{modelValue:o.value.sourceCompanyNo,"onUpdate:modelValue":e[0]||(e[0]=a=>o.value.sourceCompanyNo=a),placeholder:"\u6765\u6E90\u516C\u53F8"},null,8,["modelValue"])]),_:1}),n(t,{prop:"sourceRoleId",label:"\u6765\u6E90\u89D2\u8272"},{default:s(()=>[n(i,{modelValue:o.value.sourceRoleId,"onUpdate:modelValue":e[1]||(e[1]=a=>o.value.sourceRoleId=a),style:{width:"100%"},placeholder:"\u6765\u6E90\u89D2\u8272",disabled:!o.value.sourceCompanyNo},{default:s(()=>[(v(!0),G(J,null,K(D.value,a=>(v(),N(m,{key:a.id,value:a.id,label:a.role_name,disabled:a.id===u.roleId},null,8,["value","label","disabled"]))),128))]),_:1},8,["modelValue","disabled"])]),_:1}),P("div",ee,[n(p,{type:"primary",onClick:U},{default:s(()=>e[3]||(e[3]=[W("\u4FDD\u5B58")])),_:1})])]),_:1},8,["model"])),[[_,c.value]])]),_:1},8,["modelValue"])}}});var le=O(oe,[["__file","D:/work/jiesuan/settle-vue3/src/views/interest/role/role-copy.vue"]]);export{le as default};
