|
@ -1,24 +1,36 @@ |
|
|
import React, { useState, useRef } from 'react'; |
|
|
import React from 'react'; |
|
|
import { Button, Form, Row, Col, Table, Popconfirm, Input, message } from 'antd'; |
|
|
import { Button } from 'antd'; |
|
|
import { |
|
|
import { |
|
|
ModalForm, |
|
|
ModalForm, |
|
|
ProFormRadio, |
|
|
|
|
|
ProFormSelect, |
|
|
ProFormSelect, |
|
|
ProFormTextArea, |
|
|
ProFormTextArea, |
|
|
ProFormDigit, |
|
|
ProFormDigit, |
|
|
ProFormDependency, |
|
|
|
|
|
ProFormText |
|
|
ProFormText |
|
|
} from '@ant-design/pro-form'; |
|
|
} from '@ant-design/pro-form'; |
|
|
|
|
|
|
|
|
import moment from 'moment'; |
|
|
|
|
|
|
|
|
|
|
|
export default (props) => { |
|
|
export default (props) => { |
|
|
const { title, triggerRender, editData = null, onFinish, readOnly, } = props; |
|
|
const { title, triggerRender, editData = null, onFinish, readOnly, models } = props; |
|
|
const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 16 } }; |
|
|
const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 16 } }; |
|
|
const initialValues = editData ? { |
|
|
const initialValues = editData ? { |
|
|
...editData, |
|
|
...editData, |
|
|
} : {}; |
|
|
} : {}; |
|
|
|
|
|
|
|
|
|
|
|
const checkName = async (rule, value) => { |
|
|
|
|
|
let filter = models?.find(s => s?.attributeName == value) |
|
|
|
|
|
if (filter) { |
|
|
|
|
|
return Promise.reject(new Error('已存该属性名称!')); |
|
|
|
|
|
} |
|
|
|
|
|
return Promise.resolve(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const checkCode = async (rule, value) => { |
|
|
|
|
|
let filter = models?.find(s => s?.attributeCode == value) |
|
|
|
|
|
if (filter) { |
|
|
|
|
|
return Promise.reject(new Error('已存该属性代码!')); |
|
|
|
|
|
} |
|
|
|
|
|
return Promise.resolve(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<ModalForm |
|
|
<ModalForm |
|
|
title={title || ''} |
|
|
title={title || ''} |
|
@ -34,19 +46,17 @@ export default (props) => { |
|
|
modalProps={{ |
|
|
modalProps={{ |
|
|
destroyOnClose: true, |
|
|
destroyOnClose: true, |
|
|
onCancel: () => { }, |
|
|
onCancel: () => { }, |
|
|
// bodyStyle: { height: 800, overflowY: 'auto' }
|
|
|
|
|
|
}} |
|
|
}} |
|
|
onFinish={async (values) => { |
|
|
onFinish={async (values) => { |
|
|
onFinish && await onFinish(values, editData) |
|
|
onFinish && await onFinish(values, editData) |
|
|
return true; |
|
|
return true; |
|
|
}} |
|
|
}} |
|
|
// submitter={!readOnly}
|
|
|
|
|
|
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="属性名称" |
|
@ -54,7 +64,8 @@ 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="属性代码" |
|
@ -76,7 +87,8 @@ export default (props) => { |
|
|
<ProFormDigit |
|
|
<ProFormDigit |
|
|
name="length" |
|
|
name="length" |
|
|
label="长度" |
|
|
label="长度" |
|
|
fieldProps={{ precision: 0 }} |
|
|
fieldProps={{ precision: 0, max: 99999999, }} |
|
|
|
|
|
// rules={[{ max: 99999999, message: '长度最大值不能超过99999999' }]}
|
|
|
/> |
|
|
/> |
|
|
|
|
|
|
|
|
<ProFormSelect |
|
|
<ProFormSelect |
|
|