import{d as A,r as o,dS as D,aP as E,o as d,c as F,l as c,w as p,a as i,i as r,j as w,a2 as b,C as B,M as H,F as J,J as V,s as X,L as G,N as K,v as Q,_ as Y,__tla as Z}from"./index-b2b3c6c4.js";import{_ as $,__tla as ee}from"./DictTag-4199ec8d.js";import{d as ae,__tla as te}from"./formatTime-7e07ce72.js";import{P as m,d as le,a as re,g as ie,__tla as se}from"./index-0911c910.js";import ne,{__tla as oe}from"./PermissionForm-5600abcb.js";import{D as ue,__tla as de}from"./dict-7f0cc6d2.js";import{u as pe,__tla as _e}from"./useMessage-a5edbb0f.js";import"./color-6e929987.js";import{__tla as ce}from"./Dialog-70b24cbf.js";import{__tla as me}from"./index-292d166c.js";let C,ve=Promise.all([(()=>{try{return Z}catch{}})(),(()=>{try{return ee}catch{}})(),(()=>{try{return te}catch{}})(),(()=>{try{return se}catch{}})(),(()=>{try{return oe}catch{}})(),(()=>{try{return de}catch{}})(),(()=>{try{return _e}catch{}})(),(()=>{try{return ce}catch{}})(),(()=>{try{return me}catch{}})()]).then(async()=>{C=Y(A({name:"CrmPermissionList",__name:"PermissionList",props:{bizType:{type:Number,required:!0},bizId:{type:null,required:!0},showAction:{type:Boolean,required:!0}},setup(U,{expose:x}){const v=pe(),s=U,I=o(!0),n=o([]),P=o({ownerUserId:0}),f=D(),N=async()=>{I.value=!0;try{const e=await ie({bizType:s.bizType,bizId:s.bizId});n.value=e,n.value.find(a=>a.userId===f.getUser.id&&a.level===m.OWNER)&&(P.value.ownerUserId=f.getUser.id)}finally{I.value=!1}},y=o([]),R=o(),O=e=>{var a;if(e.findIndex(l=>l.level===m.OWNER)!==-1)return v.warning("\u4E0D\u80FD\u9009\u62E9\u8D1F\u8D23\u4EBA\uFF01"),void((a=R.value)==null?void 0:a.clearSelection());y.value=e},z=o(),W=()=>{var a,l,t;if(((a=y.value)==null?void 0:a.length)===0)return void v.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 v.warning("\u8BF7\u5148\u9009\u62E9\u56E2\u961F\u6210\u5458\u540E\u64CD\u4F5C\uFF01");await v.delConfirm();const e=(l=y.value)==null?void 0:l.map(t=>t.id);await le({bizType:s.bizType,bizId:s.bizId,ids:e})},T=()=>{var e;(e=z.value)==null||e.open("create",s.bizType,s.bizId)},u=o(!1),g=o(!1),h=o(!1);E(n,e=>{var a;if(h.value=!1,(e==null?void 0:e.length)>0){h.value=!n.value.some(t=>t.level===m.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===m.OWNER?(u.value=!0,g.value=!0):t.level===m.WRITE&&(g.value=!0)})}else h.value=!0},{immediate:!0}),x({openForm:T,validateOwnerUser:u,validateWrite:g,isPool:h});const S=async()=>{if(n.value.find(a=>a.userId===f.getUser.id&&a.level===m.OWNER))return void v.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 E(()=>s.bizId,e=>{e&&N()},{immediate:!0,deep:!0}),(e,a)=>{const l=Q,t=V,k=X,_=G,j=$,q=K;return d(),F(J,null,[e.showAction?(d(),c(k,{key:0,justify:"end"},{default:p(()=>[i(u)?(d(),c(t,{key:0,type:"primary",onClick:T},{default:p(()=>[r(l,{class:"mr-5px",icon:"ep:plus"}),w(" \u65B0\u589E ")]),_:1})):b("",!0),i(u)?(d(),c(t,{key:1,onClick:W},{default:p(()=>[r(l,{class:"mr-5px",icon:"ep:edit"}),w(" \u7F16\u8F91 ")]),_:1})):b("",!0),i(u)?(d(),c(t,{key:2,onClick:L},{default:p(()=>[r(l,{class:"mr-5px",icon:"ep:delete"}),w(" \u79FB\u9664 ")]),_:1})):b("",!0),!i(u)&&i(n).length>0?(d(),c(t,{key:3,type:"danger",onClick:S},{default:p(()=>[w(" \u9000\u51FA\u56E2\u961F ")]),_:1})):b("",!0)]),_:1})):b("",!0),B((d(),c(i(H),{ref_key:"elTableRef",ref:R,data:i(n),"show-overflow-tooltip":!0,stripe:!0,class:"mt-20px",onSelectionChange:O},{default:p(()=>[r(_,{type:"selection",width:"55"}),r(_,{align:"center",label:"\u59D3\u540D",prop:"nickname"}),r(_,{align:"center",label:"\u90E8\u95E8",prop:"deptName"}),r(_,{align:"center",label:"\u5C97\u4F4D",prop:"postNames"}),r(_,{align:"center",label:"\u6743\u9650\u7EA7\u522B",prop:"level"},{default:p(({row:M})=>[r(j,{type:i(ue).CRM_PERMISSION_LEVEL,value:M.level},null,8,["type","value"])]),_:1}),r(_,{formatter:i(ae),align:"center",label:"\u52A0\u5165\u65F6\u95F4",prop:"createTime"},null,8,["formatter"])]),_:1},8,["data"])),[[q,i(I)]]),r(ne,{ref_key:"formRef",ref:z,onSuccess:N},null,512)],64)}}}),[["__file","/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-admin/src/views/crm/permission/components/PermissionList.vue"]])});export{ve as __tla,C as default};
