1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* @Description:
* @Author: leizhe
* @Date: 2022-04-07 10:23:26
* @LastEditTime: 2022-05-20 09:30:13
* @LastEditors: leizhe
*/
import React, { useEffect } from 'react';
import { Modal, Form, Input, notification, message } from 'antd';
import { UpdateModelType } from '@/services/drawBoardManage/api';
const EditModal = props => {
const { visible, onCancel, changeObj, callBackSubmit = () => {} } = props;
const [addForm] = Form.useForm();
useEffect(() => {
addForm.setFieldsValue({ name: changeObj.name });
}, [visible]);
const submitEdit = () => {
console.log(changeObj);
console.log(addForm.getFieldValue('name'));
if (addForm.getFieldValue('name')) {
UpdateModelType({ modelTypeName: addForm.getFieldValue('name'), id: changeObj.ID })
.then(res => {
if (res.code === 0) {
callBackSubmit(addForm.getFieldValue('name'));
onCancel();
notification.success({
message: '提交成功',
duration: 2,
});
// 重新获取机构树与用户表
} else {
notification.error({
message: '提交失败',
description: res.msg,
});
}
})
.catch(err => {
message.error(err);
});
} else {
notification.warning({
message: '模板类型名称不能为空',
duration: 2,
});
}
};
return (
<Modal
title="编辑模型类型"
visible={visible}
onCancel={onCancel}
destroyOnClose
onOk={submitEdit}
afterClose={() => {
addForm.resetFields();
}}
maskClosable={false}
okText="确认"
cancelText="取消"
>
<Form form={addForm} labelCol={{ span: 6 }}>
<Form.Item
name="name"
label="模板类型名称"
rules={[{ required: true, message: '不能为空' }]}
>
<Input placeholder="请输入模板类型名称" maxLength="20" style={{ width: '330px' }} />
</Form.Item>
{/* <Form.Item name="creator" label="登录人名称">
<Input placeholder="" maxLength="20" style={{ width: '330px' }} disabled />
</Form.Item> */}
</Form>
</Modal>
);
};
export default EditModal;