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