|
@@ -1,10 +1,13 @@
|
|
|
-import { Breadcrumb, Button } from 'antd'
|
|
|
+import { Button, Popconfirm, message } from 'antd'
|
|
|
import type { ActionType } from '@ant-design/pro-table'
|
|
|
import ProTable from '@ant-design/pro-table'
|
|
|
-import React, { useState, useEffect, useRef } from 'react'
|
|
|
+import React, { useState, useRef } from 'react'
|
|
|
import { useRequest } from 'umi'
|
|
|
import { DeleteOutlined } from '@ant-design/icons'
|
|
|
-import { queryOrganizationalStructureList } from '@/services/api/institution'
|
|
|
+import {
|
|
|
+ queryOrganizationalStructureList,
|
|
|
+ moveOrganizationalStructure
|
|
|
+} from '@/services/api/institution'
|
|
|
import OrganizationModal, { ModalType } from './OrganizationModal'
|
|
|
|
|
|
type OrganizationProps = {
|
|
@@ -29,6 +32,24 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
|
|
|
MOVE: 5
|
|
|
}
|
|
|
|
|
|
+ const { run: tryOrganizationList } = useRequest(
|
|
|
+ () => queryOrganizationalStructureList({ dataID, structureType }),
|
|
|
+ {
|
|
|
+ // manual: true,
|
|
|
+ onSuccess: result => {
|
|
|
+ setState({ ...state, organizationList: result })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
+
|
|
|
+ const { run: tryMoveOrganization } = useRequest(moveOrganizationalStructure, {
|
|
|
+ manual: true,
|
|
|
+ onSuccess: () => {
|
|
|
+ tryOrganizationList()
|
|
|
+ message.success('移动成功')
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
const columns: ColumnType<API.OrganizationalStructureListItem>[] = [
|
|
|
{
|
|
|
title: '组织名称',
|
|
@@ -46,6 +67,28 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
|
|
|
key: 'operation',
|
|
|
render: (_, record) => (
|
|
|
<div className="divide-x divide-bg-gray-400 flex flex-row">
|
|
|
+ {record.isStart === false ? (
|
|
|
+ <div className="px-2 text-primary cursor-pointer hover:text-hex-967bbd">
|
|
|
+ <Popconfirm
|
|
|
+ title="确认上移吗?"
|
|
|
+ okText="确认"
|
|
|
+ cancelText="取消"
|
|
|
+ onConfirm={() => tryMoveOrganization({ ID: record.ID, moveID: record.parentID })}>
|
|
|
+ 上移
|
|
|
+ </Popconfirm>
|
|
|
+ </div>
|
|
|
+ ) : null}
|
|
|
+ {record.isEnd === false ? (
|
|
|
+ <div className="px-2 text-primary cursor-pointer hover:text-hex-967bbd">
|
|
|
+ <Popconfirm
|
|
|
+ title="确认下移吗?"
|
|
|
+ okText="确认"
|
|
|
+ cancelText="取消"
|
|
|
+ onConfirm={() => tryMoveOrganization({ ID: record.parentID, moveID: record.ID })}>
|
|
|
+ 下移
|
|
|
+ </Popconfirm>
|
|
|
+ </div>
|
|
|
+ ) : null}
|
|
|
<div
|
|
|
className="px-2 text-primary cursor-pointer hover:text-hex-967bbd"
|
|
|
onClick={() => {
|
|
@@ -64,7 +107,7 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
|
|
|
}}>
|
|
|
添加子项
|
|
|
</div>
|
|
|
- <div
|
|
|
+ {/* <div
|
|
|
className="px-2 text-primary cursor-pointer hover:text-hex-967bbd"
|
|
|
onClick={() => {
|
|
|
setState({
|
|
@@ -76,7 +119,7 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
|
|
|
})
|
|
|
}}>
|
|
|
移动
|
|
|
- </div>
|
|
|
+ </div> */}
|
|
|
<div
|
|
|
className="px-2 text-primary cursor-pointer hover:text-hex-967bbd"
|
|
|
onClick={() => {
|
|
@@ -90,46 +133,28 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
|
|
|
}}>
|
|
|
重命名
|
|
|
</div>
|
|
|
- <div className="pl-2 text-hex-fd3995 cursor-pointer hover:text-hex-967bbd">
|
|
|
- <DeleteOutlined
|
|
|
- onClick={() => {
|
|
|
- setState({
|
|
|
- ...state,
|
|
|
- visible: true,
|
|
|
- currentModalType: ModalType.DEL,
|
|
|
- defaultFormData: record,
|
|
|
- typeEum: titleType.DEL
|
|
|
- })
|
|
|
- }}
|
|
|
- />
|
|
|
- </div>
|
|
|
+ {!record.parentID === false ? (
|
|
|
+ <div className="pl-2 text-hex-fd3995 cursor-pointer hover:text-hex-967bbd">
|
|
|
+ <DeleteOutlined
|
|
|
+ onClick={() => {
|
|
|
+ setState({
|
|
|
+ ...state,
|
|
|
+ visible: true,
|
|
|
+ currentModalType: ModalType.DEL,
|
|
|
+ defaultFormData: record,
|
|
|
+ typeEum: titleType.DEL
|
|
|
+ })
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ ) : null}
|
|
|
</div>
|
|
|
)
|
|
|
}
|
|
|
]
|
|
|
- const { run: tryOrganizationList } = useRequest(
|
|
|
- () => queryOrganizationalStructureList({ dataID, structureType }),
|
|
|
- {
|
|
|
- // manual: true,
|
|
|
- onSuccess: result => {
|
|
|
- setState({ ...state, organizationList: result })
|
|
|
- }
|
|
|
- }
|
|
|
- )
|
|
|
|
|
|
- useEffect(() => {
|
|
|
- // tryOrganizationList()
|
|
|
- }, [])
|
|
|
return (
|
|
|
<div>
|
|
|
- <div className="mb-2">
|
|
|
- <Breadcrumb>
|
|
|
- <Breadcrumb.Item>
|
|
|
- <a href="/institutions/company">单位管理</a>
|
|
|
- </Breadcrumb.Item>
|
|
|
- <Breadcrumb.Item>组织架构</Breadcrumb.Item>
|
|
|
- </Breadcrumb>
|
|
|
- </div>
|
|
|
{state.organizationList && state.organizationList.length ? (
|
|
|
<ProTable<API.OrganizationalStructureListItem>
|
|
|
rowKey="ID"
|
|
@@ -170,6 +195,8 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
|
|
|
tryOrganizationList()
|
|
|
}}
|
|
|
defaultFormData={state.defaultFormData}
|
|
|
+ dataID={dataID}
|
|
|
+ structureType={structureType}
|
|
|
/>
|
|
|
</div>
|
|
|
)
|