Ver código fonte

fix: 添加通知中心刷新+清空表单

outaozhen 4 anos atrás
pai
commit
007ee10bfa

+ 4 - 1
src/pages/Hr/Notification/components/AddMessage.jsx

@@ -1,4 +1,4 @@
-import React from 'react'
+import React, { useRef } from 'react'
 import { Button, Form, message } from 'antd'
 import {
   ModalForm,
@@ -21,6 +21,7 @@ export const mediaType = {
 
 const AddMessage = props => {
   const { onConfirm } = props
+  const formRef = useRef(null)
   const handleFormValues = values => {
     const newValues = { ...values }
     switch (values.msgType) {
@@ -47,6 +48,7 @@ const AddMessage = props => {
       <ModalForm
         isKeyPressSubmit={false}
         key="modalForm"
+        formRef={formRef}
         trigger={
           <Button type="primary">
             <Plus className="mr-1" />
@@ -58,6 +60,7 @@ const AddMessage = props => {
           try {
             const nValues = handleFormValues(values)
             await onConfirm(nValues)
+            formRef.current?.resetFields()
             message.success('添加成功')
             return true
           } catch (error) {

+ 2 - 1
src/pages/Hr/Notification/index.jsx

@@ -52,7 +52,8 @@ const Notification = () => {
   const { run: trySendMessage } = useRequest(sendMessage, {
     manual: true,
     onSuccess: () => {
-      tRef.current?.reload()
+      initData({ current: state.current })
+      // tRef.current?.reload()
       // sendMsg(cmdType.Notice, result)
     },
     onError: e => {