@titaui/pc 1.7.101 → 1.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/lib/components/dialog/index.css +7 -1
  2. package/lib/components/dialog/index.js +7 -6
  3. package/lib/components/form/form-fields/input/index.css +22 -7
  4. package/lib/components/form/form-fields/input/index.js +11 -8
  5. package/lib/components/form/form-fields/input-verification-code/index.css +117 -0
  6. package/lib/components/form/form-fields/input-verification-code/index.js +230 -0
  7. package/lib/components/form/form-fields/password/index.css +2 -2
  8. package/lib/components/form/form-fields/radios/index.js +1 -1
  9. package/lib/components/form/index.js +4 -1
  10. package/lib/components/nav-top/components/user-message/components/empty/index.js +4 -2
  11. package/lib/components/nav-top/components/user-message/msg/index.js +1 -1
  12. package/lib/components/table/index.css +4 -0
  13. package/lib/components/table/index.js +3 -0
  14. package/lib/components/upload/index.js +2 -2
  15. package/lib/components/upload-photo-modal/constant.js +29 -0
  16. package/lib/components/upload-photo-modal/img/browser-preview-bgc.png +0 -0
  17. package/lib/components/upload-photo-modal/index.css +288 -0
  18. package/lib/components/upload-photo-modal/index.js +439 -0
  19. package/lib/components/upload-photo-modal/request-api.js +62 -0
  20. package/lib/components/user-selector/request-apis.js +1 -1
  21. package/lib/index.js +8 -0
  22. package/lib/pages/personal-info/components/base-info/index.css +36 -1
  23. package/lib/pages/personal-info/components/base-info/index.js +22 -90
  24. package/lib/pages/personal-info/components/edit-info/index.css +19 -0
  25. package/lib/pages/personal-info/components/edit-info/index.js +209 -0
  26. package/lib/pages/personal-info/components/edit-info/input/index.css +89 -0
  27. package/lib/pages/personal-info/components/edit-info/input/index.js +199 -0
  28. package/lib/pages/personal-info/components/person-photo/index.css +88 -0
  29. package/lib/pages/personal-info/components/person-photo/index.js +86 -0
  30. package/lib/pages/personal-info/index.js +3 -1
  31. package/package.json +3 -1
  32. package/src/components/dialog/index.js +2 -1
  33. package/src/components/dialog/index.scss +6 -1
  34. package/src/components/form/form-fields/input/index.scss +19 -7
  35. package/src/components/form/form-fields/input/index.tsx +9 -4
  36. package/src/components/form/form-fields/input-verification-code/index.scss +108 -0
  37. package/src/components/form/form-fields/input-verification-code/index.tsx +171 -0
  38. package/src/components/form/form-fields/password/index.scss +2 -2
  39. package/src/components/form/form-fields/radios/index.tsx +2 -2
  40. package/src/components/form/index.tsx +2 -0
  41. package/src/components/nav-top/components/user-message/components/empty/index.tsx +3 -2
  42. package/src/components/nav-top/components/user-message/msg/index.tsx +1 -1
  43. package/src/components/table/index.js +1 -0
  44. package/src/components/table/index.scss +5 -0
  45. package/src/components/upload/index.tsx +4 -4
  46. package/src/components/upload-photo-modal/constant.ts +27 -0
  47. package/src/components/upload-photo-modal/img/browser-preview-bgc.png +0 -0
  48. package/src/components/upload-photo-modal/index.scss +258 -0
  49. package/src/components/upload-photo-modal/index.tsx +331 -0
  50. package/src/components/upload-photo-modal/request-api.ts +33 -0
  51. package/src/components/user-selector/request-apis.js +1 -1
  52. package/src/index.js +1 -0
  53. package/src/pages/personal-info/components/base-info/index.scss +30 -1
  54. package/src/pages/personal-info/components/base-info/index.tsx +26 -97
  55. package/src/pages/personal-info/components/edit-info/index.scss +20 -0
  56. package/src/pages/personal-info/components/edit-info/index.tsx +166 -0
  57. package/src/pages/personal-info/components/edit-info/input/index.scss +82 -0
  58. package/src/pages/personal-info/components/edit-info/input/index.tsx +145 -0
  59. package/src/pages/personal-info/components/person-photo/index.scss +80 -0
  60. package/src/pages/personal-info/components/person-photo/index.tsx +49 -0
  61. package/src/pages/personal-info/index.tsx +2 -0
@@ -0,0 +1,33 @@
1
+ import qs from "qs";
2
+ import { rput, rpost } from "../../utils/request";
3
+ import { getUserInfo } from "../../utils/bs-global";
4
+
5
+ export const getUserInfoFun = () => {
6
+ return rpost("v1")(`manage/user/profile?toUserId=${getUserInfo().Id}`);
7
+ };
8
+
9
+ export const saveUserInfo = ({ data }) => {
10
+ return rput("v1")("manage/user/update", data, {
11
+ "headers": { "Content-Type": "multipart/form-data"},
12
+ "transformRequest": qs.stringify,
13
+ });
14
+ };
15
+
16
+ export const saveUserPhoto = (params) => {
17
+ return rpost("v1")("manage/user/avatar", params, {
18
+ "headers": { "Content-Type": "multipart/form-data"},
19
+ });
20
+ }
21
+
22
+ export const saveTenantLogo = (params) => {
23
+ return rpost("v1")("tenant/update/logo", params, {
24
+ "headers": { "Content-Type": "multipart/form-data"},
25
+ });
26
+ }
27
+
28
+ export const saveBrowserIcon = (params) => {
29
+ return rpost("v1")("tenant/update/browerIcon", params, {
30
+ "headers": { "Content-Type": "multipart/form-data"},
31
+ });
32
+ }
33
+
@@ -120,7 +120,7 @@ export const searchGroups = ({ searchKey }) => {
120
120
  }
121
121
 
122
122
  export const getDuties = () => {
123
- return axios.get(`${requestDomain()}/api/v1/${tenantId}/${userId}/position/getAll`)
123
+ return axios.get(`${requestDomain()}/api/v1/${tenantId}/${userId}/position/get?status=1&pageNum=1&pageSize=100`)
124
124
  .then(res => {
125
125
  return res.data;
126
126
  })
package/src/index.js CHANGED
@@ -85,3 +85,4 @@ export { default as requestApi } from "./utils/request";
85
85
  export { default as PointDemo} from './components/point-demo';
86
86
  export { default as Scrollbar } from './components/scrollbar';
87
87
  export { default as WeeklyReport} from './components/weekly-report';
88
+ export { default as UploadPhotoModal } from './components/upload-photo-modal';
@@ -5,7 +5,6 @@
5
5
  padding: 20px 32px;
6
6
  font-family: -apple-system, Arial, Verdana, Helvetica Neue, Helvetica,
7
7
  sans-serif, PingFang SC, Microsoft YaHei;
8
- height: 100%;
9
8
  &__header {
10
9
  display: flex;
11
10
  align-items: center;
@@ -31,8 +30,38 @@
31
30
  top: 3px;
32
31
  }
33
32
  }
33
+ &-btn {
34
+ width: 64px;
35
+ height: 28px;
36
+ box-sizing: border-box;
37
+ padding: 3px 18px;
38
+ background: rgba(40, 121, 255, 0.2);
39
+ border-radius: 14px;
40
+ font-size: 14px;
41
+ color: #2879FF;
42
+ line-height: 22px;
43
+ cursor: pointer;
44
+ &:hover {
45
+ color: #fff;
46
+ background-color: #2879ff;
47
+ }
48
+ }
34
49
  }
35
50
  &__form {
36
51
  width: 342px;
37
52
  }
53
+ .form-field-input__border {
54
+ padding: 0;
55
+ border: none;
56
+ background-color: #fff;
57
+ }
58
+ .form-field-input__label-text {
59
+ font-weight: 600;
60
+ }
61
+ .form-field-input__input {
62
+ background-color: #fff;
63
+ }
64
+ .form-field-input__border--disabled input:disabled {
65
+ background-color: #fff;
66
+ }
38
67
  }
@@ -1,9 +1,8 @@
1
1
  import React, { FC, useState, useRef, useEffect } from "react";
2
- import { RectBtn } from "../../../../components/button";
3
2
  import Form from "../../../../components/form";
4
- import { getUserInfoFun, saveUserInfo } from "../../request-api";
3
+ import { getUserInfoFun } from "../../request-api";
5
4
  import { getLocale } from "../../../../utils/getLocale";
6
- import Toast from "../../../../components/toast";
5
+ import EditModle from '../edit-info'
7
6
  import "./index.scss";
8
7
 
9
8
  const {Fields} = Form
@@ -12,129 +11,59 @@ const prefix = "titaui-personal-info-base-info";
12
11
  const BaseInfo: FC = () => {
13
12
  const formRef = useRef<any>();
14
13
  const [userInfo, setUserInfo] = useState({ name: "", email: "", mobile: "" });
15
- const [isDisable, setIsDisable] = useState(false);
16
- const [isEdit, setIsEdit] = useState(false);
14
+ const [visible, setVisible] = useState(false);
17
15
 
18
- const handleSaveInfo = () => {
19
- //校验
20
- const err = formRef.current.verifing({ truonlyFirstErrore: false });
21
- if (err.length > 0) {
22
- return;
23
- } else {
24
- saveUserInfo({ data: userInfo }).then((resp) => {
25
- if (resp.Code === 1) {
26
- Toast.Success(getLocale('Per_Ma_form_Updatesuc'), { canClose: false });
27
- } else {
28
- Toast.Error(resp.Message, { canClose: false });
29
- }
30
- });
31
- }
32
- };
16
+ const handleClickEdit = () => {
17
+ setVisible(true);
18
+ }
33
19
 
34
- const handleNameChange = (value) => {
35
- setUserInfo({
36
- ...userInfo,
37
- name: value || "",
38
- });
39
- setIsEdit(true);
40
- };
41
-
42
- const handlePhoneChange = (value) => {
43
- setUserInfo({
44
- ...userInfo,
45
- mobile: value || "",
46
- });
47
- setIsEdit(true);
48
- };
49
-
50
- const handleEmailChange = (value) => {
51
- setUserInfo({
52
- ...userInfo,
53
- email: value || "",
54
- });
55
- setIsEdit(true);
56
- };
57
-
58
- useEffect(() => {
59
- getUserInfoFun().then((resp) => {
60
- if (resp.Code === 1 && resp.Data) {
61
- setUserInfo({...resp.Data, position: resp.Data.positionCode});
62
- }
63
- });
64
- }, []);
20
+ const handleCancelEdit = () => {
21
+ setVisible(false);
22
+ }
65
23
 
66
24
  useEffect(() => {
67
- if (userInfo.name && userInfo.mobile && isEdit) {
68
- setIsDisable(false);
69
- } else {
70
- setIsDisable(true);
71
- }
72
- }, [userInfo, isEdit]);
25
+ getUserInfoFun().then((resp) => {
26
+ if (resp.Code === 1 && resp.Data) {
27
+ setUserInfo({ ...resp.Data, position: resp.Data.positionCode });
28
+ }
29
+ });
30
+ }, []);
73
31
 
74
32
  return (
75
33
  <div className={prefix}>
76
34
  <div className={`${prefix}__header`}>
77
35
  <span className={`${prefix}__header-title`}>{getLocale('Per_Ass_New_title_text_BasicIn')}</span>
78
- <RectBtn
79
- type={"primary"}
80
- text={getLocale('Mod_Save')}
81
- disabled={isDisable}
82
- onClick={handleSaveInfo}
83
- />
36
+ <span className={`${prefix}__header-btn`} onClick={handleClickEdit}>{getLocale('Mod_Editor')}</span>
37
+ <EditModle visible={visible} onCancel={handleCancelEdit}/>
84
38
  </div>
85
39
  <div className={`${prefix}__form`}>
86
40
  <Form ref={formRef}>
87
41
  <Fields.Input
88
42
  name="name"
89
43
  label={getLocale('Mod_UserName')}
90
- placeholder={"请输入姓名"}
44
+ placeholder={"未设置"}
91
45
  type="text"
92
- require
93
- verifies={[
94
- {
95
- "tip": "姓名不能为空",
96
- "test": /\S/,
97
- },
98
- {
99
- "tip": "姓名只能为中文,英文字母和数字及下划线的组合",
100
- "test": /^((?!(\uff08|\uff09)).)*$/g,
101
- },
102
- ]}
46
+ verifies={[]}
103
47
  value={userInfo.name}
104
- onChange={handleNameChange}
48
+ disabled
105
49
  />
106
50
  <Fields.Input
107
51
  name="phone"
108
52
  type="text"
109
53
  label={"手机号码"}
110
- placeholder={"请输入联系手机号码"}
111
- require
54
+ placeholder={"未设置"}
112
55
  value={userInfo.mobile}
113
- verifies={[
114
- {
115
- "tip": "手机号不能为空",
116
- "test": /^[\s\S]+$/,
117
- },
118
- {
119
- "tip": "请输入11位手机号",
120
- "test": /^1[3456789]\d{9}$/,
121
- },
122
- ]}
123
- onChange={handlePhoneChange}
56
+ verifies={[]}
57
+ disabled
124
58
  />
125
59
  <Fields.Input
126
60
  name="email"
127
61
  type="text"
128
62
  label={"电子邮箱"}
129
63
  value={userInfo.email}
130
- placeholder={"请输入联系邮箱"}
131
- verifies={[
132
- {
133
- "tip": "邮箱格式错误",
134
- "test": /^([a-zA-Z0-9_-]|\.)+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
135
- },
136
- ]}
137
- onChange={handleEmailChange}
64
+ placeholder={"未设置"}
65
+ verifies={[]}
66
+ disabled
138
67
  />
139
68
  </Form>
140
69
  </div>
@@ -0,0 +1,20 @@
1
+ .titaui-edit-personal-info {
2
+ &__form {
3
+ .titaui-form {
4
+ box-sizing: border-box;
5
+ padding: 0 32px;
6
+ }
7
+ .form-field-input__label {
8
+ width: 62px;
9
+ }
10
+ .form-field-input__label-text {
11
+ font-size: 14px;
12
+ font-weight: 400;
13
+ color: #89919F;
14
+ line-height: 22px;
15
+ }
16
+ .rc-tooltip {
17
+ left:110.5px !important;
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,166 @@
1
+ import React, { useState, useRef, useEffect } from 'react';
2
+ import Form from '../../../../components/form';
3
+ import { getUserInfoFun, saveUserInfo } from '../../request-api';
4
+ import Toast from '../../../../components/toast';
5
+ // import Input from './input';
6
+ import Dialog from '../../../../components/dialog';
7
+ import './index.scss';
8
+
9
+ const { Fields } = Form;
10
+
11
+ const prefix = "titaui-edit-personal-info"
12
+
13
+ const EditBaseInfo = (props) => {
14
+ const { visible, onCancel } = props;
15
+
16
+ const modalRef = useRef<any>();
17
+ const formContainerRef = useRef<any>();
18
+ const formRef = useRef<any>();
19
+
20
+ const [ isDisable, setIsDisable ] = useState(false);
21
+ const [ isEdit, setIsEdit ] = useState(false);
22
+ const [ userInfo, setUserInfo ] = useState({ name: '', email: '', mobile: '' });
23
+
24
+ const handleNameChange = (value) => {
25
+ setUserInfo({
26
+ ...userInfo,
27
+ name: value || ''
28
+ });
29
+ setIsEdit(true);
30
+ };
31
+
32
+ const handlePhoneChange = (value) => {
33
+ setUserInfo({
34
+ ...userInfo,
35
+ mobile: value || ''
36
+ });
37
+ setIsEdit(true);
38
+ };
39
+
40
+ const handleEmailChange = (value) => {
41
+ setUserInfo({
42
+ ...userInfo,
43
+ email: value || ''
44
+ });
45
+ setIsEdit(true);
46
+ };
47
+
48
+ const handleSaveUserInfo = () => {
49
+ if (!userInfo.email || !userInfo.mobile || !userInfo.name || isDisable) {
50
+ setIsDisable(true);
51
+ return;
52
+ } else {
53
+ saveUserInfo({ data: userInfo }).then((resp) => {
54
+ if (resp.Code === 1) {
55
+ Toast.Success('更新成功', { canClose: false });
56
+ onCancel();
57
+ setTimeout(() => {
58
+ window.location.reload();
59
+ }, 2000)
60
+ } else {
61
+ Toast.Error(resp.Message, { canClose: false });
62
+ }
63
+ });
64
+ }
65
+ };
66
+
67
+ useEffect(() => {
68
+ getUserInfoFun().then((resp) => {
69
+ if (resp.Code === 1 && resp.Data) {
70
+ setUserInfo({ ...resp.Data, position: resp.Data.positionCode });
71
+ }
72
+ });
73
+ }, []);
74
+
75
+ useEffect(
76
+ () => {
77
+ if (userInfo.name && userInfo.mobile && isEdit) {
78
+ setIsDisable(false);
79
+ } else {
80
+ setIsDisable(true);
81
+ }
82
+ },
83
+ [ userInfo, isEdit ]
84
+ );
85
+
86
+ return (
87
+ <Dialog
88
+ visible={visible}
89
+ ref={modalRef}
90
+ width={480}
91
+ mask
92
+ centered
93
+ title={'基本信息设置'}
94
+ noHeadLine
95
+ maskClosable={false}
96
+ onClose={onCancel}
97
+ onCancel={onCancel}
98
+ okText="确定"
99
+ noFooterLine
100
+ onOk={handleSaveUserInfo}
101
+ disabled={isDisable}
102
+ >
103
+ <div className={`${prefix}__form`} ref={formContainerRef}>
104
+ <Form ref={formRef} getFormContainer={() => formContainerRef.current}>
105
+ <Fields.Input
106
+ name="name"
107
+ label={'姓名'}
108
+ placeholder={'请输入姓名'}
109
+ type="text"
110
+ require
111
+ layout="row"
112
+ verifies={[
113
+ {
114
+ tip: '姓名不能为空',
115
+ test: /\S/
116
+ },
117
+ {
118
+ tip: '姓名只能为中文,英文字母和数字及下划线的组合',
119
+ test: /^((?!(\uff08|\uff09)).)*$/g
120
+ }
121
+ ]}
122
+ value={userInfo.name}
123
+ onChange={handleNameChange}
124
+ />
125
+ <Fields.Input
126
+ name="phone"
127
+ type="text"
128
+ label={'手机号码'}
129
+ placeholder={'请输入手机号'}
130
+ require
131
+ layout="row"
132
+ value={userInfo.mobile}
133
+ verifies={[
134
+ {
135
+ tip: '手机号不能为空',
136
+ test: /^[\s\S]+$/
137
+ },
138
+ {
139
+ tip: '请输入11位手机号',
140
+ test: /^1[3456789]\d{9}$/
141
+ }
142
+ ]}
143
+ onChange={handlePhoneChange}
144
+ />
145
+ <Fields.Input
146
+ name="email"
147
+ type="text"
148
+ label={'邮箱'}
149
+ value={userInfo.email}
150
+ layout="row"
151
+ placeholder={'请输入邮箱'}
152
+ verifies={[
153
+ {
154
+ tip: '邮箱格式错误',
155
+ test: /^([a-zA-Z0-9_-]|\.)+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/
156
+ }
157
+ ]}
158
+ onChange={handleEmailChange}
159
+ />
160
+ </Form>
161
+ </div>
162
+ </Dialog>
163
+ );
164
+ };
165
+
166
+ export default EditBaseInfo;
@@ -0,0 +1,82 @@
1
+ .edit-base-info-input {
2
+ display: flex;
3
+ box-sizing: border-box;
4
+ padding: 0 32px;
5
+ align-items: center;
6
+ margin-bottom: 16px;
7
+ &__label {
8
+ width: 56px;
9
+ height: 22px;
10
+ font-size: 14px;
11
+ margin-bottom: 5px;
12
+ margin-right: 20px;
13
+ font-family: -apple-system, Arial, Verdana, Helvetica Neue, Helvetica, sans-serif, PingFang SC, Microsoft YaHei;
14
+ font-weight: 400;
15
+ line-height: 22px;
16
+
17
+ &-text {
18
+ color: #89919F;
19
+ }
20
+
21
+ &-require {
22
+ color: red;
23
+ }
24
+ }
25
+
26
+ &__border {
27
+ flex:1;
28
+ padding: 6px 12px;
29
+ transition: all 0.2s;
30
+ border: 1px solid #e9ecf0;
31
+ box-sizing: border-box;
32
+ border-radius: 8px;
33
+
34
+ &--disabled {
35
+ background-color: #fafafa;
36
+ cursor: not-allowed;
37
+ input:disabled {
38
+ background-color: #fafafa;
39
+ cursor: not-allowed;
40
+ color: #3f475594;
41
+ }
42
+ }
43
+ }
44
+ &__border--error {
45
+ box-shadow: inset 0px 0px 4px 0px rgba(240, 94, 94, 0.3) !important;
46
+ border: 1px solid #f05e5e !important;
47
+ }
48
+ &__border--active {
49
+ box-shadow: inset 0px 0px 4px 0px rgba(40, 121, 255, 0.3);
50
+ border: 1px solid #2879ff;
51
+ }
52
+
53
+ &__input {
54
+ display: inline-block;
55
+ padding: 0;
56
+ width: calc(100% - 12px);
57
+ font-size: 14px;
58
+ font-family: -apple-system, Arial, Verdana, Helvetica Neue, Helvetica, sans-serif, PingFang SC, Microsoft YaHei;
59
+ font-weight: 400;
60
+ color: #3f4755;
61
+ height: 22px;
62
+ line-height: inherit;
63
+ border: none;
64
+
65
+ &::-webkit-input-placeholder {
66
+ color: #bfc7d5;
67
+ font-weight: unset;
68
+ }
69
+ &::-moz-placeholder {
70
+ color: #bfc7d5;
71
+ font-weight: unset;
72
+ }
73
+ &:-moz-placeholder {
74
+ color: #bfc7d5;
75
+ font-weight: unset;
76
+ }
77
+ &:-ms-input-placeholder {
78
+ color: #bfc7d5;
79
+ font-weight: unset;
80
+ }
81
+ }
82
+ }
@@ -0,0 +1,145 @@
1
+ import React, { useState, useRef, useEffect, forwardRef, useImperativeHandle } from 'react';
2
+ import classNames from 'classnames';
3
+ import ToolTip from '../../../../../components/tooltip/error-tip';
4
+ import './index.scss'
5
+
6
+ const preCls = 'edit-base-info-input';
7
+
8
+ interface verify {
9
+ tip: string;
10
+ test: RegExp;
11
+ }
12
+ interface Props {
13
+ label: string;
14
+ verifies?: verify[];
15
+ placeholder?: string;
16
+ onChange?: Function;
17
+ value?: any;
18
+ require?: boolean;
19
+ type?: string;
20
+ name: string;
21
+ getContainer?: Function;
22
+ disabled?: boolean
23
+ }
24
+ interface Error {
25
+ name: string;
26
+ tip: string;
27
+ }
28
+
29
+ const OverlayInner = ({ hasError, hasActive, tip }) => {
30
+ if (hasError) return <span style={{ 'color': '#F05E5E' }}>{tip}</span>;
31
+ if (hasActive) return <span style={{ 'color': '#3F4755' }}>{tip}</span>;
32
+ return <span />;
33
+ }
34
+
35
+ const popupAlign = {
36
+ offset: [-12, -4],
37
+ overflow: { adjustX: true, adjustY: true },
38
+ targetOffset: [0, 0],
39
+ };
40
+
41
+ export default forwardRef((props: Props, ref) => {
42
+ const {
43
+ label,
44
+ verifies,
45
+ placeholder,
46
+ onChange,
47
+ require,
48
+ type,
49
+ name,
50
+ disabled,
51
+ getContainer
52
+ } = props;
53
+
54
+ const inputRef = useRef<any>();
55
+ const [hasError, setHasError] = useState<boolean>(false);
56
+ const [hasActive, setHasActive] = useState<boolean>(false);
57
+ const [tip, setTip] = useState<string>('');
58
+ const [value, setValue] = useState<string>(props.value || '');
59
+
60
+ useEffect(() => {
61
+ setValue(props.value);
62
+ }, [props.value])
63
+
64
+ const verifing = (): Error[] => {
65
+ const value = inputRef.current && inputRef.current.value;
66
+ if (!verifies || !verifies.length) return [];
67
+ if (!require && !value) return [];
68
+ const errors: Error[] = [];
69
+ for (let i = 0; i < verifies.length; i++) {
70
+ let { test, tip } = verifies[i];
71
+ if (!value.match(test)) {
72
+ errors.push({ name, tip });
73
+ }
74
+ }
75
+ return errors;
76
+ }
77
+
78
+ const onInputFocusHandler = () => {
79
+ setHasActive(true);
80
+ inputRef.current.setSelectionRange(9999999, 9999999);
81
+ }
82
+
83
+ const onBlurHandler = () => {
84
+ setHasActive(false);
85
+ }
86
+
87
+ const onChangeHandler = () => {
88
+ const value = inputRef.current && inputRef.current.value;
89
+ onChange && onChange(value);
90
+ setValue(value);
91
+ const errors = verifing();
92
+ if (errors.length) {
93
+ setHasError(true);
94
+ setTip(errors[0].tip);
95
+ } else {
96
+ setHasError(false);
97
+ setTip('');
98
+ }
99
+ }
100
+
101
+ useImperativeHandle(ref, () => ({
102
+ 'verifing': (): Error[] => {
103
+ const errors = verifing();
104
+ if (errors.length) {
105
+ setHasError(true);
106
+ setTip(errors[0].tip);
107
+ inputRef.current.focus();
108
+ }
109
+ return errors;
110
+ }
111
+ }))
112
+
113
+ return <div className={classNames(preCls)}>
114
+ <div className={classNames(`${preCls}__label`)}>
115
+ <span className={classNames(`${preCls}__label-text`)}>{label}</span>
116
+ </div>
117
+ <div className={classNames(`${preCls}__border`, {
118
+ [`${preCls}__border--error`]: hasError,
119
+ [`${preCls}__border--active`]: hasActive,
120
+ [`${preCls}__border--disabled`]: disabled
121
+ })}>
122
+ <ToolTip
123
+ placement={'topLeft'}
124
+ popupAlign={popupAlign}
125
+ destroyTooltipOnHide={true}
126
+ visible={(hasActive || hasError) && tip}
127
+ overlay={<OverlayInner hasActive={hasActive} hasError={hasError} tip={tip} />}
128
+ getTooltipContainer={getContainer}
129
+ >
130
+ <input
131
+ ref={inputRef}
132
+ type={type}
133
+ disabled={disabled}
134
+ className={classNames(`${preCls}__input`)}
135
+ value={value}
136
+ placeholder={placeholder}
137
+ onFocus={onInputFocusHandler}
138
+ onBlur={onBlurHandler}
139
+ onChange={onChangeHandler}
140
+ autoComplete='off'
141
+ />
142
+ </ToolTip>
143
+ </div>
144
+ </div>
145
+ })