|
@@ -1,23 +1,18 @@
|
|
|
import { connect, useRequest } from 'umi'
|
|
|
import { useEffect, useRef, useState } from 'react'
|
|
|
import { Form, message, Tabs } from 'antd'
|
|
|
-import {
|
|
|
- getApprovalList,
|
|
|
- getProject,
|
|
|
- setApproval,
|
|
|
- setProjectPersonor
|
|
|
-} from '@/services/api/project'
|
|
|
-import { delay } from '@/utils/util'
|
|
|
-import FormRender, { useForm } from 'form-render'
|
|
|
-import { BaseMenuEnum } from '@/pages/Schema/Base'
|
|
|
+import { FormLayout, FormItem, Input, Select } from '@formily/antd'
|
|
|
+import { getApprovalList, setApproval, setProjectPersonor } from '@/services/api/project'
|
|
|
+import { BaseMenuEnum, SchemaEnum } from '@/pages/Schema/Base'
|
|
|
import type { SchemaBaseModelState } from '@/pages/Schema/Base/model'
|
|
|
import type { ConnectProps } from 'umi'
|
|
|
-import type { ProjectModelState } from '../../model'
|
|
|
import ProForm from '@ant-design/pro-form'
|
|
|
// import TreeNodeSelect from './TreeNodeSelect'
|
|
|
-import { ModalType } from './ProjectModal'
|
|
|
-import consts from '@/utils/consts'
|
|
|
+import type { ModalType } from './ProjectModal'
|
|
|
import TreeNodeSelect from './TreeNodeSelect'
|
|
|
+import { connectSchema } from '@/utils/schema'
|
|
|
+import { createForm, onFieldMount, onFormReact } from '@formily/core'
|
|
|
+import { createSchemaField, Field, FormProvider } from '@formily/react'
|
|
|
|
|
|
enum FormType {
|
|
|
UPLOAD_PERM = '1',
|
|
@@ -26,25 +21,21 @@ enum FormType {
|
|
|
|
|
|
type ProjectModalProps = ConnectProps & {
|
|
|
visible: boolean
|
|
|
- onVisibleChange: (visible: boolean) => void
|
|
|
type: ModalType
|
|
|
defaultFormData?: {
|
|
|
dataID: string
|
|
|
}
|
|
|
reload: () => void
|
|
|
- schema?: Record<string, any> | null
|
|
|
+ projectSchema: Record<string, any> | null
|
|
|
+ pTypeList: { label: string; value: string }[]
|
|
|
}
|
|
|
const DetailModal: React.FC<ProjectModalProps> = ({
|
|
|
visible,
|
|
|
- // onVisibleChange,
|
|
|
- dispatch,
|
|
|
- schema,
|
|
|
- type,
|
|
|
+ projectSchema,
|
|
|
defaultFormData,
|
|
|
pTypeList,
|
|
|
reload
|
|
|
}) => {
|
|
|
- const form = useForm()
|
|
|
const ref = useRef<FormInstance>(null)
|
|
|
const ref2 = useRef<FormInstance>(null)
|
|
|
const { TabPane } = Tabs
|
|
@@ -79,14 +70,6 @@ const DetailModal: React.FC<ProjectModalProps> = ({
|
|
|
})
|
|
|
|
|
|
useEffect(() => {
|
|
|
- if (visible && !schema) {
|
|
|
- dispatch({
|
|
|
- type: 'schemaBase/querySchema',
|
|
|
- payload: {
|
|
|
- columnType: BaseMenuEnum.PROJECT
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
if (state.activeKey === '2') {
|
|
|
const TabFormData = {
|
|
|
accountID: state.account.reportAccount?.ID,
|
|
@@ -100,39 +83,6 @@ const DetailModal: React.FC<ProjectModalProps> = ({
|
|
|
}
|
|
|
}, [visible, state.activeKey])
|
|
|
|
|
|
- const onMount = async () => {
|
|
|
- const { dataID } = defaultFormData
|
|
|
- const { code = -1, data } = await getProject({ ID: dataID })
|
|
|
- if (code === consts.RET_CODE.SUCCESS) {
|
|
|
- const {
|
|
|
- created: { ID: createdID },
|
|
|
- reportAccount,
|
|
|
- ...currentFormData
|
|
|
- } = { ...data }
|
|
|
-
|
|
|
- setState({
|
|
|
- ...state,
|
|
|
- account: currentFormData,
|
|
|
- perm: { createdID, reportAccount: reportAccount.map(item => item.ID) }
|
|
|
- })
|
|
|
- const keys = Object.keys(currentFormData)
|
|
|
- keys.forEach(key => {
|
|
|
- if (currentFormData[key] instanceof Object) {
|
|
|
- const targetMap = currentFormData[key]
|
|
|
- delete currentFormData[key]
|
|
|
- currentFormData[`${key}ID`] = targetMap.ID
|
|
|
- }
|
|
|
- })
|
|
|
- form.setValues({ ...currentFormData })
|
|
|
- }
|
|
|
- delay(80).then(() => {
|
|
|
- form.setSchemaByPath('projectTypeID', {
|
|
|
- enum: pTypeList.map(item => item.value),
|
|
|
- enumNames: pTypeList.map(item => item.label)
|
|
|
- })
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
const onChange = key => {
|
|
|
setState({ ...state, activeKey: key })
|
|
|
if (key === '2') {
|
|
@@ -172,14 +122,13 @@ const DetailModal: React.FC<ProjectModalProps> = ({
|
|
|
return (
|
|
|
<Tabs onChange={onChange}>
|
|
|
<TabPane tab="项目信息" key="1">
|
|
|
- {schema && (
|
|
|
- <FormRender
|
|
|
- form={form}
|
|
|
- schema={schema}
|
|
|
- onMount={onMount}
|
|
|
- readOnly={type === ModalType.PREVIEW ? true : false}
|
|
|
+ <FormProvider form={formInstance}>
|
|
|
+ <SchemaField
|
|
|
+ schema={connectSchema(SchemaEnum?.[BaseMenuEnum.PROJECT], projectSchema)}
|
|
|
+ // scope={{ useAsyncDataSource }}
|
|
|
/>
|
|
|
- )}
|
|
|
+ <Field name="input" component={[Input, { placeholder: 'Please Input' }]} />
|
|
|
+ </FormProvider>
|
|
|
</TabPane>
|
|
|
{/* <TabPane tab="上传权限" key="2">
|
|
|
<ProForm
|
|
@@ -232,9 +181,6 @@ const DetailModal: React.FC<ProjectModalProps> = ({
|
|
|
)
|
|
|
}
|
|
|
|
|
|
-export default connect(
|
|
|
- ({ project, schemaBase }: { project: ProjectModelState; schemaBase: SchemaBaseModelState }) => ({
|
|
|
- pTypeList: project.projectTypeList.map(item => ({ label: item.name, value: item.ID })),
|
|
|
- schema: schemaBase.base[BaseMenuEnum.PROJECT]?.schema
|
|
|
- })
|
|
|
-)(DetailModal)
|
|
|
+export default connect(({ schemaBase }: { schemaBase: SchemaBaseModelState }) => ({
|
|
|
+ projectSchema: schemaBase.base[BaseMenuEnum.PROJECT]
|
|
|
+}))(DetailModal)
|