@rytass/bpm-core-react 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/chunks/FormBuilderView-CAqjOYAP.cjs +3 -0
- package/dist/chunks/{FormBuilderView-D6baVqBY.cjs.map → FormBuilderView-CAqjOYAP.cjs.map} +1 -1
- package/dist/chunks/{FormBuilderView-QtREqV4j.js → FormBuilderView-TzSezeqC.js} +18 -16
- package/dist/chunks/{FormBuilderView-QtREqV4j.js.map → FormBuilderView-TzSezeqC.js.map} +1 -1
- package/dist/chunks/{FormRendererView-D8QHLvd0.js → FormRendererView-BurlEDUu.js} +44 -41
- package/dist/chunks/{FormRendererView-D8QHLvd0.js.map → FormRendererView-BurlEDUu.js.map} +1 -1
- package/dist/chunks/FormRendererView-Dde1s3I0.cjs +2 -0
- package/dist/chunks/{FormRendererView-Cw9LiidV.cjs.map → FormRendererView-Dde1s3I0.cjs.map} +1 -1
- package/dist/chunks/admin-pickers-Btvij1at.cjs.map +1 -1
- package/dist/chunks/admin-pickers-DLlG_1du.js.map +1 -1
- package/dist/chunks/approval-instance-list-page-BjX2kaoF.js.map +1 -1
- package/dist/chunks/approval-instance-list-page-CWiQvnfE.cjs +2 -0
- package/dist/chunks/{approval-instance-list-page-C408vxE2.cjs.map → approval-instance-list-page-CWiQvnfE.cjs.map} +1 -1
- package/dist/chunks/auth-provider-4BeCw7cI.cjs.map +1 -1
- package/dist/chunks/auth-provider-B5oPmvk2.js.map +1 -1
- package/dist/chunks/bpm-form-field-Bc6k4ZEO.cjs.map +1 -1
- package/dist/chunks/categories-DGlxuC6X.js.map +1 -1
- package/dist/chunks/categories-Yid05WAX.cjs +2 -0
- package/dist/chunks/{categories-DUfldZ_9.cjs.map → categories-Yid05WAX.cjs.map} +1 -1
- package/dist/chunks/{compose-D-OS-Ngs.js → compose-CUOe5Ia9.js} +4 -4
- package/dist/chunks/{compose-D-OS-Ngs.js.map → compose-CUOe5Ia9.js.map} +1 -1
- package/dist/chunks/compose-CyRkXdeu.cjs +2 -0
- package/dist/chunks/{compose-CODnd9-2.cjs.map → compose-CyRkXdeu.cjs.map} +1 -1
- package/dist/chunks/dashboard-page-CH87L5nx.cjs +2 -0
- package/dist/chunks/{dashboard-page-DwHQY6Ki.cjs.map → dashboard-page-CH87L5nx.cjs.map} +1 -1
- package/dist/chunks/dashboard-page-DJ9vOPga.js.map +1 -1
- package/dist/chunks/{delegations-DLEEFBlH.js → delegations-0MbJ7CWj.js} +3 -2
- package/dist/chunks/{delegations-DLEEFBlH.js.map → delegations-0MbJ7CWj.js.map} +1 -1
- package/dist/chunks/delegations-Bc9psOZ3.cjs +2 -0
- package/dist/chunks/{delegations-CGj-tZNO.cjs.map → delegations-Bc9psOZ3.cjs.map} +1 -1
- package/dist/chunks/{delegations-DqMpI_Nk.js → delegations-DyMGIDpp.js} +3 -2
- package/dist/chunks/{delegations-DqMpI_Nk.js.map → delegations-DyMGIDpp.js.map} +1 -1
- package/dist/chunks/delegations-vpLtus9g.cjs +2 -0
- package/dist/chunks/{delegations-kbMOSEif.cjs.map → delegations-vpLtus9g.cjs.map} +1 -1
- package/dist/chunks/{designer-DDSxwtjV.js → designer-Cb3WAC46.js} +39 -30
- package/dist/chunks/{designer-DDSxwtjV.js.map → designer-Cb3WAC46.js.map} +1 -1
- package/dist/chunks/designer-zLliyrHu.cjs +65 -0
- package/dist/chunks/{designer-Cdn10NNl.cjs.map → designer-zLliyrHu.cjs.map} +1 -1
- package/dist/chunks/detail-Bp2Nv0cs.cjs +2 -0
- package/dist/chunks/{detail-CtVu5NTi.cjs.map → detail-Bp2Nv0cs.cjs.map} +1 -1
- package/dist/chunks/{detail-DAPz2qyn.js → detail-Cmw-aQcu.js} +4 -4
- package/dist/chunks/{detail-DAPz2qyn.js.map → detail-Cmw-aQcu.js.map} +1 -1
- package/dist/chunks/format-date-time-CB-LxzqT.js.map +1 -1
- package/dist/chunks/format-date-time-D-cx5M8z.cjs +2 -0
- package/dist/chunks/{format-date-time-XxBzF0F5.cjs.map → format-date-time-D-cx5M8z.cjs.map} +1 -1
- package/dist/chunks/login-9bCXyjbX.cjs.map +1 -1
- package/dist/chunks/login-BKxpLibd.js.map +1 -1
- package/dist/chunks/notifications-Bc4mgSds.cjs +2 -0
- package/dist/chunks/{notifications--hwl-DR0.cjs.map → notifications-Bc4mgSds.cjs.map} +1 -1
- package/dist/chunks/notifications-DJ5wzCye.js.map +1 -1
- package/dist/chunks/{orgs-DytLvZ_X.js → orgs-B930facb.js} +11 -10
- package/dist/chunks/{orgs-DytLvZ_X.js.map → orgs-B930facb.js.map} +1 -1
- package/dist/chunks/orgs-BefGgeyc.cjs +2 -0
- package/dist/chunks/{orgs-Ni22buHs.cjs.map → orgs-BefGgeyc.cjs.map} +1 -1
- package/dist/chunks/providers-BsEn3ikK.cjs +2 -0
- package/dist/chunks/{providers-D_zTbkQH.cjs.map → providers-BsEn3ikK.cjs.map} +1 -1
- package/dist/chunks/{providers-DEqcuXw9.js → providers-DjLh4oLY.js} +3 -3
- package/dist/chunks/{providers-DEqcuXw9.js.map → providers-DjLh4oLY.js.map} +1 -1
- package/dist/chunks/{chunk-CMqjfN_6.cjs → rolldown-runtime-BocRIvOZ.cjs} +1 -1
- package/dist/chunks/router-adapter--gYs13E8.cjs.map +1 -1
- package/dist/chunks/routes-config-fDVHmvXi.cjs.map +1 -1
- package/dist/chunks/users-C9LA-Rd7.cjs +2 -0
- package/dist/chunks/{users-0HqlM_VQ.cjs.map → users-C9LA-Rd7.cjs.map} +1 -1
- package/dist/chunks/users-FWrb3ehW.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/next/index.cjs +1 -1
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.js +9 -9
- package/dist/next/index.js.map +1 -1
- package/dist/next/workflow-chat-route.cjs +1 -1
- package/dist/next/workflow-chat-route.cjs.map +1 -1
- package/dist/next/workflow-chat-route.js +2 -1
- package/dist/next/workflow-chat-route.js.map +1 -1
- package/dist/pages/admin/delegations/index.cjs +1 -1
- package/dist/pages/admin/delegations/index.cjs.map +1 -1
- package/dist/pages/admin/delegations/index.js +1 -1
- package/dist/pages/admin/orgs/index.cjs +1 -1
- package/dist/pages/admin/orgs/index.cjs.map +1 -1
- package/dist/pages/admin/orgs/index.js +1 -1
- package/dist/pages/admin/users/index.cjs +1 -1
- package/dist/pages/admin/users/index.cjs.map +1 -1
- package/dist/pages/cc/index.cjs.map +1 -1
- package/dist/pages/dashboard/index.cjs.map +1 -1
- package/dist/pages/delegations/index.cjs +1 -1
- package/dist/pages/delegations/index.cjs.map +1 -1
- package/dist/pages/delegations/index.js +1 -1
- package/dist/pages/inbox/index.cjs.map +1 -1
- package/dist/pages/instances/detail/index.cjs +1 -1
- package/dist/pages/instances/detail/index.cjs.map +1 -1
- package/dist/pages/instances/detail/index.js +1 -1
- package/dist/pages/instances/new/index.cjs.map +1 -1
- package/dist/pages/login/index.cjs.map +1 -1
- package/dist/pages/root/index.cjs.map +1 -1
- package/dist/pages/search/index.cjs.map +1 -1
- package/dist/pages/sent/index.cjs.map +1 -1
- package/dist/pages/settings/notifications/index.cjs +1 -1
- package/dist/pages/settings/notifications/index.cjs.map +1 -1
- package/dist/pages/templates/categories/index.cjs +1 -1
- package/dist/pages/templates/categories/index.cjs.map +1 -1
- package/dist/pages/templates/compose/index.cjs +1 -1
- package/dist/pages/templates/compose/index.cjs.map +1 -1
- package/dist/pages/templates/compose/index.js +1 -1
- package/dist/pages/templates/designer/index.cjs +1 -1
- package/dist/pages/templates/designer/index.cjs.map +1 -1
- package/dist/pages/templates/designer/index.js +1 -1
- package/dist/pages/templates/index.cjs.map +1 -1
- package/dist/pages/templates/versions/index.cjs.map +1 -1
- package/dist/views/admin/delegations/index.cjs +1 -1
- package/dist/views/admin/delegations/index.js +1 -1
- package/dist/views/admin/index.cjs +1 -1
- package/dist/views/admin/index.js +2 -2
- package/dist/views/admin/orgs/index.cjs +1 -1
- package/dist/views/admin/orgs/index.js +1 -1
- package/dist/views/admin/users/index.cjs +1 -1
- package/dist/views/cc/index.cjs +1 -1
- package/dist/views/cc/index.cjs.map +1 -1
- package/dist/views/dashboard/index.cjs +1 -1
- package/dist/views/dashboard/index.cjs.map +1 -1
- package/dist/views/delegations/index.cjs +1 -1
- package/dist/views/delegations/index.js +1 -1
- package/dist/views/forms/builder/index.cjs +1 -1
- package/dist/views/forms/builder/index.js +1 -1
- package/dist/views/forms/renderer/index.cjs +1 -1
- package/dist/views/forms/renderer/index.js +1 -1
- package/dist/views/inbox/index.cjs +1 -1
- package/dist/views/inbox/index.cjs.map +1 -1
- package/dist/views/inbox/index.js.map +1 -1
- package/dist/views/instances/detail/index.cjs +1 -1
- package/dist/views/instances/detail/index.js +1 -1
- package/dist/views/instances/new/index.cjs +1 -1
- package/dist/views/instances/new/index.cjs.map +1 -1
- package/dist/views/instances/new/index.js +1 -1
- package/dist/views/instances/new/index.js.map +1 -1
- package/dist/views/search/index.cjs +1 -1
- package/dist/views/search/index.cjs.map +1 -1
- package/dist/views/sent/index.cjs +1 -1
- package/dist/views/sent/index.cjs.map +1 -1
- package/dist/views/settings/index.cjs +1 -1
- package/dist/views/settings/notifications/index.cjs +1 -1
- package/dist/views/templates/categories/index.cjs +1 -1
- package/dist/views/templates/compose/index.cjs +1 -1
- package/dist/views/templates/compose/index.js +1 -1
- package/dist/views/templates/designer/index.cjs +1 -1
- package/dist/views/templates/designer/index.js +1 -1
- package/dist/views/templates/index.cjs +1 -1
- package/dist/views/templates/index.cjs.map +1 -1
- package/dist/views/templates/index.js.map +1 -1
- package/dist/views/templates/versions/index.cjs +1 -1
- package/dist/views/templates/versions/index.cjs.map +1 -1
- package/dist/views/templates/versions/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunks/FormBuilderView-D6baVqBY.cjs +0 -3
- package/dist/chunks/FormRendererView-Cw9LiidV.cjs +0 -2
- package/dist/chunks/approval-instance-list-page-C408vxE2.cjs +0 -2
- package/dist/chunks/categories-DUfldZ_9.cjs +0 -2
- package/dist/chunks/compose-CODnd9-2.cjs +0 -2
- package/dist/chunks/dashboard-page-DwHQY6Ki.cjs +0 -2
- package/dist/chunks/delegations-CGj-tZNO.cjs +0 -2
- package/dist/chunks/delegations-kbMOSEif.cjs +0 -2
- package/dist/chunks/designer-Cdn10NNl.cjs +0 -65
- package/dist/chunks/detail-CtVu5NTi.cjs +0 -2
- package/dist/chunks/format-date-time-XxBzF0F5.cjs +0 -2
- package/dist/chunks/notifications--hwl-DR0.cjs +0 -2
- package/dist/chunks/orgs-Ni22buHs.cjs +0 -2
- package/dist/chunks/providers-D_zTbkQH.cjs +0 -2
- package/dist/chunks/users-0HqlM_VQ.cjs +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";require('../style.css');require('../orgs.css');const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./bpm-form-field-Bc6k4ZEO.cjs"),n=require("./admin-pickers-Btvij1at.cjs");;/* empty css */let r=require("react"),i=require("@mezzanine-ui/react"),a=require("@rytass/bpm-core-client"),o=require("react/jsx-runtime"),s=require("@mezzanine-ui/core/form"),c=require("@mezzanine-ui/react/ContentHeader");c=e.t(c,1);let l=require("@mezzanine-ui/icons"),u=require("@rytass/bpm-core-client/organization"),d=require("@xyflow/react"),f=require("dagre");f=e.t(f,1);function p(e){return new Map(e.map(e=>[e.id,e.parentId]))}function m({orgUnitId:e,parentDraft:t,parentId:n}){let r=n===e?e:n,i=g({orgUnitId:e,parentDraft:t,parentId:r});if(i)return{message:i,parentDraft:t,status:`INVALID`};if((t.get(e)??null)===r)return{message:`父子關係沒有變更。`,parentDraft:t,status:`UNCHANGED`};let a=new Map(t);return a.set(e,r),{message:r?`已暫存新的上層組織。`:`已暫存為根節點。`,parentDraft:a,status:`UPDATED`}}function h({orgUnits:e,parentDraft:t}){return e.map(e=>{let n=t.get(e.id)??null;return n===e.parentId?null:{orgUnitId:e.id,parentId:n,previousParentId:e.parentId}}).filter(e=>!!e)}function g({orgUnitId:e,parentDraft:t,parentId:n}){return t.has(e)?n?t.has(n)?n===e?`組織不可成為自己的上層。`:_({orgUnitId:e,parentDraft:t,parentId:n})?`不可搬移到自己的下層組織。`:null:`找不到新的上層組織。`:null:`找不到要搬移的組織節點。`}function _({orgUnitId:e,parentDraft:t,parentId:n}){let r=new Set,i=n;for(;i;){if(i===e||r.has(i))return!0;r.add(i),i=t.get(i)??null}return!1}var v={orgTreeEditor:`bpm_orgTreeEditor_TMOtD`,orgTreeSummary:`bpm_orgTreeSummary_vpcV8`,orgTreeChangeList:`bpm_orgTreeChangeList_EzmOv`,orgTreeCanvas:`bpm_orgTreeCanvas_MeD7y`,orgTreePanel:`bpm_orgTreePanel_VFZph`,orgTreeNode:`bpm_orgTreeNode_bN4FS`,orgTreeNodeRoot:`bpm_orgTreeNodeRoot_Hr2KD`,orgTreeNodeSelected:`bpm_orgTreeNodeSelected_eRwtL`,orgTreeNodeChanged:`bpm_orgTreeNodeChanged_qPJg0`,orgTreeNodeDeleted:`bpm_orgTreeNodeDeleted_Ab0cI`,orgTreeNodeHeader:`bpm_orgTreeNodeHeader_LEXl-`,orgTreeNodeBadge:`bpm_orgTreeNodeBadge_zLc7t`,orgTreeNodeActions:`bpm_orgTreeNodeActions_cMldI`},y=`__org-tree-root__`,b=232,x=118,S=232,C=86,w=320,T=1.4,E=.25,D=.005,ee=250,te=80,O=.85,ne=.7,re=1200,k=600,A=96,ie={COMPANY:`公司`,DEPARTMENT:`部門`,DIVISION:`事業群`,TEAM:`小組`},ae={orgUnit:oe},j=(0,r.forwardRef)(function({onCreateChild:e,onCreateRoot:t,onEditOrgUnit:n,onSaveDraft:a,onStateChange:s,orgUnits:c},l){let[u,f]=(0,r.useState)(!1),[g,_]=(0,r.useState)(null),[S,C]=(0,r.useState)(null),[w,A]=(0,r.useState)(()=>p(c)),[ie,j]=(0,r.useState)(()=>new Set),[oe,ce]=(0,r.useState)(()=>new Map),[ue,M]=(0,r.useState)([]),N=(0,r.useRef)(null),P=(0,r.useRef)(null),F=(0,r.useCallback)(e=>{P.current=e,j(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),me=(0,r.useCallback)(()=>{P.current=y,j(new Set)},[]),L=(0,r.useCallback)(()=>{P.current=y,j(()=>{let e=se(c,w);return new Set([...e.keys()].filter(e=>e!==y))})},[c,w]),R=(0,r.useMemo)(()=>new Map(c.map(e=>[e.id,e])),[c]),z=(0,r.useMemo)(()=>h({orgUnits:c,parentDraft:w}),[c,w]),B=(0,r.useMemo)(()=>le({collapsedIds:ie,isEditing:u,measuredHeights:oe,onCreateChild:n=>{n?e(n):t()},onEditOrgUnit:e=>{let t=R.get(e);t&&n(t)},onToggleCollapse:F,orgUnits:c,orgUnitsById:R,parentDraft:w,selectedOrgUnitId:S}),[ie,F,u,oe,e,t,n,c,R,w,S]),he=(0,r.useRef)(B);he.current=B;let V=z.length>0,H=(0,r.useMemo)(()=>{let e=Math.max(B.bounds.width,B.bounds.height);return e<=0?E:Math.min(E,Math.max(D,ee/e))},[B.bounds.height,B.bounds.width]),ge=c.length<=te,U=(0,r.useCallback)(()=>{let e=N.current;if(!e)return;let{bounds:t,rootCenter:n}=he.current,r=t.width>0?re/t.width:1/0,i=t.height>0?k/t.height:1/0,a=Math.min(r,i);if(!Number.isFinite(a)||a>=ne){e.fitView({padding:.18});return}let o=k/(2*O);e.setCenter(n.x,Math.min(t.height/2,o),{duration:0,zoom:O})},[]),_e=(0,r.useCallback)(e=>{N.current=e,U()},[U]);(0,r.useImperativeHandle)(l,()=>({cancelEditing:xe,saveDraft:Se,startEditing:be})),(0,r.useEffect)(()=>{s({hasDraftChanges:V,isEditing:u})},[V,u,s]),(0,r.useEffect)(()=>{let e=p(c);A(e),j(new Set),ce(new Map),C(null),_(null),f(!1)},[c]),(0,r.useEffect)(()=>{M(B.nodes)},[B.nodes]),(0,r.useEffect)(()=>{if(typeof window>`u`)return()=>void 0;let e=window.requestAnimationFrame(()=>{U()});return()=>window.cancelAnimationFrame(e)},[U,c]),(0,r.useEffect)(()=>{let e=P.current;if(!e)return;P.current=null;let t=N.current,n=B.nodes.find(t=>t.id===e);!t||!n||t.setCenter(n.position.x+(n.width??b)/2,n.position.y+(n.initialHeight??x)/2,{duration:200,zoom:t.getZoom()})},[B.nodes]);let W=(0,r.useCallback)((e,t)=>{A(n=>{let r=m({orgUnitId:e,parentDraft:n,parentId:t});return _(r.message),r.parentDraft})},[]),G=(0,r.useCallback)(e=>{if(!u||!e.target||!e.source)return;let t=e.source===y?null:e.source;if(e.target===y){_(`根節點不能搬移到其他節點下。`);return}W(e.target,t)},[W,u]),ve=(0,r.useCallback)(e=>{let t=e.filter(e=>e.type===`dimensions`&&e.dimensions);t.length>0&&ce(e=>{let n=new Map(e);return t.reduce((e,t)=>{if(t.type!==`dimensions`||!t.dimensions)return e;let r=Math.ceil(t.dimensions.height);return Math.abs((n.get(t.id)??0)-r)<=1?e:(n.set(t.id,r),!0)},!1)?n:e}),u&&M(t=>(0,d.applyNodeChanges)(e,[...t]))},[u]),ye=(0,r.useCallback)((e,t,n)=>{if(!u||t.id===y)return;let r=fe(e,t.id)??de(t,n);if(r===void 0){_(`拖曳到目標父節點附近,或從父節點拉線到子節點。`);return}W(t.id,r===y?null:r)},[W,u]);function be(){f(!0),A(p(c)),_(`已進入編輯模式,拖曳節點或拉線只會更新前端草稿。`)}function xe(){f(!1),A(p(c)),_(`已取消草稿變更。`)}async function Se(){if(!a){_(`批次儲存 API 尚未接上,草稿仍保留在前端。`);return}await a(z),f(!1),_(`組織樹草稿已儲存。`)}return(0,o.jsxs)(`div`,{className:v.orgTreeEditor,children:[(0,o.jsxs)(`div`,{className:v.orgTreeSummary,children:[(0,o.jsx)(i.Typography,{color:`text-neutral`,variant:`caption`,children:g??(V?`目前有 ${z.length} 筆父子關係草稿變更。`:`目前沒有草稿變更。`)}),V?(0,o.jsx)(`ul`,{className:v.orgTreeChangeList,children:z.map(e=>(0,o.jsxs)(`li`,{children:[I(e.orgUnitId,R),`:`,I(e.previousParentId,R),` -> `,I(e.parentId,R)]},e.orgUnitId))}):null]}),(0,o.jsx)(`div`,{className:v.orgTreeCanvas,children:(0,o.jsxs)(d.ReactFlow,{connectionMode:d.ConnectionMode.Strict,edges:[...B.edges],fitViewOptions:{minZoom:H,padding:.18},isValidConnection:e=>pe({source:e.source,target:e.target},w),maxZoom:T,minZoom:H,nodeTypes:ae,nodes:[...ue],nodesConnectable:u,nodesDraggable:u,onConnect:G,onInit:_e,onNodeClick:(e,t)=>{C(t.id===y?null:t.id)},onNodeDoubleClick:(e,t)=>{if(t.id!==y){let e=R.get(t.id);e&&n(e)}},onNodeDragStop:ye,onNodesChange:ve,onPaneClick:()=>C(null),panOnDrag:!0,proOptions:{hideAttribution:!0},children:[(0,o.jsx)(d.Background,{}),(0,o.jsx)(d.Controls,{}),(0,o.jsxs)(d.Panel,{className:`${v.orgTreePanel} nopan nodrag`,position:`top-right`,children:[(0,o.jsx)(i.Button,{onClick:me,size:`sub`,variant:`base-secondary`,children:`全部展開`}),(0,o.jsx)(i.Button,{onClick:L,size:`sub`,variant:`base-secondary`,children:`全部收合`})]}),ge?(0,o.jsx)(d.MiniMap,{pannable:!0,zoomable:!0}):null]})})]})});function oe({data:e,selected:t}){return(0,o.jsxs)(`div`,{className:[v.orgTreeNode,e.isSyntheticRoot?v.orgTreeNodeRoot:``,e.changed?v.orgTreeNodeChanged:``,e.deleted?v.orgTreeNodeDeleted:``,t?v.orgTreeNodeSelected:``].filter(Boolean).join(` `),children:[e.isSyntheticRoot?null:(0,o.jsx)(d.Handle,{id:`target`,isConnectable:e.isEditing,position:d.Position.Top,type:`target`}),(0,o.jsx)(d.Handle,{id:`source`,isConnectable:e.isEditing,position:d.Position.Bottom,type:`source`}),(0,o.jsxs)(`div`,{className:v.orgTreeNodeHeader,children:[(0,o.jsx)(i.Typography,{component:`span`,ellipsis:!0,title:e.name,variant:`label-primary`,children:e.name}),e.changed?(0,o.jsx)(`span`,{className:v.orgTreeNodeBadge,children:`草稿`}):null]}),(0,o.jsx)(i.Typography,{color:`text-neutral`,component:`span`,ellipsis:!0,title:e.code,variant:`caption`,children:e.isSyntheticRoot?`根節點容器`:`${e.typeLabel} · ${e.code}`}),e.isSyntheticRoot?null:(0,o.jsxs)(i.Typography,{color:`text-neutral`,component:`span`,ellipsis:!0,title:e.parentLabel,variant:`caption`,children:[`上層:`,e.parentLabel]}),(0,o.jsxs)(`div`,{className:`${v.orgTreeNodeActions} nodrag nopan`,children:[e.childCount>0?(0,o.jsx)(i.Button,{onClick:t=>{t.stopPropagation(),e.onToggleCollapse(e.orgUnitId??y)},size:`sub`,variant:`base-secondary`,children:e.collapsed?`展開 (${e.childCount})`:`收合 (${e.childCount})`}):null,e.isSyntheticRoot?(0,o.jsx)(i.Button,{icon:l.PlusIcon,iconType:`leading`,onClick:()=>e.onCreateChild(null),size:`sub`,variant:`base-secondary`,children:`新增根節點`}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.Button,{icon:l.EditIcon,iconType:`leading`,onClick:()=>{e.orgUnitId&&e.onEdit(e.orgUnitId)},size:`sub`,variant:`base-secondary`,children:`編輯`}),(0,o.jsx)(i.Button,{icon:l.PlusIcon,iconType:`leading`,onClick:()=>e.onCreateChild(e.orgUnitId),size:`sub`,variant:`base-secondary`,children:`新增子節點`})]})]})]})}function se(e,t){let n=new Map;return e.forEach(e=>{let r=t.get(e.id)??y;n.set(r,[...n.get(r)??[],e.id])}),n}function ce({childrenMap:e,collapsedIds:t}){let n=new Set,r=i=>{t.has(i)||(e.get(i)??[]).forEach(e=>{n.add(e),r(e)})};return r(y),n}function le({collapsedIds:e,isEditing:t,measuredHeights:n,onCreateChild:r,onEditOrgUnit:i,onToggleCollapse:a,orgUnits:o,orgUnitsById:s,parentDraft:c,selectedOrgUnitId:l}){let u=se(o,c),d=ce({childrenMap:u,collapsedIds:e}),p=o.filter(e=>d.has(e.id)),m=e=>u.get(e)?.length??0,h=(e,t)=>Math.max(t,n.get(e)??0),g=new f.graphlib.Graph;g.setDefaultEdgeLabel(()=>({})),g.setGraph({marginx:36,marginy:36,nodesep:44,rankdir:`TB`,ranksep:A}),g.setNode(y,{height:h(y,C),width:S}),p.forEach(e=>{g.setNode(e.id,{height:h(e.id,x),width:b})}),p.forEach(e=>{let t=c.get(e.id)??null;g.setEdge(t??y,e.id)}),f.layout(g);let _=g.graph(),v={height:_.height??0,width:_.width??0},w=g.node(y),T={x:v.width>0?v.width/2:w?.x??0,y:w?.y??0},E={...ue({data:{changed:!1,childCount:m(y),code:y,collapsed:e.has(y),deleted:!1,isEditing:t,isSyntheticRoot:!0,name:`組織根節點`,onCreateChild:r,onEdit:i,onToggleCollapse:a,orgUnitId:null,parentLabel:``,path:``,typeLabel:``},graph:g,height:h(y,C),id:y,selected:l===null,width:S}),position:{x:T.x-S/2,y:T.y-h(y,C)/2}},D=p.map(n=>{let o=c.get(n.id)??null,u=I(o,s);return ue({data:{changed:o!==n.parentId,childCount:m(n.id),code:n.code,collapsed:e.has(n.id),deleted:!!n.deletedAt,isEditing:t,isSyntheticRoot:!1,name:n.name,onCreateChild:r,onEdit:i,onToggleCollapse:a,orgUnitId:n.id,parentLabel:u,path:n.path,typeLabel:me(n.type)},graph:g,height:h(n.id,x),id:n.id,selected:l===n.id,width:b})});return{bounds:v,edges:p.map(e=>{let n=c.get(e.id)??null,r=n!==e.parentId;return{animated:t&&r,data:{},id:`org-tree-edge-${n??`root`}-${e.id}`,source:n??y,sourceHandle:`source`,style:r?{stroke:`var(--mzn-color-primary, #0057ff)`,strokeWidth:2}:void 0,target:e.id,targetHandle:`target`,type:`smoothstep`}}),nodes:[E,...D],rootCenter:T}}function ue({data:e,graph:t,height:n,id:r,selected:i,width:a}){let o=t.node(r);return{data:e,id:r,initialHeight:n,initialWidth:a,position:o?{x:o.x-a/2,y:o.y-n/2}:{x:0,y:0},selected:i,sourcePosition:d.Position.Bottom,targetPosition:d.Position.Top,type:`orgUnit`,width:a}}function de(e,t){let n=P(e);return t.filter(t=>t.id!==e.id).map(e=>({distance:F(n,P(e)),id:e.id})).filter(e=>e.distance<=w).sort((e,t)=>e.distance-t.distance)[0]?.id}function fe(e,t){let n=M(e);if(n)return Array.from(document.querySelectorAll(`.react-flow__node[data-id]`)).map(e=>{let r=e.dataset.id;if(!r||r===t)return null;let i=e.getBoundingClientRect(),a={x:i.left+i.width/2,y:i.top+i.height/2};return{distance:F(n,a),id:r}}).filter(e=>!!e).filter(e=>e.distance<=w).sort((e,t)=>e.distance-t.distance)[0]?.id}function M(e){return N(e)?{x:e.clientX,y:e.clientY}:null}function N(e){return typeof e==`object`&&!!e&&`clientX`in e&&`clientY`in e&&typeof e.clientX==`number`&&typeof e.clientY==`number`}function P(e){return{x:e.position.x+(e.width??b)/2,y:e.position.y+(e.measured?.height??e.initialHeight??x)/2}}function F(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function pe(e,t){return!e.source||!e.target||e.target===y?!1:g({orgUnitId:e.target,parentDraft:t,parentId:e.source===y?null:e.source})===null}function I(e,t){if(!e)return`根節點`;let n=t.get(e);return n?`${n.name} · ${n.code}`:`未知組織`}function me(e){return ie[e.toUpperCase()]??`未知類型`}var L={tableIntroActions:`bpm_tableIntroActions_WO4XU`,modalFields:`bpm_modalFields_juyv6`,tableIntro:`bpm_tableIntro_u3hcm`,tableFrame:`bpm_tableFrame_IdbmB`,orgFilterArea:`bpm_orgFilterArea_Xjbbp`,membershipFilterArea:`bpm_membershipFilterArea_zob-Y`,scopeLabel:`bpm_scopeLabel_TLHMC`},R={hasDraftChanges:!1,isEditing:!1},z=100,B=[{id:`COMPANY`,name:`公司`},{id:`DIVISION`,name:`事業群`},{id:`DEPARTMENT`,name:`部門`},{id:`TEAM`,name:`小組`}],he={id:`ALL`,name:`全部類型`},V=[he,...B],H=[{id:`MEMBER`,name:`指定會員`},{id:`ORG_UNIT`,name:`指定組織`},{id:`POSITION`,name:`指定職位`}],ge={id:`ALL`,name:`全部範圍`},U=[ge,...H],_e={activeOnly:!1,id:`ALL`,name:`全部狀態`},W=[_e,{activeOnly:!0,id:`ACTIVE`,name:`目前有效`}],G=[{id:`true`,name:`主要歸屬`,value:!0},{id:`false`,name:`一般歸屬`,value:!1}],ve=[10,20,50],ye=1368,be=908,xe=1292,Se=1124;function Ce(){let[e,t]=(0,r.useState)(`ORG_UNITS`),[n,s]=(0,r.useState)(null),[l,d]=(0,r.useState)(null),[f,p]=(0,r.useState)(null),[m,h]=(0,r.useState)(!0),[g,_]=(0,r.useState)(null),[v,y]=(0,r.useState)(_e),[b,x]=(0,r.useState)(1),[S,C]=(0,r.useState)(10),[w,T]=(0,r.useState)(ge),[E,D]=(0,r.useState)(0),[ee,te]=(0,r.useState)([]),[O,ne]=(0,r.useState)(null),[re,k]=(0,r.useState)(null),[A,ie]=(0,r.useState)(null),[ae,j]=(0,r.useState)(1),[oe,se]=(0,r.useState)(10),[ce,le]=(0,r.useState)(null),[ue,de]=(0,r.useState)(0),[fe,M]=(0,r.useState)(null),[N,P]=(0,r.useState)(1),[F,pe]=(0,r.useState)(10),[I,me]=(0,r.useState)(``),[L,R]=(0,r.useState)(0),[B,V]=(0,r.useState)(he),[H,U]=(0,r.useState)(`TABLE`),[W,G]=(0,r.useState)([]),[ve,ye]=(0,r.useState)([]),[be,xe]=(0,r.useState)([]),[Se,Ce]=(0,r.useState)(null),[K,Oe]=(0,r.useState)(1),[ke,Ae]=(0,r.useState)(10),[q,J]=(0,r.useState)(``),[Fe,Ue]=(0,r.useState)(0),[We,Ge]=(0,r.useState)([]),[Ke,qe]=(0,r.useState)([]),[Je,Ye]=(0,r.useState)([]),[Y,Xe]=(0,r.useState)(!1);(0,r.useEffect)(()=>{n&&d(n)},[n]);let X=n??l,Z=(0,r.useCallback)(async()=>{h(!0),p(null);try{let e=await(0,u.readOrganizationDashboard)({managerActiveOnly:v.activeOnly,managerPage:b,managerPageSize:S,managerScopeType:w.id===`ALL`?null:w.id,membershipActiveOnly:O?.activeOnly??!1,membershipOrgUnitId:A?.id??null,membershipPage:ae,membershipPageSize:oe,membershipPositionId:ce?.id??null,orgUnitPage:N,orgUnitPageSize:F,orgUnitSearchText:I,orgUnitType:B.id===`ALL`?null:B.id,positionPage:K,positionPageSize:ke,positionSearchText:q}),t=Ie(e.memberships,e.managerResolutions),n=await(0,a.resolveMembers)(t);te(n),G(e.orgUnits),R(e.orgUnitCount),ye(e.filteredOrgUnits),Ge(e.positions),Ue(e.positionCount),xe(e.filteredPositions),de(e.membershipCount),Ye(e.filteredMemberships),D(e.managerResolutionCount),qe(e.filteredManagerResolutions)}catch(e){p(et(e))}finally{h(!1)}},[v,b,S,w,O,A,ae,oe,ce,N,F,I,B,K,ke,q]);(0,r.useEffect)(()=>{Z()},[Z]);let Q=(0,r.useMemo)(()=>new Map(W.map(e=>[e.id,e])),[W]),Qe=(0,r.useMemo)(()=>new Map(We.map(e=>[e.id,e])),[We]),$=(0,r.useMemo)(()=>new Map(ee.map(e=>[e.memberId,e])),[ee]),$e=(0,r.useMemo)(()=>ve.map(e=>({...e,key:e.id,parentName:e.parentId?ze(Q.get(e.parentId)):`根節點`,typeLabel:Be(e.type)})),[ve,Q]),tt=(0,r.useMemo)(()=>be.map(e=>({...e,key:e.id})),[be]),nt=(0,r.useMemo)(()=>Je.map(e=>({...e,key:e.id,memberName:Re($.get(e.memberId)),orgUnitName:ze(Q.get(e.orgUnitId)),positionName:e.positionId?Ve(Qe.get(e.positionId)):`未指定`})),[$,Je,Q,Qe]),rt=(0,r.useMemo)(()=>Ke.map(e=>({...e,key:e.id,managerName:Re($.get(e.managerMemberId)),scopeLabel:Le(e,{membersById:$,orgUnitsById:Q,positionsById:Qe})})),[Ke,$,Q,Qe]),it=(0,r.useMemo)(()=>({render:e=>[{name:`編輯`,onClick:()=>M({record:e,type:`EDIT`})},{name:`停用`,onClick:()=>s({confirmText:`停用組織`,description:`停用「${e.name}」後,這個組織節點將不再出現在可用組織清單中。`,id:e.id,title:`停用組織節點`,type:`ORG_UNIT`}),variant:`destructive-secondary`}],variant:`base-secondary`,width:128}),[]),at=(0,r.useMemo)(()=>({render:e=>[{name:`編輯`,onClick:()=>Ce({record:e,type:`EDIT`})}],variant:`base-secondary`,width:88}),[]),ot=(0,r.useMemo)(()=>({render:e=>[{name:`編輯`,onClick:()=>k({record:e,type:`EDIT`})},{name:`刪除`,onClick:()=>s({confirmText:`刪除歸屬`,description:`刪除「${e.memberName}」在「${e.orgUnitName}」的會員歸屬。`,id:e.id,title:`刪除會員歸屬`,type:`MEMBERSHIP`}),variant:`destructive-secondary`}],variant:`base-secondary`,width:128}),[]),st=(0,r.useMemo)(()=>({render:e=>[{name:`編輯`,onClick:()=>_({record:e,type:`EDIT`})},{name:`刪除`,onClick:()=>s({confirmText:`刪除主管規則`,description:`刪除「${e.scopeLabel}」指派給「${e.managerName}」的主管解析規則。`,id:e.id,title:`刪除主管解析規則`,type:`MANAGER_RESOLUTION`}),variant:`destructive-secondary`}],variant:`base-secondary`,width:128}),[]);function ct(e){P(1),me(e)}function lt(e){P(1),V(e)}function ut(e){Oe(1),J(e)}function dt(e){j(1),ne(e)}function ft(e){j(1),ie(e)}function pt(e){j(1),le(e)}function mt(e){x(1),y(e)}function ht(e){x(1),T(e)}function gt(){Y||s(null)}async function _t(){n&&await yt(async()=>{n.type===`ORG_UNIT`&&await(0,u.deleteOrgUnit)(n.id),n.type===`MEMBERSHIP`&&await(0,u.deleteMembership)(n.id),n.type===`MANAGER_RESOLUTION`&&await(0,u.deleteManagerResolution)(n.id),s(null)})}async function vt(e){Xe(!0),p(null);try{await(0,u.commitOrgUnitTreeDraft)({moves:e.map(e=>({baseUpdatedAt:Q.get(e.orgUnitId)?.updatedAt??``,id:e.orgUnitId,parentId:e.parentId}))}),await Z()}catch(e){throw p(et(e)),e}finally{Xe(!1)}}async function yt(e){Xe(!0),p(null);try{await e(),await Z()}catch(e){p(et(e))}finally{Xe(!1)}}return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.PageHeader,{children:(0,o.jsx)(c.default,{description:`維護組織樹、職位、會員歸屬與簽核主管解析規則。`,title:`組織管理`})}),(0,o.jsx)(i.SectionGroup,{children:(0,o.jsxs)(i.Section,{tab:(0,o.jsxs)(i.Tab,{activeKey:e,onChange:e=>t(He(e)),children:[(0,o.jsx)(i.TabItem,{children:`組織樹`},`ORG_UNITS`),(0,o.jsx)(i.TabItem,{children:`職位`},`POSITIONS`),(0,o.jsx)(i.TabItem,{children:`會員歸屬`},`MEMBERSHIPS`),(0,o.jsx)(i.TabItem,{children:`簽核主管`},`MANAGERS`)]}),children:[f?(0,o.jsx)(i.Typography,{color:`text-error`,variant:`body`,children:f}):null,e===`ORG_UNITS`?(0,o.jsx)(we,{actions:it,loading:m,onCreate:()=>M({parentId:null,record:null,type:`CREATE`}),onCreateChild:e=>M({parentId:e,record:null,type:`CREATE`}),onEditOrgUnit:e=>M({record:e,type:`EDIT`}),onPageChange:P,onSaveDraft:vt,onPageSizeChange:e=>{P(1),pe(e)},onSearchTextChange:ct,onTypeFilterChange:lt,orgUnits:W,page:N,pageSize:F,rows:$e,searchText:I,saving:Y,total:L,typeFilter:B,viewMode:H,onViewModeChange:U}):null,e===`POSITIONS`?(0,o.jsx)(Te,{actions:at,loading:m,onCreate:()=>Ce({record:null,type:`CREATE`}),onPageChange:Oe,onPageSizeChange:e=>{Oe(1),Ae(e)},onSearchTextChange:ut,page:K,pageSize:ke,rows:tt,searchText:q,total:Fe}):null,e===`MEMBERSHIPS`?(0,o.jsx)(Ee,{actions:ot,loading:m,onCreate:()=>k({record:null,type:`CREATE`}),onActiveFilterChange:dt,onOrgUnitFilterChange:ft,onPageChange:j,onPageSizeChange:e=>{j(1),se(e)},onPositionFilterChange:pt,orgUnitFilter:A,orgUnits:W,page:ae,pageSize:oe,positionFilter:ce,positions:We,rows:nt,statusFilter:O,total:ue}):null,e===`MANAGERS`?(0,o.jsx)(De,{actions:st,loading:m,onCreate:()=>_({record:null,type:`CREATE`}),onActiveFilterChange:mt,onPageChange:x,onPageSizeChange:e=>{x(1),C(e)},onScopeTypeFilterChange:ht,page:b,pageSize:S,rows:rt,scopeTypeFilter:w,statusFilter:v,total:E}):null]})}),(0,o.jsx)(je,{modal:fe,onClose:()=>M(null),onSubmit:e=>yt(async()=>{fe?.type===`EDIT`&&fe.record?await(0,u.updateOrgUnit)({...e,id:fe.record.id,metadataJson:null}):await(0,u.createOrgUnit)({code:e.code??``,metadataJson:`{}`,name:e.name??``,parentId:e.parentId,type:e.type??`DEPARTMENT`}),M(null)}),orgUnits:W,saving:Y}),(0,o.jsx)(Me,{modal:Se,onClose:()=>Ce(null),onSubmit:e=>yt(async()=>{Se?.type===`EDIT`&&Se.record?await(0,u.updatePosition)({...e,id:Se.record.id,metadataJson:null}):await(0,u.createPosition)({code:e.code??``,level:e.level??0,metadataJson:`{}`,name:e.name??``}),Ce(null)}),saving:Y}),(0,o.jsx)(Ne,{membersById:$,modal:re,onClose:()=>k(null),onSubmit:e=>yt(async()=>{re?.type===`EDIT`&&re.record?await(0,u.updateMembership)({...e,id:re.record.id}):await(0,u.createMembership)({effectiveFrom:e.effectiveFrom??Ze(),effectiveTo:e.effectiveTo,isPrimary:e.isPrimary??!1,memberId:e.memberId??``,orgUnitId:e.orgUnitId??``,positionId:e.positionId}),k(null)}),orgUnits:W,positions:We,saving:Y}),(0,o.jsx)(Pe,{membersById:$,modal:g,onClose:()=>_(null),onSubmit:e=>yt(async()=>{g?.type===`EDIT`&&g.record?await(0,u.updateManagerResolution)({...e,id:g.record.id}):await(0,u.createManagerResolution)({effectiveFrom:e.effectiveFrom??Ze(),effectiveTo:e.effectiveTo,managerMemberId:e.managerMemberId??``,priority:e.priority??z,scopeId:e.scopeId??``,scopeType:e.scopeType??`MEMBER`}),_(null)}),orgUnits:W,positions:We,saving:Y}),(0,o.jsx)(i.Modal,{cancelText:`取消`,confirmButtonProps:{variant:`destructive-primary`},confirmText:X?.confirmText??``,loading:Y,modalStatusType:`error`,modalType:`standard`,onCancel:gt,onClose:gt,onConfirm:()=>void _t(),open:!!n,showModalFooter:!0,showModalHeader:!0,size:`regular`,supportingText:`此操作會立即套用,請確認後再繼續。`,title:X?.title??``,children:(0,o.jsx)(i.Typography,{color:`text-neutral`,variant:`body`,children:X?.description??``})})]})}function we({actions:e,loading:t,onCreate:n,onCreateChild:a,onEditOrgUnit:c,onPageChange:u,onSaveDraft:d,onPageSizeChange:f,onSearchTextChange:p,onTypeFilterChange:m,onViewModeChange:h,orgUnits:g,page:_,pageSize:v,rows:y,searchText:b,saving:x,total:S,typeFilter:C,viewMode:w}){let T=(0,r.useRef)(null),[E,D]=(0,r.useState)(R),ee=w===`TABLE`?`FLOW`:`TABLE`,te=w===`TABLE`?`切換樹狀圖`:`切換表格`,O=w===`FLOW`,ne=Oe({isTreeMode:O,isTreeEditing:E.isEditing}),re=ke({isTreeMode:O,isTreeEditing:E.isEditing}),k=Ae({hasDraftChanges:E.hasDraftChanges,isTreeEditing:E.isEditing,isTreeMode:O,loading:t,saving:x}),A=(0,r.useMemo)(()=>[{dataIndex:`code`,key:`code`,title:`代碼`,width:180},{dataIndex:`name`,key:`name`,title:`名稱`,width:240},{dataIndex:`typeLabel`,key:`typeLabel`,title:`類型`,width:120},{dataIndex:`parentName`,key:`parentName`,title:`上層`,width:280},{dataIndex:`path`,key:`path`,title:`Path`,width:420}],[]);return(0,r.useEffect)(()=>{w===`TABLE`&&D(R)},[w]),(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(q,{actionDisabled:k,actionIcon:re,actionLabel:ne,actions:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.Button,{onClick:()=>h(ee),variant:`base-secondary`,children:te}),O&&E.isEditing?(0,o.jsx)(i.Button,{disabled:x,icon:l.CloseIcon,iconType:`leading`,onClick:()=>T.current?.cancelEditing(),variant:`base-secondary`,children:`取消`}):null]}),description:`組織節點使用 ltree path 維護階層,搬移節點會同步更新子節點 path。`,onCreate:()=>{if(!O){n();return}if(E.isEditing){T.current?.saveDraft();return}T.current?.startEditing()},title:`組織樹`}),w===`TABLE`?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.FilterArea,{className:L.orgFilterArea,size:`sub`,children:(0,o.jsxs)(i.FilterLine,{children:[(0,o.jsx)(i.Filter,{span:3,children:(0,o.jsx)(i.FormField,{fullWidth:!0,layout:s.FormFieldLayout.VERTICAL,name:`orgUnitSearchText`,children:(0,o.jsx)(i.Input,{fullWidth:!0,onChange:e=>p(e.target.value),placeholder:`搜尋組織名稱或代碼`,size:`sub`,value:b,variant:`base`})})}),(0,o.jsx)(i.Filter,{span:2,children:(0,o.jsx)(i.FormField,{fullWidth:!0,layout:s.FormFieldLayout.VERTICAL,name:`orgUnitTypeFilter`,children:(0,o.jsx)(i.Select,{clearable:!1,fullWidth:!0,onChange:e=>m(We(e)),options:[...V],placeholder:`類型`,size:`sub`,value:C})})})]})}),(0,o.jsx)(`div`,{className:L.tableFrame,children:(0,o.jsx)(i.Table,{actions:e,columns:A,dataSource:[...y],fullWidth:!0,loading:t,pagination:K({onPageChange:u,onPageSizeChange:f,page:_,pageSize:v,total:S}),style:{minWidth:ye}})})]}):(0,o.jsx)(j,{ref:T,onCreateChild:a,onCreateRoot:n,onEditOrgUnit:c,onSaveDraft:d,onStateChange:D,orgUnits:g,saving:x})]})}function Te({actions:e,loading:t,onCreate:n,onPageChange:a,onPageSizeChange:c,onSearchTextChange:l,page:u,pageSize:d,rows:f,searchText:p,total:m}){let h=(0,r.useMemo)(()=>[{dataIndex:`code`,key:`code`,title:`代碼`,width:180},{dataIndex:`name`,key:`name`,title:`名稱`,width:280},{dataIndex:`level`,key:`level`,title:`職等`,width:96},{dataIndex:`updatedAt`,key:`updatedAt`,title:`更新時間`,width:220}],[]);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(q,{actionLabel:`新增職位`,description:`職位提供會員歸屬與主管解析規則使用。`,onCreate:n,title:`職位`}),(0,o.jsx)(i.FilterArea,{className:L.orgFilterArea,size:`sub`,children:(0,o.jsx)(i.FilterLine,{children:(0,o.jsx)(i.Filter,{span:3,children:(0,o.jsx)(i.FormField,{fullWidth:!0,layout:s.FormFieldLayout.VERTICAL,name:`positionSearchText`,children:(0,o.jsx)(i.Input,{fullWidth:!0,onChange:e=>l(e.target.value),placeholder:`搜尋職位名稱或代碼`,size:`sub`,value:p,variant:`base`})})})})}),(0,o.jsx)(`div`,{className:L.tableFrame,children:(0,o.jsx)(i.Table,{actions:e,columns:h,dataSource:[...f],fullWidth:!0,loading:t,pagination:K({onPageChange:a,onPageSizeChange:c,page:u,pageSize:d,total:m}),style:{minWidth:be}})})]})}function Ee({actions:e,loading:t,onCreate:a,onActiveFilterChange:c,onOrgUnitFilterChange:l,onPageChange:u,onPageSizeChange:d,onPositionFilterChange:f,orgUnitFilter:p,orgUnits:m,page:h,pageSize:g,positionFilter:_,positions:v,rows:y,statusFilter:b,total:x}){let S=(0,r.useMemo)(()=>[{dataIndex:`memberName`,key:`memberName`,title:`會員`,width:280},{dataIndex:`orgUnitName`,key:`orgUnitName`,title:`組織`,width:280},{dataIndex:`positionName`,key:`positionName`,title:`職位`,width:220},{key:`isPrimary`,render:e=>e.isPrimary?`主要`:`一般`,title:`類型`,width:104},{dataIndex:`effectiveFrom`,key:`effectiveFrom`,title:`生效日`,width:140},{dataIndex:`effectiveTo`,key:`effectiveTo`,title:`結束日`,width:140}],[]),C=(0,r.useMemo)(()=>m.map(n.a),[m]),w=(0,r.useMemo)(()=>v.map(n.o),[v]);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(q,{actionLabel:`新增歸屬`,description:`會員歸屬是 BPM 內部組織權限、主管解析與條件判斷的來源。`,onCreate:a,title:`會員歸屬`}),(0,o.jsx)(i.FilterArea,{className:[L.orgFilterArea,L.membershipFilterArea].join(` `),size:`sub`,children:(0,o.jsxs)(i.FilterLine,{children:[(0,o.jsx)(i.Filter,{span:2,children:(0,o.jsx)(i.FormField,{fullWidth:!0,layout:s.FormFieldLayout.VERTICAL,name:`membershipOrgUnitFilter`,children:(0,o.jsx)(i.AutoComplete,{disabledOptionsFilter:!0,emptyText:`沒有符合的組織`,inputProps:{autoCapitalize:`none`,autoCorrect:`off`,name:`membershipOrgUnitFilter`,spellCheck:!1},mode:`single`,name:`membershipOrgUnitFilter`,onChange:e=>l(Ye(e)),options:[...C],placeholder:`全部組織`,size:`sub`,value:p})})}),(0,o.jsx)(i.Filter,{span:2,children:(0,o.jsx)(i.FormField,{fullWidth:!0,layout:s.FormFieldLayout.VERTICAL,name:`membershipPositionFilter`,children:(0,o.jsx)(i.AutoComplete,{disabledOptionsFilter:!0,emptyText:`沒有符合的職位`,inputProps:{autoCapitalize:`none`,autoCorrect:`off`,name:`membershipPositionFilter`,spellCheck:!1},mode:`single`,name:`membershipPositionFilter`,onChange:e=>f(Y(e)),options:[...w],placeholder:`全部職位`,size:`sub`,value:_})})}),(0,o.jsx)(i.Filter,{span:2,children:(0,o.jsx)(i.FormField,{fullWidth:!0,layout:s.FormFieldLayout.VERTICAL,name:`membershipStatusFilter`,children:(0,o.jsx)(i.AutoComplete,{disabledOptionsFilter:!0,emptyText:`沒有符合的狀態`,inputProps:{autoCapitalize:`none`,autoCorrect:`off`,name:`membershipStatusFilter`,spellCheck:!1},mode:`single`,name:`membershipStatusFilter`,onChange:e=>c(Je(e)),options:[...W],placeholder:`全部狀態`,size:`sub`,value:b})})})]})}),(0,o.jsx)(`div`,{className:L.tableFrame,children:(0,o.jsx)(i.Table,{actions:e,columns:S,dataSource:[...y],fullWidth:!0,loading:t,pagination:K({onPageChange:u,onPageSizeChange:d,page:h,pageSize:g,total:x}),style:{minWidth:xe}})})]})}function De({actions:e,loading:t,onCreate:n,onActiveFilterChange:a,onPageChange:c,onPageSizeChange:l,onScopeTypeFilterChange:u,page:d,pageSize:f,rows:p,scopeTypeFilter:m,statusFilter:h,total:g}){let _=(0,r.useMemo)(()=>[{dataIndex:`scopeLabel`,key:`scopeLabel`,title:`套用範圍`,width:320},{dataIndex:`managerName`,key:`managerName`,title:`簽核主管`,width:300},{dataIndex:`priority`,key:`priority`,title:`優先序`,width:96},{dataIndex:`effectiveFrom`,key:`effectiveFrom`,title:`生效日`,width:140},{dataIndex:`effectiveTo`,key:`effectiveTo`,title:`結束日`,width:140}],[]);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(q,{actionLabel:`新增主管規則`,description:`簽核主管規則獨立於組織樹 parent,解析優先序為會員、組織、職位。`,onCreate:n,title:`簽核主管`}),(0,o.jsx)(i.FilterArea,{className:L.orgFilterArea,size:`sub`,children:(0,o.jsxs)(i.FilterLine,{children:[(0,o.jsx)(i.Filter,{span:3,children:(0,o.jsx)(i.FormField,{fullWidth:!0,layout:s.FormFieldLayout.VERTICAL,name:`managerScopeTypeFilter`,children:(0,o.jsx)(i.Select,{clearable:!1,fullWidth:!0,onChange:e=>u(Ke(e)),options:[...U],placeholder:`套用範圍`,size:`sub`,value:m})})}),(0,o.jsx)(i.Filter,{span:2,children:(0,o.jsx)(i.FormField,{fullWidth:!0,layout:s.FormFieldLayout.VERTICAL,name:`managerStatusFilter`,children:(0,o.jsx)(i.Select,{clearable:!1,fullWidth:!0,onChange:e=>a(qe(e)),options:[...W],placeholder:`狀態`,size:`sub`,value:h})})})]})}),(0,o.jsx)(`div`,{className:L.tableFrame,children:(0,o.jsx)(i.Table,{actions:e,columns:_,dataSource:[...p],fullWidth:!0,loading:t,pagination:K({onPageChange:c,onPageSizeChange:l,page:d,pageSize:f,total:g}),style:{minWidth:Se}})})]})}function K({onPageChange:e,onPageSizeChange:t,page:n,pageSize:r,total:i}){return{current:n,onChange:e,onChangePageSize:t,pageSize:r,pageSizeLabel:`每頁筆數`,pageSizeOptions:[...ve],renderResultSummary:(e,t,n)=>`顯示 ${e}-${t} 筆,共 ${n} 筆`,showPageSizeOptions:!0,total:i}}function Oe({isTreeEditing:e,isTreeMode:t}){return t?e?`儲存`:`開始編輯`:`新增組織`}function ke({isTreeEditing:e,isTreeMode:t}){return t?e?l.SaveIcon:l.EditIcon:l.PlusIcon}function Ae({hasDraftChanges:e,isTreeEditing:t,isTreeMode:n,loading:r,saving:i}){return n?t?!e||i:r:!1}function q({actionDisabled:e=!1,actionIcon:t=l.PlusIcon,actionLabel:n,actions:r,description:a,onCreate:s,title:c}){return(0,o.jsxs)(`div`,{className:L.tableIntro,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(i.Typography,{component:`h2`,variant:`h3`,children:c}),(0,o.jsx)(i.Typography,{color:`text-neutral`,variant:`body`,children:a})]}),(0,o.jsxs)(`div`,{className:L.tableIntroActions,children:[r,(0,o.jsx)(i.Button,{disabled:e,icon:t,iconType:`leading`,onClick:s,children:n})]})]})}function je({modal:e,onClose:a,onSubmit:s,orgUnits:c,saving:l}){let[u,d]=(0,r.useState)(``),[f,p]=(0,r.useState)(``),[m,h]=(0,r.useState)(null),[g,_]=(0,r.useState)(B[2]);return(0,r.useEffect)(()=>{if(!e)return;let t=e.record,r=t?.parentId??e.parentId??null,i=r?c.find(e=>e.id===r)??null:null;d(t?.code??``),p(t?.name??``),h(i?n.a(i):null),_(B.find(e=>e.id===t?.type)??B[2])},[e,c]),(0,o.jsx)(i.Modal,{cancelText:`取消`,confirmButtonProps:{disabled:!u||!f},confirmText:e?.type===`EDIT`?`儲存`:`建立`,loading:l,modalType:`standard`,onCancel:a,onClose:a,onConfirm:()=>void s({code:u,name:f,parentId:m?.id??null,type:g.id}),open:!!e,showModalFooter:!0,showModalHeader:!0,size:`regular`,title:e?.type===`EDIT`?`編輯組織`:`新增組織`,children:(0,o.jsxs)(`div`,{className:L.modalFields,children:[(0,o.jsx)(J,{label:`代碼`,name:`orgCode`,onChange:d,placeholder:`例如 FIN-TW`,value:u}),(0,o.jsx)(J,{label:`名稱`,name:`orgName`,onChange:p,placeholder:`例如 財務部`,value:f}),(0,o.jsx)(t.t,{label:`類型`,name:`orgType`,children:(0,o.jsx)(i.Select,{clearable:!1,fullWidth:!0,onChange:e=>_(Ue(e)),options:[...B],placeholder:`選擇組織類型`,value:g})}),(0,o.jsx)(t.t,{label:`上層組織`,name:`parentId`,children:(0,o.jsx)(n.n,{name:`parentId`,onChange:h,orgUnits:c.filter(t=>t.id!==e?.record?.id),placeholder:`選擇上層組織`,value:m})})]})})}function Me({modal:e,onClose:t,onSubmit:n,saving:a}){let[s,c]=(0,r.useState)(``),[l,u]=(0,r.useState)(`0`),[d,f]=(0,r.useState)(``);return(0,r.useEffect)(()=>{e&&(c(e.record?.code??``),u(String(e.record?.level??0)),f(e.record?.name??``))},[e]),(0,o.jsx)(i.Modal,{cancelText:`取消`,confirmButtonProps:{disabled:!s||!d},confirmText:e?.type===`EDIT`?`儲存`:`建立`,loading:a,modalType:`standard`,onCancel:t,onClose:t,onConfirm:()=>void n({code:s,level:Number(l),name:d}),open:!!e,showModalFooter:!0,showModalHeader:!0,size:`regular`,title:e?.type===`EDIT`?`編輯職位`:`新增職位`,children:(0,o.jsxs)(`div`,{className:L.modalFields,children:[(0,o.jsx)(J,{label:`代碼`,name:`positionCode`,onChange:c,placeholder:`例如 FIN-MGR`,value:s}),(0,o.jsx)(J,{label:`名稱`,name:`positionName`,onChange:f,placeholder:`例如 財務主管`,value:d}),(0,o.jsx)(J,{label:`職等`,name:`positionLevel`,onChange:u,placeholder:`例如 5`,value:l})]})})}function Ne({membersById:e,modal:a,onClose:s,onSubmit:c,orgUnits:l,positions:u,saving:d}){let[f,p]=(0,r.useState)(Ze()),[m,h]=(0,r.useState)(``),[g,_]=(0,r.useState)(G[1]),[v,y]=(0,r.useState)(null),[b,x]=(0,r.useState)(null),[S,C]=(0,r.useState)(null);return(0,r.useEffect)(()=>{if(!a)return;let t=a.record,r=t?e.get(t.memberId):null;p(t?.effectiveFrom??Ze()),h(t?.effectiveTo??``),_(G.find(e=>e.value===t?.isPrimary)??G[1]),y(r?n.i(r):null),x(Q(l.find(e=>e.id===t?.orgUnitId),n.a)),C(Q(u.find(e=>e.id===t?.positionId),n.o))},[e,a,l,u]),(0,o.jsx)(i.Modal,{cancelText:`取消`,confirmButtonProps:{disabled:!v||!b},confirmText:a?.type===`EDIT`?`儲存`:`建立`,loading:d,modalType:`standard`,onCancel:s,onClose:s,onConfirm:()=>void c({effectiveFrom:f,effectiveTo:m||null,isPrimary:g.value,memberId:v?.id??null,orgUnitId:b?.id??null,positionId:S?.id??null}),open:!!a,showModalFooter:!0,showModalHeader:!0,size:`regular`,title:a?.type===`EDIT`?`編輯會員歸屬`:`新增會員歸屬`,children:(0,o.jsxs)(`div`,{className:L.modalFields,children:[(0,o.jsx)(t.t,{label:`會員`,name:`memberId`,children:(0,o.jsx)(n.t,{name:`memberId`,onChange:y,placeholder:`搜尋會員姓名或信箱`,value:v})}),(0,o.jsx)(t.t,{label:`組織`,name:`orgUnitId`,children:(0,o.jsx)(n.n,{name:`orgUnitId`,onChange:x,orgUnits:l,placeholder:`選擇歸屬組織`,value:b})}),(0,o.jsx)(t.t,{label:`職位`,name:`positionId`,children:(0,o.jsx)(n.r,{name:`positionId`,onChange:C,placeholder:`選擇職位`,positions:u,value:S})}),(0,o.jsx)(t.t,{label:`歸屬類型`,name:`isPrimary`,children:(0,o.jsx)(i.Select,{clearable:!1,fullWidth:!0,onChange:e=>_(Xe(e)),options:[...G],placeholder:`選擇歸屬類型`,value:g})}),(0,o.jsx)(Fe,{label:`生效日`,name:`membershipEffectiveFrom`,onChange:p,placeholder:`YYYY-MM-DD`,value:f}),(0,o.jsx)(Fe,{label:`結束日`,name:`membershipEffectiveTo`,onChange:h,placeholder:`YYYY-MM-DD,未設定代表無期限`,value:m})]})})}function Pe({membersById:e,modal:a,onClose:s,onSubmit:c,orgUnits:l,positions:u,saving:d}){let[f,p]=(0,r.useState)(Ze()),[m,h]=(0,r.useState)(``),[g,_]=(0,r.useState)(null),[v,y]=(0,r.useState)(String(z)),[b,x]=(0,r.useState)(null),[S,C]=(0,r.useState)(null),[w,T]=(0,r.useState)(null),[E,D]=(0,r.useState)(H[0]);(0,r.useEffect)(()=>{if(!a)return;let t=a.record,r=H.find(e=>e.id===t?.scopeType)??H[0];p(t?.effectiveFrom??Ze()),h(t?.effectiveTo??``),_(Q(t?e.get(t.managerMemberId):null,n.i)),y(String(t?.priority??z)),x(r.id===`MEMBER`?Q(t?e.get(t.scopeId):null,n.i):null),C(r.id===`ORG_UNIT`?Q(l.find(e=>e.id===t?.scopeId),n.a):null),T(r.id===`POSITION`?Q(u.find(e=>e.id===t?.scopeId),n.o):null),D(r)},[e,a,l,u]);let ee=E.id===`MEMBER`?b?.id:E.id===`ORG_UNIT`?S?.id:w?.id,te=!!(E.id===`MEMBER`&&b?.id&&g?.id&&b.id===g.id);return(0,o.jsx)(i.Modal,{cancelText:`取消`,confirmButtonProps:{disabled:!g||!ee||te},confirmText:a?.type===`EDIT`?`儲存`:`建立`,loading:d,modalType:`standard`,onCancel:s,onClose:s,onConfirm:()=>void c({effectiveFrom:f,effectiveTo:m||null,managerMemberId:g?.id??null,priority:Number(v),scopeId:ee??null,scopeType:E.id}),open:!!a,showModalFooter:!0,showModalHeader:!0,size:`regular`,title:a?.type===`EDIT`?`編輯主管規則`:`新增主管規則`,children:(0,o.jsxs)(`div`,{className:L.modalFields,children:[(0,o.jsx)(t.t,{label:`套用範圍`,name:`scopeType`,children:(0,o.jsx)(i.Select,{clearable:!1,fullWidth:!0,onChange:e=>D(Ge(e)),options:[...H],placeholder:`選擇套用範圍`,value:E})}),E.id===`MEMBER`?(0,o.jsx)(t.t,{label:`會員`,name:`scopeMemberId`,children:(0,o.jsx)(n.t,{name:`scopeMemberId`,onChange:x,placeholder:`搜尋套用會員`,value:b})}):null,E.id===`ORG_UNIT`?(0,o.jsx)(t.t,{label:`組織`,name:`scopeOrgUnitId`,children:(0,o.jsx)(n.n,{name:`scopeOrgUnitId`,onChange:C,orgUnits:l,placeholder:`選擇套用組織`,value:S})}):null,E.id===`POSITION`?(0,o.jsx)(t.t,{label:`職位`,name:`scopePositionId`,children:(0,o.jsx)(n.r,{name:`scopePositionId`,onChange:T,placeholder:`選擇套用職位`,positions:u,value:w})}):null,(0,o.jsx)(t.t,{label:`簽核主管`,name:`managerMemberId`,children:(0,o.jsx)(n.t,{name:`managerMemberId`,onChange:_,placeholder:`搜尋簽核主管`,value:g})}),te?(0,o.jsx)(i.Typography,{color:`text-error`,variant:`caption`,children:`簽核主管不可設定為套用會員本人。`}):null,(0,o.jsx)(J,{hintText:`數字越大越優先,同一位成員命中多條規則時只會採用最高的那一層。建議:指定到人 200、部門主管 100、全公司通用的墊底規則 10。`,label:`優先序`,name:`managerPriority`,onChange:y,placeholder:`例如 100`,value:v}),(0,o.jsx)(Fe,{label:`生效日`,name:`managerEffectiveFrom`,onChange:p,placeholder:`YYYY-MM-DD`,value:f}),(0,o.jsx)(Fe,{label:`結束日`,name:`managerEffectiveTo`,onChange:h,placeholder:`YYYY-MM-DD,未設定代表無期限`,value:m})]})})}function J({hintText:e,label:n,name:r,onChange:a,placeholder:s,value:c}){return(0,o.jsx)(t.t,{hintText:e,label:n,name:r,children:(0,o.jsx)(i.Input,{fullWidth:!0,name:r,onChange:e=>a(e.target.value),placeholder:s,value:c})})}function Fe({label:e,name:n,onChange:r,placeholder:a,value:s}){return(0,o.jsx)(t.t,{label:e,name:n,children:(0,o.jsx)(i.DatePicker,{format:`YYYY-MM-DD`,fullWidth:!0,inputProps:{name:n},onChange:e=>r(Qe(e)),placeholder:a,value:s.trim()?s:void 0})})}function Ie(e,t){return[...new Set([...e.map(e=>e.memberId),...t.map(e=>e.managerMemberId),...t.filter(e=>e.scopeType===`MEMBER`).map(e=>e.scopeId)])]}function Le(e,t){return e.scopeType===`MEMBER`?`會員:${Re(t.membersById.get(e.scopeId))}`:e.scopeType===`ORG_UNIT`?`組織:${ze(t.orgUnitsById.get(e.scopeId))}`:`職位:${Ve(t.positionsById.get(e.scopeId))}`}function Re(e){return e?`${e.name} · ${e.email}`:`未知會員`}function ze(e){return e?`${e.name} · ${e.code}`:`未知組織`}function Be(e){return B.find(t=>t.id.toLowerCase()===e.toLowerCase())?.name??`未知類型`}function Ve(e){return e?`${e.name} · ${e.code}`:`未指定`}function He(e){return e===`MANAGERS`||e===`MEMBERSHIPS`||e===`POSITIONS`?e:`ORG_UNITS`}function Ue(e){let t=Z(e)?e:null;if(typeof t?.id==`string`){let e=t.id;return B.find(t=>t.id.toLowerCase()===e.toLowerCase())??B[2]}return B[2]}function We(e){let t=Z(e)?e:null;if(typeof t?.id==`string`){let e=t.id;return V.find(t=>t.id.toLowerCase()===e.toLowerCase())??he}return he}function Ge(e){return X(e,H,H[0])}function Ke(e){return X(e,U,ge)}function qe(e){return X(e,W,_e)}function Je(e){let t=Z(e)?e:null,n=typeof t?.id==`string`?t.id:null;return W.find(e=>e.id===n)??null}function Ye(e){let t=Z(e)?e:null,n=typeof t?.id==`string`?t.id:null,r=typeof t?.name==`string`?t.name:null;return n&&r?{id:n,name:r}:null}function Y(e){let t=Z(e)?e:null,n=typeof t?.id==`string`?t.id:null,r=typeof t?.name==`string`?t.name:null;return n&&r?{id:n,name:r}:null}function Xe(e){return X(e,G,G[1])}function X(e,t,n){let r=Z(e)?e:null,i=typeof r?.id==`string`?r.id:null;return t.find(e=>e.id===i)??n}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Q(e,t){return e?t(e):null}function Ze(){return $(new Date)}function Qe(e){let t=e?new Date(e):null;return t&&!Number.isNaN(t.getTime())?$(t):``}function $(e){return`${e.getFullYear()}-${$e(e.getMonth()+1)}-${$e(e.getDate())}`}function $e(e){return String(e).padStart(2,`0`)}function et(e){return e instanceof Error?e.message:`讀取組織資料失敗。`}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Ce}});
|
|
2
|
+
//# sourceMappingURL=orgs-BefGgeyc.cjs.map
|