????
Current Path : C:/inetpub/vhost/tracnghiem.gdtsolutions.vn/wwwroot/assets/ |
Current File : C:/inetpub/vhost/tracnghiem.gdtsolutions.vn/wwwroot/assets/index-c8cef105.js |
import{p as u,g as ee,a as te,s as _,b as c,u as ne,e as se,_ as A,j as e,f as le,h as ae,aw as R,l as re,a4 as ie,aD as T,br as L,bu as oe,F as v,I as S,bv as I,bw as O,P as ce,al as y,T as de,E as he,bx as ue,bs as pe,bt as fe}from"./index-9bcd78a9.js";import{S as me,m as E,w as xe,b as C,d as H,a as B}from"./NumberFormat-694550a2.js";import{D as ge}from"./DataTable-63f87428.js";import{c as be,T as je,a as ye,C as q}from"./TreeView-f2bb0588.js";import{c as Ce}from"./reactstrap.modern-0a8c2eab.js";import{C as G}from"./Checkbox-60209323.js";import{C as k}from"./Chip-76b2389c.js";import{T as ve,a as Se,b as $,c as w,d as ke}from"./TableRow-55190f90.js";import{T as Te,a as we}from"./Tabs-59094e22.js";import{T as z}from"./Tooltip-4d2e5457.js";import{S as Ee}from"./Skeleton-16a64d4f.js";import"./tiny-warning.esm-d265c1d1.js";import"./DialogTitle-762ac824.js";import"./FormGroup-c4ebc22e.js";import"./Toolbar-d5f2ec66.js";import"./AppBar-a2b92a6e.js";import"./TablePagination-014b81e1.js";import"./KeyboardArrowRight-930a3b01.js";import"./MenuItem-3ea292e1.js";import"./listItemIconClasses-873dc6a3.js";import"./Collapse-d6305a4f.js";import"./unsupportedProp-e368368f.js";import"./popper-578b62a7.js";import"./warning-d8cd23a0.js";import"./SwitchBase-f2562236.js";import"./Popper-151dcaf9.js";const K=be();K.propTypes={children:u.node,classes:u.object,component:u.elementType,disableGutters:u.bool,fixed:u.bool,maxWidth:u.oneOfType([u.oneOf(["xs","sm","md","lg","xl",!1]),u.string]),sx:u.oneOfType([u.arrayOf(u.oneOfType([u.func,u.object,u.bool])),u.func,u.object])};const U=K;function Me(t){return ee("MuiTableContainer",t)}te("MuiTableContainer",["root"]);const Ie=["className","component"],Re=t=>{const{classes:n}=t;return ae({root:["root"]},Me,n)},qe=_("div",{name:"MuiTableContainer",slot:"Root",overridesResolver:(t,n)=>n.root})({width:"100%",overflowX:"auto"}),V=c.forwardRef(function(n,l){const s=ne({props:n,name:"MuiTableContainer"}),{className:r,component:i="div"}=s,h=se(s,Ie),a=A({},s,{component:i}),f=Re(a);return e.jsx(qe,A({ref:l,as:i,className:le(f.root,r),ownerState:a},h))});V.propTypes={children:u.node,classes:u.object,className:u.string,component:u.elementType,sx:u.oneOfType([u.arrayOf(u.oneOfType([u.func,u.object,u.bool])),u.func,u.object])};const Ne=V,Ae={SA:"ADMIN"},Le=[{value:"SA",label:"Quản trị"}],$e=[{field:"id",dataID:!0,type:"numeric",hidden:!0},{title:"Tên vai trò",field:"name",type:"string",dataCheck:!0,searchable:!0},{title:"Web đơn vị",field:"normalizedName",type:"boolean",sorting:!1},{title:"Nhóm",field:"code",type:"string",dataCheck:!0,searchable:!0,render:({code:t})=>Ae[t],editComponent:t=>e.jsx(me,{valueRef:"value",labelRef:"label",options:Le,value:t.value,onChange:n=>n?t.onChange(n.value):t.onChange(null)})},{title:"Gốc",field:"concurrencyStamp",type:"boolean",editable:"never",hidden:!0}];function ze(t){return e.jsx(R,{fontSize:"inherit",...t,color:"secondary",children:e.jsx("path",{d:"M22.047 22.074v0 0-20.147 0h-20.12v0 20.147 0h20.12zM22.047 24h-20.12q-.803 0-1.365-.562t-.562-1.365v-20.147q0-.776.562-1.351t1.365-.575h20.147q.776 0 1.351.575t.575 1.351v20.147q0 .803-.575 1.365t-1.378.562v0zM17.873 11.023h-11.826q-.375 0-.669.281t-.294.682v0q0 .401.294 .682t.669.281h11.826q.375 0 .669-.281t.294-.682v0q0-.401-.294-.682t-.669-.281z"})})}function De(t){return e.jsx(R,{fontSize:"inherit",...t,color:"primary",children:e.jsx("path",{d:"M22.047 22.074v0 0-20.147 0h-20.12v0 20.147 0h20.12zM22.047 24h-20.12q-.803 0-1.365-.562t-.562-1.365v-20.147q0-.776.562-1.351t1.365-.575h20.147q.776 0 1.351.575t.575 1.351v20.147q0 .803-.575 1.365t-1.378.562v0zM17.873 12.977h-4.923v4.896q0 .401-.281.682t-.682.281v0q-.375 0-.669-.281t-.294-.682v-4.896h-4.923q-.401 0-.682-.294t-.281-.669v0q0-.401.281-.682t.682-.281h4.923v-4.896q0-.401.294-.682t.669-.281v0q.401 0 .682.281t.281.682v4.896h4.923q.401 0 .682.281t.281.682v0q0 .375-.281.669t-.682.294z"})})}function We(t){return e.jsx(R,{className:"tree-close",fontSize:"inherit",...t,color:"disabled",children:e.jsx("path",{d:"M17.485 17.512q-.281.281-.682.281t-.696-.268l-4.12-4.147-4.12 4.147q-.294.268-.696.268t-.682-.281-.281-.682.294-.669l4.12-4.147-4.12-4.147q-.294-.268-.294-.669t.281-.682.682-.281.696 .268l4.12 4.147 4.12-4.147q.294-.268.696-.268t.682.281 .281.669-.294.682l-4.12 4.147 4.12 4.147q.294.268 .294.669t-.281.682zM22.047 22.074v0 0-20.147 0h-20.12v0 20.147 0h20.12zM22.047 24h-20.12q-.803 0-1.365-.562t-.562-1.365v-20.147q0-.776.562-1.351t1.365-.575h20.147q.776 0 1.351.575t.575 1.351v20.147q0 .803-.575 1.365t-1.378.562v0z"})})}const Pe=E({root:{flexGrow:1,padding:"1px"}}),F=(t,n,l)=>{n&&n.forEach(s=>{s.children&&s.children.length>0&&(s[t]&&l.push(s[t]),F(t,s.children,l))})},D=(t,n,l)=>{if(n){let s=[];return F(t,n,s),s}return[""]};function _e(t){const n=Pe(),{children:l,nameId:s,data:r,expandAll:i,onNodeToggle:h,expanded:a,selected:f,onNodeSelect:x,disableSelection:p=!0,multiSelect:d=!0}=t;return e.jsx(je,{multiSelect:d,disableSelection:p,className:n.root,defaultCollapseIcon:e.jsx(ze,{}),defaultExpandIcon:e.jsx(De,{}),defaultEndIcon:e.jsx(We,{}),onNodeToggle:h,onNodeSelect:x,selected:f,expanded:a||D(s,r),defaultExpanded:i&&D(s,r),children:l})}const Oe=xe(t=>({iconContainer:{"& .tree-close":{opacity:.3}},group:{marginLeft:12,paddingLeft:12,borderLeft:`1px dashed ${re(t.palette.text.primary,.4)}`}}))(t=>e.jsx(ye,{...t}));function Q(t){const{children:n,nodeId:l,title:s,icon:r,data:i,renderAfter:h,checkable:a,checked:f,onCheck:x,onSelection:p,disabled:d,classIcon:b}=t,[o,g]=c.useState(!1);return c.useEffect(()=>{a&&g(f)},[a,f]),e.jsx(Oe,{nodeId:l,label:e.jsxs("div",{style:{marginRight:"5px",display:"flex",padding:"4px 0px",alignItems:"center"},onClick:m=>p&&p(m,i),children:[a&&e.jsx(G,{disabled:d,checked:o,color:"primary",onChange:m=>{let j=!o;g(j),x&&x(m,j,i)}}),e.jsxs("div",{style:{marginRight:"5px",display:"flex",padding:"4px 0px",alignItems:"center"},children:[e.jsx("i",{className:Ce("mr-2",r,b)}),e.jsx("span",{style:{fontSize:"0.875rem",fontWeight:"400",lineHeight:"1.43",letterSpacing:"0.01071em"},children:s})]}),h]}),children:n})}function X(t,n){const l=[];return t.forEach(s=>{if(s.parentId===n){const r=X(t,s.id);r.length&&(s.children=r),l.push(s)}}),l}const He=t=>{const{show:n,children:l}=t;return e.jsxs(U,{children:[l,n&&e.jsx(T,{})]})},Be=t=>{const n=[];return t.forEach((l,s,r)=>{if(!l.parentId){const i={...l};if(r.filter(a=>a.parentId===l.id).length!==0){const a=X(t,l.id);i.children=a}n.push(i)}}),n},Ge=ie.forwardRef((t,n)=>{const{role:l,checkedKeys:s,typeModal:r}=t,[i,h]=c.useState(!0),[a,f]=c.useState([]),[x,p]=c.useState(s||null),[d,b]=c.useState(["null"]),o=m=>m==="ADMIN"?L.getMenuTree():m==="USER"?L.getMenuTree():Promise.resolve(null);c.useEffect(()=>{l&&o(r).then(m=>{const j=Be(m.value);f(j)}).catch(()=>C("Không thể load dữ liệu !")).finally(()=>h(!1))},[l,r]),c.useEffect(()=>{p(s)},[s]),c.useImperativeHandle(n,()=>({getAllChecked:()=>x}));const g=(m,j)=>{m.persist(),m.target.closest(".MuiTreeItem-iconContainer")&&b(j)};return e.jsx(He,{show:i,children:a&&a.length!==0&&s&&e.jsx(_e,{nameId:"id",expanded:d,expandAll:!0,data:[{id:"null",children:a}],onNodeToggle:g,children:e.jsx(Q,{nodeId:"null",icon:"fa-home",title:`WEB ${r}`,path:"/",children:J(a,x,p)})})})}),J=(t,n,l)=>t&&t.map((s,r)=>e.jsx(Q,{nodeId:s.id,icon:s.icon,title:s.label,checkable:!0,checked:n.includes(s.id),onCheck:(i,h)=>{n.includes(s.id)?h===!1&&(n=n.filter(a=>a!==s.id)):h===!0&&n.push(s.id),l(n)},children:s.children&&J(s.children,n,l)},`${r}${s.id}`)),Ke=t=>{const{show:n,children:l}=t;return e.jsxs(U,{children:[l,n&&e.jsx(T,{})]})},Ue=t=>{const n=c.useRef(null),{isOpen:l,typeModal:s,toggle:r,role:i}=t,[h,a]=c.useState(!1),[f,x]=c.useState(null),p=(o,g,m)=>{if(g==="ADMIN")return m===void 0?I.getMenuWithIDRole(o.id):I.setAllMenuAdministrationWithRole(m);throw new Error("Lỗi")},d=c.useCallback(async(o,g,m)=>{const j=m?oe.get(g):g,{value:[M]}=await j(),{menus:N}=M;return M["menu.@odata.nextLink"]?d(o,N["menu.@odata.nextLink"],!0):[...o,...N]},[]);c.useEffect(()=>{l===!0&&i&&i.id&&(a(!0),d([],()=>p(i,s)).then(o=>{if(o){let g=[];o.forEach(m=>g.push(m.id)),x(g)}}).catch(o=>C("Không tìm thấy vai trò !")).finally(()=>a(!1)))},[d,l,i,s]);const b=()=>{const o=n.current&&n.current.getAllChecked();let g={Role_ID:i.id,Menus_ID:[...o]};p(i,s,g).then(()=>B("Lưu thành công !")).catch(()=>C("Lưu không thành công !"))};return e.jsx(H,{open:l,handleClose:r,title:`Chọn các Menu trong WEB ${s} để hiển thị cho vai trò '${i&&i.name}'`,renderFooter:e.jsxs("div",{className:"btn-list",children:[e.jsx(v,{onClick:b,disabled:h,children:e.jsx(S,{sx:{color:"green"},children:"save"})})," ",e.jsx(v,{onClick:r,disabled:h,children:e.jsx(S,{sx:{color:"darkgray"},children:"cancel"})})]}),children:e.jsx(Ke,{show:h,children:f&&e.jsx(Ge,{ref:n,role:i,checkedKeys:f,typeModal:s})})})},W=t=>{const{checked:n,onChange:l}=t,[s,r]=c.useState(!1);return c.useEffect(()=>{r(n)},[n]),e.jsx(G,{checked:s,onChange:i=>{r(i.target.checked),l(i.target.checked)}})},Ve=({method:t})=>t==="GET"?e.jsx(k,{label:t,size:"small",style:{backgroundColor:"#61affe",color:"white",width:70,marginLeft:"1rem"}}):t==="POST"?e.jsx(k,{label:t,size:"small",style:{backgroundColor:"#49cc90",color:"white",width:70,marginLeft:"1rem"}}):t==="PUT"?e.jsx(k,{label:t,size:"small",style:{backgroundColor:"#fca130",color:"white",width:70,marginLeft:"1rem"}}):t==="DELETE"?e.jsx(k,{label:t,size:"small",style:{backgroundColor:"#f93e3e",color:"white",width:70,marginLeft:"1rem"}}):t==="PATCH"?e.jsx(k,{label:t,size:"small",style:{backgroundColor:"#fab005",color:"white",width:70,marginLeft:"1rem"}}):e.jsx(e.Fragment,{}),Fe=t=>{const{show:n,children:l}=t;return e.jsxs(q,{children:[l,n&&e.jsx(T,{})]})},P=(t,n)=>[{id:"Summary",label:`Danh sách các quyền của nhóm '${t.mota}' - Tổng:${n||""} `,style:{width:700}}],Qe=E({root:{width:"100%"},container:{height:420},tableHead:{fontWeight:"bold",width:"25rem",padding:"1rem"}}),Xe=c.forwardRef((t,n)=>{const{value:l,index:s,group:r,checks:i}=t,h=Qe(),[a,f]=c.useState(null),[x,p]=c.useState(!1),[d,b]=c.useState(null);return c.useEffect(()=>(l===s&&i&&(b(i),p(!0),O.findAllEndpointByGroupName(r.controller).then(o=>{f(o.value)}).catch(()=>C("Không tìm thấy vai trò !")).finally(()=>p(!1))),()=>{f(null),b(null)}),[r,l,s,i]),c.useImperativeHandle(n,()=>({getListChecked:()=>d})),e.jsx(Fe,{show:x,children:e.jsx(ce,{className:h.root,children:e.jsx(Ne,{className:h.container,children:e.jsxs(ve,{stickyHeader:!0,"aria-label":"sticky table",size:"small",children:[e.jsx(Se,{className:h.tableHead,children:e.jsxs($,{children:[P(r,a&&a.length).map(o=>e.jsx(w,{className:h.tableHead,align:o.align,style:{minWidth:o.minWidth},children:o.label},o.id)),e.jsx(w,{align:"center",children:a&&e.jsx(W,{checked:d?a.length===d.length:!1,onChange:o=>b(o===!0?[...a.map(g=>g.id)]:[])})})]})}),e.jsx(ke,{children:a&&a.map((o,g)=>o.summary&&e.jsxs($,{hover:!0,role:"checkbox",tabIndex:-1,children:[P(r,a.length).map(m=>e.jsx(w,{align:m.align,style:m.style,children:e.jsxs(y,{container:!0,spacing:1,children:[e.jsx(y,{xs:4,children:e.jsx(Ve,{method:o.method})}),e.jsx(y,{xs:8,children:e.jsxs("div",{children:[e.jsx("div",{style:{textTransform:"capitalize",fontWeight:"bold"},children:o.summary}),e.jsx("small",{children:o.pathTemplate})]})})]})},m.id)),e.jsx(w,{align:"center",style:{width:10},children:e.jsx(W,{checked:d?d.includes(o.id):!1,onChange:m=>b(m===!0?[...d,o.id]:[...d.filter(j=>j!==o.id)])})})]},g))})]})})})})}),Y=t=>{const{children:n,width:l,...s}=t,i=E(h=>({tabs:{width:l,borderRight:`1px solid ${h.palette.divider}`}}))();return e.jsx(Te,{variant:"scrollable","aria-label":"Vertical",className:i.tabs,...s,children:n})};Y.defaultProps={orientation:"vertical"};function Z(t){const{children:n,value:l,index:s,...r}=t;return e.jsx(de,{component:"div",role:"tabpanel",hidden:l!==s,id:`vertical-tabpanel-${s}`,"aria-labelledby":`vertical-tab-${s}`,...r,children:l===s&&e.jsx(he,{p:3,children:n})})}Z.propTypes={children:u.node,index:u.any.isRequired,value:u.any.isRequired};function Je(t){return{id:`vertical-tab-${t}`,"aria-controls":`vertical-tabpanel-${t}`}}const Ye=t=>{const{children:n,tabs:l,height:s,tabWidth:r,...i}=t,a=E(f=>({root:{height:s,flexGrow:1,backgroundColor:f.palette.background.paper,display:"flex"},tab:{maxWidth:"inherit",fontWeight:"Bold",alignItems:"left",borderBottom:"1px solid beige"}}))();return e.jsxs("div",{className:a.root,children:[e.jsx(Y,{width:r,...i,children:l.map((f,x)=>e.jsx(we,{className:a.tab,label:f.label,...Je(f.index)},x))}),n]})},Ze=t=>{const{show:n,children:l}=t;return e.jsxs(q,{children:[l,n&&e.jsx(T,{})]})},et=t=>{const{value:n,index:l,group:s,role:r}=t,i=c.useRef(null),[h,a]=c.useState(!1),[f,x]=c.useState(null);c.useEffect(()=>(r&&n===l&&(a(!0),ue.getEndpointWithIDRole(r.id,s.controller).then(d=>{const b=[];d.value.length>0&&d.value.forEach(o=>b.push(o.endpointId)),x(b)}).catch(d=>C(d)).finally(()=>a(!1))),()=>{x(null)}),[r,n,l,s]);const p=()=>{const d=i.current&&i.current.getListChecked();if(d){let b={role_ID:r.id,endpoints_ID:[...d],controller:s.controller,server:s.server};I.saveAllWithRoleAndGroupName(b).then(({message:o})=>B(o)).catch(()=>C("Lưu không thành công !"))}};return e.jsx(Z,{value:n,index:l,children:e.jsxs(y,{container:!0,spacing:2,children:[e.jsx(y,{xs:11,children:n===l&&e.jsx(Ze,{show:h,children:e.jsx(Xe,{ref:i,value:n,index:l,group:s,checks:f||null})})}),e.jsxs(y,{xs:!0,children:[h?e.jsx(v,{color:"primary",disabled:!0,children:e.jsx(S,{children:"save"})}):e.jsx(z,{title:"Lưu sự thay đổi",children:e.jsx(v,{color:"primary",onClick:()=>p(),children:e.jsx(S,{children:"save"})})}),h?e.jsx(v,{color:"secondary",disabled:!0,children:e.jsx(S,{children:"rotate_left"})}):e.jsx(z,{title:"Reset tất cả",children:e.jsx(v,{color:"secondary",children:e.jsx(S,{children:"rotate_left"})})})]})]})})},tt=t=>{const{show:n,children:l}=t;return e.jsxs(q,{children:[l,n&&e.jsx(T,{})]})},nt=t=>{const{isOpen:n,toggle:l,role:s}=t,[r,i]=c.useState(0),[h,a]=c.useState(!1),[f,x]=c.useState(null);return c.useEffect(()=>{n===!0&&s&&(a(!0),O.findAllGroupName().then(({resultObj:p})=>{x(p)}).catch(p=>C("Đã xãy ra lỗi !")).finally(()=>a(!1)))},[n,s]),e.jsx(H,{maxWidth:"lg",open:n,handleClose:()=>{l(),i(0),x(null)},title:`Cài đặt quyền cho vai trò '${s&&s.name}'`,children:f?e.jsx(tt,{show:h,children:e.jsx(Ye,{height:500,tabWidth:400,value:r,onChange:(p,d)=>{i(d)},tabs:f.map((p,d)=>({...p,index:d,label:`${p.mota}`})),children:f.map((p,d)=>e.jsx(et,{value:r,index:d,group:p,role:s},d))})}):e.jsx(Ee,{variant:"rectangular",height:500})})},st=_("div")(({theme:t})=>({margin:"30px",[t.breakpoints.down("sm")]:{margin:"16px"}}));function lt(t){if((t==null?void 0:t.role)==="ADMIN")return{backgroundColor:"rgb(177, 245, 186)"}}const qt=()=>{const[t,n]=c.useState(!1),[l,s]=c.useState(!1),[r,i]=c.useState(""),[h,a]=c.useState(null),f=c.createRef(),x=pe();return e.jsx(fe,{theme:x,children:e.jsx(st,{className:"analytics",children:e.jsx(y,{container:!0,spacing:1,children:e.jsxs(y,{item:!0,lg:12,md:12,sm:12,xs:12,children:[e.jsx(ge,{isAuth:!0,tableRef:f,noOdata:!0,url:"/admin/allow/Roles",title:"Danh sách vai trò tài khoản",columns:$e,selectType:"withColumns",onAdd:{defaultValues:[{field:"normalizedName",isSame:"name"}]},onEdit:{},onDelete:{},onActions:[p=>({icon:"fab fa-bars",color:"rgb(230, 109, 204)",typeFont:"fontawesome",tooltip:"Cấu hình hiển thị Menu",disabled:p&&p.enableAdmin===!1,onClick:(d,b)=>{a(b),n(!0),i("ADMIN")}})],rowStyle:p=>lt(p),onRowClick:(p,d)=>{a(d),s(!0)}}),e.jsx(Ue,{typeModal:r,isOpen:t,role:h,toggle:()=>{n(!t),a(null)}}),e.jsx(nt,{isOpen:l,role:h,toggle:()=>{s(!l),a(null)}})]})})})})};export{qt as default};