import { Button, Form, FormInstance, Input, Modal, Popconfirm } from "antd"; import React, { useCallback, useEffect, useRef } from "react"; import TextArea from "antd/es/input/TextArea"; import { getSmartDetailAPI, smartSaveAPI } from "@/store/action/B6Smart"; import { MessageFu } from "@/utils/message"; import { SmartSaveDataType } from "@/types"; import styles from "./index.module.scss"; type Props = { id: number; closeMoalFu: () => void; addTableFu: () => void; editTableFu: () => void; }; function SmartAutoAdd({ id, closeMoalFu, addTableFu, editTableFu }: Props) { // 表单的ref const FormBoxRef = useRef(null); // 是编辑,通过id获取详情 const getInfoByIdFu = useCallback(async (id: number) => { const res = await getSmartDetailAPI(id); FormBoxRef.current?.setFieldsValue(res.data); }, []); useEffect(() => { if (id > 0) getInfoByIdFu(id); }, [getInfoByIdFu, id]); // 没有通过校验 const onFinishFailed = useCallback(() => {}, []); // 通过校验点击确定 const onFinish = useCallback( async (value: SmartSaveDataType) => { const obj: SmartSaveDataType = { ...value, id: id > 0 ? id : null, type: "play", }; const res = await smartSaveAPI(obj); if (res.code === 0) { MessageFu.success(id > 0 ? "编辑成功!" : "新增成功!"); if (id < 0) addTableFu(); else editTableFu(); closeMoalFu(); } console.log("通过校验,点击确定"); }, [addTableFu, closeMoalFu, editTableFu, id] ); return ( 0 ? "编辑播报" : "新增播报"} footer={ [] // 设置footer为空,去掉 取消 确定默认按钮 } >
e.target.value.replace(/\s+/g, "")} > e.target.value.trim()} >