Commit ee267e47 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix: 处理品类多次请求的问题

parent 1a4f6fe5
import React from 'react' import React, { useState } from 'react'
import { Row, Col, Popconfirm, Button, Card } from 'antd'; import { Row, Col, Popconfirm, Button, Card } from 'antd';
import { PageHeaderWrapper } from '@ant-design/pro-layout'; import { PageHeaderWrapper } from '@ant-design/pro-layout';
import TabTree, { createTreeActions } from '@/components/TabTree'; import TabTree, { createTreeActions } from '@/components/TabTree';
...@@ -49,22 +49,26 @@ const ClassProperty: React.FC<{}> = () => { ...@@ -49,22 +49,26 @@ const ClassProperty: React.FC<{}> = () => {
fetchItemDetailData: getProductPlatformGetCategory fetchItemDetailData: getProductPlatformGetCategory
}) })
const [loading, setLoading] = useState<boolean>(false)
const formInitValue = (nodeRecord && treeStatus === FormState.EDIT) ? getTreeMaps(nodeRecord.key) : {} const formInitValue = (nodeRecord && treeStatus === FormState.EDIT) ? getTreeMaps(nodeRecord.key) : {}
const onFinish = (values) => { const onFinish = (values) => {
setLoading(true)
const editOrAdd = nodeRecord && treeStatus === FormState.EDIT const editOrAdd = nodeRecord && treeStatus === FormState.EDIT
const params = editOrAdd ? { ...values, parentId: nodeRecord.parentId } : { const params = editOrAdd ? { ...values, parentId: nodeRecord.parentId } : {
...values, ...values,
parentId: nodeRecord ? nodeRecord.parentId : 0, parentId: nodeRecord ? nodeRecord.parentId : 0,
id: null, id: null,
} }
postProductPlatformSaveOrUpdateCategory(params).then(res => { postProductPlatformSaveOrUpdateCategory(params).then(() => {
resetMenu() resetMenu()
setTreeStatus(FormState.FREE) setTreeStatus(FormState.FREE)
setNodeRecord(undefined) setNodeRecord(undefined)
// 保存后要将是否填写过表单设为false // 保存后要将是否填写过表单设为false
setIsEditForm(false) setIsEditForm(false)
flag = false flag = false
setLoading(false)
}) })
} }
...@@ -122,7 +126,7 @@ const ClassProperty: React.FC<{}> = () => { ...@@ -122,7 +126,7 @@ const ClassProperty: React.FC<{}> = () => {
schema={classSchema} schema={classSchema}
> >
<FormButtonGroup> <FormButtonGroup>
<Button htmlType='submit' type="primary" style={{ marginTop: 32, marginBottom: 16, marginRight: 24}}> <Button htmlType='submit' type="primary" loading={loading} style={{ marginTop: 32, marginBottom: 16, marginRight: 24}}>
保存 保存
</Button> </Button>
<Popconfirm title="确定要删除吗?" okText="是" cancelText="否" onConfirm={handleDeleteMenu}> <Popconfirm title="确定要删除吗?" okText="是" cancelText="否" onConfirm={handleDeleteMenu}>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment