dlt-for-react 1.0.23 → 1.1.0
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/README.md +12 -2
- package/lib/components/Button/index.js +79 -0
- package/lib/components/HqSelector/HqLsrySelector/index.js +3 -5
- package/lib/components/HqSelector/HqRySelector/index.js +3 -5
- package/lib/components/HqSelector/HqWzSelector/index.js +3 -5
- package/lib/components/KyEditableTable/component.js +3 -5
- package/lib/components/KyEditableTable/index.js +7 -13
- package/lib/components/KyExcel/index.js +3 -5
- package/lib/components/KyInputPicker/render.js +13 -43
- package/lib/components/KyInputPicker/setting-checkbox.js +3 -5
- package/lib/components/KyInputPicker/setting-multiSelect.js +3 -5
- package/lib/components/KyInputPicker/setting-nhcascader.js +3 -5
- package/lib/components/KyInputPicker/setting-select.js +3 -5
- package/lib/components/KyInputPicker/setting-stu-selector.js +3 -5
- package/lib/components/KyInputPicker/setting-tea-selector.js +3 -5
- package/lib/components/KyTable/checkButtons.js +4 -7
- package/lib/components/KyTree/index.js +6 -16
- package/lib/components/KyUpload/index.js +13 -21
- package/lib/components/NHAuditPanel/config/Axios.js +263 -0
- package/lib/components/NHAuditPanel/config/api.js +479 -0
- package/lib/components/NHAuditPanel/config/data.js +156 -0
- package/lib/components/NHAuditPanel/config/typeMap.js +1234 -0
- package/lib/components/NHAuditPanel/config/uiValidate.js +92 -0
- package/lib/components/NHAuditPanel/index.js +413 -0
- package/lib/components/NHAuditPanel/node.js +619 -0
- package/lib/components/NHCascader/index.js +355 -0
- package/lib/components/NHCheckboxGroup/index.js +135 -0
- package/lib/components/NHDynamicFormShow/baseInfo/index.js +194 -0
- package/lib/components/NHDynamicFormShow/custom/index.js +553 -0
- package/lib/components/NHDynamicFormShow/customModule/common/CommonMethod.js +43 -0
- package/lib/components/NHDynamicFormShow/customModule/czxy/qgzx/EditForm.js +1113 -0
- package/lib/components/NHDynamicFormShow/customModule/czxy/qgzx/index.js +263 -0
- package/lib/components/NHDynamicFormShow/customModule/czxy/xfjm/EditForm.js +880 -0
- package/lib/components/NHDynamicFormShow/customModule/czxy/xfjm/index.js +171 -0
- package/lib/components/NHDynamicFormShow/customModule/czxy/zxj/EditForm.js +865 -0
- package/lib/components/NHDynamicFormShow/customModule/czxy/zxj/index.js +138 -0
- package/lib/components/NHDynamicFormShow/customModule/eszy/zsxxhd/EditForm.js +571 -0
- package/lib/components/NHDynamicFormShow/customModule/eszy/zsxxhd/index.js +147 -0
- package/lib/components/NHDynamicFormShow/customModule/eszy/zybjtz/EditForm.js +474 -0
- package/lib/components/NHDynamicFormShow/customModule/eszy/zybjtz/index.js +139 -0
- package/lib/components/NHDynamicFormShow/customModule/gnyxy/cqzg/EditForm.js +506 -0
- package/lib/components/NHDynamicFormShow/customModule/gnyxy/cqzg/index.js +143 -0
- package/lib/components/NHDynamicFormShow/customModule/gnyxy/gwsb/EditForm.js +1074 -0
- package/lib/components/NHDynamicFormShow/customModule/gnyxy/gwsb/index.js +172 -0
- package/lib/components/NHDynamicFormShow/customModule/gnyxy/qjgl/EditForm.js +927 -0
- package/lib/components/NHDynamicFormShow/customModule/gnyxy/qjgl/index.js +195 -0
- package/lib/components/NHDynamicFormShow/customModule/gnyxy/sxsqj/EditForm.js +1064 -0
- package/lib/components/NHDynamicFormShow/customModule/gnyxy/sxsqj/index.js +183 -0
- package/lib/components/NHDynamicFormShow/customModule/hblgxy/jxj/EditForm.js +763 -0
- package/lib/components/NHDynamicFormShow/customModule/hblgxy/jxj/index.js +137 -0
- package/lib/components/NHDynamicFormShow/customModule/hblgxy/lzjxj/EditForm.js +819 -0
- package/lib/components/NHDynamicFormShow/customModule/hblgxy/lzjxj/index.js +137 -0
- package/lib/components/NHDynamicFormShow/customModule/hblgxy/qgzx/EditForm.js +700 -0
- package/lib/components/NHDynamicFormShow/customModule/hblgxy/qgzx/index.js +162 -0
- package/lib/components/NHDynamicFormShow/customModule/hblgxy/xsqj/EditForm.js +743 -0
- package/lib/components/NHDynamicFormShow/customModule/hblgxy/xsqj/index.js +177 -0
- package/lib/components/NHDynamicFormShow/customModule/hblgxy/zxj/EditForm.js +848 -0
- package/lib/components/NHDynamicFormShow/customModule/hblgxy/zxj/index.js +138 -0
- package/lib/components/NHDynamicFormShow/customModule/hljwgy/qjgl/EditForm.js +777 -0
- package/lib/components/NHDynamicFormShow/customModule/hljwgy/qjgl/index.js +161 -0
- package/lib/components/NHDynamicFormShow/customModule/hljwgy/xjgl/EditForm.js +706 -0
- package/lib/components/NHDynamicFormShow/customModule/hljwgy/xjgl/index.js +130 -0
- package/lib/components/NHDynamicFormShow/customModule/jhysxy/cfjcsq/cfjcEditForm.js +413 -0
- package/lib/components/NHDynamicFormShow/customModule/jhysxy/cfjcsq/index.js +135 -0
- package/lib/components/NHDynamicFormShow/customModule/jhysxy/xsqj/EditForm.js +1013 -0
- package/lib/components/NHDynamicFormShow/customModule/jhysxy/xsqj/index.js +175 -0
- package/lib/components/NHDynamicFormShow/customModule/jjrlx/EditForm.js +1345 -0
- package/lib/components/NHDynamicFormShow/customModule/jjrlx/index.js +274 -0
- package/lib/components/NHDynamicFormShow/customModule/jxj/EditForm.js +669 -0
- package/lib/components/NHDynamicFormShow/customModule/jxj/index.js +134 -0
- package/lib/components/NHDynamicFormShow/customModule/jxsl/fqkns/EditForm.js +378 -0
- package/lib/components/NHDynamicFormShow/customModule/jxsl/fqkns/index.js +120 -0
- package/lib/components/NHDynamicFormShow/customModule/jxsl/xwryfjjd/EditForm.js +638 -0
- package/lib/components/NHDynamicFormShow/customModule/jxsl/xwryfjjd/index.js +133 -0
- package/lib/components/NHDynamicFormShow/customModule/qgzx/EditForm.js +965 -0
- package/lib/components/NHDynamicFormShow/customModule/qgzx/index.js +237 -0
- package/lib/components/NHDynamicFormShow/customModule/qjgl/EditForm.js +823 -0
- package/lib/components/NHDynamicFormShow/customModule/qjgl/index.js +188 -0
- package/lib/components/NHDynamicFormShow/customModule/rcgl/jqlssq/EditForm.js +401 -0
- package/lib/components/NHDynamicFormShow/customModule/rcgl/jqlssq/index.js +472 -0
- package/lib/components/NHDynamicFormShow/customModule/rcgl/tssq/EditForm.js +304 -0
- package/lib/components/NHDynamicFormShow/customModule/rcgl/tssq/NHCascader/index.js +375 -0
- package/lib/components/NHDynamicFormShow/customModule/rcgl/tssq/NHInputPicker/RadioGroup.js +118 -0
- package/lib/components/NHDynamicFormShow/customModule/rcgl/tssq/NHInputPicker/index.js +62 -0
- package/lib/components/NHDynamicFormShow/customModule/rcgl/tssq/NHInputPicker/input-const.js +55 -0
- package/lib/components/NHDynamicFormShow/customModule/rcgl/tssq/NHInputPicker/render.js +1238 -0
- package/lib/components/NHDynamicFormShow/customModule/rcgl/tssq/index.js +375 -0
- package/lib/components/NHDynamicFormShow/customModule/rych/collective/EditForm.js +554 -0
- package/lib/components/NHDynamicFormShow/customModule/rych/collective/index.js +130 -0
- package/lib/components/NHDynamicFormShow/customModule/rych/personal/EditForm.js +542 -0
- package/lib/components/NHDynamicFormShow/customModule/rych/personal/index.js +133 -0
- package/lib/components/NHDynamicFormShow/customModule/sxgy/rych/collective/EditForm.js +575 -0
- package/lib/components/NHDynamicFormShow/customModule/sxgy/rych/collective/index.js +130 -0
- package/lib/components/NHDynamicFormShow/customModule/sxgy/rych/personal/EditForm.js +563 -0
- package/lib/components/NHDynamicFormShow/customModule/sxgy/rych/personal/index.js +133 -0
- package/lib/components/NHDynamicFormShow/customModule/whcz/qjgl/EditForm.js +745 -0
- package/lib/components/NHDynamicFormShow/customModule/whcz/qjgl/index.js +164 -0
- package/lib/components/NHDynamicFormShow/customModule/whcz/rccrxy/EditForm.js +587 -0
- package/lib/components/NHDynamicFormShow/customModule/whcz/rccrxy/index.js +143 -0
- package/lib/components/NHDynamicFormShow/customModule/whdlqjgl/EditForm.js +743 -0
- package/lib/components/NHDynamicFormShow/customModule/whdlqjgl/index.js +172 -0
- package/lib/components/NHDynamicFormShow/customModule/whgc/jjrlx/EditForm.js +1410 -0
- package/lib/components/NHDynamicFormShow/customModule/whgc/jjrlx/index.js +274 -0
- package/lib/components/NHDynamicFormShow/customModule/whgc/jxj/EditForm.js +755 -0
- package/lib/components/NHDynamicFormShow/customModule/whgc/jxj/index.js +130 -0
- package/lib/components/NHDynamicFormShow/customModule/whgc/qjgl/EditForm.js +814 -0
- package/lib/components/NHDynamicFormShow/customModule/whgc/qjgl/index.js +188 -0
- package/lib/components/NHDynamicFormShow/customModule/whgc/zxj/EditForm.js +769 -0
- package/lib/components/NHDynamicFormShow/customModule/whgc/zxj/index.js +130 -0
- package/lib/components/NHDynamicFormShow/customModule/whgcrych/EditForm.js +1004 -0
- package/lib/components/NHDynamicFormShow/customModule/whgcrych/index.js +126 -0
- package/lib/components/NHDynamicFormShow/customModule/whtl/jsrzsq/EditForm.js +503 -0
- package/lib/components/NHDynamicFormShow/customModule/whtl/jsrzsq/index.js +149 -0
- package/lib/components/NHDynamicFormShow/customModule/whtlyhk/EditForm.js +379 -0
- package/lib/components/NHDynamicFormShow/customModule/whtlyhk/index.js +148 -0
- package/lib/components/NHDynamicFormShow/customModule/whtlzxj/EditForm.js +748 -0
- package/lib/components/NHDynamicFormShow/customModule/whtlzxj/index.js +135 -0
- package/lib/components/NHDynamicFormShow/customModule/whtlzy/jxj/EditForm.js +762 -0
- package/lib/components/NHDynamicFormShow/customModule/whtlzy/jxj/index.js +134 -0
- package/lib/components/NHDynamicFormShow/customModule/wjcf/cfjc/cfjcEditForm.js +682 -0
- package/lib/components/NHDynamicFormShow/customModule/wjcf/cfjc/index.js +135 -0
- package/lib/components/NHDynamicFormShow/customModule/wjcf/wjsb/index.js +152 -0
- package/lib/components/NHDynamicFormShow/customModule/wjcf/wjsb/wjsbEditForm.js +783 -0
- package/lib/components/NHDynamicFormShow/customModule/zxj/EditForm.js +764 -0
- package/lib/components/NHDynamicFormShow/customModule/zxj/index.js +138 -0
- package/lib/components/NHDynamicFormShow/customModule/zzsd/cfjcsq/cfjcEditForm.js +677 -0
- package/lib/components/NHDynamicFormShow/customModule/zzsd/cfjcsq/index.js +138 -0
- package/lib/components/NHDynamicFormShow/customModule/zzsd/qjgl/EditForm.js +1173 -0
- package/lib/components/NHDynamicFormShow/customModule/zzsd/qjgl/index.js +242 -0
- package/lib/components/NHDynamicFormShow/customModule/zzsd/rcgl/rcxwgrdj/IndividualRegistForm.js +862 -0
- package/lib/components/NHDynamicFormShow/customModule/zzsd/rcgl/rcxwgrdj/IndividualRegistIndex.js +201 -0
- package/lib/components/NHDynamicFormShow/customModule/zzsd/stuinfo/messageInfo.js +196 -0
- package/lib/components/NHDynamicFormShow/customModule/zzsd/wjsb/index.js +167 -0
- package/lib/components/NHDynamicFormShow/customModule/zzsd/wjsb/wjsbEditForm.js +1096 -0
- package/lib/components/NHDynamicFormShow/index.js +647 -0
- package/lib/components/NHDynamicFormShow/oneOnMany/cardForm/cardItem/index.js +279 -0
- package/lib/components/NHDynamicFormShow/oneOnMany/cardForm/index.js +206 -0
- package/lib/components/NHDynamicFormShow/oneOnMany/index.js +419 -0
- package/lib/components/NHDynamicFormShow/oneOnOne/EditForm.js +401 -0
- package/lib/components/NHDynamicFormShow/oneOnOne/index.js +271 -0
- package/lib/components/NHImagePicker/index.js +554 -0
- package/lib/components/NHInputPicker/RadioGroup.js +118 -0
- package/lib/components/NHInputPicker/index.js +62 -0
- package/lib/components/NHInputPicker/input-const.js +55 -0
- package/lib/components/NHInputPicker/render.js +1271 -0
- package/lib/components/NHListView/index.js +374 -0
- package/lib/components/NHMapGeolocation/index.js +537 -0
- package/lib/components/NHMapGeolocation/initMap/initGdMap.js +104 -0
- package/lib/components/NHMapGeolocation/initMap/initTencentMap.js +138 -0
- package/lib/components/NHMapGeolocation/style.js +51 -0
- package/lib/components/NHMultiSelect/index.js +272 -0
- package/lib/components/NHRadioGroup/index.js +118 -0
- package/lib/components/NHSelect/index.js +364 -0
- package/lib/components/NHTreeMenu/index.js +126 -0
- package/lib/components/NHTreeMenu/treeNode.js +164 -0
- package/lib/components/StuSelector/index.js +611 -0
- package/lib/index.js +161 -116
- package/lib/layouts/KyInputPicker/edit-page.js +585 -0
- package/lib/layouts/KyInputPicker/index.js +220 -0
- package/lib/layouts/KyInputPicker/input-const.js +134 -0
- package/lib/layouts/KyInputPicker/render.js +2477 -0
- package/lib/layouts/KyInputPicker/setting-checkbox.js +850 -0
- package/lib/layouts/KyInputPicker/setting-datepicker.js +430 -0
- package/lib/layouts/KyInputPicker/setting-datetimepicker.js +443 -0
- package/lib/layouts/KyInputPicker/setting-input.js +555 -0
- package/lib/layouts/KyInputPicker/setting-inputNumber.js +612 -0
- package/lib/layouts/KyInputPicker/setting-monthpicker.js +434 -0
- package/lib/layouts/KyInputPicker/setting-multiSelect.js +532 -0
- package/lib/layouts/KyInputPicker/setting-nhcascader.js +584 -0
- package/lib/layouts/KyInputPicker/setting-old-upload.js +428 -0
- package/lib/layouts/KyInputPicker/setting-radio.js +468 -0
- package/lib/layouts/KyInputPicker/setting-rangepicker.js +466 -0
- package/lib/layouts/KyInputPicker/setting-select.js +534 -0
- package/lib/layouts/KyInputPicker/setting-stu-selector.js +507 -0
- package/lib/layouts/KyInputPicker/setting-switch.js +274 -0
- package/lib/layouts/KyInputPicker/setting-tea-selector.js +507 -0
- package/lib/layouts/KyInputPicker/setting-textarea.js +619 -0
- package/lib/layouts/KyInputPicker/setting-timepicker.js +437 -0
- package/lib/layouts/KyInputPicker/setting-upload.js +766 -0
- package/lib/layouts/KyModal/buildTitle.js +81 -0
- package/lib/layouts/KyModal/dragM.js +127 -0
- package/lib/layouts/KyModal/index.js +321 -0
- package/lib/layouts/KyPreview/index.js +219 -0
- package/lib/layouts/KyUpload/index.js +1155 -0
- package/lib/layouts/LeftMenu/index.js +5 -11
- package/lib/layouts/NavigationBar/index.js +4 -10
- package/lib/layouts/Top/editPassWord.js +5 -7
- package/lib/layouts/Top/index.js +6 -20
- package/lib/layouts/TopMenu/index.js +11 -14
- package/lib/layouts/layout/index.js +7 -13
- package/lib/layouts/{Login → login}/index-pre.js +3 -5
- package/lib/layouts/{Login → login}/index.js +6 -8
- package/lib/layouts/{Login → login}/login.js +8 -17
- package/lib/layouts/mixTop/index.js +13 -28
- package/lib/layouts/settingDrawer/index.js +3 -5
- package/lib/routes/AuthorizedRoute.js +7 -13
- package/lib/utils/NHCore.js +46 -2
- package/lib/utils/base64.js +238 -0
- package/lib/utils/browserJudge.js +33 -0
- package/lib/utils/common.js +18 -20
- package/lib/utils/createUuid.js +11 -31
- package/lib/utils/device.js +44 -0
- package/lib/utils/dynamicLoadCss.js +14 -0
- package/lib/utils/dynamicLoadJs.js +21 -0
- package/lib/utils/getLoginUser.js +1 -1
- package/lib/utils/getSize.js +2 -11
- package/lib/utils/getStyle.js +26 -0
- package/lib/utils/getSuitHeight.js +49 -0
- package/lib/utils/hasAuth.js +11 -0
- package/lib/utils/index.js +1 -34
- package/lib/utils/loadJS.js +40 -0
- package/package.json +1 -1
- /package/lib/layouts/{Login → login}/lyPassword.js +0 -0
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _toast = require('antd-mobile/lib/toast');
|
|
8
|
+
|
|
9
|
+
var _toast2 = _interopRequireDefault(_toast);
|
|
10
|
+
|
|
11
|
+
var _imagePicker = require('antd-mobile/lib/image-picker');
|
|
12
|
+
|
|
13
|
+
var _imagePicker2 = _interopRequireDefault(_imagePicker);
|
|
14
|
+
|
|
15
|
+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
16
|
+
|
|
17
|
+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
18
|
+
|
|
19
|
+
require('antd-mobile/lib/toast/style/css');
|
|
20
|
+
|
|
21
|
+
require('antd-mobile/lib/image-picker/style/css');
|
|
22
|
+
|
|
23
|
+
var _react = require('react');
|
|
24
|
+
|
|
25
|
+
var _react2 = _interopRequireDefault(_react);
|
|
26
|
+
|
|
27
|
+
var _propTypes = require('prop-types');
|
|
28
|
+
|
|
29
|
+
var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
30
|
+
|
|
31
|
+
var _NHFetch = require('../../utils/NHFetch');
|
|
32
|
+
|
|
33
|
+
var _NHFetch2 = _interopRequireDefault(_NHFetch);
|
|
34
|
+
|
|
35
|
+
var _createUuid = require('../../utils/createUuid');
|
|
36
|
+
|
|
37
|
+
var _createUuid2 = _interopRequireDefault(_createUuid);
|
|
38
|
+
|
|
39
|
+
var _reactMobileImageViewer = require('react-mobile-image-viewer');
|
|
40
|
+
|
|
41
|
+
var _reactMobileImageViewer2 = _interopRequireDefault(_reactMobileImageViewer);
|
|
42
|
+
|
|
43
|
+
require('react-mobile-image-viewer/lib/index.css');
|
|
44
|
+
|
|
45
|
+
var _reactRouterDom = require('react-router-dom');
|
|
46
|
+
|
|
47
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
48
|
+
|
|
49
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
50
|
+
|
|
51
|
+
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
52
|
+
|
|
53
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
54
|
+
|
|
55
|
+
// const fileDocDownloadPath = 'api/docrepo/download?attachmentId=';
|
|
56
|
+
var redisDownloadPath = '/proData/downloadRedisCacheImage?uuid=';
|
|
57
|
+
|
|
58
|
+
var NHImagePicker = function (_React$Component) {
|
|
59
|
+
_inherits(NHImagePicker, _React$Component);
|
|
60
|
+
|
|
61
|
+
function NHImagePicker(props) {
|
|
62
|
+
_classCallCheck(this, NHImagePicker);
|
|
63
|
+
|
|
64
|
+
var _this = _possibleConstructorReturn(this, (NHImagePicker.__proto__ || Object.getPrototypeOf(NHImagePicker)).call(this, props));
|
|
65
|
+
|
|
66
|
+
_initialiseProps.call(_this);
|
|
67
|
+
|
|
68
|
+
var value = props.value || props.defaultValue;
|
|
69
|
+
_this.state = {
|
|
70
|
+
uploadedImageList: [], //已上传图片
|
|
71
|
+
previewImageVisible: false, //是否预览图片标识
|
|
72
|
+
previewImageUrl: '', //预览图片的URL
|
|
73
|
+
previewImageName: '', //预览图片的名称
|
|
74
|
+
value: value !== undefined && value !== null && value.trim() !== '' ? value : (0, _createUuid2.default)()
|
|
75
|
+
};
|
|
76
|
+
return _this;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
_createClass(NHImagePicker, [{
|
|
80
|
+
key: 'componentDidMount',
|
|
81
|
+
value: function componentDidMount() {
|
|
82
|
+
this.loadFileList();
|
|
83
|
+
}
|
|
84
|
+
}, {
|
|
85
|
+
key: 'componentWillReceiveProps',
|
|
86
|
+
value: function componentWillReceiveProps(nextprops) {
|
|
87
|
+
if ('value' in nextprops && this.props.value !== nextprops.value) {
|
|
88
|
+
var value = nextprops.value !== undefined && nextprops.value !== null && nextprops.value.trim() !== '' ? nextprops.value : (0, _createUuid2.default)();
|
|
89
|
+
this.setState({ value: value }, this.loadFileList);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
//处理fileList
|
|
94
|
+
|
|
95
|
+
//新增附件主表和明细
|
|
96
|
+
|
|
97
|
+
//文件上传改变事件
|
|
98
|
+
|
|
99
|
+
}, {
|
|
100
|
+
key: 'handlePropsOnChange',
|
|
101
|
+
value: function handlePropsOnChange(uploadedImageList) {
|
|
102
|
+
//父组件回调方法,在父组件可以拿到已经上传成功的图片信息
|
|
103
|
+
if (this.props.onChange && typeof this.props.onChange === "function") {
|
|
104
|
+
this.props.onChange(uploadedImageList);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// handleDownloadClick = (index,fileList) => {
|
|
108
|
+
// const file = fileList[index];
|
|
109
|
+
// window.open(file.url);
|
|
110
|
+
// }
|
|
111
|
+
|
|
112
|
+
//上传图片
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
//将base64转换为blob
|
|
116
|
+
|
|
117
|
+
}, {
|
|
118
|
+
key: 'blobToFile',
|
|
119
|
+
|
|
120
|
+
//将blob转换为file
|
|
121
|
+
value: function blobToFile(theBlob, fileName, lastModifiedDate) {
|
|
122
|
+
theBlob.lastModifiedDate = lastModifiedDate;
|
|
123
|
+
theBlob.name = fileName;
|
|
124
|
+
return theBlob;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* 判断文件是否超出最大限制
|
|
129
|
+
* @param {*} file 文件
|
|
130
|
+
* @returns true/false
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
}, {
|
|
134
|
+
key: 'render',
|
|
135
|
+
value: function render() {
|
|
136
|
+
var uploadedImageList = this.state.uploadedImageList;
|
|
137
|
+
var _props = this.props,
|
|
138
|
+
numberOfLimit = _props.numberOfLimit,
|
|
139
|
+
isEdit = _props.isEdit,
|
|
140
|
+
_props$accept = _props.accept,
|
|
141
|
+
accept = _props$accept === undefined ? 'image/*' : _props$accept,
|
|
142
|
+
capture = _props.capture;
|
|
143
|
+
|
|
144
|
+
if (isEdit) {
|
|
145
|
+
return _react2.default.createElement(
|
|
146
|
+
_react2.default.Fragment,
|
|
147
|
+
null,
|
|
148
|
+
_react2.default.createElement(_imagePicker2.default, {
|
|
149
|
+
files: uploadedImageList,
|
|
150
|
+
onChange: this.handleChange,
|
|
151
|
+
onImageClick: this.preview,
|
|
152
|
+
accept: accept,
|
|
153
|
+
selectable: uploadedImageList.length < numberOfLimit,
|
|
154
|
+
capture: capture
|
|
155
|
+
}),
|
|
156
|
+
this.renderCommon()
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
return _react2.default.createElement(
|
|
160
|
+
_react2.default.Fragment,
|
|
161
|
+
null,
|
|
162
|
+
_react2.default.createElement(_imagePicker2.default, {
|
|
163
|
+
files: uploadedImageList,
|
|
164
|
+
onChange: this.handleChange,
|
|
165
|
+
onImageClick: this.preview,
|
|
166
|
+
selectable: false,
|
|
167
|
+
disableDelete: true,
|
|
168
|
+
capture: capture
|
|
169
|
+
}),
|
|
170
|
+
this.renderCommon()
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
}]);
|
|
174
|
+
|
|
175
|
+
return NHImagePicker;
|
|
176
|
+
}(_react2.default.Component);
|
|
177
|
+
|
|
178
|
+
NHImagePicker.propTypes = {
|
|
179
|
+
saveType: _propTypes2.default.string, //保存的类型
|
|
180
|
+
imageList: _propTypes2.default.array, //初始化图片信息
|
|
181
|
+
cacheTime: _propTypes2.default.number, //Redis缓存时间
|
|
182
|
+
numberOfLimit: _propTypes2.default.number, //允许上传的图片张数
|
|
183
|
+
numberOfSize: _propTypes2.default.number, //允许上传的图片大小
|
|
184
|
+
disabled: _propTypes2.default.bool, //是否禁用
|
|
185
|
+
base64UploadUrl: _propTypes2.default.string, //base64图片上传路径
|
|
186
|
+
onRemove: _propTypes2.default.func, //删除成功回调
|
|
187
|
+
onChange: _propTypes2.default.func, //值改变回调
|
|
188
|
+
serviceMark: _propTypes2.default.string, //所属服务
|
|
189
|
+
moduleName: _propTypes2.default.string, //模块名称
|
|
190
|
+
value: _propTypes2.default.string, //附件主表id
|
|
191
|
+
isEdit: _propTypes2.default.bool, //编辑模式
|
|
192
|
+
|
|
193
|
+
compressThreshold: _propTypes2.default.number, //压缩的阈值
|
|
194
|
+
isPictureCompress: _propTypes2.default.bool, //是否开启图片压缩
|
|
195
|
+
pictureQuality: _propTypes2.default.number, //指定压缩的图片质量,取值范围为0~1,quality值越小,图像越模糊
|
|
196
|
+
picScale: _propTypes2.default.number, // 每次图片(宽高)压缩的比例
|
|
197
|
+
accept: _propTypes2.default.string, //图片类型
|
|
198
|
+
maxFileSize: _propTypes2.default.number, //默认上传文件的最大限制
|
|
199
|
+
sizeWord: _propTypes2.default.string //文件大小单位 M/KB, 默认为M
|
|
200
|
+
|
|
201
|
+
//设置props默认值
|
|
202
|
+
};
|
|
203
|
+
NHImagePicker.defaultProps = {
|
|
204
|
+
saveType: 'file', //保存的类型,默认为file文档库,可选的值: 'file'(上传文档库)、
|
|
205
|
+
cacheTime: 30, //设置Redis缓存的时间,单位:分钟 表示Redis超过30分钟会删除缓存的信息
|
|
206
|
+
numberOfLimit: 1, //最多允许上传多少张图片 默认为1张
|
|
207
|
+
numberOfSize: 2, //默认上传大小限制2MB
|
|
208
|
+
disabled: false, //是否禁用
|
|
209
|
+
onRemove: function onRemove() {//删除成功回调
|
|
210
|
+
},
|
|
211
|
+
onChange: function onChange() {}, //值改变时的回调
|
|
212
|
+
base64UploadUrl: undefined, //base64上传图片路径
|
|
213
|
+
serviceMark: undefined, //服务标志,说明是属于哪个服务
|
|
214
|
+
moduleName: undefined, //模块名称,说明是属于哪个服务的哪个模块
|
|
215
|
+
value: undefined, //附件主表id
|
|
216
|
+
isEdit: true, //是否可以编辑,默认为true,查看模式必须传value
|
|
217
|
+
|
|
218
|
+
compressThreshold: 5, //压缩的阈值,图片大小超过5M,则需要进行压缩
|
|
219
|
+
isPictureCompress: false, //是否开启图片压缩
|
|
220
|
+
pictureQuality: 0.92, //指定压缩的图片质量,取值范围为0~1,quality值越小,图像越模糊,默认图片质量为0.92
|
|
221
|
+
picScale: 0.9, // 每次图片(宽高)压缩的比例
|
|
222
|
+
accept: 'image/*', //默认支持上传所有图片类型
|
|
223
|
+
capture: false, //图片捕获设置, 具体请参考MDN中关于capture的说明, camera为只拍照
|
|
224
|
+
maxFileSize: 20, //默认上传文件的最大限制 20, 单位默认为MB
|
|
225
|
+
sizeWord: 'M' //大小单位 M/KB,默认为M
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
var _initialiseProps = function _initialiseProps() {
|
|
229
|
+
var _this2 = this;
|
|
230
|
+
|
|
231
|
+
this.loadFileList = function () {
|
|
232
|
+
var _props2 = _this2.props,
|
|
233
|
+
serviceMark = _props2.serviceMark,
|
|
234
|
+
moduleName = _props2.moduleName;
|
|
235
|
+
|
|
236
|
+
if (serviceMark && moduleName) {
|
|
237
|
+
var value = _this2.state.value;
|
|
238
|
+
var t = new Date().getTime();
|
|
239
|
+
(0, _NHFetch2.default)('front/zhxg-unauth/dynamic/' + value + '/getDetailed', 'GET', t).then(function (res) {
|
|
240
|
+
if (res && res.data && res.data.length > 0) {
|
|
241
|
+
_this2.handleFileList(res.data);
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
} else {
|
|
245
|
+
_toast2.default.fail("服务标志和模块名称不能为空");
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
this.handleFileList = function (propsfileList) {
|
|
250
|
+
if (propsfileList.length > 0) {
|
|
251
|
+
var uploadedImageList = [];
|
|
252
|
+
propsfileList.map(function (item) {
|
|
253
|
+
uploadedImageList.push({
|
|
254
|
+
uuid: item.uuid,
|
|
255
|
+
url: 'zuul/docrepo/download/file?attachmentId=' + item.uuid,
|
|
256
|
+
name: item.name
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
_this2.setState({
|
|
260
|
+
uploadedImageList: uploadedImageList
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
this.handleMasterTable = function (res, fileList, fileName) {
|
|
266
|
+
var value = _this2.state.value;
|
|
267
|
+
var _props3 = _this2.props,
|
|
268
|
+
serviceMark = _props3.serviceMark,
|
|
269
|
+
moduleName = _props3.moduleName,
|
|
270
|
+
describe = _props3.describe,
|
|
271
|
+
fileMainName = _props3.fileMainName;
|
|
272
|
+
|
|
273
|
+
var param = {
|
|
274
|
+
fjzbid: value,
|
|
275
|
+
fwbz: serviceMark,
|
|
276
|
+
mkmc: moduleName,
|
|
277
|
+
ms: describe,
|
|
278
|
+
fjzbm: fileMainName,
|
|
279
|
+
|
|
280
|
+
fjid: res.data.ssbh,
|
|
281
|
+
fjmc: fileName,
|
|
282
|
+
cjsid: res.data.scyh,
|
|
283
|
+
ztm: '1' // 1 为 指定上传的附件是否默认在附件主表有效
|
|
284
|
+
};
|
|
285
|
+
(0, _NHFetch2.default)("front/zhxg-unauth/dynamic/insert", 'POST', param).then(function (res) {
|
|
286
|
+
if (res && res.code === 200) {
|
|
287
|
+
_this2.setState({ uploadedImageList: fileList });
|
|
288
|
+
_this2.handlePropsOnChange(value, fileList);
|
|
289
|
+
} else {
|
|
290
|
+
_toast2.default.fail("附件上传失败!");
|
|
291
|
+
}
|
|
292
|
+
}).catch(function () {
|
|
293
|
+
_toast2.default.fail("附件上传失败!");
|
|
294
|
+
});
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
this.removeFile = function (files, operationType, index) {
|
|
298
|
+
var uploadedImageList = _this2.state.uploadedImageList;
|
|
299
|
+
|
|
300
|
+
var file = uploadedImageList[index];
|
|
301
|
+
(0, _NHFetch2.default)("front/zhxg-unauth/dynamic/updateDel", 'POST', file.uuid).then(function (res) {
|
|
302
|
+
if (res && res.code === 200) {
|
|
303
|
+
_this2.setState({ uploadedImageList: files });
|
|
304
|
+
_this2.handlePropsOnChange(files.length === 0 ? undefined : _this2.state.value, files);
|
|
305
|
+
} else {
|
|
306
|
+
_toast2.default.fail("删除失败!");
|
|
307
|
+
}
|
|
308
|
+
}).catch(function (e) {
|
|
309
|
+
_toast2.default.fail('网络异常,删除失败');
|
|
310
|
+
});
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
this.handleChange = function (files, operationType, index) {
|
|
314
|
+
if (operationType === 'remove') {
|
|
315
|
+
_this2.removeFile(files, operationType, index);
|
|
316
|
+
//this.setState({uploadedImageList:files});
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
var saveType = _this2.props.saveType || 'file';
|
|
320
|
+
|
|
321
|
+
var file = files[files.length - 1].file;
|
|
322
|
+
var _props4 = _this2.props,
|
|
323
|
+
_props4$compressThres = _props4.compressThreshold,
|
|
324
|
+
compressThreshold = _props4$compressThres === undefined ? 5 : _props4$compressThres,
|
|
325
|
+
_props4$isPictureComp = _props4.isPictureCompress,
|
|
326
|
+
isPictureCompress = _props4$isPictureComp === undefined ? false : _props4$isPictureComp,
|
|
327
|
+
_props4$pictureQualit = _props4.pictureQuality,
|
|
328
|
+
pictureQuality = _props4$pictureQualit === undefined ? 0.92 : _props4$pictureQualit,
|
|
329
|
+
_props4$picScale = _props4.picScale,
|
|
330
|
+
picScale = _props4$picScale === undefined ? 0.9 : _props4$picScale;
|
|
331
|
+
// 设置的图片大小Max值
|
|
332
|
+
|
|
333
|
+
var MaxSize = compressThreshold * 1024 * 1024;
|
|
334
|
+
// 若需要压缩且图片大小大于Max值
|
|
335
|
+
if (isPictureCompress && file.size > MaxSize) {
|
|
336
|
+
//判断浏览器内核是否支持base64图片压缩
|
|
337
|
+
if ((typeof FileReader === 'undefined' ? 'undefined' : _typeof(FileReader)) === undefined) {
|
|
338
|
+
return file;
|
|
339
|
+
} else {
|
|
340
|
+
try {
|
|
341
|
+
// return new Promise( resolve => {
|
|
342
|
+
var fileReader = new FileReader();
|
|
343
|
+
fileReader.readAsDataURL(file);
|
|
344
|
+
fileReader.onload = function () {
|
|
345
|
+
var canvas = document.createElement('canvas');
|
|
346
|
+
var img = document.createElement('img');
|
|
347
|
+
img.src = fileReader.result;
|
|
348
|
+
img.onload = function () {
|
|
349
|
+
var ctx = canvas.getContext('2d');
|
|
350
|
+
//图片宽、高
|
|
351
|
+
var imgWidth = img.width;
|
|
352
|
+
var imgHeight = img.height;
|
|
353
|
+
var newFile = file;
|
|
354
|
+
var imageDataURL = undefined;
|
|
355
|
+
while (newFile.size > MaxSize) {
|
|
356
|
+
imgWidth = imgWidth * picScale;
|
|
357
|
+
imgHeight = imgHeight * picScale;
|
|
358
|
+
canvas.width = imgWidth;
|
|
359
|
+
canvas.height = imgHeight;
|
|
360
|
+
//清除画布
|
|
361
|
+
ctx.clearRect(0, 0, imgWidth, imgHeight);
|
|
362
|
+
//canvas绘制img
|
|
363
|
+
ctx.drawImage(img, 0, 0, imgWidth, imgHeight);
|
|
364
|
+
|
|
365
|
+
//设置图片质量,默认为0.92
|
|
366
|
+
imageDataURL = canvas.toDataURL(file.type || 'image/jpeg', pictureQuality);
|
|
367
|
+
// 去掉URL的头,并转换为byte
|
|
368
|
+
var imageBytes = window.atob(imageDataURL.split(',')[1]);
|
|
369
|
+
// 处理异常,将ascii码小于0的转换为大于0
|
|
370
|
+
var arrayBuffer = new ArrayBuffer(imageBytes.length);
|
|
371
|
+
var uint8Array = new Uint8Array(arrayBuffer);
|
|
372
|
+
for (var i = 0; i < imageBytes.length; i++) {
|
|
373
|
+
uint8Array[i] = imageBytes.charCodeAt(i);
|
|
374
|
+
}
|
|
375
|
+
var mimeType = imageDataURL.split(',')[0].match(/:(.*?);/)[1];
|
|
376
|
+
newFile = new File([uint8Array], file.name, { type: mimeType || 'image/jpeg' });
|
|
377
|
+
console.log('after compress, the file size is : ', newFile.size / 1024 / 1024 + "M");
|
|
378
|
+
// resolve(newFile);
|
|
379
|
+
// return newFile;
|
|
380
|
+
}
|
|
381
|
+
_this2.postImg(saveType, files, newFile, imageDataURL);
|
|
382
|
+
};
|
|
383
|
+
};
|
|
384
|
+
// fileReader.onerror = () => {
|
|
385
|
+
// return file;
|
|
386
|
+
// }
|
|
387
|
+
// }).then(res => {
|
|
388
|
+
// return res;
|
|
389
|
+
// })
|
|
390
|
+
} catch (error) {
|
|
391
|
+
// return file;
|
|
392
|
+
_this2.postImg(saveType, files, file, files[files.length - 1].url);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
} else {
|
|
396
|
+
// return file;
|
|
397
|
+
_this2.postImg(saveType, files, file, files[files.length - 1].url);
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
this.postImg = function (saveType, files, file, url) {
|
|
402
|
+
//判断文件是否超出最大限制
|
|
403
|
+
var flag = _this2.judgeFileSize(file);
|
|
404
|
+
if (!flag) {
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
if (saveType === 'file') {
|
|
408
|
+
//上传到文档库
|
|
409
|
+
//上传成功(success为true并且响应码为200)
|
|
410
|
+
var fileName = files[files.length - 1].file.name;
|
|
411
|
+
// let file = file;
|
|
412
|
+
var param = new FormData();
|
|
413
|
+
param.append('uuid', (0, _createUuid2.default)());
|
|
414
|
+
param.append('type', '1');
|
|
415
|
+
param.append('file', file);
|
|
416
|
+
fetch('zuul/docrepo/upload', { method: 'POST', body: param, headers: { Authorization: window.sessionStorage.getItem("access_token") } }).then(function (response) {
|
|
417
|
+
return response.json();
|
|
418
|
+
}).then(function (res) {
|
|
419
|
+
if (res && res.meta && res.meta.statusCode === 200) {
|
|
420
|
+
var newFiles = files.map(function (file) {
|
|
421
|
+
if (file.uuid === undefined) {
|
|
422
|
+
file.uuid = res.data.ssbh;
|
|
423
|
+
file.name = fileName;
|
|
424
|
+
file.url = 'zuul/docrepo/download/file?attachmentId=' + file.uuid;
|
|
425
|
+
}
|
|
426
|
+
return file;
|
|
427
|
+
});
|
|
428
|
+
_this2.handleMasterTable(res, newFiles, fileName);
|
|
429
|
+
// this.setState({ uploadedImageList: newFiles })
|
|
430
|
+
// this.handlePropsOnChange(newFiles);
|
|
431
|
+
} else {
|
|
432
|
+
_toast2.default.fail('上传失败');
|
|
433
|
+
}
|
|
434
|
+
}).catch(function () {
|
|
435
|
+
return _toast2.default.fail('图片上传失败', 1);
|
|
436
|
+
});
|
|
437
|
+
} else if (saveType === 'redis') {
|
|
438
|
+
//缓存Redis
|
|
439
|
+
//缓存成功(响应码为200)
|
|
440
|
+
// let url = files[files.length-1].url;
|
|
441
|
+
// let lastModifiedDate = files[files.length-1].file.lastModifiedDate;
|
|
442
|
+
// let fileName = files[files.length-1].file.name;
|
|
443
|
+
var lastModifiedDate = file.lastModifiedDate;
|
|
444
|
+
var _fileName = file.name;
|
|
445
|
+
var blob = _this2.dataURLtoBlob(url);
|
|
446
|
+
file = _this2.blobToFile(blob, _fileName, lastModifiedDate);
|
|
447
|
+
var _param = new FormData();
|
|
448
|
+
_param.append('redisData', _this2.props.cacheTime || 30);
|
|
449
|
+
_param.append('file', file);
|
|
450
|
+
fetch(window.baseUrl + '/proData/uploadRedis', { method: 'POST', body: _param }).then(function (response) {
|
|
451
|
+
return response.json();
|
|
452
|
+
}).then(function (res) {
|
|
453
|
+
if (res && res.code === 200) {
|
|
454
|
+
var newFiles = files.map(function (file) {
|
|
455
|
+
if (file.uuid === undefined) {
|
|
456
|
+
file.uuid = res.data;
|
|
457
|
+
file.url = window.baseUrl + redisDownloadPath + file.uuid;
|
|
458
|
+
}
|
|
459
|
+
return file;
|
|
460
|
+
});
|
|
461
|
+
_this2.setState({ uploadedImageList: newFiles });
|
|
462
|
+
_this2.handlePropsOnChange(newFiles);
|
|
463
|
+
}
|
|
464
|
+
}).catch(function () {
|
|
465
|
+
return _toast2.default.info('图片上传失败', 1);
|
|
466
|
+
});
|
|
467
|
+
} else if (saveType === 'base64') {
|
|
468
|
+
//用于保存数据库
|
|
469
|
+
// let url = files[files.length-1].url;
|
|
470
|
+
var _param2 = new FormData();
|
|
471
|
+
_param2.append('file', url);
|
|
472
|
+
fetch(_this2.props.base64UploadUrl, { method: 'POST', body: _param2 }).then(function (response) {
|
|
473
|
+
return response.json();
|
|
474
|
+
}).then(function (res) {
|
|
475
|
+
if (res && res.code === 200) {
|
|
476
|
+
var newFiles = files.map(function (file) {
|
|
477
|
+
if (file.uuid === undefined) {
|
|
478
|
+
file.uuid = res.data;
|
|
479
|
+
}
|
|
480
|
+
return file;
|
|
481
|
+
});
|
|
482
|
+
_this2.setState({ uploadedImageList: newFiles });
|
|
483
|
+
_this2.handlePropsOnChange(newFiles);
|
|
484
|
+
}
|
|
485
|
+
}).catch(function () {
|
|
486
|
+
return _toast2.default.info('图片上传失败', 1);
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
this.preview = function (index, fileList) {
|
|
492
|
+
// const file = fileList[index];
|
|
493
|
+
_this2.v = (0, _reactMobileImageViewer2.default)({
|
|
494
|
+
urls: fileList.map(function (item) {
|
|
495
|
+
return item.url;
|
|
496
|
+
}),
|
|
497
|
+
index: index
|
|
498
|
+
});
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
this.dataURLtoBlob = function (dataurl) {
|
|
502
|
+
console.log(dataurl);
|
|
503
|
+
var arr = dataurl.split(',');
|
|
504
|
+
var mime = arr[0].match(/:(.*?);/)[1];
|
|
505
|
+
var bstr = atob(arr[1]);
|
|
506
|
+
var n = bstr.length;
|
|
507
|
+
var u8arr = new Uint8Array(n);
|
|
508
|
+
while (n--) {
|
|
509
|
+
u8arr[n] = bstr.charCodeAt(n);
|
|
510
|
+
}
|
|
511
|
+
return new Blob([u8arr], { type: mime });
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
this.renderCommon = function () {
|
|
515
|
+
// 监听页面返回操作,如果是图片预览状态,就退出图片预览状态,否则进行正常的返回操作
|
|
516
|
+
return _react2.default.createElement(_reactRouterDom.Prompt, {
|
|
517
|
+
when: true,
|
|
518
|
+
message: function message(location) {
|
|
519
|
+
if (_this2.v) {
|
|
520
|
+
_this2.v.destroy();
|
|
521
|
+
_this2.v = undefined;
|
|
522
|
+
return false;
|
|
523
|
+
}
|
|
524
|
+
return true;
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
};
|
|
528
|
+
|
|
529
|
+
this.judgeFileSize = function (file) {
|
|
530
|
+
var _props5 = _this2.props,
|
|
531
|
+
_props5$maxFileSize = _props5.maxFileSize,
|
|
532
|
+
maxFileSize = _props5$maxFileSize === undefined ? 20 : _props5$maxFileSize,
|
|
533
|
+
_props5$sizeWord = _props5.sizeWord,
|
|
534
|
+
sizeWord = _props5$sizeWord === undefined ? 'M' : _props5$sizeWord;
|
|
535
|
+
|
|
536
|
+
var isOverSize = false; //是否超出文件最大限制
|
|
537
|
+
if (sizeWord.toLocaleLowerCase() === 'kb') {
|
|
538
|
+
// 若单位为kb则按kb的比较
|
|
539
|
+
var fileSize = file.size / 1024;
|
|
540
|
+
isOverSize = fileSize > maxFileSize;
|
|
541
|
+
} else {
|
|
542
|
+
var _fileSize = file.size / 1024 / 1024;
|
|
543
|
+
isOverSize = _fileSize > maxFileSize;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
if (isOverSize) {
|
|
547
|
+
_toast2.default.info('\u62B1\u6B49\uFF0C\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u6700\u5927\u4E0D\u80FD\u8D85\u8FC7' + maxFileSize + sizeWord + '!');
|
|
548
|
+
return false;
|
|
549
|
+
}
|
|
550
|
+
return true;
|
|
551
|
+
};
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
exports.default = NHImagePicker;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _list = require('antd-mobile/lib/list');
|
|
8
|
+
|
|
9
|
+
var _list2 = _interopRequireDefault(_list);
|
|
10
|
+
|
|
11
|
+
var _radio = require('antd-mobile/lib/radio');
|
|
12
|
+
|
|
13
|
+
var _radio2 = _interopRequireDefault(_radio);
|
|
14
|
+
|
|
15
|
+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
16
|
+
|
|
17
|
+
require('antd-mobile/lib/list/style/css');
|
|
18
|
+
|
|
19
|
+
require('antd-mobile/lib/radio/style/css');
|
|
20
|
+
|
|
21
|
+
var _react = require('react');
|
|
22
|
+
|
|
23
|
+
var _react2 = _interopRequireDefault(_react);
|
|
24
|
+
|
|
25
|
+
var _propTypes = require('prop-types');
|
|
26
|
+
|
|
27
|
+
var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
28
|
+
|
|
29
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
30
|
+
|
|
31
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
32
|
+
|
|
33
|
+
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
34
|
+
|
|
35
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /*
|
|
36
|
+
* @Description:移动端RadioGroup,方便对一组Radio进行处理
|
|
37
|
+
* @Author: zengweijin
|
|
38
|
+
* @Date: 2019-07-12 11:50:25
|
|
39
|
+
* @LastEditors : zengweijin
|
|
40
|
+
* @LastEditTime : 2020-01-07 14:08:31
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
var RadioGroup = function (_React$Component) {
|
|
45
|
+
_inherits(RadioGroup, _React$Component);
|
|
46
|
+
|
|
47
|
+
function RadioGroup(props) {
|
|
48
|
+
_classCallCheck(this, RadioGroup);
|
|
49
|
+
|
|
50
|
+
var _this = _possibleConstructorReturn(this, (RadioGroup.__proto__ || Object.getPrototypeOf(RadioGroup)).call(this, props));
|
|
51
|
+
|
|
52
|
+
_this.state = {
|
|
53
|
+
value: props.value || props.defaultValue || ''
|
|
54
|
+
};
|
|
55
|
+
return _this;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
_createClass(RadioGroup, [{
|
|
59
|
+
key: 'render',
|
|
60
|
+
value: function render() {
|
|
61
|
+
var _this2 = this;
|
|
62
|
+
|
|
63
|
+
var _props = this.props,
|
|
64
|
+
options = _props.options,
|
|
65
|
+
disabled = _props.disabled,
|
|
66
|
+
defaultValue = _props.defaultValue,
|
|
67
|
+
value = _props.value,
|
|
68
|
+
_onChange = _props.onChange,
|
|
69
|
+
label = _props.label;
|
|
70
|
+
|
|
71
|
+
var RadioItem = _radio2.default.RadioItem;
|
|
72
|
+
return _react2.default.createElement(
|
|
73
|
+
'div',
|
|
74
|
+
null,
|
|
75
|
+
_react2.default.createElement(
|
|
76
|
+
_list2.default,
|
|
77
|
+
{ renderHeader: function renderHeader() {
|
|
78
|
+
return label;
|
|
79
|
+
} },
|
|
80
|
+
options.map(function (item) {
|
|
81
|
+
return _react2.default.createElement(
|
|
82
|
+
RadioItem,
|
|
83
|
+
{
|
|
84
|
+
key: item.value,
|
|
85
|
+
defaultChecked: item.value === defaultValue,
|
|
86
|
+
checked: item.value === (value || _this2.state.value),
|
|
87
|
+
disabled: disabled || item.disabled,
|
|
88
|
+
onChange: function onChange(e) {
|
|
89
|
+
if (!('value' in _this2.props)) {
|
|
90
|
+
_this2.setState({ value: item.value });
|
|
91
|
+
}
|
|
92
|
+
if (_onChange) {
|
|
93
|
+
_onChange(item.value, item.label, e);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
item.label
|
|
98
|
+
);
|
|
99
|
+
})
|
|
100
|
+
)
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
}]);
|
|
104
|
+
|
|
105
|
+
return RadioGroup;
|
|
106
|
+
}(_react2.default.Component);
|
|
107
|
+
|
|
108
|
+
//属性检查
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
exports.default = RadioGroup;
|
|
112
|
+
RadioGroup.propTypes = {
|
|
113
|
+
disabled: _propTypes2.default.bool, //是否禁用
|
|
114
|
+
defaultValue: _propTypes2.default.any, //默认选中项
|
|
115
|
+
value: _propTypes2.default.any, //初始值
|
|
116
|
+
onChange: _propTypes2.default.func, //选择完成后的回调
|
|
117
|
+
options: _propTypes2.default.arrayOf(_propTypes2.default.object) // radio数组Array<{ label: string value: string disabled?: boolean }>
|
|
118
|
+
};
|