|
|
@ -1,5 +1,5 @@ |
|
|
|
import React from 'react'; |
|
|
|
import { Button } from 'antd'; |
|
|
|
import { Button, Form } from 'antd'; |
|
|
|
import { |
|
|
|
ModalForm, |
|
|
|
ProFormSelect, |
|
|
@ -14,25 +14,10 @@ export default (props) => { |
|
|
|
const initialValues = editData ? { |
|
|
|
...editData, |
|
|
|
} : {}; |
|
|
|
|
|
|
|
const checkName = async (rule, value) => { |
|
|
|
let filter = models?.find(s => s?.attributeName == value && value !== editData?.attributeName) |
|
|
|
if (filter) { |
|
|
|
return Promise.reject(new Error('已存该属性名称!')); |
|
|
|
} |
|
|
|
return Promise.resolve(); |
|
|
|
} |
|
|
|
|
|
|
|
const checkCode = async (rule, value) => { |
|
|
|
let filter = models?.find(s => s?.attributeCode == value && value !== editData?.attributeCode) |
|
|
|
if (filter) { |
|
|
|
return Promise.reject(new Error('已存该属性代码!')); |
|
|
|
} |
|
|
|
return Promise.resolve(); |
|
|
|
} |
|
|
|
|
|
|
|
const [form] = Form.useForm(); |
|
|
|
return ( |
|
|
|
<ModalForm |
|
|
|
form={form} |
|
|
|
title={title || ''} |
|
|
|
initialValues={initialValues} |
|
|
|
trigger={ |
|
|
@ -48,15 +33,14 @@ export default (props) => { |
|
|
|
onCancel: () => { }, |
|
|
|
}} |
|
|
|
onFinish={async (values) => { |
|
|
|
onFinish && await onFinish(values, editData) |
|
|
|
return true; |
|
|
|
return onFinish && await onFinish(values, editData, form) |
|
|
|
// return true;
|
|
|
|
}} |
|
|
|
width={500} |
|
|
|
> |
|
|
|
<ProFormText |
|
|
|
rules={[{ required: true, message: '请输入属性名称' }, |
|
|
|
{ max: 255, message: '属性名称长度不能大于255个字符' }, |
|
|
|
{ validator: checkName } |
|
|
|
]} |
|
|
|
name="attributeName" |
|
|
|
label="属性名称" |
|
|
@ -65,7 +49,6 @@ export default (props) => { |
|
|
|
<ProFormText |
|
|
|
rules={[{ required: true, message: '请输入属性代码' }, |
|
|
|
{ max: 255, message: '属性代码长度不能大于255个字符' }, |
|
|
|
{ validator: checkCode } |
|
|
|
]} |
|
|
|
name="attributeCode" |
|
|
|
label="属性代码" |
|
|
|