Просмотр исходного кода

feat: 组织架构上移、下移、移动功能

outaozhen 3 лет назад
Родитель
Сommit
1af777e27b

+ 22 - 18
src/pages/Institutions/Company/Detail/components/Organization.tsx

@@ -6,7 +6,7 @@ import { useRequest } from 'umi'
 import { DeleteOutlined } from '@ant-design/icons'
 import {
   queryOrganizationalStructureList,
-  moveOrganizationalStructure
+  moveSortOrganizationalStructure
 } from '@/services/api/institution'
 import OrganizationModal, { ModalType } from './OrganizationModal'
 
@@ -22,7 +22,9 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
     currentModalType: ModalType.ADD,
     defaultFormData: null,
     parentID: '',
-    typeEum: '1'
+    typeEum: '1',
+    up: 'up',
+    down: 'down'
   })
   const titleType = {
     ADD: 1,
@@ -42,7 +44,7 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
     }
   )
 
-  const { run: tryMoveOrganization } = useRequest(moveOrganizationalStructure, {
+  const { run: tryMoveOrganization } = useRequest(moveSortOrganizationalStructure, {
     manual: true,
     onSuccess: () => {
       tryOrganizationList()
@@ -73,7 +75,7 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
                 title="确认上移吗?"
                 okText="确认"
                 cancelText="取消"
-                onConfirm={() => tryMoveOrganization({ ID: record.ID, moveID: record.parentID })}>
+                onConfirm={() => tryMoveOrganization({ ID: record.ID, operation: state.up })}>
                 上移
               </Popconfirm>
             </div>
@@ -84,11 +86,26 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
                 title="确认下移吗?"
                 okText="确认"
                 cancelText="取消"
-                onConfirm={() => tryMoveOrganization({ ID: record.parentID, moveID: record.ID })}>
+                onConfirm={() => tryMoveOrganization({ ID: record.ID, operation: state.down })}>
                 下移
               </Popconfirm>
             </div>
           ) : null}
+          {record.isLeaf === true ? (
+            <div
+              className="px-2 text-primary cursor-pointer hover:text-hex-967bbd"
+              onClick={() => {
+                setState({
+                  ...state,
+                  visible: true,
+                  currentModalType: ModalType.MOVE,
+                  defaultFormData: record,
+                  typeEum: titleType.MOVE
+                })
+              }}>
+              移动
+            </div>
+          ) : null}
           <div
             className="px-2 text-primary cursor-pointer hover:text-hex-967bbd"
             onClick={() => {
@@ -107,19 +124,6 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
             }}>
             添加子项
           </div>
-          {/* <div
-            className="px-2 text-primary cursor-pointer hover:text-hex-967bbd"
-            onClick={() => {
-              setState({
-                ...state,
-                visible: true,
-                currentModalType: ModalType.MOVE,
-                defaultFormData: record,
-                typeEum: titleType.MOVE
-              })
-            }}>
-            移动
-          </div> */}
           <div
             className="px-2 text-primary cursor-pointer hover:text-hex-967bbd"
             onClick={() => {

+ 2 - 2
src/pages/Institutions/Company/Detail/components/OrganizationModal.tsx

@@ -166,7 +166,7 @@ const OrganizationModal: React.FC<OrganizationModalProps> = ({
           <p>确认删除?</p>
         </ProForm>
       ) : null}
-      {/* {type === ModalType.MOVE ? (
+      {type === ModalType.MOVE ? (
         <ProForm formRef={ref} submitter={{ render: false }}>
           <ProFormText name="ID" hidden />
           <Form.Item label="目标架构" name="moveID">
@@ -178,7 +178,7 @@ const OrganizationModal: React.FC<OrganizationModalProps> = ({
             />
           </Form.Item>
         </ProForm>
-      ) : null} */}
+      ) : null}
     </Modal>
   )
 }

+ 10 - 0
src/services/api/institution.ts

@@ -83,6 +83,16 @@ export async function updateOrganizationalStructure(
   })
 }
 
+/** 上下移动组织架构 */
+export async function moveSortOrganizationalStructure(
+  params: API.OrganizationalStructureMoveSortParams
+) {
+  return request('/OrganizationalStructure/moveSort', {
+    method: 'POST',
+    data: params
+  })
+}
+
 /** 移动组织结构 */
 export async function moveOrganizationalStructure(params: API.OrganizationalStructureMoveParams) {
   return request('/OrganizationalStructure/move', {

+ 5 - 0
src/services/api/typings.d.ts

@@ -160,6 +160,11 @@ declare namespace API {
     name: string
   }
 
+  type OrganizationalStructureMoveSortParams = {
+    ID: string
+    operation: string
+  }
+
   type OrganizationalStructureMoveParams = {
     ID: string
     moveID: string