Kaynağa Gözat

fix: 项目管理详情审批申报人改成树结构

outaozhen 3 yıl önce
ebeveyn
işleme
65a01d4e1a

+ 19 - 11
src/pages/Project/Management/components/Detail.tsx

@@ -1,8 +1,8 @@
 import { connect, useRequest } from 'umi'
 import { useEffect, useRef, useState } from 'react'
-import { message, Tabs } from 'antd'
+import { message, Tabs, TreeSelect, Form } from 'antd'
 import { getApprovalList, setApproval } from '@/services/api/project'
-import { queryAcountList } from '@/services/api/institution'
+import { queryAcountInstitutionList } from '@/services/api/institution'
 import { delay } from '@/utils/util'
 import FormRender, { useForm } from 'form-render'
 import { BaseMenuEnum } from '@/pages/Schema/Base'
@@ -44,15 +44,16 @@ const DetailModal: React.FC<ProjectModalProps> = ({
   const ref = useRef<FormInstance>(null)
   const { TabPane } = Tabs
   const [state, setState] = useState({
-    acountList: [],
+    acountInstitutionList: [],
     approvalList: [],
     activeKey: ''
   })
+  console.log(state.acountInstitutionList)
 
-  const { run: tryAcountList } = useRequest(() => queryAcountList(), {
+  const { run: tryAcountInstitutionList } = useRequest(() => queryAcountInstitutionList(), {
     manual: true,
     onSuccess: result => {
-      setState({ ...state, acountList: result.items })
+      setState({ ...state, acountInstitutionList: result })
     }
   })
 
@@ -81,7 +82,7 @@ const DetailModal: React.FC<ProjectModalProps> = ({
     }
     if (state.activeKey === '2') {
       const TabFormData = {
-        accountID: defaultFormData.approval.name,
+        // accountID: defaultFormData.approval.name,
         approvalID: defaultFormData.reportAccount.name
       }
       ref.current?.setFieldsValue({ ...TabFormData })
@@ -100,7 +101,6 @@ const DetailModal: React.FC<ProjectModalProps> = ({
     })
     // console.log(currentFormData)
     form.setValues({ ...currentFormData })
-    // form.setValues({ ...defaultFormData })
     delay(80).then(() => {
       form.setSchemaByPath('projectTypeID', {
         enum: pTypeList.map(item => item.value),
@@ -112,8 +112,8 @@ const DetailModal: React.FC<ProjectModalProps> = ({
   const onChange = key => {
     setState({ ...state, activeKey: key })
     if (key === '2') {
-      if (!state.acountList?.length) {
-        tryAcountList()
+      if (!state.acountInstitutionList?.length) {
+        tryAcountInstitutionList()
       }
       if (!state.approvalList?.length) {
         tryApprovalList()
@@ -136,7 +136,15 @@ const DetailModal: React.FC<ProjectModalProps> = ({
           formRef={ref}
           submitter={{ resetButtonProps: { style: { display: 'none' } } }}
           onFinish={onFinish}>
-          <ProFormSelect
+          <Form.Item label="上报人" name="accountID">
+            <TreeSelect
+              style={{ width: '100%' }}
+              placeholder="请选择上报人"
+              treeDefaultExpandAll
+              treeData={state.acountInstitutionList}
+            />
+          </Form.Item>
+          {/* <ProFormSelect
             name="accountID"
             label={'上报人'}
             placeholder="请选择上报人"
@@ -144,7 +152,7 @@ const DetailModal: React.FC<ProjectModalProps> = ({
               label: item.name,
               value: item.ID
             }))}
-          />
+          /> */}
           <ProFormSelect
             name="approvalID"
             label={'审批流程'}

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

@@ -32,6 +32,14 @@ export async function queryAcountList(params: API.InstitutionAddParams) {
   })
 }
 
+/** 单位下帐号列表 */
+export async function queryAcountInstitutionList(params: API.AcountInstitutionParams) {
+  return request('/account/institution', {
+    method: 'POST',
+    data: params
+  })
+}
+
 /** 编辑账号 */
 export async function updateAccount(params: API.AcountUpdateParams) {
   return request('/account/update', {

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

@@ -98,6 +98,8 @@ declare namespace API {
       ID: string
       name: string
     }
+    key: string
+    value: string
     created: string
     createdID: string
     id: string
@@ -127,6 +129,13 @@ declare namespace API {
     ID: string
   }
 
+  type AcountInstitutionParams = {
+    name: string
+    key: string
+    value: string
+    children: AccountListItem[]
+  }
+
   type AccountType = {
     value: number
     name: string