// SYSTEM PANEL //
[ROOT]
/
home
/
csender
/
legus.lawnet.me_backup_20250830-211559
/
assets
[ PARENT ]
EDIT :: Permissions-Bu_NcXnh.js
import{d as G,r as d,c as y,o as J,b as l,e as H,f as e,T as K,S as O,n as L,i as h,h as W,w as A,v as B,k as X,u as j,l as Y,t as i,F,m as P,E as ee,z as n,_ as te}from"./index-BhhcJpm2.js";import{p as S}from"./permissions-BurwELUK.js";const se={class:"min-h-screen bg-[#F4F4F6]",dir:"rtl"},oe={class:"flex pt-16"},re={class:"flex flex-col flex-1 p-6"},ae={class:"bg-white rounded-lg shadow-sm border p-6 mb-4"},le={class:"flex items-center justify-between w-full",dir:"rtl"},ne={class:"flex items-center gap-4"},de={class:"flex-1 flex justify-center"},ie={class:"relative"},ue={class:"flex items-center gap-4"},ce={class:"flex items-center gap-2"},pe={key:0,class:"flex justify-center items-center p-8"},ve={key:1,class:"p-8 text-center"},xe={class:"text-red-500 mb-4"},me={class:"text-sm text-gray-600 mt-1"},ge={key:2,class:"bg-white rounded-lg shadow-sm border flex-1"},be={class:"overflow-x-auto"},fe={class:"w-full border-collapse border border-gray-200"},ye={class:"px-4 py-3 text-sm text-[#54524F] border-r border-gray-200"},he={class:"px-4 py-3 border-r border-gray-200"},we={class:"flex items-center gap-2"},_e={class:"text-sm text-[#DA7E13] font-medium"},ke=["onClick"],Ce={class:"px-4 py-3 text-sm text-[#54524F] border-r border-gray-200"},Ae={class:"px-4 py-3 text-sm text-[#54524F] border-r border-gray-200"},Fe={class:"px-4 py-3 text-sm text-[#54524F] border-r border-gray-200"},Ve={class:"px-4 py-3 border-r border-gray-200"},De={class:"flex items-center gap-1 justify-end",dir:"rtl"},Ee=["onClick"],Me=["onClick"],He=["onClick"],Le={key:3,class:"bg-white rounded-lg shadow-sm border p-12 text-center"},Be={key:4,class:"bg-white rounded-lg shadow-sm border p-4 mt-4"},je={class:"flex items-center justify-center gap-2"},Pe=["disabled"],Se={class:"flex items-center gap-1"},Te=["onClick"],Re={key:1,class:"px-2 text-gray-500"},$e=["disabled"],ze={class:"text-center mt-2 text-sm text-gray-600"},Ne=G({__name:"Permissions",setup(Ze){const w=ee(),T=(s,t)=>{let o;return(...r)=>{clearTimeout(o),o=setTimeout(()=>s.apply(null,r),t)}},v=d(!1),x=d(!1),p=d(""),m=d([]),u=d(""),g=d(""),a=d(1),c=d(15),b=d(0),V=y(()=>{if(!Array.isArray(m.value))return[];let s=m.value;return u.value&&(s=s.filter(t=>t.display_name.toLowerCase().includes(u.value.toLowerCase())||t.name.toLowerCase().includes(u.value.toLowerCase())||(t.description||"").toLowerCase().includes(u.value.toLowerCase()))),g.value&&(s=s.filter(t=>t.guard_name===g.value)),s}),_=y(()=>{const s=V.value;if(!Array.isArray(s))return[];const t=(a.value-1)*c.value,o=t+c.value;return s.slice(t,o)}),f=y(()=>{const s=V.value;return Array.isArray(s)?Math.ceil(s.length/c.value):0}),R=y(()=>{const s=f.value,t=a.value,o=[];if(s<=7)for(let r=1;r<=s;r++)o.push(r);else t<=4?o.push(1,2,3,4,5,"...",s):t>=s-3?o.push(1,"...",s-4,s-3,s-2,s-1,s):o.push(1,"...",t-1,t,t+1,"...",s);return o}),D=()=>{v.value=!v.value},k=async()=>{x.value=!0,p.value="";try{const s=await S.getRoles({page:a.value,per_page:c.value,search:u.value||void 0,guard_name:g.value||void 0});if(s.success&&s.data){let t,o;if(Array.isArray(s.data))t=s.data,o=s.data.length;else{const r=s.data;t=Array.isArray(r.data)?r.data:[],o=r.total||t.length}m.value=t.map(r=>({...r,display_name:r.display_name||r.name||"غير محدد",description:r.description||"",users_count:r.filtered_users_count||0})),b.value=o}else throw m.value=[],b.value=0,new Error(s.message||"فشل في تحميل الصلاحيات")}catch(s){m.value=[],b.value=0,p.value=s.message||"حدث خطأ في تحميل الصلاحيات",console.error("Failed to load roles:",s)}finally{x.value=!1}},E=T(()=>{a.value=1},500),M=()=>{a.value=1},$=()=>{w.push("/office/employees/permissions/add")},z=s=>{w.push(`/office/employees/permissions/${s.id}/view`)},N=s=>{w.push(`/office/employees/permissions/${s.id}/edit`)},Z=async s=>{if(confirm(`هل أنت متأكد من حذف صلاحية "${s.display_name}"؟`))try{const t=await S.deleteRole(s.id);if(t.success)k(),alert("تم حذف الصلاحية بنجاح");else throw new Error(t.message||"فشل في حذف الصلاحية")}catch(t){alert(t.message||"حدث خطأ في حذف الصلاحية"),console.error("Failed to delete role:",t)}},I=async s=>{try{await navigator.clipboard.writeText(s)}catch(t){console.error("Failed to copy text: ",t)}},U=()=>{a.value>1&&a.value--},Q=()=>{a.value<f.value&&a.value++},q=s=>{typeof s=="number"&&s!==a.value&&(a.value=s)};return J(()=>{k()}),(s,t)=>(n(),l("div",se,[H(K,{sidebarCollapsed:v.value,onToggleSidebar:D},null,8,["sidebarCollapsed"]),e("div",oe,[H(O,{isCollapsed:v.value,onToggle:D},null,8,["isCollapsed"]),e("div",{class:L(["flex flex-col flex-1 min-h-full transition-all duration-300",v.value?"mr-16":"mr-64"])},[e("div",re,[e("div",{class:"flex items-center justify-between mb-6"},[t[5]||(t[5]=W('<div class="flex flex-col" data-v-98a19977><h1 class="text-2xl font-bold text-[#273F62] mb-1" data-v-98a19977>الصلاحيات</h1><nav class="text-sm text-[#54524F]" data-v-98a19977><span data-v-98a19977>الرئيسية</span><span class="mx-2" data-v-98a19977>/</span><span data-v-98a19977>إدارة الموظفين</span><span class="mx-2" data-v-98a19977>/</span><span class="text-[#DA7E13]" data-v-98a19977>الصلاحيات</span></nav></div>',1)),e("div",{class:"flex items-center gap-3"},[e("button",{onClick:$,class:"flex items-center gap-2 h-12 px-6 bg-[#DA7E13] text-white font-semibold text-sm rounded-lg hover:bg-[#DA7E13]/90 transition-colors",dir:"rtl"},t[4]||(t[4]=[e("svg",{class:"w-5 h-5 fill-current",viewBox:"0 0 24 24"},[e("path",{d:"M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z"})],-1),e("span",null,"إضافة صلاحية جديدة",-1)]))])]),e("div",ae,[e("div",le,[e("div",ne,[t[7]||(t[7]=e("h2",{class:"text-lg font-semibold text-[#54524F] whitespace-nowrap"},"الصلاحيات",-1)),A(e("select",{"onUpdate:modelValue":t[0]||(t[0]=o=>g.value=o),onChange:M,class:"px-4 py-2 border border-gray-300 rounded text-sm focus:ring-2 focus:ring-[#DA7E13] focus:border-[#DA7E13] bg-white min-w-[140px]"},t[6]||(t[6]=[e("option",{value:""},"جميع الأنواع",-1),e("option",{value:"web"},"ويب",-1),e("option",{value:"api"},"API",-1)]),544),[[B,g.value]])]),e("div",de,[e("div",ie,[A(e("input",{"onUpdate:modelValue":t[1]||(t[1]=o=>u.value=o),onInput:t[2]||(t[2]=(...o)=>j(E)&&j(E)(...o)),type:"text",placeholder:"بحث...",class:"w-80 px-4 py-2 pr-10 border border-gray-300 rounded text-right text-sm focus:ring-2 focus:ring-[#DA7E13] focus:border-[#DA7E13] bg-white"},null,544),[[X,u.value]]),t[8]||(t[8]=e("svg",{class:"absolute right-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})],-1))])]),e("div",ue,[e("div",ce,[t[10]||(t[10]=e("span",{class:"text-sm text-[#54524F]"},"عرض",-1)),A(e("select",{"onUpdate:modelValue":t[3]||(t[3]=o=>c.value=o),onChange:M,class:"px-3 py-2 border border-gray-300 rounded text-sm focus:ring-2 focus:ring-[#DA7E13] focus:border-[#DA7E13] bg-white"},t[9]||(t[9]=[e("option",{value:"15"},"15",-1),e("option",{value:"10"},"10",-1),e("option",{value:"25"},"25",-1),e("option",{value:"50"},"50",-1)]),544),[[B,c.value]])]),t[11]||(t[11]=e("button",{class:"flex items-center gap-2 px-4 py-2 bg-transparent text-[#54524F] text-sm font-medium rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors"},[e("svg",{class:"w-4 h-4 fill-[#DA7E13]",viewBox:"0 0 24 24"},[e("path",{d:"M5,20H19V18H5M19,9H15V3H9V9H5L12,16L19,9Z"})]),Y(" تصدير ")],-1))])])]),x.value?(n(),l("div",pe,t[12]||(t[12]=[e("div",{class:"text-center"},[e("div",{class:"animate-spin rounded-full h-12 w-12 border-b-2 border-[#DA7E13] mx-auto"}),e("p",{class:"mt-2 text-gray-600"},"جاري تحميل الصلاحيات...")],-1)]))):p.value?(n(),l("div",ve,[e("div",xe,[t[13]||(t[13]=e("svg",{class:"w-12 h-12 mx-auto mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})],-1)),t[14]||(t[14]=e("p",{class:"text-lg font-medium"},"خطأ في تحميل الصلاحيات",-1)),e("p",me,i(p.value),1)]),e("button",{onClick:k,class:"px-4 py-2 bg-[#DA7E13] text-white rounded hover:bg-[#DA7E13]/90"}," إعادة المحاولة ")])):h("",!0),!x.value&&!p.value&&_.value.length>0?(n(),l("div",ge,[e("div",be,[e("table",fe,[t[19]||(t[19]=e("thead",{class:"bg-[#F8F9FA]"},[e("tr",{class:"text-right border-b border-gray-200"},[e("th",{class:"px-4 py-3 text-sm font-medium text-[#54524F] border-r border-gray-200"},"#"),e("th",{class:"px-4 py-3 text-sm font-medium text-[#54524F] border-r border-gray-200"},[e("div",{class:"flex items-center justify-end gap-1"},[e("span",null,"اسم الصلاحية"),e("svg",{class:"w-3 h-3 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 9l4-4 4 4m0 6l-4 4-4-4"})])])]),e("th",{class:"px-4 py-3 text-sm font-medium text-[#54524F] border-r border-gray-200"},"نوع الصلاحية"),e("th",{class:"px-4 py-3 text-sm font-medium text-[#54524F] border-r border-gray-200"},"المسمى الوظيفي"),e("th",{class:"px-4 py-3 text-sm font-medium text-[#54524F] border-r border-gray-200"},"عدد المستخدمين"),e("th",{class:"px-4 py-3 text-sm font-medium text-[#54524F] border-r border-gray-200"},"خيارات")])],-1)),e("tbody",null,[(n(!0),l(F,null,P(_.value,(o,r)=>(n(),l("tr",{key:o.id,class:"hover:bg-gray-50 border-b border-gray-200 last:border-b"},[e("td",ye,i(String((a.value-1)*c.value+r+1).padStart(2,"0")),1),e("td",he,[e("div",we,[e("span",_e,i(o.display_name),1),e("button",{class:"text-gray-400 hover:text-[#DA7E13] focus:outline-none focus:ring-0 active:outline-none",onClick:C=>I(o.display_name)},t[15]||(t[15]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})],-1)]),8,ke)])]),e("td",Ce,i(o.guard_name),1),e("td",Ae,i(o.description||"غير محدد"),1),e("td",Fe,i(o.users_count||0),1),e("td",Ve,[e("div",De,[e("button",{onClick:C=>z(o),class:"p-1 text-[#DA7E13] hover:bg-orange-50 rounded",title:"عرض"},t[16]||(t[16]=[e("svg",{class:"w-4 h-4",fill:"currentColor",viewBox:"0 0 24 24"},[e("path",{d:"M12,9A3,3 0 0,0 9,12A3,3 0 0,0 12,15A3,3 0 0,0 15,12A3,3 0 0,0 12,9M12,17A5,5 0 0,1 7,12A5,5 0 0,1 12,7A5,5 0 0,1 17,12A5,5 0 0,1 12,17M12,4.5C7,4.5 2.73,7.61 1,12C2.73,16.39 7,19.5 12,19.5C17,19.5 21.27,16.39 23,12C21.27,7.61 17,4.5 12,4.5Z"})],-1)]),8,Ee),e("button",{onClick:C=>N(o),class:"p-1 text-blue-600 hover:bg-blue-50 rounded",title:"تعديل"},t[17]||(t[17]=[e("svg",{class:"w-4 h-4",fill:"currentColor",viewBox:"0 0 24 24"},[e("path",{d:"M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z"})],-1)]),8,Me),e("button",{onClick:C=>Z(o),class:"p-1 text-red-600 hover:bg-red-50 rounded",title:"حذف"},t[18]||(t[18]=[e("svg",{class:"w-4 h-4",fill:"currentColor",viewBox:"0 0 24 24"},[e("path",{d:"M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z"})],-1)]),8,He)])])]))),128))])])])])):h("",!0),!x.value&&!p.value&&_.value.length===0?(n(),l("div",Le,t[20]||(t[20]=[e("svg",{class:"w-16 h-16 mx-auto mb-4 text-gray-300",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.031 9-11.622 0-1.042-.133-2.052-.382-3.016z"})],-1),e("h3",{class:"text-lg font-medium text-gray-900 mb-2"},"لا توجد صلاحيات",-1),e("p",{class:"text-gray-600 mb-4"},"لا توجد صلاحيات مطابقة لمعايير البحث الخاصة بك",-1)]))):h("",!0),f.value>1?(n(),l("div",Be,[e("div",je,[e("button",{onClick:U,disabled:a.value===1,class:"px-3 py-1 border border-gray-300 rounded text-sm disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-50"}," السابق ",8,Pe),e("div",Se,[(n(!0),l(F,null,P(R.value,o=>(n(),l(F,{key:o},[typeof o=="number"?(n(),l("button",{key:0,onClick:r=>q(o),class:L(["px-3 py-1 rounded text-sm",o===a.value?"bg-[#DA7E13] text-white":"border border-gray-300 hover:bg-gray-50"])},i(o),11,Te)):(n(),l("span",Re,i(o),1))],64))),128))]),e("button",{onClick:Q,disabled:a.value===f.value,class:"px-3 py-1 border border-gray-300 rounded text-sm disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-50"}," التالي ",8,$e)]),e("div",ze," من أصل "+i(b.value)+" صفحة ",1)])):h("",!0)])],2)])]))}}),Qe=te(Ne,[["__scopeId","data-v-98a19977"]]);export{Qe as default};
SAVE
CANCEL