@digitalc/drm-dxp-package 0.0.6 → 0.0.8

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.
@@ -0,0 +1,500 @@
1
+ import React from 'react';
2
+ import { formatLocalMessage } from '@utils/utils';
3
+ import { useSelector, useDispatch } from 'react-redux';
4
+ import moment from 'moment';
5
+ import { Form, Input, Row, Col, Select, Tooltip, Icon } from '@whalecloud/fdx';
6
+ import { PARTNER_STATUS, PARTNER_HIERARCHY_STATUS, DATE_TABLE_FORMAT, DEFAULT_DATE_TABLE_FORMAT } from '@/constants';
7
+ import { validatorRule } from '@/utils/getRule';
8
+ import ParentSelect from '../ParentSelect';
9
+ import styles from './index.module.less';
10
+
11
+ const { Option } = Select;
12
+ const BasicInfo = props => {
13
+ const dispatch = useDispatch();
14
+ const { form: { getFieldDecorator, setFieldsValue, getFieldValue, setFields }, isNew } = props;
15
+ const { DRM_DATETIME_FORMAT_UI_NEW = DATE_TABLE_FORMAT } = useSelector(state => state.esalesCommom);
16
+ const {
17
+ partnerStatus, orgBaseInfoDetails = {}, channelTypeList = [], selectedOwner = {},
18
+ subBaseInfoData = {}, orgRegTypes = [],
19
+ basicInfoCom = [], ownerInformationError = {},
20
+ } = useSelector(state => state.partner360);
21
+ const [formDisabled, setFormDisabled] = React.useState(true);
22
+ const [infoData, setInfoData] = React.useState({});
23
+ const [brnPattern, setBrnPattern] = React.useState('');
24
+ const [taxCodeList, setTaxCodeList] = React.useState([]);
25
+ const [regNumData, setRegNumData] = React.useState({});
26
+
27
+ const foundBrnComponent = basicInfoCom.find(item => item.componentCode === 'COMMON_PARTNER_BRN');
28
+ const ruleList = foundBrnComponent && foundBrnComponent.componentValidateRuleList || [];
29
+ // validateType=R表示正则表达式,S表示接口服务,L表示长度校验
30
+ const foundSRule = ruleList.find(item => item.validateType === 'S');
31
+ const serveUrl = foundSRule && foundSRule.validateRule;
32
+ const foundRRule = ruleList.find(item => item.validateType === 'R');
33
+ const ruleBrn = foundRRule && foundRRule.validateRule || '';
34
+
35
+ React.useEffect(() => {
36
+ setInfoData(isNew ? subBaseInfoData : orgBaseInfoDetails);
37
+ }, [JSON.stringify(subBaseInfoData), JSON.stringify(orgBaseInfoDetails)]);
38
+
39
+ React.useEffect(() => {
40
+ if (selectedOwner && selectedOwner.orgSubtype) {
41
+ dispatch({
42
+ type: 'partner360/qryChannelTypeByParentId',
43
+ payload: { channelTypeCode: selectedOwner && selectedOwner.orgSubtype },
44
+ });
45
+ }
46
+ dispatch({
47
+ type: 'partner360/save',
48
+ payload: {
49
+ orgSubtype: infoData.orgSubtype,
50
+ },
51
+ });
52
+ dispatch({
53
+ type: 'partner360/qryTaxCode',
54
+ }).then(res => {
55
+ setTaxCodeList(res);
56
+ });
57
+ }, [selectedOwner && selectedOwner.orgSubtype]);
58
+
59
+ React.useEffect(() => {
60
+ if (partnerStatus === PARTNER_STATUS.NEW && getFieldValue('orgSubtype')) {
61
+ dispatch({
62
+ type: 'partner360/queryFormConfigList',
63
+ payload: getFieldValue('orgSubtype') || '',
64
+ });
65
+ }
66
+ if (orgBaseInfoDetails && orgBaseInfoDetails.orgSubtype) {
67
+ dispatch({
68
+ type: 'partner360/queryFormConfigList',
69
+ payload: (orgBaseInfoDetails && orgBaseInfoDetails.orgSubtype) || '',
70
+ });
71
+ }
72
+ }, [getFieldValue('orgSubtype'), orgBaseInfoDetails && orgBaseInfoDetails.orgSubtype]);
73
+
74
+ React.useEffect(() => {
75
+ switch (partnerStatus) {
76
+ case PARTNER_STATUS.DETAIL:
77
+ setFormDisabled(true);
78
+ break;
79
+ default:
80
+ setFormDisabled(false);
81
+ }
82
+ }, [partnerStatus]);
83
+
84
+ React.useEffect(() => {
85
+ dispatch({
86
+ type: 'partner360/qryRegType',
87
+ });
88
+ }, []);
89
+
90
+ const qryComponent = async data => {
91
+ const resp = await dispatch({
92
+ type: 'partner360/componentCheck',
93
+ payload: {
94
+ serveUrl,
95
+ data,
96
+ },
97
+ });
98
+ dispatch({
99
+ type: 'partner360/save',
100
+ payload: {
101
+ ownerInformationError: {
102
+ ...ownerInformationError,
103
+ [data && data.key]: {
104
+ message: (resp && resp.code === '200') ? '' : (resp && resp.message) || formatLocalMessage('SYSTEM_ERROR'),
105
+ },
106
+ },
107
+ },
108
+ });
109
+ if (resp && resp.code !== '200') {
110
+ return {
111
+ validateStatus: 'error',
112
+ help: resp && resp.message,
113
+ };
114
+ }
115
+ return {
116
+ validateStatus: 'success',
117
+ help: null,
118
+ };
119
+ };
120
+
121
+ const changeRegNbr = async (val, ruleAll, isQry, rule) => {
122
+ const msg = validatorRule(val, ruleAll || brnPattern, 'ESALES_ITEM_RULES_BRN_TIPS', false, rule);
123
+ setRegNumData(msg);
124
+ if (msg && msg.validateStatus === 'error') {
125
+ return;
126
+ }
127
+ const data = { key: 'regNum', regNum: val, regType: getFieldValue('regType'), orgId: orgBaseInfoDetails.orgId };
128
+ if (!isQry) {
129
+ dispatch({
130
+ type: 'partner360/save',
131
+ payload: {
132
+ ownerInformationError: {
133
+ ...ownerInformationError,
134
+ regNum: {
135
+ serveUrl,
136
+ data,
137
+ },
138
+ },
139
+ },
140
+ });
141
+ }
142
+ if (isQry && serveUrl) {
143
+ const qryMsg = await qryComponent(data);
144
+ setRegNumData(qryMsg);
145
+ }
146
+ };
147
+
148
+ const handleParentModalShow = () => {
149
+ dispatch({
150
+ type: 'partner360/save',
151
+ payload: {
152
+ parentModalVisible: true,
153
+ },
154
+ });
155
+ };
156
+
157
+ const clearOrgSubtype = () => {
158
+ setFieldsValue({
159
+ orgSubtype: null,
160
+ });
161
+ };
162
+
163
+ const handleChangeChannelType = val => {
164
+ setFieldsValue({
165
+ orgSubtype: val,
166
+ });
167
+ };
168
+
169
+ const handleChangeRegType = async val => {
170
+ const brnValue = getFieldValue('regNum');
171
+ setFieldsValue({
172
+ regType: val,
173
+ });
174
+ if (ruleBrn) {
175
+ const brnPatterns = {};
176
+ ruleBrn.split('|').forEach(item => {
177
+ const key = item.split('=')[0];
178
+ const value = item.split('=')[1];
179
+ brnPatterns[key] = value;
180
+ });
181
+ const currentBrnPatt = brnPatterns[val];
182
+ setBrnPattern(currentBrnPatt);
183
+ setFields({
184
+ regNum: {
185
+ value: brnValue,
186
+ },
187
+ });
188
+ changeRegNbr(brnValue, null, true, currentBrnPatt);
189
+ }
190
+ };
191
+ const colConfig = {
192
+ sm: 8,
193
+ xs: 24,
194
+ };
195
+
196
+ // list
197
+ const FORM_LIST = {
198
+ COMMON_PARTNER_PARENT: (selectedOwner && selectedOwner.orgName) ? {
199
+ index: 1,
200
+ components: com => (
201
+ <Col {...colConfig}>
202
+ <Form.Item label={formatLocalMessage('PARTNER_PARENT')}>
203
+ {getFieldDecorator('parentOrgId', {
204
+ initialValue: selectedOwner && selectedOwner.orgName,
205
+ rules: [
206
+ {
207
+ required: com.required === 'Y',
208
+ message: formatLocalMessage('ESALES_ITEM_IS_REQUIRED'),
209
+ },
210
+ ],
211
+ })(
212
+ <Input
213
+ disabled={formDisabled || com.editable !== 'Y'}
214
+ placeholder={formatLocalMessage('TRANSFER_DESTINATION')}
215
+ readonly="readonly"
216
+ suffix={<span className="iconfont icon-ic_nav_expand" onClick={handleParentModalShow} />}
217
+ onClick={handleParentModalShow}
218
+ className={styles.orgInput}
219
+ />)}
220
+ </Form.Item>
221
+ </Col>
222
+ ),
223
+ } : {
224
+ index: 1,
225
+ components: () => {},
226
+ },
227
+ COMMON_PARTNER_NAME: {
228
+ index: 2,
229
+ components: com => (
230
+ <Col {...colConfig}>
231
+ <Form.Item label={formatLocalMessage('PARTNER_NAME')}>
232
+ {getFieldDecorator('orgName', {
233
+ initialValue: infoData && infoData.orgName || null,
234
+ rules: [
235
+ {
236
+ required: com.required === 'Y',
237
+ message: formatLocalMessage('ESALES_ITEM_IS_REQUIRED'),
238
+ },
239
+ ],
240
+ })(<Input
241
+ maxLength={100}
242
+ allowClear
243
+ placeholder={formatLocalMessage('COMMON_PLEASE_INPUT')}
244
+ disabled={formDisabled || com.editable !== 'Y'}
245
+ />)}
246
+ </Form.Item>
247
+ </Col>
248
+ ),
249
+ },
250
+ COMMON_PARTNER_CODE: {
251
+ index: 3,
252
+ components: com => (
253
+ <Col {...colConfig}>
254
+ <Form.Item label={formatLocalMessage('PARTNER_CODE')}>
255
+ {getFieldDecorator('orgCode', {
256
+ initialValue: infoData && infoData.orgCode || null,
257
+ rules: [
258
+ {
259
+ required: com.required === 'Y',
260
+ message: formatLocalMessage('ESALES_ITEM_IS_REQUIRED'),
261
+ },
262
+ ],
263
+ })(<Input disabled={formDisabled || com.editable !== 'Y'} />)}
264
+ </Form.Item>
265
+ </Col>
266
+ ),
267
+ },
268
+ COMMON_PARTNER_CATEGORY: {
269
+ index: 4,
270
+ components: com => (
271
+ <Col {...colConfig}>
272
+ <Form.Item label={formatLocalMessage('PARTNER_CATEGORY')}>
273
+ {getFieldDecorator('channelCategoryName', {
274
+ initialValue: (selectedOwner && selectedOwner.channelCategoryName) || (infoData && infoData.channelCategoryName) || null,
275
+ rules: [
276
+ {
277
+ required: com.required === 'Y',
278
+ message: formatLocalMessage('ESALES_ITEM_IS_REQUIRED'),
279
+ },
280
+ ],
281
+ })(<Input disabled={formDisabled || com.editable !== 'Y'} />)}
282
+ </Form.Item>
283
+ </Col>
284
+ ),
285
+ },
286
+ COMMON_PARTNER_TYPE: {
287
+ index: 5,
288
+ components: com => (
289
+ <Col {...colConfig}>
290
+ <Form.Item label={formatLocalMessage('PARTNER_TYPE')}>
291
+ {getFieldDecorator('orgSubtype', {
292
+ initialValue: (
293
+ partnerStatus === PARTNER_STATUS.NEW
294
+ ? (infoData && infoData.orgSubtype) || (channelTypeList[0] && channelTypeList[0].channelTypeCode)
295
+ : (infoData && infoData.orgSubtypeName)
296
+ ),
297
+ rules: [
298
+ {
299
+ required: com.required === 'Y',
300
+ message: formatLocalMessage('ESALES_ITEM_IS_REQUIRED'),
301
+ },
302
+ ],
303
+ })(
304
+ <Select
305
+ onChange={handleChangeChannelType}
306
+ allowClear
307
+ placeholder={formatLocalMessage('COMMON_PLEASE_SELECT')}
308
+ disabled={formDisabled || com.editable !== 'Y'}
309
+ >
310
+ {channelTypeList.map((item, index) => (
311
+ <Option value={item.channelTypeCode} key={index}>
312
+ {item.channelTypeName}
313
+ </Option>
314
+ ))}
315
+ </Select>,
316
+ )}
317
+ </Form.Item>
318
+ </Col>
319
+ ),
320
+ },
321
+ COMMON_PARTNER_REGISTRATION_TYPE: {
322
+ index: 6,
323
+ components: com => (
324
+ <Col {...colConfig}>
325
+ <Form.Item label={formatLocalMessage('PARTNER_REGISTER_TYPE')}>
326
+ {getFieldDecorator('regType', {
327
+ initialValue: infoData && infoData.regType || null,
328
+ rules: [
329
+ {
330
+ required: com.required === 'Y',
331
+ message: formatLocalMessage('ESALES_ITEM_IS_REQUIRED'),
332
+ },
333
+ ],
334
+ })(
335
+ <Select
336
+ onChange={handleChangeRegType}
337
+ placeholder={formatLocalMessage('COMMON_PLEASE_SELECT')}
338
+ allowClear
339
+ disabled={formDisabled || com.editable !== 'Y'}
340
+ >
341
+ {orgRegTypes.map(item => (
342
+ <Option value={item.value} key={item.configValueId}>
343
+ {item.displayName}
344
+ </Option>
345
+ ))}
346
+ </Select>
347
+ )}
348
+ </Form.Item>
349
+ </Col>
350
+ ),
351
+ },
352
+ COMMON_PARTNER_BRN: {
353
+ index: 7,
354
+ components: com => (
355
+ <Col {...colConfig}>
356
+ <Form.Item
357
+ validateStatus={regNumData.validateStatus}
358
+ help={regNumData.help}
359
+ label={(
360
+ <>
361
+ {formatLocalMessage('PARTNER_BRN')}
362
+ <Tooltip trigger="hover/click" title={formatLocalMessage('ESALES_ITEM_RULES_BRN_TIPS')}>
363
+ <Icon className="form-item-required-label-tips" type="info-circle" theme="filled" />
364
+ </Tooltip>
365
+ </>
366
+ )}
367
+ >
368
+ {getFieldDecorator('regNum', {
369
+ initialValue: infoData && infoData.regNum || null,
370
+ rules: [
371
+ {
372
+ required: com.required === 'Y',
373
+ message: formatLocalMessage('ESALES_ITEM_IS_REQUIRED'),
374
+ },
375
+ {
376
+ pattern: brnPattern,
377
+ message: formatLocalMessage('ESALES_ITEM_RULES_BRN_TIPS'),
378
+ },
379
+ ],
380
+ })(<Input
381
+ maxLength={20}
382
+ allowClear
383
+ placeholder={formatLocalMessage('COMMON_PLEASE_INPUT')}
384
+ disabled={formDisabled || com.editable !== 'Y'}
385
+ onChange={e => changeRegNbr(e.target.value, com)}
386
+ onBlur={e => changeRegNbr(e.target.value, com, true)}
387
+ />)}
388
+ </Form.Item>
389
+ </Col>
390
+ ),
391
+ },
392
+ COMMON_PARTNER_STATUS: {
393
+ index: 8,
394
+ components: com => (
395
+ <Col {...colConfig}>
396
+ <Form.Item label={formatLocalMessage('PARTNER_STATUS')}>
397
+ {getFieldDecorator('statusCd', {
398
+ initialValue: infoData && infoData.statusCd && PARTNER_HIERARCHY_STATUS[infoData.statusCd] && PARTNER_HIERARCHY_STATUS[infoData.statusCd].label || null,
399
+ rules: [
400
+ {
401
+ required: com.required === 'Y',
402
+ message: formatLocalMessage('ESALES_ITEM_IS_REQUIRED'),
403
+ },
404
+ ],
405
+ })(<Input disabled={formDisabled || com.editable !== 'Y'} />)}
406
+ </Form.Item>
407
+ </Col>
408
+ ),
409
+ },
410
+ COMMON_PARTNER_CREATED_DATE: {
411
+ index: 9,
412
+ components: com => (
413
+ <Col {...colConfig}>
414
+ <Form.Item label={formatLocalMessage('PARTNER_CREATED_DATE')}>
415
+ {getFieldDecorator('createDate', {
416
+ initialValue: (
417
+ infoData && infoData.createDate && moment(infoData.createDate, DEFAULT_DATE_TABLE_FORMAT).format(DRM_DATETIME_FORMAT_UI_NEW)
418
+ ) || null,
419
+ rules: [
420
+ {
421
+ required: com.required === 'Y',
422
+ message: formatLocalMessage('ESALES_ITEM_IS_REQUIRED'),
423
+ },
424
+ ],
425
+ })(<Input disabled={formDisabled || com.editable !== 'Y'} />)}
426
+ </Form.Item>
427
+ </Col>
428
+ ),
429
+ },
430
+ COMMON_PARTNER_TAX_CODE: {
431
+ index: 10,
432
+ components: com => (
433
+ <Col {...colConfig}>
434
+ <Form.Item label={formatLocalMessage('PARTNER_TAX_CODE')}>
435
+ {getFieldDecorator('taxCode', {
436
+ initialValue: infoData && infoData.taxCode || null,
437
+ rules: [
438
+ {
439
+ required: com.required === 'Y',
440
+ message: formatLocalMessage('ESALES_ITEM_IS_REQUIRED'),
441
+ },
442
+ ],
443
+ })(
444
+ <Select
445
+ allowClear
446
+ placeholder={formatLocalMessage('COMMON_PLEASE_SELECT')}
447
+ disabled={formDisabled || com.editable !== 'Y'}
448
+ >
449
+ {taxCodeList.map(item => (
450
+ <Option value={item.value} key={item.configValueId}>
451
+ {item.displayName}
452
+ </Option>
453
+ ))}
454
+ </Select>
455
+ )}
456
+ </Form.Item>
457
+ </Col>
458
+ ),
459
+ },
460
+ COMMON_PARTNER_TIN_ID: {
461
+ index: 11,
462
+ components: com => (
463
+ <Col {...colConfig}>
464
+ <Form.Item
465
+ label={formatLocalMessage('PARTNER_TIN_ID')}
466
+ >
467
+ {getFieldDecorator('tinId', {
468
+ initialValue: infoData && infoData.tinId || null,
469
+ rules: [
470
+ {
471
+ required: com.required === 'Y',
472
+ message: formatLocalMessage('ESALES_ITEM_IS_REQUIRED'),
473
+ },
474
+ ],
475
+ })(<Input maxLength={60} disabled={formDisabled || com.editable !== 'Y'} placeholder={formatLocalMessage('COMMON_PLEASE_INPUT')} />)}
476
+ </Form.Item>
477
+ </Col>
478
+ ),
479
+ },
480
+ };
481
+
482
+ return (
483
+ <>
484
+ <div className="secondary-title">{formatLocalMessage('PARTNER_BASIC_INFORMATION')}</div>
485
+ <div className={styles.formContainer}>
486
+ <Row gutter={24}>
487
+ {basicInfoCom.map((item, index) => {
488
+ if ((index + 1) % 3 === 0) {
489
+ return <>{FORM_LIST && FORM_LIST[item.componentCode] && FORM_LIST[item.componentCode].components(item)}<div style={{ clear: 'both' }} /></>;
490
+ }
491
+ return FORM_LIST && FORM_LIST[item.componentCode] && FORM_LIST[item.componentCode].components(item);
492
+ })}
493
+ </Row>
494
+ <ParentSelect clearOrgSubtype={clearOrgSubtype} />
495
+ </div>
496
+ </>
497
+ );
498
+ };
499
+
500
+ export default BasicInfo;
@@ -0,0 +1,67 @@
1
+ import React from 'react';
2
+ import { useDispatch, useSelector } from 'react-redux';
3
+ import isEmpty from 'lodash/isEmpty';
4
+ import { formatLocalMessage } from '@utils/utils';
5
+ import { EModal, OrgSelect } from '@/components';
6
+ import IMessage from '@/utils/IMessage';
7
+ import styles from './index.module.less';
8
+
9
+ const ParentSelect = prprs => {
10
+ const { clearOrgSubtype } = prprs;
11
+ const dispatch = useDispatch();
12
+ const { parentModalVisible, activeRow } = useSelector(state => state.partner360);
13
+
14
+ const handleOwnerModalClose = () => {
15
+ dispatch({
16
+ type: 'partner360/save',
17
+ payload: {
18
+ parentModalVisible: false,
19
+ },
20
+ });
21
+ };
22
+
23
+ const handleSelect = () => {
24
+ if (isEmpty(activeRow)) {
25
+ IMessage.error(formatLocalMessage('REQUEST_PLEASE_SELECT_ONE_ROW'));
26
+ return;
27
+ }
28
+ dispatch({
29
+ type: 'partner360/save',
30
+ payload: {
31
+ selectedOwner: activeRow,
32
+ },
33
+ });
34
+ clearOrgSubtype();
35
+ handleOwnerModalClose();
36
+ };
37
+
38
+ const handleRowDBClick = row => {
39
+ dispatch({
40
+ type: 'partner360/save',
41
+ payload: {
42
+ selectedOwner: row,
43
+ },
44
+ });
45
+ clearOrgSubtype();
46
+ handleOwnerModalClose();
47
+ };
48
+
49
+ const modalProps = {
50
+ className: styles.parentSelectModal,
51
+ closable: true,
52
+ title: 'Parent',
53
+ width: '80%',
54
+ visible: parentModalVisible,
55
+ okText: 'Select',
56
+ onOk: handleSelect,
57
+ onCancel: handleOwnerModalClose,
58
+ };
59
+
60
+ return (
61
+ <EModal modalProps={{ ...modalProps }}>
62
+ <OrgSelect ownNamespace="partner360" onRowDBClick={handleRowDBClick} modalVisible={parentModalVisible} />
63
+ </EModal>
64
+ );
65
+ };
66
+
67
+ export default ParentSelect;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitalc/drm-dxp-package",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "files": [