|
@@ -1,7 +1,7 @@
|
|
import { queryTemplateList } from '@/services/api/schema'
|
|
import { queryTemplateList } from '@/services/api/schema'
|
|
import { PageContainer } from '@ant-design/pro-layout'
|
|
import { PageContainer } from '@ant-design/pro-layout'
|
|
-import React, { useState } from 'react'
|
|
|
|
-import { history, useRequest } from '@umijs/max'
|
|
|
|
|
|
+import React, { useEffect, useState } from 'react'
|
|
|
|
+import { history, useRequest, connect, useDispatch } from '@umijs/max'
|
|
import { createForm } from '@formily/core'
|
|
import { createForm } from '@formily/core'
|
|
import { createSchemaField } from '@formily/react'
|
|
import { createSchemaField } from '@formily/react'
|
|
import {
|
|
import {
|
|
@@ -24,14 +24,24 @@ import { Button } from 'antd'
|
|
import LeftMenu from '../Base/components/LeftMenu'
|
|
import LeftMenu from '../Base/components/LeftMenu'
|
|
|
|
|
|
type iState = {
|
|
type iState = {
|
|
- menuData: API.TemplateListItem[]
|
|
|
|
- activeKey: Nullable<string>
|
|
|
|
|
|
+ menuData?: API.TemplateListItem[]
|
|
|
|
+ activeKey?: string
|
|
}
|
|
}
|
|
-const Budget = () => {
|
|
|
|
|
|
+
|
|
|
|
+const Budget: React.FC = () => {
|
|
|
|
+ const dispatch = useDispatch()
|
|
const [state, setState] = useState<iState>({
|
|
const [state, setState] = useState<iState>({
|
|
menuData: [],
|
|
menuData: [],
|
|
activeKey: null
|
|
activeKey: null
|
|
})
|
|
})
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ if (state.menuData?.length) {
|
|
|
|
+ dispatch({
|
|
|
|
+ type: 'templateSchema/changeSchemaByColumnType',
|
|
|
|
+ payload: state.menuData
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }, [state.menuData])
|
|
useRequest(queryTemplateList, {
|
|
useRequest(queryTemplateList, {
|
|
onSuccess: (result: API.TemplateListItem[]) => {
|
|
onSuccess: (result: API.TemplateListItem[]) => {
|
|
setState({
|
|
setState({
|
|
@@ -81,8 +91,8 @@ const Budget = () => {
|
|
|
|
|
|
<div className="w-6/7 ml-8 bg-white p-4 rounded-20px shadow-hex-3e2c5a relative">
|
|
<div className="w-6/7 ml-8 bg-white p-4 rounded-20px shadow-hex-3e2c5a relative">
|
|
<div className="flex justify-end">
|
|
<div className="flex justify-end">
|
|
- {state.activeID && (
|
|
|
|
- <Button type="primary" onClick={() => history.push(`/schema/budget/${state.activeID}`)}>
|
|
|
|
|
|
+ {state.activeKey && (
|
|
|
|
+ <Button type="primary" onClick={() => history.push(`/schema/budget/${state.activeKey}`)}>
|
|
编辑
|
|
编辑
|
|
</Button>
|
|
</Button>
|
|
)}
|
|
)}
|