import{d as F,r as o,d$ as M,w as C,o as d,c as j,A as _,B as c,a as i,f as r,E as w,D as b,k as K,Y as V,F as X,_ as $,K as Q,L as Y,X as Z,Z as q,__tla as G}from"./index-92ad187a.js";import{_ as H,__tla as J}from"./DictTag.vue_vue_type_script_lang-96bcb962.js";import{d as ee,__tla as ae}from"./formatTime-c7f253d6.js";import{g as te,P as v,d as le,a as re,__tla as ie}from"./index-a4b5469a.js";import{_ as se,__tla as ne}from"./PermissionForm.vue_vue_type_script_setup_true_lang-98e85819.js";import{D as oe,__tla as ue}from"./dict-221f3e01.js";import{u as de,__tla as ce}from"./useMessage-d9788660.js";let N,pe=Promise.all([(()=>{try{return G}catch{}})(),(()=>{try{return J}catch{}})(),(()=>{try{return ae}catch{}})(),(()=>{try{return ie}catch{}})(),(()=>{try{return ne}catch{}})(),(()=>{try{return ue}catch{}})(),(()=>{try{return ce}catch{}})()]).then(async()=>{N=F({name:"CrmPermissionList",__name:"PermissionList",props:{bizType:{},bizId:{},showAction:{type:Boolean}},setup(U,{expose:x}){const m=de(),s=U,I=o(!0),n=o([]),O=o({ownerUserId:0}),f=M(),E=async()=>{I.value=!0;try{const e=await te({bizType:s.bizType,bizId:s.bizId});n.value=e,n.value.find(a=>a.userId===f.getUser.id&&a.level===v.OWNER)&&(O.value.ownerUserId=f.getUser.id)}finally{I.value=!1}},y=o([]),T=o(),W=e=>{var a;if(e.findIndex(l=>l.level===v.OWNER)!==-1)return m.warning("\u4E0D\u80FD\u9009\u62E9\u8D1F\u8D23\u4EBA\uFF01"),void((a=T.value)==null?void 0:a.clearSelection());y.value=e},z=o(),P=()=>{var a,l,t;if(((a=y.value)==null?void 0:a.length)===0)return void m.warning("\u8BF7\u5148\u9009\u62E9\u56E2\u961F\u6210\u5458\u540E\u64CD\u4F5C\uFF01");const e=(l=y.value)==null?void 0:l.map(k=>k.id);(t=z.value)==null||t.open("update",s.bizType,s.bizId,e)},L=async()=>{var a,l;if(((a=y.value)==null?void 0:a.length)===0)return void m.warning("\u8BF7\u5148\u9009\u62E9\u56E2\u961F\u6210\u5458\u540E\u64CD\u4F5C\uFF01");await m.delConfirm();const e=(l=y.value)==null?void 0:l.map(t=>t.id);await le({bizType:s.bizType,bizId:s.bizId,ids:e})},R=()=>{var e;(e=z.value)==null||e.open("create",s.bizType,s.bizId)},u=o(!1),g=o(!1),h=o(!1);C(n,e=>{var a;if(h.value=!1,(e==null?void 0:e.length)>0){h.value=!n.value.some(t=>t.level===v.OWNER),u.value=!1,g.value=!1;const l=(a=f.getUser)==null?void 0:a.id;n.value.filter(t=>t.userId===l).forEach(t=>{t.level===v.OWNER?(u.value=!0,g.value=!0):t.level===v.WRITE&&(g.value=!0)})}else h.value=!0},{immediate:!0}),x({openForm:R,validateOwnerUser:u,validateWrite:g,isPool:h});const S=async()=>{if(n.value.find(a=>a.userId===f.getUser.id&&a.level===v.OWNER))return void m.warning("\u8D1F\u8D23\u4EBA\u4E0D\u80FD\u9000\u51FA\u56E2\u961F\uFF01");const e=n.value.find(a=>a.userId===f.getUser.id);e&&await re(e.id)};return C(()=>s.bizId,e=>{e&&E()},{immediate:!0,deep:!0}),(e,a)=>{const l=$,t=Q,k=Y,p=Z,A=H,B=q;return d(),j(X,null,[e.showAction?(d(),_(k,{key:0,justify:"end"},{default:c(()=>[i(u)?(d(),_(t,{key:0,type:"primary",onClick:R},{default:c(()=>[r(l,{class:"mr-5px",icon:"ep:plus"}),w(" \u65B0\u589E ")]),_:1})):b("",!0),i(u)?(d(),_(t,{key:1,onClick:P},{default:c(()=>[r(l,{class:"mr-5px",icon:"ep:edit"}),w(" \u7F16\u8F91 ")]),_:1})):b("",!0),i(u)?(d(),_(t,{key:2,onClick:L},{default:c(()=>[r(l,{class:"mr-5px",icon:"ep:delete"}),w(" \u79FB\u9664 ")]),_:1})):b("",!0),!i(u)&&i(n).length>0?(d(),_(t,{key:3,type:"danger",onClick:S},{default:c(()=>[w(" \u9000\u51FA\u56E2\u961F ")]),_:1})):b("",!0)]),_:1})):b("",!0),K((d(),_(i(V),{ref_key:"elTableRef",ref:T,data:i(n),"show-overflow-tooltip":!0,stripe:!0,class:"mt-20px",onSelectionChange:W},{default:c(()=>[r(p,{type:"selection",width:"55"}),r(p,{align:"center",label:"\u59D3\u540D",prop:"nickname"}),r(p,{align:"center",label:"\u90E8\u95E8",prop:"deptName"}),r(p,{align:"center",label:"\u5C97\u4F4D",prop:"postNames"}),r(p,{align:"center",label:"\u6743\u9650\u7EA7\u522B",prop:"level"},{default:c(({row:D})=>[r(A,{type:i(oe).CRM_PERMISSION_LEVEL,value:D.level},null,8,["type","value"])]),_:1}),r(p,{formatter:i(ee),align:"center",label:"\u52A0\u5165\u65F6\u95F4",prop:"createTime"},null,8,["formatter"])]),_:1},8,["data"])),[[B,i(I)]]),r(se,{ref_key:"formRef",ref:z,onSuccess:E},null,512)],64)}}})});export{N as _,pe as __tla};
