|  | @@ -1,52 +1,53 @@
 | 
	
		
			
				|  |  |  import { PageContainer } from '@ant-design/pro-layout'
 | 
	
		
			
				|  |  |  import LeftMenu from './components/LeftMenu'
 | 
	
		
			
				|  |  | -import { useState } from 'react'
 | 
	
		
			
				|  |  | +import { useState, useEffect } from 'react'
 | 
	
		
			
				|  |  |  import FormRender, { useForm } from 'form-render'
 | 
	
		
			
				|  |  |  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 {
 | 
	
		
			
				|  |  | -  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 [state, setState] = useState({
 | 
	
		
			
				|  |  |      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 = [
 | 
	
		
			
				|  |  |      { label: '项目信息', value: BaseMenuEnum.PROJECT },
 | 
	
		
			
				|  |  |      { label: '企事业单位信息', value: BaseMenuEnum.COMPANY },
 | 
	
		
			
				|  |  |      { label: '人员信息', value: BaseMenuEnum.STAFF }
 | 
	
		
			
				|  |  |    ]
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  const gotoDetail = key => {
 | 
	
		
			
				|  |  | +  const gotoDetail = (columnType, ID) => {
 | 
	
		
			
				|  |  |      history.push({
 | 
	
		
			
				|  |  |        pathname: '/work-setting/schema/detail',
 | 
	
		
			
				|  |  | -      query: {
 | 
	
		
			
				|  |  | -        columnType: key
 | 
	
		
			
				|  |  | -      }
 | 
	
		
			
				|  |  | +      query: { columnType },
 | 
	
		
			
				|  |  | +      state: { ID }
 | 
	
		
			
				|  |  |      })
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |    return (
 | 
	
		
			
				|  |  |      <PageContainer title={false}>
 | 
	
		
			
				|  |  |        <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="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>{state.schema && <FormRender form={form} schema={state.schema} />}</div>
 | 
	
		
			
				|  |  |          </div>
 | 
	
		
			
				|  |  |        </div>
 | 
	
		
			
				|  |  |      </PageContainer>
 | 
	
		
			
				|  |  |    )
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -export default Index
 | 
	
		
			
				|  |  | +export default connect(({ schemaBase }: { schemaBase: SchemaBaseModelState }) => ({
 | 
	
		
			
				|  |  | +  base: schemaBase.base
 | 
	
		
			
				|  |  | +}))(Index)
 |