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
81
82
83
84
/*
* @Description:
* @Author: leizhe
* @Date: 2022-01-13 17:26:14
* @LastEditTime: 2022-03-22 16:17:58
* @LastEditors: leizhe
*/
import React, { useEffect } from 'react';
import { Modal, Form, Input, notification, message } from 'antd';
import { editOrgInfo } from '@/services/userManage/api';
const EditOrgModal = props => {
const { visible, orgID, description, onCancel, updateTrees, onSelect, orgTitle1 } = props;
const [editOrgForm] = Form.useForm(); // 添加用户
useEffect(() => {
console.log(orgTitle1);
editOrgForm.setFieldsValue({
OUName: orgTitle1,
description,
});
}, [visible]);
// 提交-编辑当前机构
const submitEditOrg = () =>
editOrgInfo(
orgID.id,
editOrgForm.getFieldValue('OUName'),
editOrgForm.getFieldValue('description') || '',
'',
)
.then(res => {
if (res.code === 0) {
onCancel();
notification.success({
message: '提交成功',
duration: 2,
});
// 重新获取机构树与用户表
updateTrees();
onSelect([orgID]);
// setExpandedKeys([`${orgID}`]);
} else {
notification.error({
message: '提交失败',
description: res.msg,
});
}
})
.catch(err => {
message.error(err);
});
const title = (
<span>
编辑<span style={{ fontWeight: 'bold', color: '#1890ff' }}>【{orgTitle1}】</span>信息
</span>
);
return (
<Modal
title={title}
visible={visible}
onCancel={onCancel}
maskClosable={false}
destroyOnClose
// afterClose={() => {
// editOrgForm.resetFields();
// }}
onOk={submitEditOrg}
okText="确认"
cancelText="取消"
>
<Form form={editOrgForm} labelCol={{ span: 4 }}>
<Form.Item name="OUName" label="机构名称" rules={[{ required: true, message: '不能为空' }]}>
<Input placeholder="请输入机构名称" maxLength="20" />
</Form.Item>
<Form.Item name="description" label="描述">
<Input placeholder="请输入相关描述" maxLength="100" />
</Form.Item>
</Form>
</Modal>
);
};
export default EditOrgModal;