|
@@ -1,4 +1,4 @@
|
|
|
-import { Button, Popconfirm, message, Tooltip } from 'antd'
|
|
|
+import { Button, Popconfirm, message, Table, Tooltip } from 'antd'
|
|
|
import type { ActionType } from '@ant-design/pro-table'
|
|
|
import ProTable from '@ant-design/pro-table'
|
|
|
import React, { useState, useEffect, useRef } from 'react'
|
|
@@ -26,6 +26,7 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
|
|
|
const [state, setState] = useState({
|
|
|
organizationList: [],
|
|
|
visible: false,
|
|
|
+ expandTreeIds: [],
|
|
|
currentModalType: ModalType.ADD,
|
|
|
defaultFormData: null,
|
|
|
parentID: '',
|
|
@@ -34,7 +35,6 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
|
|
|
down: 'down',
|
|
|
accountTotal: null
|
|
|
})
|
|
|
- const [expandTree, setExpandTree] = useState([])
|
|
|
const titleType = {
|
|
|
ADD: 1,
|
|
|
ADDITEM: 2,
|
|
@@ -52,17 +52,17 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
|
|
|
let idArr: string[] = []
|
|
|
data.forEach((item: OrganizationalStructureListItem) => {
|
|
|
if (item.children?.length) {
|
|
|
- idArr.push(item.id)
|
|
|
+ idArr.push(item.ID)
|
|
|
const childIDs = expandTreeList(item.children)
|
|
|
idArr = [...idArr, ...childIDs]
|
|
|
}
|
|
|
})
|
|
|
+ return idArr
|
|
|
}
|
|
|
setState({
|
|
|
...state,
|
|
|
organizationList: result,
|
|
|
- ...setExpandTree,
|
|
|
- expandTree: expandTreeList
|
|
|
+ expandTreeIds: expandTreeList(result)
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -222,13 +222,25 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
|
|
|
|
|
|
return (
|
|
|
<div>
|
|
|
- <ProTable<API.OrganizationalStructureListItem>
|
|
|
+ <Table<API.OrganizationalStructureListItem>
|
|
|
rowKey="ID"
|
|
|
actionRef={tRef}
|
|
|
columns={columns}
|
|
|
dataSource={state.organizationList}
|
|
|
- defaultExpandAllRows={true}
|
|
|
- expandable={{ defaultExpandedRowKeys: state.expandTree }}
|
|
|
+ // defaultExpandAllRows={true}
|
|
|
+ expandable={{
|
|
|
+ expandedRowKeys: state.expandTreeIds,
|
|
|
+ onExpand: (expanded, record) => {
|
|
|
+ if (expanded) {
|
|
|
+ if (state.expandTreeIds.includes(record.ID)) return
|
|
|
+ setState({ ...state, expandTreeIds: [...state.expandTreeIds, record.ID] })
|
|
|
+ }
|
|
|
+ setState({
|
|
|
+ ...state,
|
|
|
+ expandTreeIds: state.expandTreeIds.filter(item => item !== record.ID)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }}
|
|
|
// expandedRowRender={expandedRowRender}
|
|
|
indentSize={30}
|
|
|
search={false}
|