|
@@ -1,13 +1,14 @@
|
|
|
import React, { useEffect } from 'react'
|
|
|
-import { Space, Button } from 'antd'
|
|
|
+import { Space, Button, message } from 'antd'
|
|
|
import { useDesigner, TextWidget } from '@designable/react'
|
|
|
import { GlobalRegistry } from '@designable/core'
|
|
|
import { observer } from '@formily/react'
|
|
|
import { loadInitialSchema } from '../service'
|
|
|
-import { useHistory, useLocation } from 'umi'
|
|
|
+import { useDispatch, useHistory, useLocation, useRequest } from 'umi'
|
|
|
import { transformToSchema } from '@designable/formily-transformer'
|
|
|
+import { updateSchema } from '@/services/api/schema'
|
|
|
|
|
|
-export const ActionsWidget = observer(({ updateAction, schema }) => {
|
|
|
+export const ActionsWidget = observer(({ schema }) => {
|
|
|
const history = useHistory()
|
|
|
const designer = useDesigner()
|
|
|
const {
|
|
@@ -17,9 +18,23 @@ export const ActionsWidget = observer(({ updateAction, schema }) => {
|
|
|
schema && loadInitialSchema(designer, schema)
|
|
|
GlobalRegistry.setDesignerLanguage('zh-cn')
|
|
|
}, [schema])
|
|
|
+ const dispatch = useDispatch()
|
|
|
+ const { run: tryUpdateSchema } = useRequest(updateSchema, {
|
|
|
+ manual: true,
|
|
|
+ onSuccess: result => {
|
|
|
+ message.success('更新成功')
|
|
|
+ dispatch({
|
|
|
+ type: 'schemaBase/changeSchemaByColumnType',
|
|
|
+ payload: {
|
|
|
+ columnType,
|
|
|
+ schema: result.schema
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
const saveSchema = () => {
|
|
|
- updateAction({
|
|
|
+ tryUpdateSchema({
|
|
|
columnType,
|
|
|
schema: transformToSchema(designer.getCurrentTree()).schema
|
|
|
})
|