PageSourceSearch

https://tudienav.com/_nuxt/CSGabzn2.js

js tudienav.com collected 2026-10-02 01:49:09 UTC 10,014 bytes, 1 lines download raw bytes

1import{G as re,J as de,g as ue,j as o,o as l,c,a as s,t as r,i as K,v as P,aq as j,k as x,d as N,F as B,r as D,n as E,m as X,z as he,q as u,p as me,x as pe,_ as ve}from"./tzJnjie6.js";import{u as fe,A as G}from"./Bl4xsHaL.js";import{u as _e}from"./BOyzDctL.js";const ge={key:0,class:"perm-loading"},ye={key:1,class:"perm-root"},ke={class:"perm-bar"},be={class:"perm-bar-left"},Ce={width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",style:{color:"#a78bfa","flex-shrink":"0"}},$e={class:"perm-bar-chip"},we={class:"perm-bar-chip green"},Te={class:"perm-search"},Ae={key:0,class:"perm-state"},Se={key:1,class:"perm-state"},xe={key:2,class:"perm-state"},Ne={key:3,class:"perm-scroll"},Be={class:"perm-table"},De={class:"c-feature corner"},Ee={class:"corner-hint"},Le=["title"],Ue=["title"],Fe={class:"sub-id"},ze=["onClick"],Me=["onClick"],Ie={class:"c-feature row-head"},Re={class:"row-head-inner"},qe={class:"move-col"},Oe=["disabled","onClick"],Ve=["disabled","onClick"],Ke={class:"feature-label"},Pe=["onClick"],je=["onClick"],Xe=["checked","disabled","onChange"],Ge={class:"note-modal"},Je={class:"note-head"},He={class:"note-title"},Ye={class:"note-sub"},Ze={class:"note-subid"},Qe={class:"note-body"},We={key:0,class:"note-state"},et={key:1,class:"note-state"},tt={key:2,class:"note-list"},nt={class:"note-item-top"},st={class:"note-date"},ot={class:"note-content"},it={class:"note-actions"},at=["onClick"],lt=["onClick"],ct={class:"note-form"},rt={class:"note-form-actions"},dt=["disabled"],J="admin_feature_order_v1",ut=re({__name:"index",setup(ht){const{getUserToken:b,logoutUser:H}=pe(),{isFullAdmin:Y,fetchPermissions:Z}=fe(),{success:$,error:f}=_e(),_=he().public.apiBase,R=de(),g=u([]),L=u(!1),q=u(!1),m=u(""),w=me(()=>{const t=m.value.trim().toLowerCase();return t?g.value.filter(e=>(e.name||"").toLowerCase().includes(t)||(e.email||"").toLowerCase().includes(t)||(e.phone||"").toLowerCase().includes(t)||String(e.id).includes(t)||(e.public_id||"").toLowerCase().includes(t)):g.value}),C=u(new Set),T=u(!1),p=u(null),U=u([]),F=u(!1),v=u(""),A=u(!1),h=u(null),d=u([...G]);function Q(){try{const t=localStorage.getItem(J);if(!t)return;const e=JSON.parse(t),n=new Map(G.map(a=>[a.key,a])),i=[];for(const a of e){const k=n.get(a);k&&(i.push(k),n.delete(a))}for(const a of n.values())i.push(a);d.value=i}catch{}}function W(){try{localStorage.setItem(J,JSON.stringify(d.value.map(t=>t.key)))}catch{}}function O(t,e){const n=t+e;if(n<0||n>=d.value.length)return;const i=d.value.slice();[i[t],i[n]]=[i[n],i[t]],d.value=i,W()}async function ee(){L.value=!0;try{const t=b(),e=await $fetch(`${_}/admin/sub-admin-permissions`,{headers:{Authorization:`Bearer ${t}`}});g.value=e.sub_admins||[]}catch{f("Không tải được danh sách phân quyền")}finally{L.value=!1}}ue(async()=>{if(Q(),await Z(),!Y.value){R.replace("/admin");return}q.value=!0,await ee()});function te(){H(),R.push("/login")}function y(t,e){return t.permissions.includes(e)}function z(t,e){return`${t}:${e}`}async function S(t,e){const n=!y(t,e),i=z(t.id,e);if(!C.value.has(i)){C.value.add(i),n?t.permissions.includes(e)||t.permissions.push(e):t.permissions=t.permissions.filter(a=>a!==e);try{const a=b();await $fetch(`${_}/admin/sub-admin-permissions`,{method:"POST",headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json"},body:{account_id:t.id,feature_key:e,enabled:n}})}catch{n?t.permissions=t.permissions.filter(a=>a!==e):t.permissions.includes(e)||t.permissions.push(e),f("Lưu thất bại, thử lại")}finally{C.value.delete(i)}}}async function ne(t){const e=t.permissions.length<d.value.length;for(const n of d.value)y(t,n.key)!==e&&await S(t,n.key);$(e?`Đã bật tất cả cho ${t.name}`:`Đã tắt tất cả cho ${t.name}`)}async function se(t){const e=w.value,n=e.some(i=>!y(i,t));for(const i of e)y(i,t)!==n&&await S(i,t)}function M(t){return t.permissions.filter(e=>d.value.some(n=>n.key===e)).length}async function oe(t){p.value=t,T.value=!0,v.value="",h.value=null,await I()}async function I(){if(p.value){F.value=!0;try{const t=b(),e=await $fetch(`${_}/admin/sub-admin-notes/${p.value.id}`,{headers:{Authorization:`Bearer ${t}`}});U.value=e.notes||[]}catch{f("Không tải được ghi chú")}finally{F.value=!1}}}async function ie(){if(!p.value)return;const t=v.value.trim();if(!t){f("Nhập nội dung ghi chú");return}A.value=!0;try{const e=b();h.value?(await $fetch(`${_}/admin/sub-admin-notes/${h.value}`,{method:"PUT",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:{content:t}}),$("Đã cập nhật ghi chú")):(await $fetch(`${_}/admin/sub-admin-notes/${p.value.id}`,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:{content:t}}),$("Đã thêm ghi chú")),v.value="",h.value=null,await I()}catch{f("Lưu ghi chú thất bại")}finally{A.value=!1}}function ae(t){h.value=t.id,v.value=t.content}function V(){h.value=null,v.value=""}async function le(t){if(confirm("Xoá ghi chú này?"))try{const e=b();await $fetch(`${_}/admin/sub-admin-notes/${t.id}`,{method:"DELETE",headers:{Authorization:`Bearer ${e}`}}),h.value===t.id&&V(),$("Đã xoá ghi chú"),await I()}catch{f("Xoá thất bại")}}function ce(t){if(!t)return"—";const e=/[zZ]|[+-]\d{2}:?\d{2}$/.test(t)?t:t+"Z",n=new Date(e);if(isNaN(n.getTime()))return"—";const i=new Date(n.getTime()+420*60*1e3),a=k=>String(k).padStart(2,"0");return`${a(i.getUTCDate())}/${a(i.getUTCMonth()+1)}/${i.getUTCFullYear()}`}return(t,e)=>o(q)?(l(),c("div",ye,[s("header",ke,[s("div",be,[(l(),c("svg",Ce,[...e[6]||(e[6]=[s("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2"},null,-1),s("path",{d:"M7 11V7a5 5 0 0110 0v4"},null,-1)])])),e[8]||(e[8]=s("span",{class:"perm-bar-title"},"Phân quyền Sub-admin",-1)),s("span",$e,r(o(g).length)+" sub-admin",1),s("span",we,r(o(d).length)+" tính năng",1),s("div",Te,[e[7]||(e[7]=s("svg",{class:"perm-search-icon",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[s("circle",{cx:"11",cy:"11",r:"7"}),s("path",{d:"M21 21l-4.3-4.3"})],-1)),K(s("input",{"onUpdate:modelValue":e[0]||(e[0]=n=>j(m)?m.value=n:null),type:"text",placeholder:"Tên, email, SĐT, ID...",class:"perm-search-input"},null,512),[[P,o(m)]]),o(m)?(l(),c("button",{key:0,class:"perm-search-clear",title:"Xoá tìm kiếm",onClick:e[1]||(e[1]=n=>m.value="")},"✕")):x("",!0)])]),s("div",{class:"perm-bar-right"},[e[9]||(e[9]=s("a",{href:"/admin",class:"perm-bar-btn"},"← Về Admin",-1)),s("button",{class:"perm-bar-btn perm-bar-logout",onClick:te},"Đăng xuất")])]),o(L)?(l(),c("div",Ae,"Đang tải dữ liệu...")):o(g).length===0?(l(),c("div",Se,[...e[10]||(e[10]=[N(" Chưa có sub-admin nào. Hãy gán quyền Sub-Admin cho user ở trang ",-1),s("a",{href:"/admin/users",target:"_blank",class:"perm-link"},"Quản lý Users",-1),N(". ",-1)])])):o(m)&&!o(w).length?(l(),c("div",xe," Không tìm thấy sub-admin khớp “"+r(o(m))+"”. ",1)):(l(),c("div",Ne,[s("table",Be,[s("thead",null,[s("tr",null,[s("th",De,[e[11
1]||(e[11]=s("div",{class:"corner-title"},"Tính năng",-1)),s("div",Ee,r(o(g).length)+" sub-admin · "+r(o(d).length)+" mục",1)]),(l(!0),c(B,null,D(o(w),n=>(l(),c("th",{key:n.id,class:"c-sub"},[s("div",{class:"sub-name",title:n.email||""},r(n.name),9,Le),n.email?(l(),c("div",{key:0,class:"sub-email",title:n.email},r(n.email),9,Ue)):x("",!0),s("div",Fe,[N(" ID: "+r(n.public_id||n.id)+" ",1),s("button",{class:"sub-note-icon",onClick:i=>oe(n),title:"Ghi chú"},"📝",8,ze)]),s("div",{class:E(["sub-count",{full:M(n)===o(d).length,zero:M(n)===0}])},r(M(n))+"/"+r(o(d).length),3),s("button",{class:"sub-all-btn",onClick:i=>ne(n)},r(n.permissions.length<o(d).length?"Bật tất cả":"Tắt tất cả"),9,Me)]))),128))])]),s("tbody",null,[(l(!0),c(B,null,D(o(d),(n,i)=>(l(),c("tr",{key:n.key,class:E({alt:i%2===1})},[s("th",Ie,[s("div",Re,[s("div",qe,[s("button",{class:"move-btn",disabled:i===0,title:"Di chuyển lên",onClick:a=>O(i,-1)},"▲",8,Oe),s("button",{class:"move-btn",disabled:i===o(d).length-1,title:"Di chuyển xuống",onClick:a=>O(i,1)},"▼",8,Ve)]),s("span",Ke,r(n.label),1),s("button",{class:"row-all-btn",title:"Áp dụng cho tất cả sub-admin",onClick:a=>se(n.key)},"⇆",8,Pe)])]),(l(!0),c(B,null,D(o(w),a=>(l(),c("td",{key:a.id,class:E(["cell",{on:y(a,n.key),saving:o(C).has(z(a.id,n.key))}]),onClick:k=>S(a,n.key)},[s("label",{class:"switch",onClick:e[2]||(e[2]=X(()=>{},["stop"]))},[s("input",{type:"checkbox",checked:y(a,n.key),disabled:o(C).has(z(a.id,n.key)),onChange:k=>S(a,n.key)},null,40,Xe),e[12]||(e[12]=s("span",{class:"slider"},null,-1))])],10,je))),128))],2))),128))])])])),o(T)?(l(),c("div",{key:4,class:"note-overlay",onClick:e[5]||(e[5]=X(n=>T.value=!1,["self"]))},[s("div",Ge,[s("div",Je,[s("div",He,[e[13]||(e[13]=N(" 📝 Ghi chú — ",-1)),s("span",Ye,r(o(p)?.name),1),s("span",Ze,"(ID: "+r(o(p)?.public_id||o(p)?.id)+")",1)]),s("button",{class:"note-close",onClick:e[3]||(e[3]=n=>T.value=!1)},"✕")]),s("div",Qe,[o(F)?(l(),c("div",We,"Đang tải...")):o(U).length?(l(),c("ul",tt,[(l(!0),c(B,null,D(o(U),n=>(l(),c("li",{key:n.id,class:E(["note-item",{editing:o(h)===n.id}])},[s("div",nt,[s("span",st,r(ce(n.created_at)),1),s("span",ot,r(n.content),1)]),s("div",it,[s("button",{class:"note-edit",onClick:i=>ae(n)},"Sửa",8,at),s("button",{class:"note-del",onClick:i=>le(n)},"Xoá",8,lt)])],2))),128))])):(l(),c("div",et,"Chưa có ghi chú nào."))]),s("div",ct,[K(s("textarea",{"onUpdate:modelValue":e[4]||(e[4]=n=>j(v)?v.value=n:null),rows:"2",placeholder:"Thêm ghi chú mới...",class:"note-input"},null,512),[[P,o(v)]]),s("div",rt,[o(h)?(l(),c("button",{key:0,class:"note-cancel",onClick:V},"Huỷ sửa")):x("",!0),s("button",{class:"note-add",disabled:o(A),onClick:ie},r(o(A)?"Đang lưu...":o(h)?"Cập nhật":"+ Thêm"),9,dt)])])])])):x("",!0)])):(l(),c("div",ge,"Đang kiểm tra quyền truy cập..."))}}),_t=ve(ut,[["__scopeId","data-v-50fc333c"]]);export{_t as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.