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
| (function (vc) {
| vc.extends({
| data: {
| addContractInfo: {
| communityId: vc.getCurrentCommunity().communityId,
| contractId: '',
| contractName: '',
| contractCode: '',
| contractType: '',
| aPartyaId: '',
| bPartyaId: '',
| cPartyaId: '',
| partyA: '',
| partyB: '',
| partyC: '',
| aContacts: '',
| bContacts: '',
| cContacts: '',
| aLink: '',
| bLink: '',
| cLink: '',
| operator: '',
| operatorLink: '',
| allNum: '',
| amount: '',
| startTime: '',
| endTime: '',
| signingTime: '',
| contractTypes: [],
| contractTypeSpecs: [],
| roomId: '',
| ownerName: '',
| link: '',
| objType: '1111',
| objId: '-1',
| contractParentId: '',
| parentContractCode: '',
| parentContractName: '',
| parentStateName: '',
| objName: '',
| objPersonName: '',
| objPersonId: '',
| rooms: [],
| contractFilePo: [],
| tempfile: '',
| contractPartyAs: [],
| contractPartyBs: [],
| contractPartyCs: [],
| audit: '',
| staffName: '',
| nextUserId: ''
| }
| },
| _initMethod: function () {
| vc.component._initAddContractInfo();
| $that._loadAddContractType();
| $that._loadAddContractParkA();
| $that._loadAddContractParkB();
| $that._loadAddContractParkC();
| if (vc.getParam("contractId")) {
| $that.addContractInfo.contractParentId = vc.getParam("contractId");
| $that.addContractInfo.parentContractCode = vc.getParam("contractCode");
| $that.addContractInfo.parentContractName = vc.getParam("contractName");
| $that.addContractInfo.parentStateName = vc.getParam("stateName");
| $that.addContractInfo.contractId = '';
| $that.addContractInfo.contractCode = '';
| $that.addContractInfo.contractName = '';
| $that.addContractInfo.allNum = vc.getParam("objId");
| $that._queryRoom();
| $that._listContracts();
| }
| /*vc.initDateTime('addStartTime', function (_value) {
| $that.addContractInfo.startTime = _value;
| });
| vc.initDateTime('addEndTime', function (_value) {
| $that.addContractInfo.endTime = _value;
| });
| vc.initDateTime('addSigningTime', function (_value) {
| $that.addContractInfo.signingTime = _value;
| });
| $that.addContractInfo.signingTime = vc.dateTimeFormat(new Date().getTime());*/
| },
| _initEvent: function () {
| vc.on('addContract', 'chooseRoom', function (param) {
| $that.addContractInfo.rooms.push(param);
| })
| vc.on('addContract', 'chooseOwner', function (param) {
| $that.addContractInfo.partyB = param.name;
| $that.addContractInfo.bContacts = param.name;
| $that.addContractInfo.bLink = param.link;
| $that.addContractInfo.objId = param.ownerId;
| })
| vc.on("addContract", "notify3", function (info) {
| $that.addContractInfo.nextUserId = info.staffId;
| $that.addContractInfo.staffName = info.staffName;
| });
| },
| methods: {
| formatAmount(event) {
| let value = event.target.value;
| // 移除非数字和小数点字符
| let number = value.replace(/[^0-9.]/g, '');
|
| // 限制小数点后两位并合并输入
| const parts = number.split('.');
| if (parts.length > 2) {
| number = parts[0] + '.' + parts.slice(1).join('').substring(0, 2);
| } else if (parts.length === 2) {
| number = parts[0] + '.' + parts[1].substring(0, 2);
| }
| // 如果不是有效数字则返回
| if (isNaN(number) || number === '') {
| $that.addContractInfo.amount = '';
| return;
| }
| // 更新原始金额
| $that.addContractInfo.amount = number;
| // 格式化为千分位
| let formattedAmount = parseFloat(number).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 2 });
|
| // 设置显示值
| event.target.value = formattedAmount;
| },
| _initAddContractInfo: function () {
| // $that.addContractInfo.signingTime = vc.dateTimeFormat(new Date().getTime());
| $that.addContractInfo.signingTime = vc.dateFormat(new Date(), "yyyy-MM-dd");
| $('.addStartTime').datetimepicker({
| language: 'zh-CN',
| fontAwesome: 'fa',
| format: 'yyyy-mm-dd',
| minView: "month",
| initTime: true,
| initialDate: new Date(),
| autoClose: 1,
| todayBtn: true
| });
| $('.addStartTime').datetimepicker()
| .on('changeDate', function (ev) {
| var value = $(".addStartTime").val();
| vc.component.addContractInfo.startTime = value;
| });
| $('.addEndTime').datetimepicker({
| language: 'zh-CN',
| fontAwesome: 'fa',
| format: 'yyyy-mm-dd',
| minView: "month",
| initTime: true,
| initialDate: new Date(),
| autoClose: 1,
| todayBtn: true
| });
| $('.addEndTime').datetimepicker()
| .on('changeDate', function (ev) {
| var value = $(".addEndTime").val();
| var start = Date.parse(new Date(vc.component.addContractInfo.startTime))
| var end = Date.parse(new Date(value))
| if (start - end >= 0) {
| vc.toast("结束时间必须大于开始时间")
| $(".addEndTime").val('')
| } else {
| vc.component.addContractInfo.endTime = value;
| }
| });
| $('.addSigningTime').datetimepicker({
| language: 'zh-CN',
| fontAwesome: 'fa',
| format: 'yyyy-mm-dd',
| minView: "month",
| startView: "month",
| initTime: true,
| initialDate: new Date(),
| autoClose: 1,
| todayBtn: true
| });
| $('.addSigningTime').datetimepicker()
| .on('changeDate', function (ev) {
| var value = $(".addSigningTime").val();
| vc.component.addContractInfo.signingTime = value.split(' ')[0];
| });
| //防止多次点击时间插件失去焦点
| document.getElementsByClassName('form-control addStartTime')[0].addEventListener('click', myfunc)
|
| function myfunc(e) {
| e.currentTarget.blur();
| }
|
| document.getElementsByClassName("form-control addEndTime")[0].addEventListener('click', myfunc)
|
| function myfunc(e) {
| e.currentTarget.blur();
| }
|
| document.getElementsByClassName("form-control addSigningTime")[0].addEventListener('click', myfunc)
|
| function myfunc(e) {
| e.currentTarget.blur();
| }
| },
| addContractValidate() {
| return vc.validate.validate({
| addContractInfo: $that.addContractInfo
| }, {
| 'addContractInfo.contractName': [
| {
| limit: "required",
| param: "",
| errInfo: "合同名称不能为空"
| },
| {
| limit: "maxLength",
| param: "200",
| errInfo: "合同名称不能超过64位"
| },
| ],
| 'addContractInfo.contractCode': [
| {
| limit: "required",
| param: "",
| errInfo: "合同编号不能为空"
| },
| {
| limit: "maxLength",
| param: "30",
| errInfo: "合同编号错误"
| },
| ],
| 'addContractInfo.contractType': [
| {
| limit: "required",
| param: "",
| errInfo: "合同类型不能为空"
| },
| {
| limit: "num",
| param: "",
| errInfo: "合同类型格式错误"
| },
| ],
| 'addContractInfo.partyA': [
| {
| limit: "required",
| param: "",
| errInfo: "甲方不能为空"
| },
| {
| limit: "maxLength",
| param: "200",
| errInfo: "甲方名称太长"
| },
| ],
| 'addContractInfo.partyB': [
| {
| limit: "required",
| param: "",
| errInfo: "乙方不能为空"
| },
| {
| limit: "maxLength",
| param: "200",
| errInfo: "乙方名称太长"
| },
| ],
| // 'addContractInfo.aContacts': [
| // {
| // limit: "required",
| // param: "",
| // errInfo: "甲方联系人不能为空"
| // },
| // {
| // limit: "maxLength",
| // param: "64",
| // errInfo: "甲方联系人长度超过64位"
| // },
| // ],
| // 'addContractInfo.bContacts': [
| // {
| // limit: "required",
| // param: "",
| // errInfo: "乙方联系人不能为空"
| // },
| // {
| // limit: "maxLength",
| // param: "64",
| // errInfo: "乙方联系人长度超过64位"
| // },
| // ],
| // 'addContractInfo.aLink': [
| // {
| // limit: "required",
| // param: "",
| // errInfo: "甲方联系电话不能为空"
| // }
| // ],
| // 'addContractInfo.bLink': [
| // {
| // limit: "required",
| // param: "",
| // errInfo: "乙方联系电话不能为空"
| // }
| // ],
| 'addContractInfo.operator': [
| {
| limit: "required",
| param: "",
| errInfo: "经办人不能为空"
| },
| {
| limit: "maxLength",
| param: "64",
| errInfo: "经办人超过64位"
| },
| ],
| 'addContractInfo.operatorLink': [
| {
| limit: "required",
| param: "",
| errInfo: "联系电话不能为空"
| }
| ],
| 'addContractInfo.amount': [
| {
| limit: "money",
| param: "",
| errInfo: "合同金额格式错误,如1.50"
| }
| ],
| 'addContractInfo.startTime': [
| {
| limit: "required",
| param: "",
| errInfo: "开始时间不能为空"
| }
| ],
| 'addContractInfo.endTime': [
| {
| limit: "required",
| param: "",
| errInfo: "结束时间不能为空"
| }
| ],
| 'addContractInfo.signingTime': [
| {
| limit: "required",
| param: "",
| errInfo: "合同签订时间不能为空"
| }
| ]
| });
| },
| _queryRoom: function () {
| let param = {
| params: {
| contractId: vc.getParam("contractId"),
| page: 1,
| row: 100
| }
| }
| //发送get请求
| vc.http.apiGet('/contract/queryContractRoom',
| param,
| function (json, res) {
| var _contractTFile = JSON.parse(json);
| $that.addContractInfo.rooms = _contractTFile.data;
| },
| function (errInfo, error) {
| console.log('请求失败处理');
| }
| );
| },
| saveContractInfo: function () {
| if (!$that.addContractValidate()) {
| vc.toast(vc.validate.errInfo);
| return;
| }
| $that.addContractInfo.communityId = vc.getCurrentCommunity().communityId;
|
| vc.http.apiPost(
| '/contract/saveContract',
| JSON.stringify($that.addContractInfo), {
| emulateJSON: true
| },
| function (json, res) {
| //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
| let _json = JSON.parse(json);
| if (_json.code == 0) {
| //关闭model
| vc.toast('提交成功');
| $that._goBack();
| return;
| } else {
| vc.toast(_json.msg);
| }
| },
| function (errInfo, error) {
| console.log('请求失败处理');
| vc.toast(errInfo);
| });
| },
| clearAddContractInfo: function () {
| let _contractTypes = $that.addContractInfo.contractTypes;
| $that.addContractInfo = {
| contractName: '',
| contractCode: '',
| contractType: '',
| aPartyaId: '',
| bPartyaId: '',
| cPartyaId: '',
| partyA: '',
| partyB: '',
| partyC: '',
| aContacts: '',
| bContacts: '',
| cContacts: '',
| aLink: '',
| bLink: '',
| cLink: '',
| operator: '',
| operatorLink: '',
| amount: '',
| startTime: '',
| endTime: '',
| signingTime: '',
| contractTypes: _contractTypes,
| contractTypeSpecs: [],
| allNum: '',
| roomId: '',
| ownerName: '',
| link: '',
| objId: '-1',
| objType: '1111',
| contractParentId: '',
| parentContractCode: '',
| parentContractName: '',
| parentStateName: '',
| objName: '',
| objPersonName: '',
| objPersonId: '',
| rooms: [],
| contractPartyAs: [],
| contractPartyBs: [],
| contractPartyCs: [],
| audit: '',
| staffName: '',
| nextUserId: ''
| };
| },
| _loadAddContractType: function () {
| let param = {
| params: {
| page: 1,
| row: 100,
| communityId: vc.getCurrentCommunity().communityId,
|
| }
| }
| //发送get请求
| vc.http.apiGet('/contract/queryContractType',
| param,
| function (json, res) {
| var _contractTypeManageInfo = JSON.parse(json);
| $that.addContractInfo.contractTypes = _contractTypeManageInfo.data;
| },
| function (errInfo, error) {
| console.log('请求失败处理');
| }
| );
| },
| _loadAddContractParkA: function () {
| let param = {
| params: {
| page: 1,
| row: 100,
| typeId: 1,
| communityId: vc.getCurrentCommunity().communityId,
|
| }
| }
| //发送get请求
| vc.http.apiGet('/contractPartya/queryContractPartya',
| param,
| function (json, res) {
| var _contractTypeManageInfo = JSON.parse(json);
| $that.addContractInfo.contractPartyAs = _contractTypeManageInfo.data;
| },
| function (errInfo, error) {
| console.log('请求失败处理');
| }
| );
| },
| _loadAddContractParkB: function () {
| let param = {
| params: {
| page: 1,
| row: 100,
| typeId: 2,
| communityId: vc.getCurrentCommunity().communityId,
|
|
| }
| }
| //发送get请求
| vc.http.apiGet('/contractPartya/queryContractPartya',
| param,
| function (json, res) {
| var _contractTypeManageInfo = JSON.parse(json);
| $that.addContractInfo.contractPartyBs = _contractTypeManageInfo.data;
| },
| function (errInfo, error) {
| console.log('请求失败处理');
| }
| );
| },
| _loadAddContractParkC: function () {
| let param = {
| params: {
| page: 1,
| row: 100,
| typeId: 3,
| communityId: vc.getCurrentCommunity().communityId,
|
|
| }
| }
| //发送get请求
| vc.http.apiGet('/contractPartya/queryContractPartya',
| param,
| function (json, res) {
| var _contractTypeManageInfo = JSON.parse(json);
| $that.addContractInfo.contractPartyCs = _contractTypeManageInfo.data;
| },
| function (errInfo, error) {
| console.log('请求失败处理');
| }
| );
| },
| _changeContractType: function () {
| $that.addContractInfo.contractTypes.forEach(item => {
| if ($that.addContractInfo.contractType == item.contractTypeId) {
| $that.addContractInfo.audit = item.audit;
| }
| })
| let param = {
| params: {
| page: 1,
| row: 100,
| contractTypeId: $that.addContractInfo.contractType,
| communityId: vc.getCurrentCommunity().communityId,
|
| }
| }
| $that.addContractInfo.contractTypeSpecs = [];
| vc.http.apiGet('/contract/queryContractTypeSpec',
| param,
| function (json, res) {
| let _contractTypeSpecManageInfo = JSON.parse(json);
| _contractTypeSpecManageInfo.data.forEach(item => {
| item.value = '';
| if (item.specShow == 'Y') {
| item.values = [];
| //$that._loadAttrValue(item.specCd, item.values);
| $that.addContractInfo.contractTypeSpecs.push(item);
| }
| });
| },
| function (errInfo, error) {
| console.log('请求失败处理');
| }
| );
| },
| _goBack: function () {
| vc.goBack();
| },
| _selectRoom: function () {
| vc.emit('searchRoom', 'openSearchRoomModel', {})
| },
| _openDelRoomModel: function (_room) {
| let _tmpRooms = [];
| $that.addContractInfo.rooms.forEach(item => {
| if (item.roomId != _room.roomId) {
| _tmpRooms.push(item);
| }
| });
| $that.addContractInfo.rooms = _tmpRooms;
| },
| addFileStep: function () {
| let _file = {
| seq: $that.addContractInfo.contractFilePo.length,
| fileSaveName: '',
| fileRealName: ''
| }
| $that.addContractInfo.contractFilePo.push(_file);
| },
| deleteStep: function (_step) {
| for (var i = 0; i < $that.addContractInfo.contractFilePo.length; i++) {
| if ($that.addContractInfo.contractFilePo[i].seq == _step.seq) {
| $that.addContractInfo.contractFilePo.splice(i, 1);
| }
| }
| },
| getFile: function (e, index) {
| $that.addContractInfo.tempfile = e.target.files[0];
| $that.addContractInfo.contractFilePo[index].fileRealName = $that.addContractInfo.tempfile.name;
| $that._importData(index);
| },
| _importData: function (index) {
| // 导入数据
| let _fileName = $that.addContractInfo.tempfile.name;
| let _suffix = _fileName.substring(_fileName.lastIndexOf('.') + 1);
| if (!$that.checkFileType(_suffix.toLowerCase())) {
| vc.toast('操作失败,请上传图片、PDF或Word格式的文件');
| return;
| }
| let param = new FormData();
| param.append("uploadFile", $that.addContractInfo.tempfile);
| vc.http.upload(
| 'importRoomFee',
| 'uploadContactFile',
| param, {
| emulateJSON: true,
| //添加请求头
| headers: {
| "Content-Type": "multipart/form-data"
| }
| },
| function (json, res) {
| //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
| if (res.status == 200) {
| $that.addContractInfo.contractFilePo[index].fileSaveName = json;
| vc.toast("上传成功");
| return;
| }
| vc.toast(json, 10000);
| },
| function (errInfo, error) {
| console.log('请求失败处理');
| vc.toast(errInfo, 10000);
| });
| },
| checkFileType: function (fileType) {
| const acceptTypes = ['png', 'pdf', 'jpg', 'doc', 'docx'];
| return acceptTypes.includes(fileType);
| // for (var i = 0; i < acceptTypes.length; i++) {
| // if (fileType === acceptTypes[i]) {
| // return true;
| // }
| // }
| // return false;
| },
| _changeContractPartyA: function () {
| let _partyA = $that.addContractInfo.partyA;
| $that.addContractInfo.contractPartyAs.forEach(item => {
| if (_partyA == item.partyA) {
| $that.addContractInfo.aLink = item.aLink;
| $that.addContractInfo.aPartyaId = item.partyaId;
| $that.addContractInfo.aContacts = item.aContacts;
| }
| })
| },
| _changeContractPartyB: function () {
| let _partyB = $that.addContractInfo.partyB;
| $that.addContractInfo.contractPartyBs.forEach(item => {
| if (_partyB == item.partyA) {
| $that.addContractInfo.bLink = item.aLink;
| $that.addContractInfo.bPartyaId = item.partyaId;
| $that.addContractInfo.bContacts = item.aContacts;
| }
| })
| },
| _changeContractPartyC: function() {
| let _partyC = $that.addContractInfo.partyC;
| $that.addContractInfo.contractPartyCs.forEach(item => {
| if (_partyC == item.partyA) {
| $that.addContractInfo.cLink = item.aLink;
| $that.addContractInfo.cPartyaId = item.partyaId;
| $that.addContractInfo.cContacts = item.aContacts;
| }
| });
| },
| _searchOwner: function () {
| vc.emit('searchOwner', 'openSearchOwnerModel', {});
| },
| _listContracts: function () {
| let param = {
| params: {
| page: 1,
| row: 1,
| contractId: vc.getParam('contractId')
| }
| };
| //发送get请求
| vc.http.apiGet('/contract/queryContract',
| param,
| function (json, res) {
| let _expirationContractInfo = JSON.parse(json);
| vc.copyObject(_expirationContractInfo.data[0], $that.addContractInfo);
| $that.addContractInfo.contractId = '';
| $that.addContractInfo.contractCode = '';
| $that.addContractInfo.contractName = '';
| $that.addContractInfo.startTime = $that.addContractInfo.endTime;
| $that.addContractInfo.endTime = '';
| $that.addContractInfo.signingTime = '';
| },
| function (errInfo, error) {
| console.log('请求失败处理');
| }
| );
| },
| },
| });
|
| })(window.vc);
|
|