index.jsx
4.11 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import { useState, useEffect } from "react";
import { ConfigProvider, Modal, Form, Input, Select, message, Button } from "antd";
import commonConfig from "@/utils/config";
import * as commonServices from "@/services/services";
const UserRegistrationEvent = () => {
const [state, setState0] = useState({});
const setState = payload => {
setState0({ ...state, ...payload });
};
// 初始化获取所属客户
useEffect(() => {
const url = `${commonConfig.feedback_host}sysworkorder/getCustomerData`;
commonServices.postValueService("", {}, url).then(({ data: result = {} }) => {
const { code = -1, data, msg = "接口出错" } = result;
if (code > -1) {
setState({ customerData: data });
} else {
message.error(msg);
}
});
}, []);
return {
...state,
setState,
};
};
const UserRegistration = ({ _this }) => {
const { userRegisterMode } = _this.state;
if (!userRegisterMode) return "";
const props = UserRegistrationEvent();
const { customerData = [], successModalVisible } = props;
const [form] = Form.useForm();
const handleCancel = () => {
_this.setState({
userRegisterMode: false,
});
};
const handleOk = () => {
form.submit();
};
const onFinish = ({ username, phonenumber, sCustomerId }) => {
const url = `${commonConfig.feedback_host}sftlogininfo/insertPasswordUserName/add`;
const params = {
sUserName: username,
sLanguage: "sChinese",
sBrandsId: "1111111111",
sSubsidiaryId: "1111111111",
sPhone: phonenumber,
sCustomerId,
};
commonServices.postValueService("", params, url).then(({ data: result = {} }) => {
const { code = -1, msg = "接口出错" } = result;
if (code > -1) {
props.setState({
successModalVisible: true,
phonenumber,
});
} else {
message.error(msg);
}
});
};
return (
<ConfigProvider prefixCls="antdV5">
<Modal
title="用户注册"
open={userRegisterMode && !successModalVisible}
okText="确认"
cancelText="取消"
onOk={handleOk}
onCancel={handleCancel}
width={400}
>
<Form
name="basic"
form={form}
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
style={{ maxWidth: 600 }}
initialValues={{ remember: true }}
onFinish={onFinish}
autoComplete="off"
labelAlign="left"
>
<Form.Item label="用户名" name="username" rules={[{ required: true, message: "未填写用户名!" }]}>
<Input />
</Form.Item>
<Form.Item
label="手机号"
name="phonenumber"
rules={[
{ required: true, message: "未填写手机号!" },
{
pattern: /^1[3-9]\d{9}$/,
message: "请输入有效的中国大陆手机号",
},
]}
>
<Input />
</Form.Item>
<Form.Item label="公司名称" name="company" rules={[{ required: true, message: "未选择公司!" }]}>
<Select
fieldNames={{ label: "sCustomerName", value: "sCustomerId" }}
options={customerData}
showSearch
filterOption={(inputValue, option) => option.sCustomerName?.includes(inputValue)}
/>
</Form.Item>
</Form>
</Modal>
<Modal
open={successModalVisible}
title="注册成功"
onCancel={handleCancel}
footer={
<Button type="primary" onClick={handleCancel}>
确认
</Button>
}
width={400}
>
<p style={{ fontWeight: "bold", fontSize: 16 }}>请等待【管理员审核】成功后用以下账号登陆!</p>
<p>
用户名: <span style={{ fontSize: 16 }}>{props.phonenumber}</span>
</p>
<p>
密 码: <span style={{ fontSize: 16 }}>{props.phonenumber}</span>
</p>
</Modal>
</ConfigProvider>
);
};
export default UserRegistration;