|
@@ -13,22 +13,19 @@ function EditBlock(props) {
|
|
const [form] = Form.useForm();
|
|
const [form] = Form.useForm();
|
|
const [visible, setVisible] = useState(false);
|
|
const [visible, setVisible] = useState(false);
|
|
const [title, setTitle] = useState();
|
|
const [title, setTitle] = useState();
|
|
- const [data, setData] = useState({});
|
|
|
|
|
|
+ const [data, setData] = useState(null);
|
|
const { regularDetail, type, flag } = useContext(RegularContext);
|
|
const { regularDetail, type, flag } = useContext(RegularContext);
|
|
const initialValues = regularDetail;
|
|
const initialValues = regularDetail;
|
|
const onFinish = values => {
|
|
const onFinish = values => {
|
|
- setData(values)
|
|
|
|
- if(type == 2){
|
|
|
|
|
|
+ if (flag == 1) {
|
|
|
|
+ setData(values)
|
|
setVisible(true)
|
|
setVisible(true)
|
|
- if (flag == 1) {
|
|
|
|
- setTitle('该正则式关联字段校验规则,修改后将同步更新,确认修改?')
|
|
|
|
- } else {
|
|
|
|
- setTitle('是否确认修改该正则式?')
|
|
|
|
- }
|
|
|
|
- }else{
|
|
|
|
|
|
+ setTitle('该正则式关联字段校验规则,修改后将同步更新,确认修改?')
|
|
|
|
+ } else {
|
|
|
|
+ console.log(data);
|
|
addRegular(values)
|
|
addRegular(values)
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
};
|
|
};
|
|
//添加
|
|
//添加
|
|
function addRegular(values) {
|
|
function addRegular(values) {
|
|
@@ -38,7 +35,12 @@ function EditBlock(props) {
|
|
url = api.addRegular
|
|
url = api.addRegular
|
|
param = values
|
|
param = values
|
|
} else {
|
|
} else {
|
|
- param = data
|
|
|
|
|
|
+ if (flag == 1) {
|
|
|
|
+ param = data
|
|
|
|
+ } else {
|
|
|
|
+ param = values
|
|
|
|
+ }
|
|
|
|
+
|
|
url = api.upRegularById
|
|
url = api.upRegularById
|
|
param.id = regularDetail.id
|
|
param.id = regularDetail.id
|
|
}
|
|
}
|
|
@@ -56,7 +58,7 @@ function EditBlock(props) {
|
|
function cancel() {
|
|
function cancel() {
|
|
props.cancel()
|
|
props.cancel()
|
|
}
|
|
}
|
|
- function onCancel(){
|
|
|
|
|
|
+ function onCancel() {
|
|
setVisible(false)
|
|
setVisible(false)
|
|
}
|
|
}
|
|
return (
|
|
return (
|
|
@@ -70,16 +72,16 @@ function EditBlock(props) {
|
|
onFinish={onFinish}
|
|
onFinish={onFinish}
|
|
initialValues={initialValues}
|
|
initialValues={initialValues}
|
|
>
|
|
>
|
|
- <Form.Item label="正则式名称" name="name" getValueFromEvent={getValueFromEvent} rules={[{ required: true,message:'请输入正则式名称'},{ max: 30,message:'正则式名称不能超过30个字符' }]}>
|
|
|
|
- <Input placeholder="请输入" autoComplete='off'/>
|
|
|
|
|
|
+ <Form.Item label="正则式名称" name="name" getValueFromEvent={getValueFromEvent} rules={[{ required: true, message: '请输入正则式名称' }, { max: 30, message: '正则式名称不能超过30个字符' }]}>
|
|
|
|
+ <Input placeholder="请输入" autoComplete='off' />
|
|
</Form.Item>
|
|
</Form.Item>
|
|
- <Form.Item label="正则式值" name="val" getValueFromEvent={getValueFromEvent} rules={[{ required: true,message:'请输入正则式值'},{ max: 512,message:'正则式值不能超过512个字符' }]}>
|
|
|
|
|
|
+ <Form.Item label="正则式值" name="val" getValueFromEvent={getValueFromEvent} rules={[{ required: true, message: '请输入正则式值' }, { max: 512, message: '正则式值不能超过512个字符' }]}>
|
|
<TextArea
|
|
<TextArea
|
|
autoSize={{ minRows: 5, maxRows: 5 }}
|
|
autoSize={{ minRows: 5, maxRows: 5 }}
|
|
placeholder="请输入"
|
|
placeholder="请输入"
|
|
/>
|
|
/>
|
|
</Form.Item>
|
|
</Form.Item>
|
|
- <Form.Item label="说明" name="description" getValueFromEvent={getValueFromEvent} rules={[{ max: 200,message:'说明不能超过200个字符' }]}>
|
|
|
|
|
|
+ <Form.Item label="说明" name="description" getValueFromEvent={getValueFromEvent} rules={[{ max: 200, message: '说明不能超过200个字符' }]}>
|
|
<TextArea
|
|
<TextArea
|
|
autoSize={{ minRows: 5, maxRows: 5 }}
|
|
autoSize={{ minRows: 5, maxRows: 5 }}
|
|
placeholder="请输入"
|
|
placeholder="请输入"
|