|
@@ -1,52 +1,53 @@
|
|
import { PageContainer } from '@ant-design/pro-layout'
|
|
import { PageContainer } from '@ant-design/pro-layout'
|
|
import LeftMenu from './components/LeftMenu'
|
|
import LeftMenu from './components/LeftMenu'
|
|
-import { useState } from 'react'
|
|
|
|
|
|
+import { useState, useEffect } from 'react'
|
|
import FormRender, { useForm } from 'form-render'
|
|
import FormRender, { useForm } from 'form-render'
|
|
import { Button } from 'antd'
|
|
import { Button } from 'antd'
|
|
-import { history } from 'umi'
|
|
|
|
|
|
+import { history, connect } from 'umi'
|
|
|
|
+import type { ConnectProps } from 'umi'
|
|
|
|
+import type { SchemaBaseModelState } from './model'
|
|
export enum BaseMenuEnum {
|
|
export enum BaseMenuEnum {
|
|
- PROJECT = 1,
|
|
|
|
- COMPANY = 2,
|
|
|
|
- STAFF = 3
|
|
|
|
|
|
+ PROJECT = '1',
|
|
|
|
+ COMPANY = '2',
|
|
|
|
+ STAFF = '3'
|
|
}
|
|
}
|
|
|
|
|
|
-const schema = {
|
|
|
|
- type: 'object',
|
|
|
|
- properties: {
|
|
|
|
- input1: {
|
|
|
|
- title: '简单输入框',
|
|
|
|
- type: 'string',
|
|
|
|
- required: true
|
|
|
|
- },
|
|
|
|
- select1: {
|
|
|
|
- title: '单选',
|
|
|
|
- type: 'string',
|
|
|
|
- enum: ['a', 'b', 'c'],
|
|
|
|
- enumNames: ['早', '中', '晚']
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+type BaseProps = ConnectProps & {
|
|
|
|
+ base: SchemaBaseModelState
|
|
}
|
|
}
|
|
|
|
|
|
-const Index = () => {
|
|
|
|
|
|
+const Index: React.FC<BaseProps> = ({ base, dispatch }) => {
|
|
const form = useForm()
|
|
const form = useForm()
|
|
const [state, setState] = useState({
|
|
const [state, setState] = useState({
|
|
activeKey: BaseMenuEnum.PROJECT,
|
|
activeKey: BaseMenuEnum.PROJECT,
|
|
- schema: {}
|
|
|
|
|
|
+ schema: base?.[BaseMenuEnum.PROJECT]?.schema
|
|
})
|
|
})
|
|
|
|
+ const currentSchema = base?.[state.activeKey]
|
|
|
|
+
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ if (state.activeKey && !base[state.activeKey]) {
|
|
|
|
+ dispatch({
|
|
|
|
+ type: 'schemaBase/querySchema',
|
|
|
|
+ payload: {
|
|
|
|
+ columnType: state.activeKey
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }, [state.activeKey])
|
|
const menuOptions = [
|
|
const menuOptions = [
|
|
{ label: '项目信息', value: BaseMenuEnum.PROJECT },
|
|
{ label: '项目信息', value: BaseMenuEnum.PROJECT },
|
|
{ label: '企事业单位信息', value: BaseMenuEnum.COMPANY },
|
|
{ label: '企事业单位信息', value: BaseMenuEnum.COMPANY },
|
|
{ label: '人员信息', value: BaseMenuEnum.STAFF }
|
|
{ label: '人员信息', value: BaseMenuEnum.STAFF }
|
|
]
|
|
]
|
|
|
|
|
|
- const gotoDetail = key => {
|
|
|
|
|
|
+ const gotoDetail = (columnType, ID) => {
|
|
history.push({
|
|
history.push({
|
|
pathname: '/work-setting/schema/detail',
|
|
pathname: '/work-setting/schema/detail',
|
|
- query: {
|
|
|
|
- columnType: key
|
|
|
|
- }
|
|
|
|
|
|
+ query: { columnType },
|
|
|
|
+ state: { ID }
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
+
|
|
return (
|
|
return (
|
|
<PageContainer title={false}>
|
|
<PageContainer title={false}>
|
|
<div className="h-full w-full flex flex-row">
|
|
<div className="h-full w-full flex flex-row">
|
|
@@ -58,15 +59,15 @@ const Index = () => {
|
|
/>
|
|
/>
|
|
<div className="w-max-3/4 ml-8 bg-white p-4 shadow-card relative ">
|
|
<div className="w-max-3/4 ml-8 bg-white p-4 shadow-card relative ">
|
|
<div className="text-right">
|
|
<div className="text-right">
|
|
- <Button onClick={() => gotoDetail(state.activeKey)}>编辑</Button>
|
|
|
|
- </div>
|
|
|
|
- <div>
|
|
|
|
- <FormRender form={form} schema={schema} />
|
|
|
|
|
|
+ <Button onClick={() => gotoDetail(state.activeKey, currentSchema?.ID)}>编辑</Button>
|
|
</div>
|
|
</div>
|
|
|
|
+ <div>{state.schema && <FormRender form={form} schema={state.schema} />}</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</PageContainer>
|
|
</PageContainer>
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
-export default Index
|
|
|
|
|
|
+export default connect(({ schemaBase }: { schemaBase: SchemaBaseModelState }) => ({
|
|
|
|
+ base: schemaBase.base
|
|
|
|
+}))(Index)
|