import{_ as U,d as M,aV as j,x as C,W as L,aP as O,A as I,r,aD as z,o as v,G as F,D as s,H as G,l as n,m as w,bI as H,c as P,F as Q,E as T,h as W,M as Z,ar as J,aZ as y}from"./index.js";import{h as K,d as X,b as Y}from"./index.5eaa637e.js";const $={class:"w-full flex justify-end"},ee=M({__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(D,{emit:R}){const f=D,d=j(f,"visible"),h=C(null),{currentCompany:B}=L(),E=C([]),c=O(!1),g={name:"",companyNo:"",sourceRoleId:"",sourceCompanyNo:""},e=C({...g});I(()=>B.value,()=>e.value.companyNo=B.value.companyNo);async function V(u){c.value=!0;const{code:o,data:l,message:t}=await K({size:1e3,level:"2",companyNo:u});if(o===0){const{list:m,count:i}=l;E.value=m}c.value=!1}I(()=>e.value.sourceCompanyNo,u=>{E.value=[],e.value.sourceRoleId="",e.value.sourceCompanyNo&&V(e.value.sourceCompanyNo)},{immediate:!0});const k={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 q(){e.value={...g},d.value=!1}async function x(){try{const{sourceCompanyNo:u,sourceRoleId:o}=e.value,{data:l,code:t}=await X({companyNo:u,roleid:o});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 A(u={}){try{const{data:o,code:l}=await Y(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 S(){try{c.value=!0,await h.value.validate();const{sourceCompanyNo:u,sourceRoleId:o,companyNo:l,name:t}=e.value;y.info("\u6B63\u5728\u8BFB\u53D6\u6765\u6E90\u89D2\u8272\u4FE1\u606F(1/3)...");const m=await x();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:b}=m,_={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(N=>!!N)};await A(_),c.value=!1,y.success("\u89D2\u8272\u590D\u5236\u6210\u529F(3/3)..."),R("refresh"),d.value=!1}catch(u){y.warning(u),c.value=!1}}return(u,o)=>{const l=r("ElInput"),t=r("ElFormItem"),m=r("ElOption"),i=r("ElSelect"),p=r("ElButton"),b=r("ElForm"),_=r("ElDialog"),N=z("loading");return v(),F(_,{title:"\u590D\u5236\u89D2\u8272",center:"",modelValue:w(d),"onUpdate:modelValue":o[2]||(o[2]=a=>J(d)?d.value=a:null),onClose:q,"close-on-click-modal":!1,"close-on-press-escape":!1},{default:s(()=>[G((v(),F(b,{model:e.value,rules:k,ref_key:"formRef",ref:h,"label-width":"80px"},{default:s(()=>[n(t,{prop:"name",label:"\u89D2\u8272\u540D\u79F0"},{default:s(()=>[n(l,{modelValue:D.roleName,placeholder:"\u89D2\u8272\u540D\u79F0",disabled:""},null,8,["modelValue"])]),_:1}),n(t,{prop:"sourceCompanyNo",label:"\u6765\u6E90\u516C\u53F8"},{default:s(()=>[n(w(H),{modelValue:e.value.sourceCompanyNo,"onUpdate:modelValue":o[0]||(o[0]=a=>e.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:e.value.sourceRoleId,"onUpdate:modelValue":o[1]||(o[1]=a=>e.value.sourceRoleId=a),style:{width:"100%"},placeholder:"\u6765\u6E90\u89D2\u8272",disabled:!e.value.sourceCompanyNo},{default:s(()=>[(v(!0),P(Q,null,T(E.value,a=>(v(),F(m,{key:a.id,value:a.id,label:a.role_name,disabled:a.id===D.roleId},null,8,["value","label","disabled"]))),128))]),_:1},8,["modelValue","disabled"])]),_:1}),W("div",$,[n(p,{type:"primary",onClick:S},{default:s(()=>[Z("\u4FDD\u5B58")]),_:1})])]),_:1},8,["model"])),[[N,w(c)]])]),_:1},8,["modelValue"])}}});var ae=U(ee,[["__file","C:/Users/89793/Desktop/projects/settle-vue3/src/views/interest/role/role-copy.vue"]]);export{ae as default};
