import{d as A,r as o,dT as D,aM as N,o as _,c as F,x as c,w as d,a as i,f as r,y as w,a0 as b,z as B,J as G,F as H,G as J,i as K,I as V,K as X,j as Q,_ as Y,__tla as Z}from"./index-8dc1e40a.js";import{_ as $,__tla as ee}from"./DictTag-85aade2b.js";import{d as ae,__tla as te}from"./formatTime-8a155b2e.js";import{P as m,d as le,a as re,g as ie,__tla as se}from"./index-791ea028.js";import ne,{__tla as oe}from"./PermissionForm-40244de8.js";import{D as ue,__tla as _e}from"./dict-f13a3c8f.js";import{u as de,__tla as pe}from"./useMessage-7a27dd80.js";import"./color-6e929987.js";import{__tla as ce}from"./Dialog-41802231.js";import{__tla as me}from"./index-6f284c9a.js";let x,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 pe}catch{}})(),(()=>{try{return ce}catch{}})(),(()=>{try{return me}catch{}})()]).then(async()=>{x=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:C}){const f=de(),s=U,I=o(!0),n=o([]),O=o({ownerUserId:0}),v=D(),T=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})},E=()=>{var e;(e=z.value)==null||e.open("create",s.bizType,s.bizId)},u=o(!1),g=o(!1),h=o(!1);N(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}),C({openForm:E,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 N(()=>s.bizId,e=>{e&&T()},{immediate:!0,deep:!0}),(e,a)=>{const l=Q,t=J,k=K,p=V,j=$,q=X;return _(),F(H,null,[e.showAction?(_(),c(k,{key:0,justify:"end"},{default:d(()=>[i(u)?(_(),c(t,{key:0,type:"primary",onClick:E},{default:d(()=>[r(l,{class:"mr-5px",icon:"ep:plus"}),w(" \u65B0\u589E ")]),_:1})):b("",!0),i(u)?(_(),c(t,{key:1,onClick:W},{default:d(()=>[r(l,{class:"mr-5px",icon:"ep:edit"}),w(" \u7F16\u8F91 ")]),_:1})):b("",!0),i(u)?(_(),c(t,{key:2,onClick:L},{default:d(()=>[r(l,{class:"mr-5px",icon:"ep:delete"}),w(" \u79FB\u9664 ")]),_:1})):b("",!0),!i(u)&&i(n).length>0?(_(),c(t,{key:3,type:"danger",onClick:S},{default:d(()=>[w(" \u9000\u51FA\u56E2\u961F ")]),_:1})):b("",!0)]),_:1})):b("",!0),B((_(),c(i(G),{ref_key:"elTableRef",ref:R,data:i(n),"show-overflow-tooltip":!0,stripe:!0,class:"mt-20px",onSelectionChange:P},{default:d(()=>[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:d(({row:M})=>[r(j,{type:i(ue).CRM_PERMISSION_LEVEL,value:M.level},null,8,["type","value"])]),_:1}),r(p,{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:T},null,512)],64)}}}),[["__file","/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-admin/src/views/crm/permission/components/PermissionList.vue"]])});export{fe as __tla,x as default};
