fix(): 表单校验

test
李神峰 2024-12-27 10:55:33 +08:00
parent 79d8a0d0a1
commit c6fd00bb26
2 changed files with 13 additions and 7 deletions

View File

@ -1,4 +1,4 @@
import { Button, Form, Input, Popconfirm, Table } from 'antd';
import { Button, Form, Input, InputNumber, Popconfirm, Table } from 'antd';
import React, { useContext, useEffect, useRef, useState } from 'react';
const EditableContext = React.createContext(null);
const EditableRow = ({ index, ...props }) => {
@ -60,8 +60,14 @@ const EditableCell = ({
margin: 0,
}}
name={dataIndex}
rules={[
{
required: true,
message: `${title}必填`,
},
]}
>
<Input ref={inputRef} onPressEnter={save} onBlur={save} />
<InputNumber min={0} ref={inputRef} onPressEnter={save} onBlur={save} />
</Form.Item>
) : (
<div

View File

@ -1470,11 +1470,11 @@ export default function TestLine() {
}
const save = async () => {
const all = editData.some(item => !item.drp)
if (all) {
message.error("所有雨量不能为空")
return
}
// const all = editData.some(item => !item.drp)
// if (all) {
// message.error("所有雨量不能为空")
// return
// }
try {
const newTabl = editData.map(item => ({
...item,