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