unis_crm/frontend1/dist/assets/index-MAV1etLv.js

2 lines
5.1 KiB
JavaScript
Raw Normal View History

2026-04-13 01:35:05 +00:00
import{u as H,r as a,j as e,B as O,x as F,H as J,z as N,a6 as Y,J as W,aE as Z,T as q,C as G,Z as Q,aj as U,aa as V,s as C,ak as X}from"./index-D2cxrzyv.js";import{P as ee}from"./index-DICUnuN_.js";import{R as se,C as v}from"./row-C5EMotZ4.js";import{C as T}from"./index-BFDbUxK1.js";import{I as te}from"./index-4zw5l6IX.js";import{F as re,T as ae}from"./Table-BLvbgkX9.js";import{T as y}from"./index-C8Xnkbw4.js";import"./iconUtil-CAY5Il88.js";import"./index-COTHVrjr.js";import"./useForm-CaItC8xb.js";import"./index-Iw46KAPi.js";import"./Pagination-lXX40XmA.js";const{Text:le}=q;function oe(t){if(!t.length)return[];const l=t.filter(r=>r.status!==0),m=new Map,n=[];l.forEach(r=>{m.set(r.permId,{...r,key:r.permId,children:[]})}),m.forEach(r=>{if(r.parentId&&r.parentId!==0){const i=m.get(r.parentId);i&&i.children.push(r)}else n.push(r)});const p=r=>{r.sort((i,h)=>(i.sortOrder||0)-(h.sortOrder||0)),r.forEach(i=>{var h;(h=i.children)!=null&&h.length&&p(i.children)})};return p(n),n}function k(t){return t.map(l=>{var m;return{key:l.permId,title:e.jsxs(N,{children:[e.jsx("span",{children:l.name}),l.permType==="button"?e.jsx(y,{color:"blue",style:{marginLeft:4},children:"Button"}):null]}),children:(m=l.children)!=null&&m.length?k(l.children):void 0}})}function je(){const{t}=H(),[l,m]=a.useState([]),[n,p]=a.useState([]),[r,i]=a.useState(!1),[h,I]=a.useState(!1),[P,R]=a.useState(!1),[o,S]=a.useState(null),[b,f]=a.useState([]),[E,g]=a.useState([]),[x,_]=a.useState(""),M=a.useMemo(()=>{const s=sessionStorage.getItem("userProfile");return s?JSON.parse(s).isPlatformAdmin&&localStorage.getItem("activeTenantId")==="0":!1},[]),u=a.useMemo(()=>l.find(s=>s.roleId===o)||null,[l,o]),z=a.useMemo(()=>{if(!x)return l;const s=x.toLowerCase();return l.filter(c=>c.roleName.toLowerCase().includes(s)||c.roleCode.toLowerCase().includes(s))},[l,x]),A=a.useMemo(()=>k(oe(n)),[n]),L=async()=>{i(!0);try{const s=await Q();m(s||[])}finally{i(!1)}},B=async()=>{I(!0);try{const s=await U();p(s||[])}finally{I(!1)}},K=async s=>{try{const j=(await V(s)||[]).map(d=>Number(d)).filter(d=>!Number.isNaN(d)).filter(d=>!n.some(D=>D.parentId===d));f(j),g([])}catch{f([]),g([])}};a.useEffect(()=>{L(),B()},[]),a.useEffect(()=>{o&&n.length>0?K(o):(f([]),g([]))},[o,n]);const $=async()=>{if(!o){C.warning(t("rolePerm.selectRole"));return}R(!0);try{await X(o,Array.from(new Set([...b,...E]))),C.success(t("common.success"))}finally{R(!1)}};return e.jsxs("div",{className:"app-page",children:[e.jsx(ee,{title:t("rolePerm.title"),subtitle:t("rolePerm.subtitle")}),e.jsx("div",{className:"app-page__page-actions",children:e.jsx(O,{type:"primary",icon:e.jsx(F,{"aria-hidden":"true"}),onClick:$,loading:P,disabled:!o||(u==null?void 0:u.roleCode)==="TENANT_ADMIN"&&!M,children:t(P?"common.loading":"common.save")})}),e.jsxs(se,{gutter:24,className:"app-page__split",style:{height:"calc(100vh - 180px)"},children:[e.jsx(v,{xs:24,lg:10,style:{height:"100%"},children:e.jsxs(T,{title:e.jsxs(N,{children:[e.jsx(Y,{"aria-hidden":"true"}),e.jsx("span",{children:t("rolePerm.roleList")})]}),className:"app-page__panel-card full-height-card",children:[e.jsx("div",{className:"mb-4",children:e.jsx(te,{placeholder:t("rolePerm.searchRole"),prefix:e.jsx(J,{"aria-hidden":"true",className:"text-gray-400"}),value:x,onChange:s=>_(s.target.value),allowClear:!0,"aria-label":t("rolePerm.searchRole")})}),e.jsx("div",{style:{height:"calc(100% - 60px)",overflowY:"auto"},children:e.jsx(re,{rowKey:"roleId",size:"middle",loading:r,dataSource:z,rowSelection:{type:"radio",selectedRowKeys:o?[o]:[],onChange:s=>S(s[0])},onRow:s=>({onClick:()=>S(s.roleId),className:"cursor-pointer"}),pagination:{pageSize:10,showTotal:s=>t("common.total",{total:s})},columns:[{title:t("roles.roleName"),key:"role",render:(s,c)=>e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{style:{fontWeight:500},className:"truncate",children:c.roleName}),e.jsx("div",{style:{fontSize:12,color:"#8c8c8c"},className:"truncate tabular-nums",children:c.roleCode})]})},{title:t("common.status"),dataIndex:"status",width:80,render:s=>s===1?e.jsx(y,{color:"green",className: