import React from 'react'; import { Input, Button, DatePicker, Drawer, message } from 'kts-xui'; import agent from '../../Server'; import { Form,Space } from 'kts-components-antd-x4'; const { RangePicker } = DatePicker; interface IProps { onClose: () => void; onSuccess?: () => void; type: number; } //添加商品 const GoodsPanel = (props: IProps) => { const [form] = Form.useForm(); const onFinish = async (values: any) => { values = values.goods.map((item: any) => { return { productName: item['productName'], specification: item['specification'], authStartTime: item['validdate'][0].format('YYYY-MM-DD'), authEndTime: item['validdate'][1].format('YYYY-MM-DD'), type: props.type } }); const res: any = await agent.post('/verifierparty/config/default/scope/batch/save', values, this); if (res.err) { return false; } if (res.res) { if (res.res.failList.length > 0) { const tips = res.res.failList.map((item, index) => { return
{item.productName}/{item.specification}
}) message.warn('重复导入'); // Modal.confirm({ // title: '以下商品导入失败', // content: tips, // }) } else { message.success('操作成功'); props.onSuccess && props.onSuccess(); } } }; const submit = () => { form.submit(); } const initValues = [{ productName: '', specification: '' }] return (
} >
{(fields, { add, remove }) => ( <> {fields.map(({ key, name, fieldKey, ...restField }) => (
{/* */}
))} {/* add()} > 添加一行商品 */} )}
); }; export default GoodsPanel