|
@@ -1,4 +1,4 @@
|
|
|
-import { Button, Popconfirm, message, Table, Tooltip } from 'antd'
|
|
|
+import { Button, Popconfirm, message, Tooltip } from 'antd'
|
|
|
import type { ActionType } from '@ant-design/pro-table'
|
|
|
import ProTable from '@ant-design/pro-table'
|
|
|
import React, { useState, useRef } from 'react'
|
|
@@ -16,33 +16,31 @@ import {
|
|
|
moveSortOrganizationalStructure
|
|
|
} from '@/services/api/institution'
|
|
|
import OrganizationModal from './OrganizationModal'
|
|
|
-import { ModalType } from '@/utils/enum'
|
|
|
|
|
|
type OrganizationProps = {
|
|
|
dataID: string
|
|
|
structureType: string
|
|
|
}
|
|
|
+
|
|
|
+export enum OrganizationModalEnum {
|
|
|
+ ADD = 1,
|
|
|
+ ADDITEM = 2,
|
|
|
+ RENAME = 3,
|
|
|
+ DEL = 4,
|
|
|
+ MOVE = 5
|
|
|
+}
|
|
|
+
|
|
|
const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) => {
|
|
|
const tRef = useRef<ActionType>(null)
|
|
|
const [state, setState] = useState({
|
|
|
organizationList: [],
|
|
|
visible: false,
|
|
|
expandTreeIds: [],
|
|
|
- currentModalType: ModalType.ADD,
|
|
|
defaultFormData: null,
|
|
|
parentID: '',
|
|
|
- typeEum: '1',
|
|
|
- up: 'up',
|
|
|
- down: 'down',
|
|
|
+ modalType: OrganizationModalEnum.ADD,
|
|
|
accountTotal: null
|
|
|
})
|
|
|
- const titleType = {
|
|
|
- ADD: 1,
|
|
|
- ADDITEM: 2,
|
|
|
- RENAME: 3,
|
|
|
- DEL: 4,
|
|
|
- MOVE: 5
|
|
|
- }
|
|
|
|
|
|
const { run: tryOrganizationList } = useRequest(
|
|
|
() => queryOrganizationalStructureList({ dataID, structureType }),
|
|
@@ -69,32 +67,6 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
|
|
|
}
|
|
|
)
|
|
|
|
|
|
- // const getData = () => {
|
|
|
- // // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
- // return new Promise((resolve, reject) => {
|
|
|
- // // setState(data)
|
|
|
- // const newExpandedKeys = []
|
|
|
- // const render = treeDatas => {
|
|
|
- // // 获取到所有可展开的父节点
|
|
|
- // treeDatas.map(item => {
|
|
|
- // if (item.children) {
|
|
|
- // newExpandedKeys.push(item.key)
|
|
|
- // render(item.children)
|
|
|
- // }
|
|
|
- // })
|
|
|
- // return newExpandedKeys
|
|
|
- // }
|
|
|
- // // setDefaultExpanded(render(newData))
|
|
|
- // resolve({
|
|
|
- // // data: newData
|
|
|
- // })
|
|
|
- // })
|
|
|
- // }
|
|
|
-
|
|
|
- // useEffect(() => {
|
|
|
- // getData()
|
|
|
- // }, [])
|
|
|
-
|
|
|
const { run: tryMoveOrganization } = useRequest(moveSortOrganizationalStructure, {
|
|
|
manual: true,
|
|
|
onSuccess: () => {
|
|
@@ -126,7 +98,8 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
|
|
|
title="确认上移吗?"
|
|
|
okText="确认"
|
|
|
cancelText="取消"
|
|
|
- onConfirm={() => tryMoveOrganization({ ID: record.ID, operation: state.up })}>
|
|
|
+ onConfirm={() => tryMoveOrganization({ ID: record.ID, operation: 'up' })}
|
|
|
+ >
|
|
|
<Tooltip placement="top" title="上移">
|
|
|
<ArrowUpOutlined />
|
|
|
</Tooltip>
|
|
@@ -139,7 +112,8 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
|
|
|
title="确认下移吗?"
|
|
|
okText="确认"
|
|
|
cancelText="取消"
|
|
|
- onConfirm={() => tryMoveOrganization({ ID: record.ID, operation: state.down })}>
|
|
|
+ onConfirm={() => tryMoveOrganization({ ID: record.ID, operation: 'down' })}
|
|
|
+ >
|
|
|
<Tooltip placement="top" title="下移">
|
|
|
<ArrowDownOutlined />
|
|
|
</Tooltip>
|
|
@@ -153,11 +127,11 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
|
|
|
setState({
|
|
|
...state,
|
|
|
visible: true,
|
|
|
- currentModalType: ModalType.MOVE,
|
|
|
defaultFormData: record,
|
|
|
- typeEum: titleType.MOVE
|
|
|
+ modalType: OrganizationModalEnum.MOVE
|
|
|
})
|
|
|
- }}>
|
|
|
+ }}
|
|
|
+ >
|
|
|
<Tooltip placement="top" title="移动">
|
|
|
<SwapOutlined />
|
|
|
</Tooltip>
|
|
@@ -170,15 +144,15 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
|
|
|
setState({
|
|
|
...state,
|
|
|
visible: true,
|
|
|
- currentModalType: ModalType.ADD,
|
|
|
defaultFormData: {
|
|
|
dataID: dataID,
|
|
|
structureType: structureType,
|
|
|
parentID: record.ID
|
|
|
},
|
|
|
- typeEum: titleType.ADDITEM
|
|
|
+ modalType: OrganizationModalEnum.ADDITEM
|
|
|
})
|
|
|
- }}>
|
|
|
+ }}
|
|
|
+ >
|
|
|
<Tooltip placement="top" title="添加子项">
|
|
|
<PlusSquareOutlined />
|
|
|
</Tooltip>
|
|
@@ -189,11 +163,11 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
|
|
|
setState({
|
|
|
...state,
|
|
|
visible: true,
|
|
|
- currentModalType: ModalType.UPDATE,
|
|
|
defaultFormData: record,
|
|
|
- typeEum: titleType.RENAME
|
|
|
+ modalType: OrganizationModalEnum.RENAME
|
|
|
})
|
|
|
- }}>
|
|
|
+ }}
|
|
|
+ >
|
|
|
<Tooltip placement="top" title="重命名">
|
|
|
<EditOutlined />
|
|
|
</Tooltip>
|
|
@@ -206,9 +180,8 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
|
|
|
setState({
|
|
|
...state,
|
|
|
visible: true,
|
|
|
- currentModalType: ModalType.DEL,
|
|
|
defaultFormData: record,
|
|
|
- typeEum: titleType.DEL,
|
|
|
+ modalType: OrganizationModalEnum.DEL,
|
|
|
accountTotal: record.accountTotal
|
|
|
})
|
|
|
}}
|
|
@@ -256,15 +229,15 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
|
|
|
setState({
|
|
|
...state,
|
|
|
visible: true,
|
|
|
- currentModalType: ModalType.ADD,
|
|
|
- typeEum: titleType.ADD,
|
|
|
+ modalType: OrganizationModalEnum.ADD,
|
|
|
defaultFormData: {
|
|
|
dataID: dataID,
|
|
|
structureType: structureType,
|
|
|
parentID: state.parentID
|
|
|
}
|
|
|
})
|
|
|
- }>
|
|
|
+ }
|
|
|
+ >
|
|
|
添加组织
|
|
|
</Button>
|
|
|
]
|
|
@@ -288,7 +261,7 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
|
|
|
...state,
|
|
|
visible: true,
|
|
|
currentModalType: ModalType.ADD,
|
|
|
- typeEum: titleType.ADD,
|
|
|
+ modalType: titleType.ADD,
|
|
|
defaultFormData: {
|
|
|
dataID: dataID,
|
|
|
structureType: structureType,
|
|
@@ -303,8 +276,7 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
|
|
|
/>
|
|
|
) : null} */}
|
|
|
<OrganizationModal
|
|
|
- type={state.currentModalType}
|
|
|
- typeEum={state.typeEum}
|
|
|
+ type={state.modalType}
|
|
|
visible={state.visible}
|
|
|
setVisible={(visible: boolean) => setState({ ...state, visible })}
|
|
|
reload={() => {
|