lanjianrong 3 years ago
parent
commit
3a546ddc83

+ 1 - 66
src/pages/Institutions/Company/List/index.tsx

@@ -11,53 +11,22 @@ import CompanyDrawer from './components/CompanyDrawer'
 import { ModalType } from '@/utils/enum'
 import AnimateContent from '@/components/AnimateContent'
 
-// type ListProps = ConnectProps & {
-//   pTypeList: { label: string; value: string }[]
-//   base: Record<string, any>
-// }
-
 export type InstitutionDetailProps = {
   dataID: string
-  // structureType: string
-  // name: string
-  // memberTotal: number
-  // managerID: string
 }
 
 const CompanyList = () => {
   const tRef = useRef<ActionType>(null)
-  // const schema = base?.[BaseMenuEnum.COMPANY]?.schema
-  // useEffect(() => {
-  // if (!pTypeList.length) {
-  //   dispatch({
-  //     type: 'project/queryProjectTypeList'
-  //   })
-  // }
-  // if (!base[BaseMenuEnum.COMPANY]) {
-  //   dispatch({
-  //     type: 'schemaBase/querySchema',
-  //     payload: {
-  //       columnType: BaseMenuEnum.COMPANY
-  //     }
-  //   })
-  // }
-  // }, [])
   const [state, setState] = useState({
     params: {
-      search: null,
-      accountType: '1'
+      search: null
     },
     visible: false,
     currentModalType: ModalType.ADD,
     defaultFormData: null
   })
-  // const { run: tryDelProject } = useRequest(delProject, {
-  //   manual: true,
-  //   onSuccess: () => tRef.current?.reload()
-  // })
 
   const goToDetail = (params: InstitutionDetailProps) => {
-    // return history.push(`/institutions/company/companyname`)
     return history.push({
       pathname: '/institutions/company/detail',
       state: params
@@ -75,10 +44,6 @@ const CompanyList = () => {
           onClick={() =>
             goToDetail({
               dataID: record.ID
-              // structureType: state.structureType,
-              // name: record.name,
-              // memberTotal: record.memberTotal,
-              // managerID: record.manager.ID
             })
           }
           className="text-primary cursor-pointer">
@@ -108,20 +73,6 @@ const CompanyList = () => {
       onHeaderCell: () => ({ style: { textAlign: 'center' } }),
       renderText: text => dayjs(text).format('YYYY-MM-DD')
     },
-    // {
-    //   dataIndex: 'project_type_id',
-    //   title: '项目类型',
-    //   filters: true,
-    //   filterMultiple: false,
-    //   render: (_, record) => <div>{record.project_type.name}</div>,
-    //   valueEnum: pTypeList.reduce((prev, curr) => {
-    //     const items = { ...prev }
-    //     items[curr.value] = {
-    //       text: curr.label
-    //     }
-    //     return items
-    //   }, {})
-    // },
     {
       dataIndex: 'created',
       title: '创建人',
@@ -149,16 +100,6 @@ const CompanyList = () => {
             }}>
             编辑
           </div>
-          {/* <Popconfirm
-            title="确认删除吗?"
-            okText="确认"
-            cancelText="取消"
-            onConfirm={() => tryDelProject({ id: record.id })}
-          >
-            <div className="pl-2 text-hex-fd3995 cursor-pointer hover:text-hex-e7026e">
-              <DeleteOutlined />
-            </div>
-          </Popconfirm> */}
         </div>
       )
     }
@@ -217,10 +158,4 @@ const CompanyList = () => {
   )
 }
 
-// export default connect(
-//   ({ project, schemaBase }: { project: ProjectModelState; schemaBase: SchemaBaseModelState }) => ({
-//     pTypeList: project.projectTypeList.map(item => ({ label: item.name, value: item.ID }))
-//     // base: schemaBase.base
-//   })
-// )(CompanyList)
 export default CompanyList

+ 58 - 54
src/pages/Institutions/Staff/components/StaffDetail.tsx

@@ -1,4 +1,4 @@
-import React, { useEffect, useRef } from 'react'
+import React, { useEffect, useMemo, useRef } from 'react'
 import { message, Button } from 'antd'
 import { connect, Link, useRequest } from 'umi'
 import { addAccount, updateAccount } from '@/services/api/institution'
@@ -10,7 +10,7 @@ import { ModalType } from '@/utils/enum'
 import type { ProFormInstance } from '@ant-design/pro-form'
 import { ModalForm, ProFormText } from '@ant-design/pro-form'
 import { changeAccountPsw } from '@/services/api/user'
-import { createForm, onFieldMount, onFieldReact, onFieldValueChange } from '@formily/core'
+import { createForm, onFieldMount, onFieldReact } from '@formily/core'
 import { createSchemaField } from '@formily/react'
 import { loadOrganizationalStructureList } from '@/utils/schema'
 import {
@@ -101,59 +101,63 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
       message.error(error)
     }
   }
-  const normalForm = createForm({
-    validateFirst: true,
-    readPretty: type === ModalType.PREVIEW,
-    initialValues: { ...otherValues, institutionID: institution.ID },
-    effects(form) {
-      onFieldMount('password', field => {
-        type !== ModalType.ADD && field.setDisplay('none')
-      })
-      onFieldMount('account', field => {
-        type !== ModalType.ADD && (field.disabled = true)
-      })
-      onFieldReact('isCreated', field => {
-        if (defaultFormData.ID) {
-          field.disabled = true
-          field.value &&
-            field.setDecoratorProps({
-              addonAfter: (
-                <div>
-                  <span className="text-red-500 mr-2">需要移除请进入</span>
-                  <Link to="/project/created" className="text-primary">
-                    项目创建人
-                  </Link>
-                </div>
-              )
-            })
-        } else {
-          return generateFieldIsCreated(field)
-        }
-      })
-      onFieldMount('institutionID', field => {
-        field.dataSource = [{ label: institution?.name, value: institution?.ID }]
-      })
-      onFieldMount('accountType', field => {
-        field.dataSource = accountTypeList
-      })
-      onFieldReact('organizationalStructureID', async field => {
-        if (type === ModalType.PREVIEW) {
-          defaultFormData.organizationalStructure &&
-            (field.dataSource = [
-              {
-                label: defaultFormData.organizationalStructure.name,
-                value: defaultFormData.organizationalStructure.ID
-              }
-            ])
-        } else {
-          const institutionID = form.values.institutionID
-          const dataSource = await loadOrganizationalStructureList({ dataID: institutionID })
+  const normalForm = useMemo(
+    () =>
+      createForm({
+        validateFirst: true,
+        readPretty: type === ModalType.PREVIEW,
+        initialValues: { ...otherValues, institutionID: institution.ID },
+        effects(form) {
+          onFieldMount('password', field => {
+            type !== ModalType.ADD && field.setDisplay('none')
+          })
+          onFieldMount('account', field => {
+            type !== ModalType.ADD && (field.disabled = true)
+          })
+          onFieldReact('isCreated', field => {
+            if (defaultFormData.ID) {
+              field.disabled = true
+              field.value &&
+                field.setDecoratorProps({
+                  addonAfter: (
+                    <div>
+                      <span className="text-red-500 mr-2">需要移除请进入</span>
+                      <Link to="/project/created" className="text-primary">
+                        项目创建人
+                      </Link>
+                    </div>
+                  )
+                })
+            } else {
+              return generateFieldIsCreated(field)
+            }
+          })
+          onFieldMount('institutionID', field => {
+            field.dataSource = [{ label: institution?.name, value: institution?.ID }]
+          })
+          onFieldMount('accountType', field => {
+            field.dataSource = accountTypeList
+          })
+          onFieldReact('organizationalStructureID', async field => {
+            if (type === ModalType.PREVIEW) {
+              defaultFormData.organizationalStructure &&
+                (field.dataSource = [
+                  {
+                    label: defaultFormData.organizationalStructure.name,
+                    value: defaultFormData.organizationalStructure.ID
+                  }
+                ])
+            } else {
+              const institutionID = form.values.institutionID
+              const dataSource = await loadOrganizationalStructureList({ dataID: institutionID })
 
-          field.dataSource = dataSource
+              field.dataSource = dataSource
+            }
+          })
         }
-      })
-    }
-  })
+      }),
+    []
+  )
   const SchemaField = createSchemaField({
     components: {
       FormLayout,
@@ -186,7 +190,7 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
               trigger={<Button>重置密码</Button>}
               onFinish={async values => {
                 try {
-                  await tryChangePsw({ ...values, ID: defaultFormData?.dataID })
+                  await tryChangePsw({ ...values, ID: defaultFormData?.ID })
                   return true
                 } catch (error) {
                   return false

+ 2 - 9
src/pages/Project/Verification/Detail/Flow/components/Drawer/index.tsx

@@ -1,16 +1,10 @@
-import { useState, useEffect, useContext, useMemo } from 'react'
+import { useState, useEffect, useContext, useMemo, useCallback } from 'react'
 import { Button, Drawer, Radio, Tabs, Tooltip, Row, Col, Switch, Collapse } from 'antd'
 import { Actions, FlowContext } from '../../context'
 import type { RadioChangeEvent } from 'antd'
 import { ApprovalWay, ConfigureType, ParticipantMode } from '../../enum'
 import { QuestionCircleFilled } from '@ant-design/icons'
-import {
-  createForm,
-  onFieldMount,
-  onFieldReact,
-  onFieldValueChange,
-  onFormValuesChange
-} from '@formily/core'
+import { createForm, onFieldMount, onFieldReact, onFormValuesChange } from '@formily/core'
 import { createSchemaField, FormProvider } from '@formily/react'
 import { FormItem, Select } from '@formily/antd'
 import { participantSchema } from '../../utils'
@@ -150,7 +144,6 @@ const FlowDrawer = () => {
               }
             }
           })
-          onFieldValueChange('ID', (_, form) => console.log(form.getValuesIn()))
         }
       })
       const useAsyncDataSource = service => field => {