dlt-for-react 1.1.3 → 1.1.4

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.
Files changed (187) hide show
  1. package/README.md +4 -0
  2. package/lib/index.js +7 -1
  3. package/lib/layouts/Top/index.js +1 -1
  4. package/lib/layouts/layout/index.js +77 -31
  5. package/lib/layouts/mixTop/index.js +3 -3
  6. package/lib/utils/createUuid.js +31 -11
  7. package/lib/utils/getLoginUser.js +1 -1
  8. package/lib/utils/getSize.js +11 -2
  9. package/lib/utils/index.js +35 -2
  10. package/package.json +1 -1
  11. package/lib/components/Button/index.js +0 -79
  12. package/lib/components/NHAuditPanel/config/Axios.js +0 -263
  13. package/lib/components/NHAuditPanel/config/api.js +0 -479
  14. package/lib/components/NHAuditPanel/config/data.js +0 -156
  15. package/lib/components/NHAuditPanel/config/typeMap.js +0 -1234
  16. package/lib/components/NHAuditPanel/config/uiValidate.js +0 -92
  17. package/lib/components/NHAuditPanel/index.js +0 -413
  18. package/lib/components/NHAuditPanel/node.js +0 -619
  19. package/lib/components/NHCascader/index.js +0 -355
  20. package/lib/components/NHCheckboxGroup/index.js +0 -135
  21. package/lib/components/NHDynamicFormShow/baseInfo/index.js +0 -194
  22. package/lib/components/NHDynamicFormShow/custom/index.js +0 -553
  23. package/lib/components/NHDynamicFormShow/customModule/common/CommonMethod.js +0 -43
  24. package/lib/components/NHDynamicFormShow/customModule/czxy/qgzx/EditForm.js +0 -1113
  25. package/lib/components/NHDynamicFormShow/customModule/czxy/qgzx/index.js +0 -263
  26. package/lib/components/NHDynamicFormShow/customModule/czxy/xfjm/EditForm.js +0 -880
  27. package/lib/components/NHDynamicFormShow/customModule/czxy/xfjm/index.js +0 -171
  28. package/lib/components/NHDynamicFormShow/customModule/czxy/zxj/EditForm.js +0 -865
  29. package/lib/components/NHDynamicFormShow/customModule/czxy/zxj/index.js +0 -138
  30. package/lib/components/NHDynamicFormShow/customModule/eszy/zsxxhd/EditForm.js +0 -571
  31. package/lib/components/NHDynamicFormShow/customModule/eszy/zsxxhd/index.js +0 -147
  32. package/lib/components/NHDynamicFormShow/customModule/eszy/zybjtz/EditForm.js +0 -474
  33. package/lib/components/NHDynamicFormShow/customModule/eszy/zybjtz/index.js +0 -139
  34. package/lib/components/NHDynamicFormShow/customModule/gnyxy/cqzg/EditForm.js +0 -506
  35. package/lib/components/NHDynamicFormShow/customModule/gnyxy/cqzg/index.js +0 -143
  36. package/lib/components/NHDynamicFormShow/customModule/gnyxy/gwsb/EditForm.js +0 -1074
  37. package/lib/components/NHDynamicFormShow/customModule/gnyxy/gwsb/index.js +0 -172
  38. package/lib/components/NHDynamicFormShow/customModule/gnyxy/qjgl/EditForm.js +0 -927
  39. package/lib/components/NHDynamicFormShow/customModule/gnyxy/qjgl/index.js +0 -195
  40. package/lib/components/NHDynamicFormShow/customModule/gnyxy/sxsqj/EditForm.js +0 -1064
  41. package/lib/components/NHDynamicFormShow/customModule/gnyxy/sxsqj/index.js +0 -183
  42. package/lib/components/NHDynamicFormShow/customModule/hblgxy/jxj/EditForm.js +0 -763
  43. package/lib/components/NHDynamicFormShow/customModule/hblgxy/jxj/index.js +0 -137
  44. package/lib/components/NHDynamicFormShow/customModule/hblgxy/lzjxj/EditForm.js +0 -819
  45. package/lib/components/NHDynamicFormShow/customModule/hblgxy/lzjxj/index.js +0 -137
  46. package/lib/components/NHDynamicFormShow/customModule/hblgxy/qgzx/EditForm.js +0 -700
  47. package/lib/components/NHDynamicFormShow/customModule/hblgxy/qgzx/index.js +0 -162
  48. package/lib/components/NHDynamicFormShow/customModule/hblgxy/xsqj/EditForm.js +0 -743
  49. package/lib/components/NHDynamicFormShow/customModule/hblgxy/xsqj/index.js +0 -177
  50. package/lib/components/NHDynamicFormShow/customModule/hblgxy/zxj/EditForm.js +0 -848
  51. package/lib/components/NHDynamicFormShow/customModule/hblgxy/zxj/index.js +0 -138
  52. package/lib/components/NHDynamicFormShow/customModule/hljwgy/qjgl/EditForm.js +0 -777
  53. package/lib/components/NHDynamicFormShow/customModule/hljwgy/qjgl/index.js +0 -161
  54. package/lib/components/NHDynamicFormShow/customModule/hljwgy/xjgl/EditForm.js +0 -706
  55. package/lib/components/NHDynamicFormShow/customModule/hljwgy/xjgl/index.js +0 -130
  56. package/lib/components/NHDynamicFormShow/customModule/jhysxy/cfjcsq/cfjcEditForm.js +0 -413
  57. package/lib/components/NHDynamicFormShow/customModule/jhysxy/cfjcsq/index.js +0 -135
  58. package/lib/components/NHDynamicFormShow/customModule/jhysxy/xsqj/EditForm.js +0 -1013
  59. package/lib/components/NHDynamicFormShow/customModule/jhysxy/xsqj/index.js +0 -175
  60. package/lib/components/NHDynamicFormShow/customModule/jjrlx/EditForm.js +0 -1345
  61. package/lib/components/NHDynamicFormShow/customModule/jjrlx/index.js +0 -274
  62. package/lib/components/NHDynamicFormShow/customModule/jxj/EditForm.js +0 -669
  63. package/lib/components/NHDynamicFormShow/customModule/jxj/index.js +0 -134
  64. package/lib/components/NHDynamicFormShow/customModule/jxsl/fqkns/EditForm.js +0 -378
  65. package/lib/components/NHDynamicFormShow/customModule/jxsl/fqkns/index.js +0 -120
  66. package/lib/components/NHDynamicFormShow/customModule/jxsl/xwryfjjd/EditForm.js +0 -638
  67. package/lib/components/NHDynamicFormShow/customModule/jxsl/xwryfjjd/index.js +0 -133
  68. package/lib/components/NHDynamicFormShow/customModule/qgzx/EditForm.js +0 -965
  69. package/lib/components/NHDynamicFormShow/customModule/qgzx/index.js +0 -237
  70. package/lib/components/NHDynamicFormShow/customModule/qjgl/EditForm.js +0 -823
  71. package/lib/components/NHDynamicFormShow/customModule/qjgl/index.js +0 -188
  72. package/lib/components/NHDynamicFormShow/customModule/rcgl/jqlssq/EditForm.js +0 -401
  73. package/lib/components/NHDynamicFormShow/customModule/rcgl/jqlssq/index.js +0 -472
  74. package/lib/components/NHDynamicFormShow/customModule/rcgl/tssq/EditForm.js +0 -304
  75. package/lib/components/NHDynamicFormShow/customModule/rcgl/tssq/NHCascader/index.js +0 -375
  76. package/lib/components/NHDynamicFormShow/customModule/rcgl/tssq/NHInputPicker/RadioGroup.js +0 -118
  77. package/lib/components/NHDynamicFormShow/customModule/rcgl/tssq/NHInputPicker/index.js +0 -62
  78. package/lib/components/NHDynamicFormShow/customModule/rcgl/tssq/NHInputPicker/input-const.js +0 -55
  79. package/lib/components/NHDynamicFormShow/customModule/rcgl/tssq/NHInputPicker/render.js +0 -1238
  80. package/lib/components/NHDynamicFormShow/customModule/rcgl/tssq/index.js +0 -375
  81. package/lib/components/NHDynamicFormShow/customModule/rych/collective/EditForm.js +0 -554
  82. package/lib/components/NHDynamicFormShow/customModule/rych/collective/index.js +0 -130
  83. package/lib/components/NHDynamicFormShow/customModule/rych/personal/EditForm.js +0 -542
  84. package/lib/components/NHDynamicFormShow/customModule/rych/personal/index.js +0 -133
  85. package/lib/components/NHDynamicFormShow/customModule/sxgy/rych/collective/EditForm.js +0 -575
  86. package/lib/components/NHDynamicFormShow/customModule/sxgy/rych/collective/index.js +0 -130
  87. package/lib/components/NHDynamicFormShow/customModule/sxgy/rych/personal/EditForm.js +0 -563
  88. package/lib/components/NHDynamicFormShow/customModule/sxgy/rych/personal/index.js +0 -133
  89. package/lib/components/NHDynamicFormShow/customModule/whcz/qjgl/EditForm.js +0 -745
  90. package/lib/components/NHDynamicFormShow/customModule/whcz/qjgl/index.js +0 -164
  91. package/lib/components/NHDynamicFormShow/customModule/whcz/rccrxy/EditForm.js +0 -587
  92. package/lib/components/NHDynamicFormShow/customModule/whcz/rccrxy/index.js +0 -143
  93. package/lib/components/NHDynamicFormShow/customModule/whdlqjgl/EditForm.js +0 -743
  94. package/lib/components/NHDynamicFormShow/customModule/whdlqjgl/index.js +0 -172
  95. package/lib/components/NHDynamicFormShow/customModule/whgc/jjrlx/EditForm.js +0 -1410
  96. package/lib/components/NHDynamicFormShow/customModule/whgc/jjrlx/index.js +0 -274
  97. package/lib/components/NHDynamicFormShow/customModule/whgc/jxj/EditForm.js +0 -755
  98. package/lib/components/NHDynamicFormShow/customModule/whgc/jxj/index.js +0 -130
  99. package/lib/components/NHDynamicFormShow/customModule/whgc/qjgl/EditForm.js +0 -814
  100. package/lib/components/NHDynamicFormShow/customModule/whgc/qjgl/index.js +0 -188
  101. package/lib/components/NHDynamicFormShow/customModule/whgc/zxj/EditForm.js +0 -769
  102. package/lib/components/NHDynamicFormShow/customModule/whgc/zxj/index.js +0 -130
  103. package/lib/components/NHDynamicFormShow/customModule/whgcrych/EditForm.js +0 -1004
  104. package/lib/components/NHDynamicFormShow/customModule/whgcrych/index.js +0 -126
  105. package/lib/components/NHDynamicFormShow/customModule/whtl/jsrzsq/EditForm.js +0 -503
  106. package/lib/components/NHDynamicFormShow/customModule/whtl/jsrzsq/index.js +0 -149
  107. package/lib/components/NHDynamicFormShow/customModule/whtlyhk/EditForm.js +0 -379
  108. package/lib/components/NHDynamicFormShow/customModule/whtlyhk/index.js +0 -148
  109. package/lib/components/NHDynamicFormShow/customModule/whtlzxj/EditForm.js +0 -748
  110. package/lib/components/NHDynamicFormShow/customModule/whtlzxj/index.js +0 -135
  111. package/lib/components/NHDynamicFormShow/customModule/whtlzy/jxj/EditForm.js +0 -762
  112. package/lib/components/NHDynamicFormShow/customModule/whtlzy/jxj/index.js +0 -134
  113. package/lib/components/NHDynamicFormShow/customModule/wjcf/cfjc/cfjcEditForm.js +0 -682
  114. package/lib/components/NHDynamicFormShow/customModule/wjcf/cfjc/index.js +0 -135
  115. package/lib/components/NHDynamicFormShow/customModule/wjcf/wjsb/index.js +0 -152
  116. package/lib/components/NHDynamicFormShow/customModule/wjcf/wjsb/wjsbEditForm.js +0 -783
  117. package/lib/components/NHDynamicFormShow/customModule/zxj/EditForm.js +0 -764
  118. package/lib/components/NHDynamicFormShow/customModule/zxj/index.js +0 -138
  119. package/lib/components/NHDynamicFormShow/customModule/zzsd/cfjcsq/cfjcEditForm.js +0 -677
  120. package/lib/components/NHDynamicFormShow/customModule/zzsd/cfjcsq/index.js +0 -138
  121. package/lib/components/NHDynamicFormShow/customModule/zzsd/qjgl/EditForm.js +0 -1173
  122. package/lib/components/NHDynamicFormShow/customModule/zzsd/qjgl/index.js +0 -242
  123. package/lib/components/NHDynamicFormShow/customModule/zzsd/rcgl/rcxwgrdj/IndividualRegistForm.js +0 -862
  124. package/lib/components/NHDynamicFormShow/customModule/zzsd/rcgl/rcxwgrdj/IndividualRegistIndex.js +0 -201
  125. package/lib/components/NHDynamicFormShow/customModule/zzsd/stuinfo/messageInfo.js +0 -196
  126. package/lib/components/NHDynamicFormShow/customModule/zzsd/wjsb/index.js +0 -167
  127. package/lib/components/NHDynamicFormShow/customModule/zzsd/wjsb/wjsbEditForm.js +0 -1096
  128. package/lib/components/NHDynamicFormShow/index.js +0 -647
  129. package/lib/components/NHDynamicFormShow/oneOnMany/cardForm/cardItem/index.js +0 -279
  130. package/lib/components/NHDynamicFormShow/oneOnMany/cardForm/index.js +0 -206
  131. package/lib/components/NHDynamicFormShow/oneOnMany/index.js +0 -419
  132. package/lib/components/NHDynamicFormShow/oneOnOne/EditForm.js +0 -401
  133. package/lib/components/NHDynamicFormShow/oneOnOne/index.js +0 -271
  134. package/lib/components/NHImagePicker/index.js +0 -554
  135. package/lib/components/NHInputPicker/RadioGroup.js +0 -118
  136. package/lib/components/NHInputPicker/index.js +0 -62
  137. package/lib/components/NHInputPicker/input-const.js +0 -55
  138. package/lib/components/NHInputPicker/render.js +0 -1271
  139. package/lib/components/NHListView/index.js +0 -374
  140. package/lib/components/NHMapGeolocation/index.js +0 -537
  141. package/lib/components/NHMapGeolocation/initMap/initGdMap.js +0 -104
  142. package/lib/components/NHMapGeolocation/initMap/initTencentMap.js +0 -138
  143. package/lib/components/NHMapGeolocation/style.js +0 -51
  144. package/lib/components/NHMultiSelect/index.js +0 -272
  145. package/lib/components/NHRadioGroup/index.js +0 -118
  146. package/lib/components/NHSelect/index.js +0 -364
  147. package/lib/components/NHTreeMenu/index.js +0 -126
  148. package/lib/components/NHTreeMenu/treeNode.js +0 -164
  149. package/lib/components/StuSelector/index.js +0 -611
  150. package/lib/layouts/KyInputPicker/edit-page.js +0 -585
  151. package/lib/layouts/KyInputPicker/index.js +0 -220
  152. package/lib/layouts/KyInputPicker/input-const.js +0 -134
  153. package/lib/layouts/KyInputPicker/render.js +0 -2477
  154. package/lib/layouts/KyInputPicker/setting-checkbox.js +0 -850
  155. package/lib/layouts/KyInputPicker/setting-datepicker.js +0 -430
  156. package/lib/layouts/KyInputPicker/setting-datetimepicker.js +0 -443
  157. package/lib/layouts/KyInputPicker/setting-input.js +0 -555
  158. package/lib/layouts/KyInputPicker/setting-inputNumber.js +0 -612
  159. package/lib/layouts/KyInputPicker/setting-monthpicker.js +0 -434
  160. package/lib/layouts/KyInputPicker/setting-multiSelect.js +0 -532
  161. package/lib/layouts/KyInputPicker/setting-nhcascader.js +0 -584
  162. package/lib/layouts/KyInputPicker/setting-old-upload.js +0 -428
  163. package/lib/layouts/KyInputPicker/setting-radio.js +0 -468
  164. package/lib/layouts/KyInputPicker/setting-rangepicker.js +0 -466
  165. package/lib/layouts/KyInputPicker/setting-select.js +0 -534
  166. package/lib/layouts/KyInputPicker/setting-stu-selector.js +0 -507
  167. package/lib/layouts/KyInputPicker/setting-switch.js +0 -274
  168. package/lib/layouts/KyInputPicker/setting-tea-selector.js +0 -507
  169. package/lib/layouts/KyInputPicker/setting-textarea.js +0 -619
  170. package/lib/layouts/KyInputPicker/setting-timepicker.js +0 -437
  171. package/lib/layouts/KyInputPicker/setting-upload.js +0 -766
  172. package/lib/layouts/KyModal/buildTitle.js +0 -81
  173. package/lib/layouts/KyModal/dragM.js +0 -127
  174. package/lib/layouts/KyModal/index.js +0 -321
  175. package/lib/layouts/KyPreview/index.js +0 -219
  176. package/lib/layouts/KyUpload/index.js +0 -1155
  177. package/lib/utils/browserJudge.js +0 -33
  178. package/lib/utils/dynamicLoadCss.js +0 -14
  179. package/lib/utils/dynamicLoadJs.js +0 -21
  180. package/lib/utils/getStyle.js +0 -26
  181. package/lib/utils/getSuitHeight.js +0 -49
  182. package/lib/utils/hasAuth.js +0 -11
  183. package/lib/utils/loadJS.js +0 -40
  184. /package/lib/layouts/{login → Login}/index-pre.js +0 -0
  185. /package/lib/layouts/{login → Login}/index.js +0 -0
  186. /package/lib/layouts/{login → Login}/login.js +0 -0
  187. /package/lib/layouts/{login → Login}/lyPassword.js +0 -0
@@ -1,1155 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _getLoginUser2 = require('xgui-for-react/lib/utils/getLoginUser');
8
-
9
- var _getLoginUser3 = _interopRequireDefault(_getLoginUser2);
10
-
11
- var _getIterator2 = require('babel-runtime/core-js/get-iterator');
12
-
13
- var _getIterator3 = _interopRequireDefault(_getIterator2);
14
-
15
- var _spin = require('antd/lib/spin');
16
-
17
- var _spin2 = _interopRequireDefault(_spin);
18
-
19
- var _upload = require('antd/lib/upload');
20
-
21
- var _upload2 = _interopRequireDefault(_upload);
22
-
23
- var _button = require('antd/lib/button');
24
-
25
- var _button2 = _interopRequireDefault(_button);
26
-
27
- var _icon = require('antd/lib/icon');
28
-
29
- var _icon2 = _interopRequireDefault(_icon);
30
-
31
- var _regenerator = require('babel-runtime/regenerator');
32
-
33
- var _regenerator2 = _interopRequireDefault(_regenerator);
34
-
35
- var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
36
-
37
- var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
38
-
39
- var _message2 = require('antd/lib/message');
40
-
41
- var _message3 = _interopRequireDefault(_message2);
42
-
43
- var _NHFetch2 = require('xgui-for-react/lib/utils/NHFetch');
44
-
45
- var _NHFetch3 = _interopRequireDefault(_NHFetch2);
46
-
47
- var _stringify = require('babel-runtime/core-js/json/stringify');
48
-
49
- var _stringify2 = _interopRequireDefault(_stringify);
50
-
51
- var _createUuid2 = require('xgui-for-react/lib/utils/createUuid');
52
-
53
- var _createUuid3 = _interopRequireDefault(_createUuid2);
54
-
55
- var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
56
-
57
- var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
58
-
59
- var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
60
-
61
- var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
62
-
63
- var _createClass2 = require('babel-runtime/helpers/createClass');
64
-
65
- var _createClass3 = _interopRequireDefault(_createClass2);
66
-
67
- var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
68
-
69
- var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
70
-
71
- var _inherits2 = require('babel-runtime/helpers/inherits');
72
-
73
- var _inherits3 = _interopRequireDefault(_inherits2);
74
-
75
- var _promise = require('babel-runtime/core-js/promise');
76
-
77
- var _promise2 = _interopRequireDefault(_promise);
78
-
79
- require('antd/lib/spin/style');
80
-
81
- require('antd/lib/upload/style');
82
-
83
- require('antd/lib/button/style');
84
-
85
- require('antd/lib/icon/style');
86
-
87
- require('antd/lib/message/style');
88
-
89
- var _react = require('react');
90
-
91
- var _react2 = _interopRequireDefault(_react);
92
-
93
- var _classnames = require('classnames');
94
-
95
- var _classnames2 = _interopRequireDefault(_classnames);
96
-
97
- var _KyModal = require('../KyModal');
98
-
99
- var _KyModal2 = _interopRequireDefault(_KyModal);
100
-
101
- var _KyPreview = require('../KyPreview');
102
-
103
- var _KyPreview2 = _interopRequireDefault(_KyPreview);
104
-
105
- require('../../../assets/components/KyUpload/index.less');
106
-
107
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
108
-
109
- var downloadPrefix = 'zuul/docrepo/download/file';
110
-
111
-
112
- /**
113
- * 文件上传路径:
114
- * file模式:zuul/docrepo/upload
115
- * redis模式:${baseUrl}/proData/uploadRedis
116
- * 文件下载路径:
117
- * file模式:zuul/docrepo/download/file?attachmentId={uuid}
118
- * redis模式:${baseUrl}/proData/downloadRedis
119
- * 文件删除路径:
120
- * ${baseUrl}/dynamic/updateDel
121
- */
122
-
123
- function getBase64(file) {
124
- return new _promise2.default(function (resolve, reject) {
125
- var reader = new FileReader();
126
- reader.readAsDataURL(file);
127
- reader.onload = function () {
128
- return resolve(reader.result);
129
- };
130
- reader.onerror = function (error) {
131
- return reject(error);
132
- };
133
- });
134
- }
135
-
136
- var xtglUrl = undefined.props.baseUrl ? undefined.props.baseUrl : 'api/ky-core';
137
-
138
- //pageOffice附件(Office文档)预览接口url(参数:attachmentId(必填),openType(非必填))
139
- var previewOfficeUrl = xtglUrl + '/pageoffice/docShow';
140
-
141
- //pdf预览url(参数:attachmentId(必填))
142
- var previewPdfUrl = xtglUrl + '/pageoffice/preview/pdf';
143
-
144
- //pageOffice正文新增与编辑接口url(参数:docId(必填),openType(非必填),templateId(非必填))
145
- var docUrl = 'api/pageoffice/docPageOffice/docAddOrShow';
146
-
147
- var KyUpload = function (_React$Component) {
148
- (0, _inherits3.default)(KyUpload, _React$Component);
149
-
150
- function KyUpload(props) {
151
- (0, _classCallCheck3.default)(this, KyUpload);
152
-
153
- var _this = (0, _possibleConstructorReturn3.default)(this, (KyUpload.__proto__ || (0, _getPrototypeOf2.default)(KyUpload)).call(this, props));
154
-
155
- _initialiseProps.call(_this);
156
-
157
- var value = props.value || props.defaultValue;
158
- _this.state = {
159
- fileList: [], //上传的文件
160
- value: value !== undefined && value !== null && value.trim() !== '' ? value : (0, _createUuid3.default)(), //传了附件主表id,查询附件明细
161
- imageVisible: false,
162
- previewFile: '',
163
- fileName: '',
164
- spinLoading: false, //加载中标识
165
- rotateDeg: 0, //旋转角度
166
- KY_FJFWBZ: 'http://192.168.35.210:1101', //附件服务地址
167
- KY_FJYLBZ: 'http://192.168.35.131:8012' //附件预览服务地址
168
- };
169
- return _this;
170
- }
171
- //设置可以传递参数的默认值
172
-
173
-
174
- (0, _createClass3.default)(KyUpload, [{
175
- key: 'componentWillReceiveProps',
176
- value: function componentWillReceiveProps(nextProps) {
177
- var _this2 = this;
178
-
179
- if (this.props.uploadType === 'file') {
180
- var _props = this.props,
181
- serviceMark = _props.serviceMark,
182
- moduleName = _props.moduleName;
183
-
184
- if (serviceMark && moduleName) {
185
- if ('value' in nextProps) {
186
- var value = nextProps.value;
187
- if ((0, _stringify2.default)(value) === '[]' || typeof value === 'undefined' || typeof value === 'string' && value.trim() === '' || value === null) {
188
- this.setState({ fileList: [] });
189
- } else {
190
- if (value !== this.state.value) {
191
- this.setState({ value: value, fileList: [] });
192
- var t = new Date().getTime();
193
- // 获取动态文件
194
- (0, _NHFetch3.default)(xtglUrl + '/dynamic/' + value + '/getDetailed', 'GET', t).then(function (res) {
195
- if (res && res.data && res.data.length > 0) {
196
- _this2.handleFileList(res.data);
197
- }
198
- });
199
- }
200
- }
201
- }
202
- } else {
203
- _message3.default.error('服务标志和模块名称不能为空');
204
- }
205
- }
206
- }
207
-
208
- //在组件挂载之前调用一次。如果在这个函数里面调用setState,本次的render函数可以看到更新后的state,并且只渲染一次。
209
-
210
- }, {
211
- key: 'UNSAFE_componentWillMount',
212
- value: function UNSAFE_componentWillMount() {
213
- var _this3 = this;
214
-
215
- this.setState({ fileList: [] });
216
- if (this.props.uploadType === 'file') {
217
- var _props2 = this.props,
218
- serviceMark = _props2.serviceMark,
219
- moduleName = _props2.moduleName,
220
- newValue = _props2.value;
221
-
222
- if (serviceMark && moduleName) {
223
- var value = this.state.value;
224
- if (newValue !== value) return;
225
- var t = new Date().getTime();
226
- (0, _NHFetch3.default)(xtglUrl + '/dynamic/' + value + '/getDetailed', 'GET', t).then(function (res) {
227
- if (res && res.data && res.data.length > 0) {
228
- _this3.handleFileList(res.data);
229
- }
230
- });
231
- } else {
232
- _message3.default.error('服务标志和模块名称不能为空');
233
- }
234
- }
235
- if (!window.POBrowser) {
236
- // 检测是否有引入pageoffice相关的js
237
- // 引入pageoffice相关的js
238
- // dynamicLoadJs(xtglUrl + '/jquery.min.js');
239
- // dynamicLoadJs(xtglUrl + '/pageoffice.js');
240
- }
241
- }
242
-
243
- //在组件挂载之后调用一次。
244
-
245
- }, {
246
- key: 'componentDidMount',
247
- value: function () {
248
- var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
249
- var params, res, _ref2, KY_FJFWBZ, KY_FJYLBZ;
250
-
251
- return _regenerator2.default.wrap(function _callee$(_context) {
252
- while (1) {
253
- switch (_context.prev = _context.next) {
254
- case 0:
255
- params = ['KY_FJFWBZ', 'KY_FJYLBZ'];
256
- _context.next = 3;
257
- return (0, _NHFetch3.default)(xtglUrl + '/common/parameters/get', 'POST', params);
258
-
259
- case 3:
260
- res = _context.sent;
261
-
262
- if (!(res && res.code !== 200)) {
263
- _context.next = 6;
264
- break;
265
- }
266
-
267
- return _context.abrupt('return');
268
-
269
- case 6:
270
- _ref2 = res.data || {}, KY_FJFWBZ = _ref2.KY_FJFWBZ, KY_FJYLBZ = _ref2.KY_FJYLBZ;
271
-
272
- this.setState({ KY_FJFWBZ: KY_FJFWBZ, KY_FJYLBZ: KY_FJYLBZ });
273
-
274
- case 8:
275
- case 'end':
276
- return _context.stop();
277
- }
278
- }
279
- }, _callee, this);
280
- }));
281
-
282
- function componentDidMount() {
283
- return _ref.apply(this, arguments);
284
- }
285
-
286
- return componentDidMount;
287
- }()
288
-
289
- //处理fileList
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
- // 图片旋转90度
319
-
320
- }, {
321
- key: 'render',
322
- value: function render() {
323
- var _this4 = this;
324
-
325
- var baseUrl = this.props.baseUrl || window.baseUrl;
326
- var action = this.props.uploadType === 'file' ? 'zuul/docrepo/upload' : baseUrl + '/proData/uploadRedis?fileName=' + this.state.fileName;
327
- var _state = this.state,
328
- imageVisible = _state.imageVisible,
329
- previewFile = _state.previewFile,
330
- fileList = _state.fileList,
331
- rotateDeg = _state.rotateDeg,
332
- fileType = _state.fileType;
333
-
334
- var showUploadList = {
335
- showDownloadIcon: this.props.uploadType === 'file' ? true : false
336
- };
337
- var _props3 = this.props,
338
- _props3$templateList = _props3.templateList,
339
- templateList = _props3$templateList === undefined ? [] : _props3$templateList,
340
- _props3$accept = _props3.accept,
341
- accept = _props3$accept === undefined ? '*/*' : _props3$accept,
342
- image = _props3.image,
343
- fileCountLimit = _props3.fileCountLimit,
344
- _props3$disableDelete = _props3.disableDelete,
345
- disableDelete = _props3$disableDelete === undefined ? false : _props3$disableDelete,
346
- fileView = _props3.fileView;
347
-
348
- var uploadButton = image ? _react2.default.createElement(
349
- 'div',
350
- null,
351
- _react2.default.createElement(_icon2.default, { type: 'plus' })
352
- ) : _react2.default.createElement(
353
- _button2.default,
354
- { disabled: this.props.disabled },
355
- _react2.default.createElement(_icon2.default, { type: 'upload' }),
356
- ' \u70B9\u51FB\u4E0A\u4F20'
357
- );
358
- if (fileList.length >= fileCountLimit) {
359
- uploadButton = null;
360
- }
361
- var maxHeight = window.screen.height * 2 / 3;
362
- return _react2.default.createElement(
363
- 'div',
364
- { className: (0, _classnames2.default)('ky-upload', disableDelete ? 'nhUpload-removeDelete' : '') },
365
- this.props.isEdit === true ? _react2.default.createElement(
366
- 'div',
367
- null,
368
- _react2.default.createElement(
369
- _upload2.default,
370
- {
371
- className: fileView ? 'file-view' : '',
372
- name: 'file',
373
- accept: accept,
374
- action: action,
375
- beforeUpload: this.beforeUpload,
376
- transformFile: this.transformFile,
377
- listType: this.props.listType,
378
- onChange: this.handleChange,
379
- disabled: this.props.disabled,
380
- data: this.requestData(),
381
- fileList: fileList,
382
- onPreview: this.handlePreview,
383
- onDownload: this.handleDownload,
384
- showUploadList: showUploadList,
385
- multiple: this.props.multiple
386
- },
387
- uploadButton,
388
- _react2.default.createElement(
389
- 'p',
390
- {
391
- className: 'kyUpload-hint',
392
- style: { display: this.props.hideTips ? 'none' : 'block' }
393
- },
394
- this.props.tips
395
- )
396
- ),
397
- templateList.map(function (item) {
398
- return _react2.default.createElement(
399
- 'a',
400
- { key: item.uuid, href: downloadPrefix + '?attachmentId=' + item.uuid },
401
- item.name
402
- );
403
- }),
404
- this.state.spinLoading && _react2.default.createElement(_spin2.default, null)
405
- ) : _react2.default.createElement(_upload2.default, {
406
- className: fileView ? 'file-view' : '',
407
- name: 'file',
408
- accept: accept,
409
- action: action,
410
- beforeUpload: this.beforeUpload,
411
- transformFile: this.transformFile,
412
- listType: this.props.listType,
413
- disabled: true,
414
- data: this.requestData(),
415
- fileList: fileList,
416
- onPreview: this.handlePreview,
417
- onDownload: this.handleDownload,
418
- showUploadList: showUploadList,
419
- multiple: this.props.multiple
420
- }),
421
- imageVisible && _react2.default.createElement(_KyPreview2.default, {
422
- fileType: fileType,
423
- previewFile: previewFile,
424
- visible: imageVisible,
425
- height: maxHeight * 0.8,
426
- onCancel: this.handleCancel
427
- }),
428
- _react2.default.createElement(
429
- _KyModal2.default,
430
- {
431
- ref: 'kyModal',
432
- title: '\u9644\u4EF6\u9884\u89C8',
433
- maxSize: true,
434
- footer: [{
435
- text: '关闭',
436
- type: 'default',
437
- onClick: function onClick() {
438
- _this4.refs.kyModal.close();
439
- }
440
- }]
441
- },
442
- _react2.default.createElement(_KyPreview2.default, {
443
- fileType: fileType,
444
- previewFile: previewFile,
445
- visible: true,
446
- height: maxHeight * 0.8,
447
- onCancel: this.handleCancel
448
- })
449
- ),
450
- _react2.default.createElement(
451
- 'style',
452
- { jsx: 'true', global: 'true' },
453
- '\n .ant-upload-list-picture .ant-upload-list-item-name,\n .ant-upload-list-picture-card .ant-upload-list-item-name {\n color: #40a9ff;\n cursor: pointer;\n }\n // .ant-upload-list-item-info svg {\n // display: none;\n // }\n '
454
- )
455
- );
456
- }
457
- }]);
458
- return KyUpload;
459
- }(_react2.default.Component);
460
-
461
- KyUpload.defaultProps = {
462
- multiple: false, //是否支持上传多个文件,默认false
463
- // fileList:[],//设置默认上传的内容,格式:[{uuid:'附件文档库的标志',name:'文件名称'}],只有uploadType为file(文档库)模式的时候才能使用此功能
464
- uploadType: 'file', //文件上传方式,file:文档库,redis:Redis缓存,如果是需要永久上传请使用文档库,如果只是暂存,建议使用redis缓存
465
- redisData: 30, //缓存时间,单位:分钟,设置缓存时间,意思是超过这个时间就会删除这个缓存信息
466
- fileCountLimit: 10, //上传文件个数限制
467
- fileTypeLimit: undefined, //上传文件格式限制
468
- disabled: false, //是否禁用
469
- onChange: undefined, //值改变事件,参数:resultStr,resultList
470
- maxFileSize: 20, //默认上传最大大小限制20MB,
471
- sizeWord: 'M', //大小单位,默认为M
472
- serviceMark: 'ly-ky', //服务标志,说明是属于哪个服务
473
- moduleName: '科研系统', //模块名称,说明是属于哪个服务的哪个模块
474
- value: '', //附件主表id
475
- describe: '', //描述,对上传的附件的一个描述信息
476
- fileMainName: '', //附件主表名,存储该附件对应的主表的名称,主要是为了以后进行追溯
477
- isEdit: true, //是否可以编辑,默认为true,查看模式必须传value
478
- listType: 'text', //上传列表的内建样式,基本样式 text, picture,picture-card
479
- compressThreshold: 5, //压缩的阈值,图片大小超过5M,则需要进行压缩
480
- isPictureCompress: false, //是否开启图片压缩
481
- pictureQuality: 0.92, //指定压缩的图片质量,取值范围为0~1,quality值越小,图像越模糊,默认图片质量为0.92
482
- defaultEffective: false, //指定上传的附件是否默认在附件主表有效
483
- templateList: [], // 附件模板
484
- image: false, //listType为picture-card才能使用true
485
- disableDelete: false, // 是否隐藏删除按钮,默认为false
486
- hideTips: true, //默认隐藏附件上传提示语
487
- tips: '附件上传提示语',
488
- kkFileView: true, //默认使用新版预览方式
489
- fileView: true //组件为不可编辑模式下,listType为picture-card,非图片文件默认支持预览
490
- };
491
-
492
- var _initialiseProps = function _initialiseProps() {
493
- var _this5 = this;
494
-
495
- this.handleFileList = function (propsfileList) {
496
- var initFielList = propsfileList;
497
- if (typeof propsfileList === 'string') {
498
- initFielList = [];
499
- propsfileList.split(',').map(function (item) {
500
- initFielList.push({
501
- uuid: item.split(';')[0],
502
- name: item.split(';')[1]
503
- });
504
- return item;
505
- });
506
- }
507
- var fileList = _this5.state.fileList;
508
- var uuidList = [];
509
- if (fileList.length > 0) {
510
- fileList.map(function (item) {
511
- uuidList.push(item.uuid);
512
- });
513
- }
514
- var img = ['png', 'jpeg', 'jpg', 'gif', 'bmp'];
515
- initFielList.map(function (item, index) {
516
- if (uuidList.indexOf(item.uuid) === -1) {
517
- if (!_this5.checkIsImage(item.name)) {
518
- fileList.push({
519
- uuid: item.uuid,
520
- uid: item.uuid,
521
- name: item.name,
522
- status: 'done',
523
- reponse: 'Server Error 500' // custom error message to show
524
- // url: 'api/docrepo/download/file?attachmentId='+item.uuid,
525
- });
526
- return item;
527
- }
528
- fileList.push({
529
- uuid: item.uuid,
530
- uid: item.uuid,
531
- name: item.name,
532
- status: 'done',
533
- reponse: 'Server Error 500', // custom error message to show
534
- url: 'zuul/docrepo/download/file?attachmentId=' + item.uuid
535
- });
536
- return item;
537
- }
538
- });
539
- _this5.setState({
540
- fileList: fileList
541
- });
542
- };
543
-
544
- this.checkTypeLimit = function (filename, fileTypeLimit) {
545
- for (var i = 0; i < fileTypeLimit.length; i++) {
546
- if (filename.toUpperCase().indexOf(fileTypeLimit[i].toUpperCase()) > -1) {
547
- return true;
548
- }
549
- }
550
- return false;
551
- };
552
-
553
- this.checkIsRun = function (filename, executable) {
554
- for (var i = 0; i < executable.length; i++) {
555
- if (filename.toUpperCase().indexOf(executable[i].toUpperCase()) > -1) {
556
- return true;
557
- }
558
- }
559
- return false;
560
- };
561
-
562
- this.beforeUpload = function (file, fileList) {
563
- var suffixMap = {
564
- word: ['.doc', '.docx'],
565
- exce: ['.xls', '.xlsx'],
566
- img: ['.png', '.jpeg', '.jpg', '.gif', '.bmp']
567
- };
568
- var executable = ['.exe', '.sys', '.com', '.bat', '.jsp', '.asp', '.php', '.aspx', '.asa', '.asax', '.asmx', '.ashx', '.ascx', '.pif', '.acf', '.arj', '.swg', '.swf', '.svx', '.dos'];
569
- //文件格式的限制
570
- if (_this5.checkIsRun(file.name, executable)) {
571
- _message3.default.info('不允许上传可执行的文件!');
572
- return false;
573
- } else {
574
- if (_this5.props.fileTypeLimit && _this5.props.fileTypeLimit.length > 0) {
575
- var fileTypeLimit = _this5.props.fileTypeLimit;
576
- for (var i = fileTypeLimit.length - 1; i >= 0; i--) {
577
- var list = suffixMap[fileTypeLimit[i]];
578
- if (list) {
579
- fileTypeLimit.splice(i, 1);
580
- for (var j = 0; j < list.length; j++) {
581
- fileTypeLimit.push(list[j]);
582
- }
583
- }
584
- }
585
- if (!_this5.checkTypeLimit(file.name, fileTypeLimit)) {
586
- _message3.default.info('只能上传后缀为[' + fileTypeLimit.join(',') + ']格式的文件!');
587
- return false;
588
- }
589
- }
590
- }
591
- if (_this5.props.image && !_this5.checkIsImage(file.name)) {
592
- _message3.default.info('只能上传图片类型');
593
- return false;
594
- }
595
- //文件上传数量限制
596
- var fileCountLimit = !_this5.props.multiple ? 1 : _this5.props.fileCountLimit;
597
- if (fileCountLimit && fileCountLimit <= _this5.state.fileList.length) {
598
- _message3.default.info('最多只能上传' + fileCountLimit + '个文件!');
599
- return false;
600
- }
601
-
602
- //限制上传文件大小(默认上传大小限制20MB)
603
- var _props4 = _this5.props,
604
- _props4$maxFileSize = _props4.maxFileSize,
605
- maxFileSize = _props4$maxFileSize === undefined ? 20 : _props4$maxFileSize,
606
- _props4$sizeWord = _props4.sizeWord,
607
- sizeWord = _props4$sizeWord === undefined ? 'M' : _props4$sizeWord;
608
-
609
- var isOverSize = false;
610
- if (sizeWord.toLocaleLowerCase() === 'kb') {
611
- // 若单位为kb则按kb的比较
612
- var fileSize = file.size / 1024;
613
- isOverSize = fileSize > maxFileSize;
614
- } else {
615
- var _fileSize = file.size / 1024 / 1024;
616
- isOverSize = _fileSize > maxFileSize;
617
- }
618
-
619
- if (isOverSize) {
620
- var msg = '抱歉,上传文件大小最大不能超过' + maxFileSize + sizeWord + '!';
621
- _message3.default.error(msg);
622
- return !isOverSize;
623
- }
624
- _this5.setState({ fileName: file.name });
625
- return true;
626
- };
627
-
628
- this.transformFile = function (file) {
629
- /**
630
- * 针对图片进行压缩,如果图片大小超过压缩阈值,则执行压缩,否则不压缩
631
- */
632
- //判断是否是图片类型
633
- if (_this5.checkIsImage(file.name)) {
634
- var _props5 = _this5.props,
635
- _props5$compressThres = _props5.compressThreshold,
636
- compressThreshold = _props5$compressThres === undefined ? 5 : _props5$compressThres,
637
- _props5$isPictureComp = _props5.isPictureCompress,
638
- isPictureCompress = _props5$isPictureComp === undefined ? false : _props5$isPictureComp,
639
- _props5$pictureQualit = _props5.pictureQuality,
640
- pictureQuality = _props5$pictureQualit === undefined ? 0.92 : _props5$pictureQualit;
641
-
642
- var fileSize = file.size / 1024 / 1024;
643
- // console.log('before compress, the file size is : ', fileSize + "M");
644
- //当开启图片压缩且图片大小大于等于压缩阈值,进行压缩
645
- if (fileSize >= compressThreshold && isPictureCompress) {
646
- //判断浏览器内核是否支持base64图片压缩
647
- if (typeof FileReader === 'undefined') {
648
- return file;
649
- } else {
650
- try {
651
- _this5.setState({
652
- spinLoading: true
653
- });
654
- return new _promise2.default(function (resolve) {
655
- //声明FileReader文件读取对象
656
- var reader = new FileReader();
657
- reader.readAsDataURL(file);
658
- reader.onload = function () {
659
- // 生成canvas画布
660
- var canvas = document.createElement('canvas');
661
- // 生成img
662
- var img = document.createElement('img');
663
- img.src = reader.result;
664
- img.onload = function () {
665
- var ctx = canvas.getContext('2d');
666
- //原始图片宽度、高度
667
- var originImageWidth = img.width,
668
- originImageHeight = img.height;
669
- //默认最大尺度的尺寸限制在(1920 * 1080)
670
- var maxWidth = 1920,
671
- maxHeight = 1080,
672
- ratio = maxWidth / maxHeight;
673
- //目标尺寸
674
- var targetWidth = originImageWidth,
675
- targetHeight = originImageHeight;
676
- //当图片的宽度或者高度大于指定的最大宽度或者最大高度时,进行缩放图片
677
- if (originImageWidth > maxWidth || originImageHeight > maxHeight) {
678
- //超过最大宽高比例
679
- if (originImageWidth / originImageHeight > ratio) {
680
- //宽度取最大宽度值maxWidth,缩放高度
681
- targetWidth = maxWidth;
682
- targetHeight = Math.round(maxWidth * (originImageHeight / originImageWidth));
683
- } else {
684
- //高度取最大高度值maxHeight,缩放宽度
685
- targetHeight = maxHeight;
686
- targetWidth = Math.round(maxHeight * (originImageWidth / originImageHeight));
687
- }
688
- }
689
- // canvas对图片进行缩放
690
- canvas.width = targetWidth;
691
- canvas.height = targetHeight;
692
- // 清除画布
693
- ctx.clearRect(0, 0, targetWidth, targetHeight);
694
- // 绘制图片
695
- ctx.drawImage(img, 0, 0, targetWidth, targetHeight);
696
- // quality值越小,图像越模糊,默认图片质量为0.92
697
- var imageDataURL = canvas.toDataURL(file.type || 'image/jpeg', pictureQuality);
698
- // 去掉URL的头,并转换为byte
699
- var imageBytes = window.atob(imageDataURL.split(',')[1]);
700
- // 处理异常,将ascii码小于0的转换为大于0
701
- var arrayBuffer = new ArrayBuffer(imageBytes.length);
702
- var uint8Array = new Uint8Array(arrayBuffer);
703
- for (var i = 0; i < imageBytes.length; i++) {
704
- uint8Array[i] = imageBytes.charCodeAt(i);
705
- }
706
- var mimeType = imageDataURL.split(',')[0].match(/:(.*?);/)[1];
707
- var newFile = new File([uint8Array], file.name, {
708
- type: mimeType || 'image/jpeg'
709
- });
710
- // console.log('after compress, the file size is : ', (newFile.size / 1024 / 1024) + "M");
711
- resolve(newFile);
712
- };
713
- };
714
- reader.onerror = function () {
715
- _this5.setState({
716
- spinLoading: false
717
- });
718
- return file;
719
- };
720
- }).then(function (res) {
721
- _this5.setState({
722
- spinLoading: false
723
- });
724
- return res;
725
- }).catch(function () {
726
- _this5.setState({
727
- spinLoading: false
728
- });
729
- return file;
730
- });
731
- } catch (e) {
732
- _this5.setState({
733
- spinLoading: false
734
- });
735
- //压缩出错,直接返回原file对象
736
- return file;
737
- }
738
- }
739
- } else {
740
- //不需要压缩,直接返回原file对象
741
- return file;
742
- }
743
- } else {
744
- //非图片文件,不进行压缩,直接返回原file对象
745
- return file;
746
- }
747
- };
748
-
749
- this.checkIsImage = function (fileName) {
750
- var flag = void 0;
751
- var imageTypeList = ['.jpg', '.png', '.jpeg', '.gif', '.GIF', '.JPG', '.PNG', '.JPEG'];
752
- var _iteratorNormalCompletion = true;
753
- var _didIteratorError = false;
754
- var _iteratorError = undefined;
755
-
756
- try {
757
- for (var _iterator = (0, _getIterator3.default)(imageTypeList), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
758
- var item = _step.value;
759
-
760
- flag = fileName.endsWith(item);
761
- if (flag) {
762
- return true;
763
- }
764
- }
765
- } catch (err) {
766
- _didIteratorError = true;
767
- _iteratorError = err;
768
- } finally {
769
- try {
770
- if (!_iteratorNormalCompletion && _iterator.return) {
771
- _iterator.return();
772
- }
773
- } finally {
774
- if (_didIteratorError) {
775
- throw _iteratorError;
776
- }
777
- }
778
- }
779
-
780
- return flag;
781
- };
782
-
783
- this.handleMasterTable = function (e, fileList) {
784
- var value = _this5.state.value;
785
- var _props6 = _this5.props,
786
- serviceMark = _props6.serviceMark,
787
- moduleName = _props6.moduleName,
788
- describe = _props6.describe,
789
- fileMainName = _props6.fileMainName,
790
- defaultEffective = _props6.defaultEffective;
791
-
792
- var param = {
793
- fjzbid: value,
794
- fwbz: serviceMark,
795
- mkmc: moduleName,
796
- ms: describe,
797
- fjzbm: fileMainName,
798
-
799
- fjid: e.file.response.data.ssbh,
800
- fjmc: e.file.name,
801
- cjsid: (0, _getLoginUser3.default)().userId
802
- };
803
- if (defaultEffective) {
804
- param.ztm = '1';
805
- }
806
- (0, _NHFetch3.default)(xtglUrl + '/dynamic/insert', 'POST', param).then(function (res) {
807
- if (res && res.code === 200) {
808
- // 插入主表成功后 去掉将size设置为false,size存在应该为上传阶段的,若存在则未成功保存到接口,getResult时将去掉当前数据
809
- fileList.map(function (item) {
810
- if (e.file.uid = item.uid) {
811
- item.size = false;
812
- }
813
- });
814
- _this5.getResult(fileList);
815
- } else {
816
- fileList.map(function (item, key) {
817
- if (e.file.uid = item.uid) {
818
- fileList.splice(key, 1);
819
- }
820
- });
821
- _this5.setState({ fileList: fileList });
822
- _message3.default.error('附件上传失败!');
823
- }
824
- }).catch(function () {
825
- fileList.map(function (item, key) {
826
- if (e.file.uid = item.uid) {
827
- fileList.splice(key, 1);
828
- }
829
- });
830
- _this5.setState({ fileList: fileList });
831
- });
832
- };
833
-
834
- this.handleChange = function (e) {
835
- var fileList = e.fileList;
836
- if (e.file.status === 'done') {
837
- //上传链接调用成功
838
- var response = e.file.response;
839
- if (_this5.props.uploadType === 'file') {
840
- //上传到文档库中
841
- if (response.meta && response.meta.statusCode === 200) {
842
- //导出成功
843
- fileList = fileList.map(function (file) {
844
- if (file.uid === e.file.uid) {
845
- file.uuid = response.data.ssbh;
846
- }
847
- return file;
848
- });
849
- _this5.handleMasterTable(e, fileList);
850
- } else {
851
- _message3.default.error('文件上传失败,请重新上传!');
852
- fileList = _this5.filterCurrentFile(e.fileList, e.file);
853
- }
854
- } else {
855
- //上传到redis中缓存
856
- if (response.code === 200) {
857
- fileList = fileList.map(function (file) {
858
- if (file.uid === e.file.uid) {
859
- file.uuid = e.file.response.data;
860
- }
861
- return file;
862
- });
863
- _this5.getResult(fileList);
864
- } else {
865
- _message3.default.error('文件上传失败,请重新上传!');
866
- fileList = _this5.filterCurrentFile(e.fileList, e.file);
867
- }
868
- }
869
- } else if (e.file.status === 'uploading') {
870
- //上传中,此时不需要做处理
871
- _this5.setState({
872
- // loading: true,
873
- fileList: fileList
874
- });
875
- } else if (e.file.status === 'error') {
876
- //上传错误
877
- _message3.default.error('文件由于未知原因失败,请重新上传!');
878
- fileList = _this5.filterCurrentFile(e.fileList, e.file);
879
- } else if (e.file.status === 'removed') {
880
- //删除
881
- (0, _NHFetch3.default)(xtglUrl + '/dynamic/updateDel', 'POST', e.file.uid).then(function (res) {
882
- if (res && res.code === 200) {
883
- _this5.getResult(fileList);
884
- } else {
885
- _message3.default.error('附件上传失败!');
886
- fileList = _this5.filterCurrentFile(e.fileList, e.file);
887
- }
888
- });
889
- }
890
- };
891
-
892
- this.filterCurrentFile = function (list, currFile) {
893
- var fileList = [];
894
- list.map(function (file) {
895
- if (file.uid !== currFile.uid) {
896
- fileList.push(file);
897
- }
898
- return file;
899
- });
900
- return fileList;
901
- };
902
-
903
- this.requestData = function () {
904
- if (_this5.props.uploadType === 'file') {
905
- return { uuid: (0, _createUuid3.default)(), type: '1' };
906
- } else {
907
- return { redisData: _this5.props.redisData };
908
- }
909
- };
910
-
911
- this.handelFileUrl = function (fileList) {
912
- // 上传完后修改图片链接
913
- if (fileList.length > 0) {
914
- fileList.map(function (item) {
915
- if (item.response && item.response.meta && item.response.meta.statusCode === 200) {
916
- var img = ['png', 'jpeg', 'jpg', 'gif', 'bmp'];
917
- var fileNameSplitArry = item.name.split('.');
918
- if (img.indexOf(img.indexOf(fileNameSplitArry[fileNameSplitArry.length - 1]) === -1)) {
919
- item.uuid = item.response.data.ssbh;
920
- item.uid = item.response.data.ssbh;
921
- // item.name = item.name;
922
- item.reponse = 'Server Error 500'; // custom error message to show
923
- // item.url = 'api/docrepo/download/file?attachmentId='+item.response.data.ssbh;
924
- } else {
925
- item.uuid = item.response.data.ssbh;
926
- item.uid = item.response.data.ssbh;
927
- // item.name = item.name;
928
- item.reponse = 'Server Error 500'; // custom error message to show
929
- item.url = 'api/docrepo/download/file?attachmentId=' + item.response.data.ssbh;
930
- }
931
- }
932
- });
933
- }
934
- return fileList;
935
- };
936
-
937
- this.getResult = function (fileList) {
938
- if (_this5.props.uploadType === 'file') {
939
- var list = [];
940
- var listMap = [];
941
- fileList.map(function (item, index) {
942
- if (item.name) {
943
- list.push(item.name);
944
- }
945
- if (item.size || item.size === 0) {
946
- fileList.splice(index, 1);
947
- }
948
- if (item.uuid) {
949
- var param = {};
950
- param.uuid = item.uuid;
951
- param.name = item.name;
952
- listMap.push(param);
953
- }
954
- });
955
- fileList = _this5.handelFileUrl(fileList);
956
- _this5.setState({ fileList: fileList });
957
- var value = _this5.state.value;
958
- if (_this5.props.onChange) {
959
- if (fileList.length > 0) {
960
- _this5.props.onChange(value, list, listMap);
961
- } else {
962
- _this5.props.onChange(undefined);
963
- }
964
- }
965
- } else {
966
- var resultStr = '';
967
- var resultList = [];
968
- fileList.map(function (file) {
969
- resultList.push({
970
- uuid: file.uuid,
971
- name: file.name
972
- });
973
- resultStr += ',' + file.uuid + ';' + file.name;
974
- return file;
975
- });
976
- _this5.setState({ fileList: fileList });
977
- if (resultStr) {
978
- resultStr = resultStr.substring(1);
979
- }
980
- if (_this5.props.onChange) {
981
- _this5.props.onChange(resultStr, resultList);
982
- }
983
- }
984
- };
985
-
986
- this.handleDownload = function () {
987
- var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(file) {
988
- return _regenerator2.default.wrap(function _callee2$(_context2) {
989
- while (1) {
990
- switch (_context2.prev = _context2.next) {
991
- case 0:
992
- window.open('zuul/docrepo/download/file?attachmentId=' + file.uid);
993
-
994
- case 1:
995
- case 'end':
996
- return _context2.stop();
997
- }
998
- }
999
- }, _callee2, _this5);
1000
- }));
1001
-
1002
- return function (_x) {
1003
- return _ref3.apply(this, arguments);
1004
- };
1005
- }();
1006
-
1007
- this.handlePreview = function () {
1008
- var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(file) {
1009
- var name, previewFile, imageListType, fileListType, imageVisible;
1010
- return _regenerator2.default.wrap(function _callee3$(_context3) {
1011
- while (1) {
1012
- switch (_context3.prev = _context3.next) {
1013
- case 0:
1014
- if (!(!file.url && !file.preview)) {
1015
- _context3.next = 14;
1016
- break;
1017
- }
1018
-
1019
- _context3.prev = 1;
1020
-
1021
- if (!file.originFileObj) {
1022
- _context3.next = 8;
1023
- break;
1024
- }
1025
-
1026
- _context3.next = 5;
1027
- return getBase64(file.originFileObj);
1028
-
1029
- case 5:
1030
- file.preview = _context3.sent;
1031
- _context3.next = 9;
1032
- break;
1033
-
1034
- case 8:
1035
- file.preUrl = 'zuul/docrepo/download/file?attachmentId=' + file.uid;
1036
-
1037
- case 9:
1038
- _context3.next = 14;
1039
- break;
1040
-
1041
- case 11:
1042
- _context3.prev = 11;
1043
- _context3.t0 = _context3['catch'](1);
1044
-
1045
- console.log(_context3.t0);
1046
-
1047
- case 14:
1048
- name = file.name.split('.')[1];
1049
- previewFile = file.url || file.preview || file.preUrl;
1050
- imageListType = ['png', 'jpeg', 'jpg', 'gif', 'bmp']; //图片格式
1051
-
1052
- fileListType = ['doc', 'xls', 'ppt', 'pptx', 'vsd', 'mpp']; //file文档
1053
-
1054
- imageVisible = imageListType.includes(name); //判断是否预览图片文件
1055
-
1056
- _this5.setState({ previewFile: previewFile, fileType: name, imageVisible: imageVisible }, function () {
1057
- if (!imageVisible) {
1058
- if (_this5.props.kkFileView) {
1059
- var _state2 = _this5.state,
1060
- KY_FJFWBZ = _state2.KY_FJFWBZ,
1061
- KY_FJYLBZ = _state2.KY_FJYLBZ;
1062
- // 使用新版附件预览服务
1063
-
1064
- var originUrl = KY_FJFWBZ + '/zuul/docrepo/download/file?attachmentId=' + file.uid; //要预览文件的访问地址
1065
- var index = file.name.lastIndexOf('.');
1066
- var _name = file.name;
1067
- if (index > -1) {
1068
- var firstName = file.name.substring(0, index);
1069
- var lastName = file.name.substring(index);
1070
- var size = file.uid.length;
1071
- _name = firstName + '_' + file.uid.substring(size - 4) + lastName;
1072
- }
1073
-
1074
- var previewUrl = originUrl + '&fullfilename=/' + _name;
1075
- window.open(KY_FJYLBZ + '/onlinePreview?url=' + encodeURIComponent(Base64.encode(previewUrl)));
1076
- } else {
1077
- //旧版-预览非图片格式
1078
- if (fileListType.includes(name)) {
1079
- // 使用pageOffice预览附件
1080
- _this5.previewAttachment(file.uid, name);
1081
- } else {
1082
- // 使用KyPreview封装组件预览附件
1083
- _this5.refs.kyModal.show();
1084
- }
1085
- }
1086
- }
1087
- });
1088
-
1089
- case 20:
1090
- case 'end':
1091
- return _context3.stop();
1092
- }
1093
- }
1094
- }, _callee3, _this5, [[1, 11]]);
1095
- }));
1096
-
1097
- return function (_x2) {
1098
- return _ref4.apply(this, arguments);
1099
- };
1100
- }();
1101
-
1102
- this.previewAttachment = function (uid, name) {
1103
- var previewUrl = name === 'pdf' ? previewPdfUrl : previewOfficeUrl;
1104
- var _window$location = window.location,
1105
- origin = _window$location.origin,
1106
- pathname = _window$location.pathname;
1107
-
1108
- var url = origin + pathname + previewUrl + ('?attachmentId=' + uid);
1109
- if (window.POBrowser) {
1110
- window.POBrowser.openWindowModeless(url, 'width=1200px;height=850px;');
1111
- } else {
1112
- _message3.default.error('pageoffice错误,请检查服务是否正常启动!');
1113
- }
1114
- };
1115
-
1116
- this.openDoc = function (docId, openType, templateId) {
1117
- //新增或者编辑正文(附件)必需参数:docId,openType
1118
- //若docId存在,则是编辑附件,不存在则是新增附件,新增时可传递模板Id,即原有附件的Id,在其基础上修改
1119
-
1120
- //docId(对应附件表的所属编号ssbh): 添加附件记录时,标明该附件是属于哪个发文
1121
- // docId: this.state.documentData.id,
1122
-
1123
- //打开模式:docNormalEdit(word普通编辑模式),docReadOnly(word只读模式)
1124
- // openType: "docNormalEdit",
1125
-
1126
- //templateId: 附件表原有的附件Id,即新增附件记录时,在原有的附件基础上进行修改、添加,可不用该字段
1127
- //templateId: "3ab374b70f88704ef209b9e02eb6ecc4130d"
1128
- if (window.POBrowser) {
1129
- var url = window.location.origin + window.location.pathname + docUrl + '?docId=' + docId + '&openType=' + openType;
1130
- window.POBrowser.openWindowModeless(url, 'width=1200px;height=850px;');
1131
- } else {
1132
- _message3.default.error('pageoffice错误,请检查服务是否正常启动!');
1133
- }
1134
- };
1135
-
1136
- this.handleCancel = function () {
1137
- return _this5.setState({ imageVisible: false });
1138
- };
1139
-
1140
- this.imgTrunDeg = function (direction) {
1141
- var rotateDeg = _this5.state.rotateDeg;
1142
-
1143
- if (direction == 'left') {
1144
- rotateDeg -= 90;
1145
- }
1146
- if (direction == 'right') {
1147
- rotateDeg += 90;
1148
- }
1149
- _this5.setState({
1150
- rotateDeg: rotateDeg
1151
- });
1152
- };
1153
- };
1154
-
1155
- exports.default = KyUpload;