addCustomer.js
56.7 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
import React from 'react'
import './index.less'
import { Form, Button, Input, Select, message, Spin , Radio, Row, Col, DatePicker, Checkbox,Tag, Icon,Tooltip } from 'antd'
import { NavLink } from 'react-router-dom'
import UserManageBar from '@components/Common/WhiteBar/index'
import axios from '@src/axios/index'
import Utils from '@src/utils/utils'
import moment from 'moment';
import storage from '@src/utils/localStorage'
import { API_DICT_MANAGE, API_CUSTOMER_MANAGE } from '@src/Api'
import locale from 'antd/lib/date-picker/locale/zh_CN';
const FormItem = Form.Item;
const RadioGroup = Radio.Group;
const CheckableTag = Tag.CheckableTag;
class AddCustomer extends React.Component {
state = {
disabled: false,
addForm:{
certExpiry: null,
certValidity: null,
name: ''
},
options:{
nation: '', //国籍
marriage: '', //婚姻
cert: '', // 证件类型
occupation: [], //职业
},
certReg:'',
startTime: null,
endTiem: null,
isCertExpiry: true, // 如果勾选了长期 那么必选就不必校验。
certExpiryChk: false,
titleParams: '新增客户', //新增修改的标题
optStatus: true, // true 代表新增 false 代表修改
id: null,
isEditStatus: false, // 根据是否是真客户来判断 如果是真客户 那么 带*号的不让编辑
spinStatus: false,
insuranceList: [],
insuranceCompany: '', //公司下拉
typesInsurance: '', //险种下拉
isShowInsurance: false, // 显示
inputVisible: false, //客户标签
tagValue: '', // 新增tag标签单个值
tags: [], // 所有标签集合
selectedTags: [], //选中的tag
allTagsArr: [], // 判断标签是否重复
allTagsObj: {}, // 为了显示用 allTagsObj[name] = id
allTagsIdObj: {}, // 为了显示用 allTagsObj[id] = name
};
userInfo= {}
certList = []
async componentWillMount() {
document.getElementById('root').scrollIntoView(true);//为ture返回顶部,false为底部
this.userInfo = storage.get('userInfo')
// 获取公司以及险种
await this.getCompanyList()
await this.getTagList()
await this.getInsuranceList()
// 获取下拉
this.getNationOption()
}
//获取跳转过来的传参判断是新增、修改、新增下级机构
getRouterParams = () => {
const params = this.props.match.params
if (!params || !params.params) {
message.warn('请重新选择,或者刷新页面')
this.props.history.push({
pathname: '/home/customer/list',
});
return
}
if (params.params === 'addOpt') {
this.setState({
titleParams: '新增客户',
optStatus: true,
spinStatus: false
})
} else{
this.setState({
titleParams: '修改客户',
optStatus: false,
})
this.getByCustomer()
}
}
getByCustomer() {
const params = this.props.match.params
axios.ajax({
url: API_CUSTOMER_MANAGE.getCustomerByid,
data: {id: params.id}
}).then(res => {
if(res) {
this.isInsuredOpt(res.historyOfInsurance)
const formLabel = this.props.form.getFieldsValue()
const fillForm = Object.assign({}, res, {
birthday: moment(Utils.formateDateToYMD(res.birthday), 'YYYY/MM/DD'),
beginTime: moment(Utils.formateDateToYMD(res.beginTime), 'YYYY/MM/DD'),
endTime: moment(Utils.formateDateToYMD(res.endTime), 'YYYY/MM/DD'),
certValidity: moment(Utils.formateDateToYMD(res.certValidity), 'YYYY/MM/DD'),
certExpiry: res.certExpiry === 9999 ? null : moment(Utils.formateDateToYMD(res.certExpiry)),
owner: '' + res.owner,
ownerName: this.userInfo.userName,
insuranceTime: moment(Utils.formateDateToYMD(res.insuranceTime), 'YYYY/MM/DD'),
})
for (let item in fillForm) {
if (fillForm[item] === null) {
fillForm[item] = undefined
}
}
if (res.certExpiry === 9999) {
this.setState({
certExpiryChk: true,
isCertExpiry: false
})
}
if (res.type === 2) {
this.setState({isEditStatus: true})
}
if ( res.certType == 187) {
let certReg = res.certType == 187 ? Utils.getFormRules('IDCode').regular : ''
this.setState({certReg})
}
const { allTagsIdObj } = this.state
const tagsStr = res.customerLabel ? res.customerLabel.split(',') : []
const selectedTags = []
for(let item of tagsStr) {
selectedTags.push(allTagsIdObj[item])
}
this.setState({
id: res.id,
selectedTags: selectedTags
})
var obj = {}
for (let item in formLabel) {
obj[item] = fillForm[item]
}
console.log(1111)
this.setState({addForm: obj, spinStatus: false}, ()=> {
this.bigClassChange(res.occupationBigClass, true)
})
}
})
}
// 获取公司
getCompanyList() {
this.setState({spinStatus: true})
axios.ajax({
url: API_CUSTOMER_MANAGE.getAllListInsuranceCompany,
}).then(res => {
const insuranceCompany = Utils.getOptionHtml(res, 'id', 'name')
this.setState({
insuranceCompany
})
})
}
// 获取险种
getInsuranceList() {
axios.ajax({
url: API_CUSTOMER_MANAGE.getAllListTypesInsurance,
}).then(res => {
const typesInsurance = Utils.getOptionHtml(res, 'id', 'name')
this.setState({
typesInsurance
})
})
}
// 获取所有的下拉
getNationOption () {
let codes = ['nation', 'marriage', 'cert', 'occupation', 'userGrade', 'creditGrade', 'insurance', 'smoke'];
const options = Utils.getDictOpt(codes);
options.then( (res)=> {
for (let item of res){
if (item.childDicts && item.childDicts.length > 0) {
var list
let arr = []
let obj = {}
if (item.code === 'occupation') { //职业里面的东西分了子类
for (let i in item.childDicts) {
let data= item.childDicts[i]
arr.push({name: data.name, id: data.id, value: data.value, code: data.code});
}
options['occupationBigClass'] = Utils.getOptionHtml(arr, 'id', 'name')
options[item.code] = item.childDicts
} else {
for (let i in item.childDicts) {
let data= item.childDicts[i]
arr.push({name: data.name, id: data.id, value: data.value, code: data.code});
}
list = Utils.getOptionHtml(arr, 'id', 'name')
if(item.code === 'cert') {
this.certList= arr
}
if(item.code === 'insurance'){
this.setState({
insuranceList: arr
})
}
options[item.code] = list
}
}
}
this.setState({options}, ()=> {
this.getRouterParams()
})
})
}
// 职业大类选择事件
bigClassChange = (e, isChange)=> {
const data = this.state.options.occupation
const occupationSmallClass = []
if(!isChange) {
this.props.form.setFieldsValue({occupationSmallClass: undefined, occupationCode: undefined, occupationType: undefined} )
}
if (data) {
for( let item of data) {
if(e === item.id) {
if (item.childDicts && item.childDicts.length > 0) {
for (let i in item.childDicts) {
let data= item.childDicts[i]
occupationSmallClass.push({name: data.name, id: data.id, value: data.value, code: data.code});
}
}
}
}
}
const options= Object.assign(
{},
this.state.options,
{occupationSmallClass: Utils.getOptionHtml(occupationSmallClass, 'id', 'name'), occupationSamll: occupationSmallClass}
)
const addForm = Object.assign(
{},
this.state.addForm,
{ occupationSmallClass: undefined,
occupationCode: undefined,
occupationType: undefined }
)
if(isChange) {
this.setState({options})
} else {
this.setState({options, addForm})
}
}
// 职业小类选择事件
smallClassChange = (e)=>{
let {occupationSamll} = this.state.options
if (e && occupationSamll && occupationSamll.length > 0 ) {
for (let item of occupationSamll) {
if (item.id === e) {
let data = {occupationCode: item.code, occupationType: item.value}
this.props.form.setFieldsValue(data)
const addForm = Object.assign(
{},
this.state.addForm,
data
)
this.setState({addForm})
}
}
}else {
this.props.form.setFieldsValue({occupationCode: '', occupationType: ''})
}
}
// 证件长期按钮选择
certExpiryChange = (e)=>{
if (e.target.checked) {
this.props.form.setFieldsValue({certExpiry: null});
this.setState({isCertExpiry: false, certExpiryChk: true})
} else {
this.setState({isCertExpiry: true, certExpiryChk: false})
}
}
// 证件类型选择事件
certChange = (e)=> {
this.props.form.resetFields('certNo');
const data = this.certList
var certReg
for (let i of data) {
if(i.id === e) {
certReg = i.value ==='身份证' ? /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/ : ''
}
}
const addForm = Object.assign({}, this.state.addForm, {certNo: ''})
this.setState({certReg, addForm})
}
// 保存操作
handleOperator = ()=>{
const data = Utils.trim(this.props.form.getFieldsValue());
const { selectedTags , allTagsObj} = this.state
const formData = Object.assign({}, data, {
birthday: Utils.formatTimeStamp(data.birthday),
certExpiry: this.state.isCertExpiry? Utils.formatTimeStamp(data.certExpiry) : 9999,
certValidity: Utils.formatTimeStamp(data.certValidity),
insuranceTime: data.insuranceTime ? Utils.formatTimeStamp(data.insuranceTime) : null,
owner: this.userInfo.id
})
let postData = {}
for (let item in formData) {
if (item === 'qq' || item === 'annualIncome'|| item === 'postalCode') {
postData[item] = +formData[item]
}else {
postData[item] = formData[item]
}
}
if (!this.state.optStatus) {
postData['id'] = this.state.id
}
const customeTags = selectedTags.map( (item, index) => {
return allTagsObj[item]
})
postData['customerId'] = ''
postData['customerLabel']= customeTags.join(',')
let _url = this.state.optStatus ? API_CUSTOMER_MANAGE.addCustomerAndCustomer : API_CUSTOMER_MANAGE.updCustomerAndCustomer
this.props.form.validateFieldsAndScroll((err, values) => {
if (!err) {
this.setState({
spinStatus: true,
})
axios.optAjax({
url: _url,
data: postData
}).then(res => {
if(res) {
if(res && res.code && res.code !== 0){
this.setState({
spinStatus: false,
})
return
}
message.success('操作成功')
this.props.history.push({
pathname: '/home/customer/list',
});
}
})
}
})
}
// 证件有效期限制
disabledStartDate = (certValidity) => {
const certExpiry = this.state.addForm.certExpiry;
if (!certValidity || !certExpiry) {
return false;
}
return certValidity.valueOf() > certExpiry.valueOf();
}
disabledEndDate = (certExpiry) => {
const certValidity = this.state.addForm.certValidity;
if (!certExpiry || !certValidity) {
return false;
}
return certExpiry.valueOf() <= certValidity.valueOf();
}
onChange = (field, value) => {
let addForm = Object.assign({}, this.state.addForm, {[field]: value})
this.setState({
addForm
});
}
onStartChange = (value) => {
this.onChange('certValidity', value);
}
onEndChange = (value) => {
this.onChange('certExpiry', value);
}
isInsuredOpt = (value) => {
const { insuranceList } = this.state
console.log(value)
let isShowInsurance = false
for (let item of insuranceList) {
if (item.id === value) {
isShowInsurance = item.name === '是' ? true : false
}
}
this.setState({
isShowInsurance: isShowInsurance
})
}
showInput = ()=>{
this.setState({ inputVisible: true }, () => this.input.focus());
}
handleInputChange = (e) => {
this.setState({ tagValue: e.target.value });
}
// 获取标签
getTagList() {
axios.ajax({
url: API_CUSTOMER_MANAGE.getAllListCustomerLabel,
data: {owner: this.userInfo.id}
}).then(res => {
let tags = [], allTagsArr = [], allTagsObj= {}, allTagsIdObj= {}
if(res) {
res.map( (item, index) => {
tags.push({id: item.id, name: item.name, owner: item.owner});
allTagsArr.push(item.name)
allTagsObj[item.name] = item.id
allTagsIdObj[item.id] = item.name
})
}
this.setState({
tags,
allTagsArr,
allTagsObj,
allTagsIdObj,
})
})
}
// 新增标签
handleInputConfirm = (e)=>{
const {tagValue, tags, selectedTags, allTagsArr} =this.state;
let tag = tags, selectedTag = selectedTags
if (tagValue && allTagsArr.indexOf(tagValue) === -1) {
if(tagValue.length > 20) {
return
}
const postData = {
name: tagValue,
owner: this.userInfo.id
}
axios.ajax({
url: API_CUSTOMER_MANAGE.addCustomerLabel,
data: postData
}).then(res => {
selectedTag = [...selectedTag, tagValue];
this.setState({
selectedTags: selectedTag,
});
this.getTagList()
})
} else {
selectedTag = [...selectedTag, tagValue];
}
this.setState({
selectedTags: selectedTag,
inputVisible: false,
tagValue: '',
});
}
// 删除标签
deleteTag = (e, item)=>{
e.preventDefault();
const { selectedTags } = this.state;
const tag = item.name
axios.ajax({
url: API_CUSTOMER_MANAGE.delCustomerLabelByid,
data: {owner: this.userInfo.id, id: item.id}
}).then(res => {
if (tag && selectedTags.indexOf(tag) !== -1) {
const nextSelectedTags = selectedTags.filter(t => t !== tag);
this.setState({ selectedTags: nextSelectedTags });
}
this.getTagList()
})
}
//改变标签
handleChange(tag, checked) {
const { selectedTags } = this.state;
const nextSelectedTags = checked
? [...selectedTags, tag]
: selectedTags.filter(t => t !== tag);
this.setState({ selectedTags: nextSelectedTags });
}
saveInputRef = input => this.input = input
render () {
const { getFieldDecorator } = this.props.form;
const state = this.state;
const {nation, marriage, cert, userGrade, creditGrade, insurance, smoke, occupationBigClass, occupationSmallClass } = this.state.options
const statusList = Utils.getOptionHtml([
{code: 1, text: '正常'},
{code: 2, text: '异常'},
], 'code', 'text')
const typeList = Utils.getOptionHtml([
{code: 1, text: '准客户'},
{code: 2, text: '真客户'},
], 'code', 'text')
const formItemLayout = {
labelCol: {
md: { span: 12 },
lg: { span: 6 },
},
wrapperCol: {
md: { span: 24 },
lg: { span: 18 },
},
}
const formItemLayout4 = {
labelCol: {
md: { span: 12 },
lg: { span: 7 },
},
wrapperCol: {
md: { span: 24 },
lg: { span: 17 },
},
}
const formItemLayout2 = {
labelCol: {
md: { span: 12 },
lg: { span: 7 },
},
wrapperCol: {
md: { span: 24 },
lg: { span: 17 },
},
}
const formItemLayout3 = {
labelCol: {
md: { span: 12 },
lg: { span: 3 },
},
wrapperCol: {
md: { span: 24 },
lg: { span: 21 },
},
}
const { inputVisible, tagValue, tags, selectedTags, insuranceCompany, typesInsurance } = this.state;
return (
<div className='customer dictBg'>
<Spin tip="加载中..." spinning = {this.state.spinStatus}>
<div className="roleAdd">
<div className="nav">
<NavLink to='/home/customer/list' > 客户管理 </NavLink> >
<span>{this.state.titleParams} </span>
</div>
<UserManageBar title="基本信息" />
<Form layout="horizontal" className = "publicForm">
<div className="dictDetail contentForm">
<Row gutter={24}>
<Col span="8">
<FormItem label="姓  名" {...formItemLayout}>
{
getFieldDecorator('name', {
initialValue: state.addForm.name || '',
validateFirst: true,
rules: [
{required: true, whitespace: true, message: '请输入姓名'},
{
pattern: Utils.getFormRules('chartLetters').regular,
message: '姓名必须是中文和英文, 最长为64位字符'
},
{max: 64, message: '姓名必须是中文和英文, 最长为64位字符'},
],
})(
<Input placeholder="姓名" className = "formInput" disabled= {this.state.isEditStatus}/>
)
}
</FormItem>
</Col>
<Col span="8">
<FormItem label="性  别" {...formItemLayout} >
{
getFieldDecorator('gender', {
initialValue: state.addForm.gender || "M",
rules: [
{ required: true, message: '请选择性别'}
],
})(
<RadioGroup disabled= {this.state.isEditStatus}>
<Radio value={'M'}>男</Radio>
<Radio value={'F'}>女</Radio>
</RadioGroup>
)
}
</FormItem>
</Col>
<Col span="8">
<FormItem label="归 属 人" {...formItemLayout}>
{
getFieldDecorator('ownerName', {
initialValue: state.addForm.ownerName || this.userInfo.userName,
validateFirst: true,
rules: [
{required: true, whitespace: true, message: '请输入归属人'},
{max: 64, message: '归属人最长为64位字符'},
],
})(
<Input placeholder="归属人" className = "formInput" disabled/>
)
}
</FormItem>
</Col>
</Row>
<Row gutter={24}>
<Col span="8">
<FormItem label="国  籍" {...formItemLayout}>
{
getFieldDecorator('nationality', {
initialValue: state.addForm.nationality,
validateFirst: true,
rules: [
{required: true, message: '请选择国籍'},
],
})(
<Select placeholder="国籍" allowClear ={true} className = "formInput" disabled= {this.state.isEditStatus}>
{nation}
</Select>
)
}
</FormItem>
</Col>
<Col span="8">
<FormItem label="出生日期" {...formItemLayout}>
{
getFieldDecorator('birthday', {
initialValue: state.addForm.birthday,
validateFirst: true,
rules: [
{required: true, message: '请选择出生日期'},
],
})(
<DatePicker
disabled= {this.state.isEditStatus}
placeholder= '年/月/日'
format="YYYY/MM/DD"
className = "formInput"
disabledDate = { (current) => {
return current > moment().endOf('day')
}}
/>
)
}
</FormItem>
</Col>
<Col span="8">
<FormItem label="婚姻状态" {...formItemLayout}>
{
getFieldDecorator('maritalStatus', {
initialValue: state.addForm.maritalStatus,
validateFirst: true,
rules: [
{ required: true, message: '请选择婚姻状态'}
],
})(
<Select disabled= {this.state.isEditStatus} placeholder="婚姻状态" allowClear ={true} className = "formInput">
{marriage}
</Select>
)
}
</FormItem>
</Col>
</Row>
<Row gutter={24}>
<Col span="8">
<FormItem label="证件类型" {...formItemLayout}>
{
getFieldDecorator('certType', {
initialValue: state.addForm.certType,
validateFirst: true,
onChange: this.certChange,
rules: [
{required: true, message: '请选择证件类型'},
],
})(
<Select disabled= {this.state.isEditStatus} placeholder="证件类型" allowClear ={true} className = "formInput">
{cert}
</Select>
)
}
</FormItem>
</Col>
<Col span="8">
<FormItem label="证件号码" {...formItemLayout}>
{
getFieldDecorator('certNo', {
initialValue: state.addForm.certNo,
validateFirst: true,
rules: [
{required: true, message: '请输入证件号码'},
{
pattern: state.certReg,
message: '请输入正确的证件号码'
},
{ max: 32, message: '证件号码最长为32位字符'}
],
})(
<Input disabled= {this.state.isEditStatus} placeholder="证件号码" className = "formInput"/>
)
}
</FormItem>
</Col>
<Col span="8">
<FormItem label="客户状态" {...formItemLayout}>
{
getFieldDecorator('status', {
initialValue: state.addForm.status ,
rules: [
{required: true, message: '请选择客户状态'}
],
})(
<Select disabled= {this.state.isEditStatus} placeholder="客户状态" allowClear ={true} className = "formInput">
{statusList}
</Select>
)
}
</FormItem>
</Col>
</Row>
<Row gutter={24}>
<Col span="8">
<FormItem label="证件有效期" {...formItemLayout2}>
{
getFieldDecorator('certValidity', {
initialValue: state.addForm.certValidity,
rules: [
{ required: true, message: '请选择证件有效期'}
],
})(
<DatePicker
disabled= {this.state.isEditStatus}
disabledDate={this.disabledStartDate}
onChange={this.onStartChange}
placeholder= '年/月/日'
className = "formInput"
format="YYYY/MM/DD"
/>
)
}
</FormItem>
</Col>
<Col span="8" >
<div className="ant-form-item-label ant-col-md-12 ant-col-lg-7">
<label htmlFor="certExpiryChange" className="ant-form-item-required">证件失效期</label>
</div>
<FormItem {...formItemLayout2}>
{
getFieldDecorator('certExpiry', {
initialValue: state.addForm.certExpiry,
rules: [
{ required: state.isCertExpiry, message: '请选择证件失效期'}
],
})(
<DatePicker
disabledDate={this.disabledEndDate}
disabled = {!state.isCertExpiry || this.state.isEditStatus}
onChange={this.onEndChange}
className = "formInput50"
placeholder= '年/月/日'
format="YYYY/MM/DD"
/>
)
}
<Checkbox disabled= {this.state.isEditStatus} checked = {this.state.certExpiryChk} onChange={this.certExpiryChange} style= {{ marginLeft: "20px"}}> 长期 </Checkbox>
</FormItem>
</Col>
<Col span="8">
<FormItem label="客户类型" {...formItemLayout}>
{
getFieldDecorator('type', {
initialValue: state.addForm.type,
rules: [
{required: true, message: '请选择客户类型'}
],
})(
<Select placeholder="客户类型" disabled= {this.state.isEditStatus} allowClear ={true} className = "formInput">
{typeList}
</Select>
)
}
</FormItem>
</Col>
</Row>
</div>
<UserManageBar title="职业信息" />
<div className="dictDetail contentForm">
<Row gutter={24}>
<Col span="8">
<FormItem label="工作单位" {...formItemLayout}>
{
getFieldDecorator('workUnid', {
initialValue: state.addForm.workUnid,
validateFirst: true,
rules: [
{ max: 20, message: '工作单位最长为20位字符' }
],
})(
<Input placeholder="工作单位" className = "formInput"/>
)
}
</FormItem>
</Col>
<Col span="8">
<FormItem label="职  务" {...formItemLayout}>
{
getFieldDecorator('position', {
initialValue: state.addForm.position,
validateFirst: true,
rules: [
{ max: 20, message: '职务最长为20位字符' }
],
})(
<Input placeholder="职务" className = "formInput" />
)
}
</FormItem>
</Col>
<Col span="8">
<FormItem label="职业大类" {...formItemLayout}>
{
getFieldDecorator('occupationBigClass', {
initialValue: state.addForm.occupationBigClass,
validateFirst: true,
onChange: (e)=>this.bigClassChange(e, false),
rules: [
{ required: true, message: '请选择职业大类'}
],
})(
<Select placeholder="职业大类" disabled= {this.state.isEditStatus} allowClear ={true} className = "formInput">
{occupationBigClass}
</Select>
)
}
</FormItem>
</Col>
</Row>
<Row gutter={24}>
<Col span="8">
<FormItem label="职业小类" {...formItemLayout}>
{
getFieldDecorator('occupationSmallClass', {
initialValue: state.addForm.occupationSmallClass,
onChange: (e)=> this.smallClassChange(e),
rules: [
{required: true, message: '请选择职业小类'},
],
})(
<Select placeholder="请根据大类选择职业小类" disabled= {this.state.isEditStatus} allowClear ={true} className = "formInput">
{occupationSmallClass}
</Select>
)
}
</FormItem>
</Col>
<Col span="8">
<FormItem label="职业代码" {...formItemLayout}>
{
getFieldDecorator('occupationCode', {
initialValue: state.addForm.occupationCode,
validateFirst: true,
rules: [
{required: true, whitespace: true, message: '请输入职业代码'},
{max: 50, message: '职业代码最长为10位字符' }
],
})(
<Input placeholder="职业代码" disabled className = "formInput"/>
)
}
</FormItem>
</Col>
<Col span="8">
<FormItem label="职业类别" {...formItemLayout}>
{
getFieldDecorator('occupationType', {
initialValue: state.addForm.occupationType,
rules: [
{ required: true, message: '请输入职业类别'},
{ max: 40, message: '职业类别最长为40位字符' }
],
})(
<Input placeholder="职业类别" disabled className = "formInput"/>
)
}
</FormItem>
</Col>
</Row>
<Row gutter={24}>
<Col span="8">
<FormItem className="multiLine " label={<span className="multLable">年 收 入<br /><span className="smallFont">(万  元)</span></span>} {...formItemLayout}>
{
getFieldDecorator('annualIncome', {
initialValue: state.addForm.annualIncome ? '' + state.addForm.annualIncome : '',
validateFirst: true,
rules: [
{required: true, message: '请输入年收入'},
{pattern: /^([1-9]\d{0,4}|0)([.]?|(\.\d{1,2})?)$/, message: '年收入必须为整数或小数(2位小数),最大不超过99999.99'},
{ max: 8, message: '年收入必须为整数或小数(2位小数),最大不超过99999.99,' },
],
})(
<Input placeholder="年收入(万元)" disabled= {this.state.isEditStatus} className = "formInput"/>
)
}
</FormItem>
</Col>
</Row>
</div>
<UserManageBar title="联系方式" />
<div className="dictDetail contentForm">
<Row gutter={24}>
<Col span="16">
<FormItem label="联系地址" {...formItemLayout3}>
{
getFieldDecorator('address', {
initialValue: state.addForm.address,
validateFirst: true,
rules: [
{required: true, whitespace: true, message: '请输入联系地址'},
{ max: 60, message: '联系地址最长为60位字符' }
],
})(
<Input placeholder="联系地址" disabled= {this.state.isEditStatus} className = "formInput" />
)
}
</FormItem>
</Col>
<Col span="8">
<FormItem label=" 乡镇(街道)" {...formItemLayout}>
{
getFieldDecorator('villagesTowns', {
initialValue: state.addForm.villagesTowns || '',
validateFirst: true,
rules: [
{required: true, whitespace: true, message: '请输入乡镇(街道)'},
{ max: 20, message: '乡镇最长为20位字符' }
],
})(
<Input placeholder="乡镇(街道)" disabled= {this.state.isEditStatus} className = "formInput"/>
)
}
</FormItem>
</Col>
</Row>
<Row gutter={24}>
<Col span="8">
<FormItem label="村(社区)" {...formItemLayout}>
{
getFieldDecorator('hamlet', {
initialValue: state.addForm.hamlet || '',
rules: [
{required: true, whitespace: true, message: '请输入村(社区)'},
{ max: 20, message: '村(社区)最长为20位字符' }
],
})(
<Input placeholder="村(社区)" disabled= {this.state.isEditStatus} className = "formInput"/>
)
}
</FormItem>
</Col>
<Col span="8">
<FormItem label="电话号码" {...formItemLayout}>
{
getFieldDecorator('phone', {
initialValue: state.addForm.phone || '',
validateFirst: true,
rules: [
{ pattern: Utils.getFormRules('phone').regular, message: '请输入正确的电话号码'},
{ max: 32, message: '请输入正确的电话号码'}
],
})(
<Input placeholder="电话号码" className = "formInput"/>
)
}
</FormItem>
</Col>
<Col span="8">
<FormItem label="手机号码" {...formItemLayout}>
{
getFieldDecorator('mobile', {
initialValue: state.addForm.mobile,
validateFirst: true,
rules: [
{required: true, whitespace: true, message: '请输入手机号码)'},
{pattern: Utils.getFormRules('mobile').regular, message: '请输入正确的手机号码' },
{ max: 32, message: '请输入正确的手机号码'}
],
})(
<Input placeholder="手机号码" disabled= {this.state.isEditStatus} className = "formInput"/>
)
}
</FormItem>
</Col>
</Row>
<Row gutter={24}>
<Col span="8">
<FormItem label="电子邮箱" {...formItemLayout}>
{
getFieldDecorator('email', {
initialValue: state.addForm.email || '',
validateFirst: true,
rules: [
{pattern: Utils.getFormRules('email').regular, message: '请输入正确的电子邮箱'},
{ max: 32, message: '请输入正确的电子邮箱'}
],
})(
<Input placeholder="电子邮箱" className = "formInput"/>
)
}
</FormItem>
</Col>
<Col span="8">
<FormItem label="Q    Q" {...formItemLayout}>
{
getFieldDecorator('qq', {
initialValue: state.addForm.qq ? '' + state.addForm.qq : '',
validateFirst: true,
rules: [
{ pattern: Utils.getFormRules('number').regular, message: '请输入正确的QQ'},
{ max: 10, min: 5, message: 'QQ为5-10位字符之间' }
],
})(
<Input className = "formInput" placeholder="QQ"/>
)
}
</FormItem>
</Col>
<Col span="8">
<FormItem label="微  信" {...formItemLayout}>
{
getFieldDecorator('weChat', {
initialValue: state.addForm.weChat || '',
rules: [
{ max: 50, message: '微信最长为50位字符' }
],
})(
<Input placeholder="微信" className = "formInput"/>
)
}
</FormItem>
</Col>
</Row>
<Row gutter={24}>
<Col span="8">
<FormItem label="邮政编码" {...formItemLayout} >
{
getFieldDecorator('postalCode', {
initialValue: state.addForm.postalCode ? '' + state.addForm.postalCode : '',
rules: [
{ max: 6, message: '邮编最长为6位字符' }
],
})(
<Input placeholder="邮政编码" className = "formInput"/>
)
}
</FormItem>
</Col>
</Row>
</div>
<UserManageBar title="其他信息" />
<div className="dictDetail contentForm">
<Row gutter={24}>
<Col span="8">
<FormItem label="民  族" {...formItemLayout4}>
{
getFieldDecorator('ethnic', {
initialValue: state.addForm.ethnic || '',
validateFirst: true,
rules: [
{required: true, whitespace: true, message: '请输入民族'},
{ max: 10, message: '民族最长为10位字符' }
],
})(
<Input placeholder="民族" disabled= {this.state.isEditStatus} className = "formInput"/>
)
}
</FormItem>
</Col>
<Col span="8">
<FormItem label="信用等级" {...formItemLayout4}>
{
getFieldDecorator('creditRating', {
initialValue: state.addForm.creditRating || undefined,
rules: [
],
})(
<Select placeholder="信用等级" className = "formInput">
{creditGrade}
</Select>
)
}
</FormItem>
</Col>
<Col span="8">
<FormItem label="客户等级" {...formItemLayout4}>
{
getFieldDecorator('customerRating', {
initialValue: state.addForm.customerRating || undefined,
rules: [
],
})(
<Select placeholder="客户等级" className = "formInput">
{userGrade}
</Select>
)
}
</FormItem>
</Col>
</Row>
<Row gutter={24}>
<Col span="8">
<FormItem label="籍  贯" {...formItemLayout4} >
{
getFieldDecorator('nativePlace', {
initialValue: state.addForm.nativePlace || '',
validateFirst: true,
rules: [
{ required: true, message: '请输入籍贯' },
{max: 10, message: '籍贯最长为10位字符' },
],
})(
<Input placeholder="籍贯" disabled= {this.state.isEditStatus} className = "formInput"/>
)
}
</FormItem>
</Col>
<Col span="8">
<FormItem label="户口所在地" {...formItemLayout4} >
{
getFieldDecorator('registeredPermanentResidence', {
initialValue: state.addForm.registeredPermanentResidence || '',
rules: [
{ max: 60, message: '户口所在地最长为60位字符' }
],
})(
<Input placeholder="户口所在地" className = "formInput"/>
)
}
</FormItem>
</Col>
<Col span="8">
<FormItem label="健康状况" {...formItemLayout4}>
{
getFieldDecorator('healthCondition', {
initialValue: state.addForm.healthCondition || '',
rules: [
{ max: 20, message: '健康状态最长为20位字符' }
],
})(
<Input placeholder="健康状况" className = "formInput"/>
)
}
</FormItem>
</Col>
</Row>
<Row gutter={24}>
<Col span="8">
<FormItem label="社保编号" {...formItemLayout4}>
{
getFieldDecorator('socialSecurityNumber', {
initialValue: state.addForm.socialSecurityNumber || '',
rules: [
{ max: 20, message: '社保编号最长为20位字符' }
],
})(
<Input placeholder="社保编号" className = "formInput"/>
)
}
</FormItem>
</Col>
<Col span="8">
<FormItem label="英文名称" {...formItemLayout4}>
{
getFieldDecorator('englishName', {
initialValue: state.addForm.englishName || '',
validateFirst: true,
rules: [
{pattern: Utils.getFormRules('letters').regular, message: '英文名称必须是字母,最长为20位字符'},
{ max: 20, message: '英文名称必须是字母,最长为20位字符' }
],
})(
<Input placeholder="英文名称" className = "formInput"/>
)
}
</FormItem>
</Col>
</Row>
<Row gutter={24}>
<Col span="8">
<FormItem label="汉语拼音名" {...formItemLayout4}>
{
getFieldDecorator('chineseName', {
initialValue: state.addForm.chineseName || '',
validateFirst: true,
rules: [
{pattern: Utils.getFormRules('letters').regular, message: '汉语拼音名必须是字母,最长为20位字符'},
{ max: 20, message: '汉语拼音名必须是字母,最长为20位字符' }
],
})(
<Input placeholder="汉语拼音名" className = "formInput"/>
)
}
</FormItem>
</Col>
<Col span="8">
<FormItem label="吸烟状况" {...formItemLayout4}>
{
getFieldDecorator('smokingStatus', {
initialValue: state.addForm.smokingStatus || undefined,
rules: [
],
})(
<Select placeholder="吸烟状况" className = "formInput">
{smoke}
</Select>
)
}
</FormItem>
</Col>
<Col span="8">
<FormItem label="既往险史" {...formItemLayout4}>
{
getFieldDecorator('historyOfInsurance', {
initialValue: state.addForm.historyOfInsurance || undefined,
onChange: this.isInsuredOpt,
rules: [
{ required: true, message: '请选择既往险史' },
],
})(
<Select placeholder="既往险史" disabled= {this.state.isEditStatus} className = "formInput">
{insurance}
</Select>
)
}
</FormItem>
</Col>
</Row>
</div>
{
this.state.isShowInsurance ?
<div>
<UserManageBar title="既往险史" />
<div className="dictDetail contentForm">
<Row gutter={24}>
<Col span="8">
<FormItem label="时间" {...formItemLayout4}>
{
getFieldDecorator('insuranceTime', {
initialValue: state.addForm.insuranceTime || null,
validateFirst: true,
rules: [
{ required: true, message: '请选择时间' },
],
})(
<DatePicker
onChange={ (date, dateString)=> {
console.log(date, dateString);
}}
disabled= {this.state.isEditStatus}
placeholder= '年/月/日'
className = "formInput"
format="YYYY/MM/DD"
/>
)
}
</FormItem>
</Col>
<Col span="8">
<FormItem label="公司" {...formItemLayout4}>
{
getFieldDecorator('insuranceCompany', {
initialValue: state.addForm.insuranceCompany ,
onChange: this.companyChange,
validateFirst: true,
rules: [
{ required: true, message: '请选择公司' },
],
})(
<Select placeholder="公司" disabled= {this.state.isEditStatus} allowClear ={true} className = "formInput">
{insuranceCompany}
</Select>
)
}
</FormItem>
</Col>
<Col span="8">
<FormItem label="险种" {...formItemLayout4}>
{
getFieldDecorator('typesInsurance', {
initialValue: state.addForm.typesInsurance,
validateFirst: true,
rules: [
{ required: true, message: '请选择险种' },
],
})(
<Select placeholder="险种" disabled= {this.state.isEditStatus} allowClear ={true} className = "formInput">
{typesInsurance}
</Select>
)
}
</FormItem>
</Col>
</Row>
<Row gutter={24}>
<Col span="8">
<FormItem label="产品名称" {...formItemLayout4}>
{
getFieldDecorator('insuranceName', {
initialValue: state.addForm.insuranceName || '',
validateFirst: true,
rules: [
{ required: true, message: '请选择填写产品名称' },
],
})(
<Input placeholder="产品名称" disabled= {this.state.isEditStatus} className = "formInput"/>
)
}
</FormItem>
</Col>
</Row>
</div>
</div>
:''
}
<UserManageBar title="客户标签" />
<div className="dictDetail contentForm">
<Row gutter={24}>
<Col span="8">
<FormItem label="客户标签" {...formItemLayout4} className="tagMarginBton">
{inputVisible && (
getFieldDecorator('tagValue', {
initialValue: tagValue || '',
validateFirst: true,
onChange: this.handleInputChange,
rules: [
{ max: 20, message: '客户标签最长为20位字符' },
],
})(
<Input
ref={this.saveInputRef}
type="text"
className = "formInput"
style={{ width: 200 }}
onPressEnter={this.handleInputConfirm}
placeholder="请按回车进行添加标签"
/>
)
)}
{!inputVisible && (
<Tag
onClick={this.showInput}
style={{ background: '#fff', borderStyle: 'dashed' }}
>
<Icon type="plus" /> 新增标签
</Tag>
)}
</FormItem>
</Col>
</Row>
<Row gutter={24}>
<Col span="24">
{tags.map((tag, index) => {
const isLongTag = tag.name.length > 20;
const tagElem = (
<Tag closable = {true} onClose={(e) => this.deleteTag(e, tag) } key={tag.id}>
<CheckableTag
key={tag.id}
checked={selectedTags.indexOf(tag.name) > -1}
onChange={checked => this.handleChange(tag.name, checked)}
>
{ isLongTag ? tag.name.substring(0, 10) + '...': tag.name}
</CheckableTag>
</Tag>
);
return isLongTag ? <Tooltip title={tag.name} key={tag.id}>{tagElem}</Tooltip> : tagElem;
})}
</Col>
</Row>
</div>
<div className="submitBtn" >
<Button type="primary" disabled = {this.state.spinStatus} onClick={this.handleOperator} >保存</Button>
<NavLink to='/home/customer/list' ><Button> 返回 </Button></NavLink>
</div>
</Form>
</div>
</Spin>
</div>
)
}
}
export default Form.create()(AddCustomer);