@bchr/bchr-front-lib 0.5.8 → 0.5.10
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.
- package/lib/base/BaseAppUtils.js +10 -2
- package/lib/base/layout/ActionButton.js +6 -0
- package/lib/base/layout/FormRefInput.js +248 -0
- package/lib/base/layout/GridSelectModal.js +507 -0
- package/lib/base/layout/InputRefAddonBtn.js +300 -0
- package/lib/base/layout/KendoGridCellRenders.js +1170 -0
- package/lib/base/layout/RefInput.js +262 -0
- package/lib/base/utils/TableDataProcessors.js +103 -0
- package/lib/services/KendoGridAPI.js +392 -0
- package/lib/services/http.js +605 -0
- package/package.json +1 -1
- package/src/base/BaseAppUtils.js +10 -1
- package/src/base/layout/ActionButton.js +7 -1
- package/src/base/layout/FormRefInput.js +144 -0
- package/src/base/layout/GridSelectModal.js +329 -0
- package/src/base/layout/InputRefAddonBtn.js +120 -0
- package/src/base/layout/KendoGridCellRenders.js +790 -0
- package/src/base/layout/RefInput.js +148 -0
- package/src/base/utils/TableDataProcessors.js +87 -0
- package/src/services/KendoGridAPI.js +298 -0
- package/src/services/http.js +611 -0
package/lib/services/http.js
CHANGED
|
@@ -480,6 +480,611 @@ var http = {
|
|
|
480
480
|
} else if (_this.isInView("main_view2")) {
|
|
481
481
|
_this.redirectTo("main_view", parameterObject);
|
|
482
482
|
}
|
|
483
|
+
},
|
|
484
|
+
post: function post(options, jsonObject, mockData) {
|
|
485
|
+
var ajaxOptions = {};
|
|
486
|
+
var failedDealFunction = this.dealAjaxException;
|
|
487
|
+
|
|
488
|
+
if (_lodash["default"].isPlainObject(options)) {
|
|
489
|
+
if (_lodash["default"].isFunction(options.fail)) {
|
|
490
|
+
failedDealFunction = options.fail;
|
|
491
|
+
delete options.fail;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
ajaxOptions = _objectSpread({}, options);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
try {
|
|
498
|
+
this.__checkJSONObjectSecurity(jsonObject);
|
|
499
|
+
} catch (e) {
|
|
500
|
+
var promise = new Promise(function (resolve, reject) {
|
|
501
|
+
return reject(e);
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
if (this.isUseDefaultExceptionHandler()) {
|
|
505
|
+
return promise["catch"](failedDealFunction);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
return promise;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
if (jsonObject) {
|
|
512
|
+
ajaxOptions.data = jsonObject;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
if (ajaxOptions.rpcMethodName) {
|
|
516
|
+
delete ajaxOptions.rpcMethodName;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
ajaxOptions.type = "post";
|
|
520
|
+
ajaxOptions.dataType = "json";
|
|
521
|
+
|
|
522
|
+
if (!ajaxOptions.url) {
|
|
523
|
+
ajaxOptions.url = this.getRequestPath(options);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
if (this.isValidMockData(mockData)) {
|
|
527
|
+
var _promise = this.__postForMock(mockData);
|
|
528
|
+
|
|
529
|
+
if (this.isUseDefaultExceptionHandler()) {
|
|
530
|
+
return _promise["catch"](failedDealFunction);
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
return _promise;
|
|
534
|
+
} else {
|
|
535
|
+
var deferred = window.$.ajax(ajaxOptions);
|
|
536
|
+
|
|
537
|
+
if (this.isUseDefaultExceptionHandler()) {
|
|
538
|
+
return this.__toStdPromise(deferred, failedDealFunction);
|
|
539
|
+
} else {
|
|
540
|
+
return this.__toStdPromise(deferred);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
},
|
|
544
|
+
__postForMock: function __postForMock(mockData) {
|
|
545
|
+
var waitTime = mockData.waitTime ? mockData.waitTime : 600;
|
|
546
|
+
return new Promise(function (resolve, reject) {
|
|
547
|
+
setTimeout(function () {
|
|
548
|
+
if (mockData.success === false) {
|
|
549
|
+
return reject(new Error(mockData.message ? mockData.message : "请求数据发生异常"));
|
|
550
|
+
} else {
|
|
551
|
+
var resultData = mockData.data ? mockData.data : mockData;
|
|
552
|
+
return resolve(resultData);
|
|
553
|
+
}
|
|
554
|
+
}, waitTime);
|
|
555
|
+
});
|
|
556
|
+
},
|
|
557
|
+
postJSONWithNotCareSecurity: function postJSONWithNotCareSecurity(options, jsonObject, mockData) {
|
|
558
|
+
var ajaxOptions = {};
|
|
559
|
+
var failedDealFunction = this.dealAjaxException;
|
|
560
|
+
|
|
561
|
+
if (_lodash["default"].isPlainObject(options)) {
|
|
562
|
+
if (_lodash["default"].isFunction(options.fail)) {
|
|
563
|
+
failedDealFunction = options.fail;
|
|
564
|
+
delete options.fail;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
ajaxOptions = _objectSpread({}, options);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
if (ajaxOptions.rpcMethodName) {
|
|
571
|
+
delete ajaxOptions.rpcMethodName;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
if (_lodash["default"].isPlainObject(ajaxOptions.data)) {
|
|
575
|
+
jsonObject = ajaxOptions.data;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
if (jsonObject) {
|
|
579
|
+
ajaxOptions.data = jsonObject;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
if (ajaxOptions.data) {
|
|
583
|
+
ajaxOptions.data = JSON.stringify(ajaxOptions.data);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
ajaxOptions.type = "post";
|
|
587
|
+
ajaxOptions.dataType = "json";
|
|
588
|
+
ajaxOptions.contentType = "application/json; charset=utf-8";
|
|
589
|
+
|
|
590
|
+
if (!ajaxOptions.url) {
|
|
591
|
+
ajaxOptions.url = this.getRequestPath(options);
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
if (this.isValidMockData(mockData)) {
|
|
595
|
+
var promise = this.__postJSONForMock(mockData);
|
|
596
|
+
|
|
597
|
+
if (this.isUseDefaultExceptionHandler()) {
|
|
598
|
+
return promise["catch"](failedDealFunction);
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
return promise;
|
|
602
|
+
} else {
|
|
603
|
+
var deferred = window.$.ajax(ajaxOptions);
|
|
604
|
+
|
|
605
|
+
if (this.isUseDefaultExceptionHandler()) {
|
|
606
|
+
return this.__toStdPromise(deferred, failedDealFunction);
|
|
607
|
+
} else {
|
|
608
|
+
return this.__toStdPromise(deferred);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
},
|
|
612
|
+
postJSON: function postJSON(options, jsonObject, mockData) {
|
|
613
|
+
var ajaxOptions = {};
|
|
614
|
+
var failedDealFunction = this.dealAjaxException;
|
|
615
|
+
|
|
616
|
+
if (_lodash["default"].isPlainObject(options)) {
|
|
617
|
+
if (_lodash["default"].isFunction(options.fail)) {
|
|
618
|
+
failedDealFunction = options.fail;
|
|
619
|
+
delete options.fail;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
ajaxOptions = _objectSpread({}, options);
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
if (_lodash["default"].isPlainObject(ajaxOptions.data)) {
|
|
626
|
+
jsonObject = ajaxOptions.data;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
try {
|
|
630
|
+
this.__checkJSONObjectSecurity(jsonObject);
|
|
631
|
+
} catch (e) {
|
|
632
|
+
var promise = new Promise(function (resolve, reject) {
|
|
633
|
+
return reject(e);
|
|
634
|
+
});
|
|
635
|
+
|
|
636
|
+
if (this.isUseDefaultExceptionHandler()) {
|
|
637
|
+
return promise["catch"](failedDealFunction);
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
return promise;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
return this.postJSONWithNotCareSecurity(options, jsonObject, mockData);
|
|
644
|
+
},
|
|
645
|
+
postJSONAllowHTML: function postJSONAllowHTML(options, jsonObject, mockData) {
|
|
646
|
+
var ajaxOptions = {};
|
|
647
|
+
var failedDealFunction = this.dealAjaxException;
|
|
648
|
+
|
|
649
|
+
if (_lodash["default"].isPlainObject(options)) {
|
|
650
|
+
if (_lodash["default"].isFunction(options.fail)) {
|
|
651
|
+
failedDealFunction = options.fail;
|
|
652
|
+
delete options.fail;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
ajaxOptions = _objectSpread({}, options);
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
if (_lodash["default"].isPlainObject(ajaxOptions.data)) {
|
|
659
|
+
jsonObject = ajaxOptions.data;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
try {
|
|
663
|
+
this.__checkJSONObjectContainsScriptTag(jsonObject);
|
|
664
|
+
} catch (e) {
|
|
665
|
+
var promise = new Promise(function (resolve, reject) {
|
|
666
|
+
return reject(e);
|
|
667
|
+
});
|
|
668
|
+
|
|
669
|
+
if (this.isUseDefaultExceptionHandler()) {
|
|
670
|
+
return promise["catch"](failedDealFunction);
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
return promise;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
return this.postJSONWithNotCareSecurity(options, jsonObject, mockData);
|
|
677
|
+
},
|
|
678
|
+
__checkJSONObjectContainsScriptTag: function __checkJSONObjectContainsScriptTag(jsonObject) {
|
|
679
|
+
if (!jsonObject) {
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
if (_lodash["default"].isString(jsonObject)) {
|
|
684
|
+
this.__checkStringContainsScriptTag(jsonObject);
|
|
685
|
+
} else if (Array.isArray(jsonObject)) {
|
|
686
|
+
var len = jsonObject.length;
|
|
687
|
+
|
|
688
|
+
if (len === 0) {
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
for (var i = 0; i < len; i++) {
|
|
693
|
+
this.__checkJSONObjectContainsScriptTag(jsonObject[i]);
|
|
694
|
+
}
|
|
695
|
+
} else if (_lodash["default"].isPlainObject(jsonObject)) {
|
|
696
|
+
for (var p in jsonObject) {
|
|
697
|
+
this.__checkJSONObjectContainsScriptTag(jsonObject[p]);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
return;
|
|
702
|
+
},
|
|
703
|
+
__checkStringContainsScriptTag: function __checkStringContainsScriptTag(str) {
|
|
704
|
+
if (!str || str.length < 3) {
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
var containsHTML = /<(noframes|noscript|object|script|video).*?<\/\2>/i.test(str);
|
|
709
|
+
|
|
710
|
+
if (containsHTML) {
|
|
711
|
+
throw new IllegalArgumentError("不安全的输入,请检查!");
|
|
712
|
+
}
|
|
713
|
+
},
|
|
714
|
+
__checkJSONObjectSecurity: function __checkJSONObjectSecurity(jsonObject) {
|
|
715
|
+
if (!jsonObject) {
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
if (_lodash["default"].isString(jsonObject)) {
|
|
720
|
+
this.__checkStringIfSecurity(jsonObject);
|
|
721
|
+
} else if (Array.isArray(jsonObject)) {
|
|
722
|
+
var len = jsonObject.length;
|
|
723
|
+
|
|
724
|
+
if (len === 0) {
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
for (var i = 0; i < len; i++) {
|
|
729
|
+
this.__checkJSONObjectSecurity(jsonObject[i]);
|
|
730
|
+
}
|
|
731
|
+
} else if (_lodash["default"].isPlainObject(jsonObject)) {
|
|
732
|
+
for (var p in jsonObject) {
|
|
733
|
+
this.__checkJSONObjectSecurity(jsonObject[p]);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
return;
|
|
738
|
+
},
|
|
739
|
+
__checkStringIfSecurity: function __checkStringIfSecurity(str) {
|
|
740
|
+
if (!str || str.length < 3) {
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
var containsHTML = /<(br|basefont|hr|input|source|frame|param|area|meta|!--|col|link|option|base|img|wbr|!DOCTYPE).*?>|<(a|abbr|acronym|address|applet|article|aside|audio|b|bdi|bdo|big|blockquote|body|button|canvas|caption|center|cite|code|colgroup|command|datalist|dd|del|details|dfn|dialog|dir|div|dl|dt|em|embed|fieldset|figcaption|figure|font|footer|form|frameset|head|header|hgroup|h1|h2|h3|h4|h5|h6|html|i|iframe|ins|kbd|keygen|label|legend|li|map|mark|menu|meter|nav|noframes|noscript|object|ol|optgroup|output|p|pre|progress|q|rp|rt|ruby|s|samp|script|section|select|small|span|strike|strong|style|sub|summary|sup|table|tbody|td|textarea|tfoot|th|thead|time|title|tr|track|tt|u|ul|var|video).*?<\/\2>/i.test(str);
|
|
745
|
+
|
|
746
|
+
if (containsHTML) {
|
|
747
|
+
throw new IllegalArgumentError("不安全的输入,请检查!");
|
|
748
|
+
}
|
|
749
|
+
},
|
|
750
|
+
__postJSONForMock: function __postJSONForMock(mockData) {
|
|
751
|
+
var waitTime = mockData.waitTime ? mockData.waitTime : 300;
|
|
752
|
+
return new Promise(function (resolve, reject) {
|
|
753
|
+
setTimeout(function () {
|
|
754
|
+
if (mockData.success === false) {
|
|
755
|
+
return reject(new Error(mockData.message ? mockData.message : "请求数据发生异常"));
|
|
756
|
+
} else {
|
|
757
|
+
var resultData = mockData.data ? mockData.data : mockData;
|
|
758
|
+
return resolve(resultData);
|
|
759
|
+
}
|
|
760
|
+
}, waitTime);
|
|
761
|
+
});
|
|
762
|
+
},
|
|
763
|
+
getJSON: function getJSON(options, paramObject, mockData) {
|
|
764
|
+
var ajaxOptions = {};
|
|
765
|
+
var failedDealFunction = this.dealAjaxException;
|
|
766
|
+
|
|
767
|
+
if (_lodash["default"].isPlainObject(options)) {
|
|
768
|
+
if (_lodash["default"].isFunction(options.fail)) {
|
|
769
|
+
failedDealFunction = options.fail;
|
|
770
|
+
delete options.fail;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
ajaxOptions = _objectSpread({}, options);
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
ajaxOptions.type = "get";
|
|
777
|
+
ajaxOptions.dataType = "json";
|
|
778
|
+
|
|
779
|
+
if (_lodash["default"].isPlainObject(paramObject)) {
|
|
780
|
+
ajaxOptions.data = paramObject;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
if (!ajaxOptions.data) {
|
|
784
|
+
ajaxOptions.data = {};
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
if (!ajaxOptions.data.euts) {
|
|
788
|
+
ajaxOptions.data.euts = new Date().getTime();
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
if (!ajaxOptions.url) {
|
|
792
|
+
ajaxOptions.url = this.getRequestPath(options);
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
if (this.isValidMockData(mockData)) {
|
|
796
|
+
var promise = this.__getJSONForMock(mockData);
|
|
797
|
+
|
|
798
|
+
if (this.isUseDefaultExceptionHandler()) {
|
|
799
|
+
return promise["catch"](failedDealFunction);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
return promise;
|
|
803
|
+
} else {
|
|
804
|
+
var deferred = window.$.ajax(ajaxOptions);
|
|
805
|
+
|
|
806
|
+
if (this.isUseDefaultExceptionHandler()) {
|
|
807
|
+
return this.__toStdPromise(deferred, failedDealFunction);
|
|
808
|
+
} else {
|
|
809
|
+
return this.__toStdPromise(deferred);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
},
|
|
813
|
+
isValidMockData: function isValidMockData(mockData) {
|
|
814
|
+
if (mockData === null || mockData === void 0) {
|
|
815
|
+
return false;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
return _lodash["default"].isPlainObject(mockData);
|
|
819
|
+
},
|
|
820
|
+
__getJSONForMock: function __getJSONForMock(mockData) {
|
|
821
|
+
var waitTime = mockData.waitTime ? mockData.waitTime : 600;
|
|
822
|
+
return new Promise(function (resolve, reject) {
|
|
823
|
+
setTimeout(function () {
|
|
824
|
+
if (mockData.success === false) {
|
|
825
|
+
return reject(new Error(mockData.message ? mockData.message : "请求数据发生异常"));
|
|
826
|
+
} else {
|
|
827
|
+
var resultData = mockData.data ? mockData.data : mockData;
|
|
828
|
+
return resolve(resultData);
|
|
829
|
+
}
|
|
830
|
+
}, waitTime);
|
|
831
|
+
});
|
|
832
|
+
},
|
|
833
|
+
requestStaticHTMLTemplate: function requestStaticHTMLTemplate(staticTemplateFilePath) {
|
|
834
|
+
var deferred = window.$.ajax({
|
|
835
|
+
url: staticTemplateFilePath,
|
|
836
|
+
dataType: "html"
|
|
837
|
+
});
|
|
838
|
+
var failedDealFunction = this.dealAjaxException;
|
|
839
|
+
return this.__toStdPromise(deferred, failedDealFunction);
|
|
840
|
+
},
|
|
841
|
+
downloadFileByPostJSON: function downloadFileByPostJSON(options, jsonObject, saveFileName) {
|
|
842
|
+
var ajaxOptions = {};
|
|
843
|
+
var failedDealFunction = this.dealAjaxException;
|
|
844
|
+
|
|
845
|
+
if (_lodash["default"].isPlainObject(options)) {
|
|
846
|
+
if (_lodash["default"].isFunction(options.fail)) {
|
|
847
|
+
failedDealFunction = options.fail;
|
|
848
|
+
delete options.fail;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
ajaxOptions = _objectSpread({}, options);
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
if (_lodash["default"].isPlainObject(ajaxOptions.data)) {
|
|
855
|
+
jsonObject = ajaxOptions.data;
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
try {
|
|
859
|
+
this.__checkJSONObjectSecurity(jsonObject);
|
|
860
|
+
} catch (e) {
|
|
861
|
+
var promise = new Promise(function (resolve, reject) {
|
|
862
|
+
return reject(e);
|
|
863
|
+
});
|
|
864
|
+
|
|
865
|
+
if (this.isUseDefaultExceptionHandler()) {
|
|
866
|
+
return promise["catch"](failedDealFunction);
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
return promise;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
if (jsonObject) {
|
|
873
|
+
ajaxOptions.data = jsonObject;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
if (ajaxOptions.rpcMethodName) {
|
|
877
|
+
delete ajaxOptions.rpcMethodName;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
ajaxOptions.type = "post";
|
|
881
|
+
ajaxOptions.dataType = "*";
|
|
882
|
+
|
|
883
|
+
if (!ajaxOptions.data) {
|
|
884
|
+
ajaxOptions.data = {};
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
if (!ajaxOptions.data.euts) {
|
|
888
|
+
ajaxOptions.data.euts = new Date().getTime();
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
if (!ajaxOptions.url) {
|
|
892
|
+
ajaxOptions.url = this.getRequestPath(options);
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
ajaxOptions.xhrFields = {
|
|
896
|
+
responseType: "blob"
|
|
897
|
+
};
|
|
898
|
+
|
|
899
|
+
ajaxOptions.success = function (result, request, xhr) {
|
|
900
|
+
var fileName = "下载文件-" + new Date().getTime();
|
|
901
|
+
|
|
902
|
+
if (_lodash["default"].isString(saveFileName) && saveFileName.length > 0) {
|
|
903
|
+
fileName = saveFileName;
|
|
904
|
+
} else {
|
|
905
|
+
var contentDisposition = xhr.getResponseHeader('Content-Disposition');
|
|
906
|
+
|
|
907
|
+
if (contentDisposition && contentDisposition.split) {
|
|
908
|
+
var parts = contentDisposition.split(';');
|
|
909
|
+
|
|
910
|
+
if (parts.length >= 1) {
|
|
911
|
+
var fileInfo = parts[1];
|
|
912
|
+
var fileInfoArray = fileInfo.split('=');
|
|
913
|
+
|
|
914
|
+
if (fileInfoArray.length >= 1) {
|
|
915
|
+
fileName = fileInfoArray[1];
|
|
916
|
+
fileName = decodeURIComponent(fileName);
|
|
917
|
+
fileName = fileName.replaceAll("\"", "");
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
var type = xhr.getResponseHeader("content-type");
|
|
924
|
+
|
|
925
|
+
if (!type) {
|
|
926
|
+
type = "application/octet-stream";
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
var blob = new Blob([result], {
|
|
930
|
+
type: type
|
|
931
|
+
});
|
|
932
|
+
saveAs(blob, fileName);
|
|
933
|
+
};
|
|
934
|
+
|
|
935
|
+
ajaxOptions.error = function (error) {
|
|
936
|
+
console.log('ajaxOptions :', error);
|
|
937
|
+
};
|
|
938
|
+
|
|
939
|
+
var deferred = window.$.ajax(ajaxOptions);
|
|
940
|
+
|
|
941
|
+
if (this.isUseDefaultExceptionHandler()) {
|
|
942
|
+
return this.__toStdPromise(deferred, failedDealFunction);
|
|
943
|
+
} else {
|
|
944
|
+
return this.__toStdPromise(deferred);
|
|
945
|
+
}
|
|
946
|
+
},
|
|
947
|
+
createRequestURL: function createRequestURL(requestURL, params) {
|
|
948
|
+
var lastRequestURL = this.getRequestPath(requestURL);
|
|
949
|
+
|
|
950
|
+
if (!params) {
|
|
951
|
+
return lastRequestURL;
|
|
952
|
+
} else if (_lodash["default"].isString(params)) {
|
|
953
|
+
if (requestURL.includes('?')) {
|
|
954
|
+
var requestURLData = _queryString["default"].parseUrl(requestURL);
|
|
955
|
+
|
|
956
|
+
if (JSON.stringify(requestURLData.query) === '{}') {
|
|
957
|
+
return "".concat(requestURL).concat(params);
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
return "".concat(requestURL, "&").concat(params);
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
return "".concat(requestURL, "?").concat(params);
|
|
964
|
+
} else if (_lodash["default"].isPlainObject(params)) {
|
|
965
|
+
if (requestURL.includes('?')) {
|
|
966
|
+
var _requestURLData = _queryString["default"].parseUrl(requestURL);
|
|
967
|
+
|
|
968
|
+
if (JSON.stringify(_requestURLData.query) === '{}') {
|
|
969
|
+
return "".concat(requestURL).concat(this.encodeObject2ParameterString(params));
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
return "".concat(requestURL, "&").concat(this.encodeObject2ParameterString(params));
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
return "".concat(requestURL, "?").concat(this.encodeObject2ParameterString(params));
|
|
976
|
+
}
|
|
977
|
+
},
|
|
978
|
+
|
|
979
|
+
/**
|
|
980
|
+
* !important! <br/>
|
|
981
|
+
* DoNot use this pointer in this function body.
|
|
982
|
+
*/
|
|
983
|
+
dealAjaxException: function dealAjaxException(httpExceptionResponse) {
|
|
984
|
+
var errorID = "[ClientTraceID=" + new Date().getTime() + "] ";
|
|
985
|
+
var errorMsg = null;
|
|
986
|
+
|
|
987
|
+
if (_lodash["default"].isString(httpExceptionResponse)) {
|
|
988
|
+
errorMsg = httpExceptionResponse;
|
|
989
|
+
Toast.error(errorMsg);
|
|
990
|
+
} else if (httpExceptionResponse && (httpExceptionResponse.responseJSON || httpExceptionResponse.response)) {
|
|
991
|
+
var responseJSON = httpExceptionResponse.responseJSON || (Strings.isNotBlankString(httpExceptionResponse.response) ? JSON.parse(httpExceptionResponse.response) : httpExceptionResponse.response);
|
|
992
|
+
var responseJSONData = responseJSON.resultData || responseJSON.data;
|
|
993
|
+
var statusCode = responseJSON.statusCode;
|
|
994
|
+
|
|
995
|
+
if (statusCode && statusCode > 40000 && statusCode < 50000) {
|
|
996
|
+
errorMsg = responseJSON.msg || responseJSON.message;
|
|
997
|
+
Toast.error(errorMsg);
|
|
998
|
+
console.error(errorID + "Http request error:" + errorMsg, httpExceptionResponse);
|
|
999
|
+
|
|
1000
|
+
if (isNeedForceRedirect()) {
|
|
1001
|
+
setTimeout(function () {
|
|
1002
|
+
forceRedirectToForError();
|
|
1003
|
+
}, 300);
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
return httpExceptionResponse;
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
if (_utils.Values.isNotEmptyArray(responseJSONData)) {
|
|
1010
|
+
var msgItemList = responseJSONData.map(function (msgItem) {
|
|
1011
|
+
return /*#__PURE__*/React.createElement("li", null, msgItem);
|
|
1012
|
+
});
|
|
1013
|
+
var durationSeconds = responseJSONData.length * 1;
|
|
1014
|
+
durationSeconds = durationSeconds < 3 ? 3 : durationSeconds;
|
|
1015
|
+
var multiLineOpts = {
|
|
1016
|
+
content: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", null, responseJSON.msg), /*#__PURE__*/React.createElement("ol", {
|
|
1017
|
+
style: {
|
|
1018
|
+
marginTop: 8,
|
|
1019
|
+
paddingLeft: 0
|
|
1020
|
+
}
|
|
1021
|
+
}, msgItemList)),
|
|
1022
|
+
duration: durationSeconds
|
|
1023
|
+
};
|
|
1024
|
+
Toast.error(multiLineOpts);
|
|
1025
|
+
} else {
|
|
1026
|
+
if (responseJSON.error) {
|
|
1027
|
+
if (_utils.Values.isNotBlankString(responseJSON.error.msg)) {
|
|
1028
|
+
errorMsg = responseJSON.error.msg;
|
|
1029
|
+
} else if (_utils.Values.isNotBlankString(responseJSON.error.message)) {
|
|
1030
|
+
errorMsg = responseJSON.error.message;
|
|
1031
|
+
} else if (_utils.Values.isNotBlankString(responseJSON.error)) {
|
|
1032
|
+
errorMsg = responseJSON.error;
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
if (_utils.Values.isNotBlankString(errorMsg)) {
|
|
1036
|
+
Toast.error(errorMsg);
|
|
1037
|
+
}
|
|
1038
|
+
} else {
|
|
1039
|
+
errorMsg = responseJSON.msg || responseJSON.message || responseJSON.err;
|
|
1040
|
+
|
|
1041
|
+
if (_utils.Values.isNotBlankString(errorMsg)) {
|
|
1042
|
+
Toast.error(errorMsg);
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
console.error(errorID + "Http request error:" + errorMsg, httpExceptionResponse);
|
|
1048
|
+
return httpExceptionResponse;
|
|
1049
|
+
} else if (_utils.Values.isNotBlankString(httpExceptionResponse.message)) {
|
|
1050
|
+
Toast.error(httpExceptionResponse.message);
|
|
1051
|
+
} else if (httpExceptionResponse.status === 502) {
|
|
1052
|
+
Toast.error("[502]服务正在重启,请稍后重试");
|
|
1053
|
+
} else if (httpExceptionResponse.status === 200) {
|
|
1054
|
+
Toast.error("[200]Http状态码为200,但是出错,可能的原因是数据格式转换异常,请排查。");
|
|
1055
|
+
} else if (httpExceptionResponse.status === 404) {
|
|
1056
|
+
var contentType = httpExceptionResponse.getResponseHeader("Content-Type");
|
|
1057
|
+
|
|
1058
|
+
if (_utils.Values.isNotBlankString(contentType) && !contentType.toLowerCase().startsWith("application/json")) {
|
|
1059
|
+
// because the request is always to for backend service
|
|
1060
|
+
// but when failed, we always return json;
|
|
1061
|
+
// when not json, that is always the backend service not available (not start);
|
|
1062
|
+
Toast.error("[404] Not Found, 可能是后端服务尚未启动.");
|
|
1063
|
+
|
|
1064
|
+
if (isNeedForceRedirect()) {
|
|
1065
|
+
setTimeout(function () {
|
|
1066
|
+
forceRedirectToForError();
|
|
1067
|
+
}, 300);
|
|
1068
|
+
}
|
|
1069
|
+
} else {
|
|
1070
|
+
Toast.error("[404] Not Found(所请求的资源不存在)");
|
|
1071
|
+
}
|
|
1072
|
+
} else if (httpExceptionResponse.status === 0 || httpExceptionResponse.readyState === 0) {
|
|
1073
|
+
Toast.error("应用服务链路不通:请联系管理员检查应用服务是否已启动.");
|
|
1074
|
+
} else if (httpExceptionResponse.status && httpExceptionResponse.statusText) {
|
|
1075
|
+
var errorTip = "[" + httpExceptionResponse.status + "] " + httpExceptionResponse.statusText;
|
|
1076
|
+
Toast.error(errorTip);
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
console.error(errorID + "Maybe Http request error or Unresolved promise message:", httpExceptionResponse);
|
|
1080
|
+
return httpExceptionResponse;
|
|
1081
|
+
},
|
|
1082
|
+
__toStdPromise: function __toStdPromise(deferred, failedDealFunction) {
|
|
1083
|
+
if (failedDealFunction === null || failedDealFunction === void 0) {
|
|
1084
|
+
return Promise.resolve(deferred);
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
return Promise.resolve(deferred)["catch"](failedDealFunction);
|
|
483
1088
|
}
|
|
484
1089
|
};
|
|
485
1090
|
var _default = http;
|
package/package.json
CHANGED
package/src/base/BaseAppUtils.js
CHANGED
|
@@ -273,6 +273,14 @@ const jsonToMap = function(json) {
|
|
|
273
273
|
return map;
|
|
274
274
|
}
|
|
275
275
|
|
|
276
|
+
const loadingTips = {
|
|
277
|
+
loading: '加载中...',
|
|
278
|
+
update: '更新中...',
|
|
279
|
+
save: '保存中...',
|
|
280
|
+
upload: '上传中...',
|
|
281
|
+
remove: '删除中...'
|
|
282
|
+
}
|
|
283
|
+
|
|
276
284
|
export {
|
|
277
285
|
genGetterAndReadonlySetter,
|
|
278
286
|
FunctionLetHelper,
|
|
@@ -287,5 +295,6 @@ export {
|
|
|
287
295
|
parentsInsertchildrenOfCustomizeAsParentColumn,
|
|
288
296
|
mapToJson,
|
|
289
297
|
jsonToMap,
|
|
290
|
-
treeDataToListByChildFieldName
|
|
298
|
+
treeDataToListByChildFieldName,
|
|
299
|
+
loadingTips
|
|
291
300
|
}
|
|
@@ -404,6 +404,11 @@ const buildActionButton = function(props, subActionButton, innerLine) {
|
|
|
404
404
|
throw new Error("Please enter the check field and table data before transmitting the check field and table data");
|
|
405
405
|
}
|
|
406
406
|
|
|
407
|
+
if (Values.isEmptyArray(checkData)) {
|
|
408
|
+
message.warning('未找到选中的记录,请检查选中状态');
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
|
|
407
412
|
let checkedNames = [];
|
|
408
413
|
if (Values.isNotBlankString(checkField) && Values.isNotEmptyArray(checkData)) {
|
|
409
414
|
if (Array.isArray(checkData)) {
|
|
@@ -415,13 +420,14 @@ const buildActionButton = function(props, subActionButton, innerLine) {
|
|
|
415
420
|
}
|
|
416
421
|
else {
|
|
417
422
|
message.warning('未找到选中的记录,请检查选中状态');
|
|
418
|
-
return
|
|
423
|
+
return;
|
|
419
424
|
}
|
|
420
425
|
}
|
|
421
426
|
else if (lodash.isPlainObject(checkData)) {
|
|
422
427
|
checkedNames.push(checkData[checkField]);
|
|
423
428
|
}
|
|
424
429
|
}
|
|
430
|
+
|
|
425
431
|
modalOptions.content = modalOptions.content.replace('[options]', checkedNames.join(','));
|
|
426
432
|
|
|
427
433
|
if (confirmType) {
|