easy3wui 1.5.53-beta2 → 1.5.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Easy3wUpload/index.js +1 -1
- package/lib/Easy3wUploadB/index.js +1 -1
- package/lib/Easy3wUploadM/index.js +263 -309
- package/package.json +1 -1
|
@@ -64,17 +64,22 @@ require('antd/lib/modal/style');
|
|
|
64
64
|
|
|
65
65
|
var _comonConfig = require('comonConfigPath/comonConfig');
|
|
66
66
|
|
|
67
|
-
var
|
|
67
|
+
var _Easy3wGetCookie = require('../Easy3wGetCookie');
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
var _Easy3wGetCookie2 = _interopRequireDefault(_Easy3wGetCookie);
|
|
70
|
+
|
|
71
|
+
var _Easy3wDownLoad = require('../Easy3wDownLoad');
|
|
72
|
+
|
|
73
|
+
var _Easy3wDownLoad2 = _interopRequireDefault(_Easy3wDownLoad);
|
|
70
74
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
var _Easy3wAESEncrypt = require('../Easy3wAESEncrypt');
|
|
76
|
+
|
|
77
|
+
var _Easy3wAESEncrypt2 = _interopRequireDefault(_Easy3wAESEncrypt);
|
|
78
|
+
|
|
79
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
74
80
|
|
|
75
81
|
// const { previewFileUrl, previewFileFlag, previewFileType } = objPreviewFile || {};
|
|
76
82
|
|
|
77
|
-
/* eslint-disable react/sort-comp */
|
|
78
83
|
var formItemStyle = {
|
|
79
84
|
marginBottom: 6
|
|
80
85
|
};
|
|
@@ -82,69 +87,53 @@ var formItemStyle = {
|
|
|
82
87
|
var Easy3wUploadM = function (_Component) {
|
|
83
88
|
(0, _inherits3['default'])(Easy3wUploadM, _Component);
|
|
84
89
|
|
|
85
|
-
function Easy3wUploadM(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
var _this = (0, _possibleConstructorReturn3['default'])(this, _Component.call(this, props));
|
|
89
|
-
|
|
90
|
-
_initialiseProps.call(_this);
|
|
90
|
+
function Easy3wUploadM() {
|
|
91
|
+
var _temp, _this, _ret;
|
|
91
92
|
|
|
92
|
-
|
|
93
|
-
urlDownloadFile = _this$props.urlDownloadFile,
|
|
94
|
-
initialValue = _this$props.initialValue;
|
|
95
|
-
|
|
96
|
-
var fileList = [];
|
|
97
|
-
var fileIds = '';
|
|
98
|
-
if (initialValue && initialValue.length > 0) {
|
|
99
|
-
fileList = initialValue.map(function (obj) {
|
|
100
|
-
var uid = obj.uid,
|
|
101
|
-
name = obj.name,
|
|
102
|
-
status = obj.status;
|
|
93
|
+
(0, _classCallCheck3['default'])(this, Easy3wUploadM);
|
|
103
94
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
} else {
|
|
107
|
-
fileIds = fileIds + ',' + uid;
|
|
108
|
-
}
|
|
109
|
-
var url = _this.urlDeal(urlDownloadFile, uid);
|
|
110
|
-
return { uid: uid, name: name, url: url, status: status || 'done' };
|
|
111
|
-
});
|
|
95
|
+
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
|
96
|
+
args[_key] = arguments[_key];
|
|
112
97
|
}
|
|
113
|
-
_this.state = {
|
|
114
|
-
fileList: fileList, // 文件列表
|
|
115
|
-
fileIds: fileIds // 文件ID
|
|
116
|
-
};
|
|
117
|
-
return _this;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
Easy3wUploadM.prototype.componentDidUpdate = function componentDidUpdate(prevProps) {
|
|
121
|
-
var initialValue = prevProps.initialValue;
|
|
122
|
-
|
|
123
|
-
if (!this.touchCompareList(this.props.initialValue, initialValue)) {
|
|
124
|
-
this.updateFileList(this.props.initialValue);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
// 对比传入文件列表 返回值 false 不等则更新 true 相等则不更新
|
|
128
|
-
|
|
129
|
-
// 更新文件列表
|
|
130
|
-
|
|
131
|
-
// 预览
|
|
132
|
-
|
|
133
|
-
// 文件地址处理
|
|
134
|
-
|
|
135
|
-
// 文件删除
|
|
136
|
-
|
|
137
|
-
// 验证文件是否上传完成
|
|
138
|
-
|
|
139
|
-
// 文件上传前
|
|
140
|
-
|
|
141
|
-
// 表单值改变
|
|
142
98
|
|
|
99
|
+
return _ret = (_temp = (_this = (0, _possibleConstructorReturn3['default'])(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.state = {
|
|
100
|
+
fileList: [{}]
|
|
101
|
+
// 预览
|
|
102
|
+
}, _this.onPreview = function (file) {
|
|
103
|
+
var objPreviewFileNew = (0, _extends3['default'])({}, _comonConfig.objPreviewFile, _this.props.objPreviewFile);
|
|
104
|
+
var previewFileUrl = objPreviewFileNew.previewFileUrl,
|
|
105
|
+
previewFileType = objPreviewFileNew.previewFileType;
|
|
106
|
+
var uid = file.uid,
|
|
107
|
+
url = file.url,
|
|
108
|
+
name = file.name;
|
|
109
|
+
|
|
110
|
+
var fileNameArr = name.toLowerCase().split('.');
|
|
111
|
+
var fileType = fileNameArr[fileNameArr.length - 1];
|
|
112
|
+
if (previewFileType.indexOf(fileType) >= 0) {
|
|
113
|
+
var src = _this.urlDeal(previewFileUrl, uid);
|
|
114
|
+
window.open(src, '_blank');
|
|
115
|
+
} else {
|
|
116
|
+
window.open(url);
|
|
117
|
+
}
|
|
118
|
+
}, _this.urlDeal = function (urlDownloadFile, uid) {
|
|
119
|
+
var propsAFlag = _this.props.propsAFlag; // propsAFlag 加密标识 从引用组件处传入 '1':加密 '0':不加密
|
|
120
|
+
|
|
121
|
+
var retUrl = '';
|
|
122
|
+
if (uid !== '' && propsAFlag === '1' || uid !== '' && propsAFlag !== '0' && (_comonConfig.aFlag === '1' || _comonConfig.aFlag === '2')) {
|
|
123
|
+
var authToken = (0, _Easy3wGetCookie2['default'])('userToken') || 'E3WSAFEAPPQWEFGHYI7I483S';
|
|
124
|
+
var nowStr = _.now();
|
|
125
|
+
var encUrl = (0, _Easy3wAESEncrypt2['default'])(uid + '@#' + nowStr + '@#' + authToken, _comonConfig.a, _comonConfig.b);
|
|
126
|
+
return '' + urlDownloadFile + encUrl;
|
|
127
|
+
} else {
|
|
128
|
+
retUrl = '' + urlDownloadFile + uid;
|
|
129
|
+
return retUrl;
|
|
130
|
+
}
|
|
131
|
+
}, _temp), (0, _possibleConstructorReturn3['default'])(_this, _ret);
|
|
132
|
+
}
|
|
143
133
|
|
|
144
134
|
Easy3wUploadM.prototype.render = function render() {
|
|
145
|
-
var
|
|
146
|
-
|
|
147
|
-
fileIds = _state.fileIds;
|
|
135
|
+
var _this2 = this;
|
|
136
|
+
|
|
148
137
|
var _props = this.props,
|
|
149
138
|
urlUpFileService = _props.urlUpFileService,
|
|
150
139
|
urlDownloadFile = _props.urlDownloadFile,
|
|
@@ -152,6 +141,7 @@ var Easy3wUploadM = function (_Component) {
|
|
|
152
141
|
sendData = _props.sendData,
|
|
153
142
|
listType = _props.listType,
|
|
154
143
|
accept = _props.accept,
|
|
144
|
+
limitSize = _props.limitSize,
|
|
155
145
|
required = _props.required,
|
|
156
146
|
initialValue = _props.initialValue,
|
|
157
147
|
help = _props.help,
|
|
@@ -164,14 +154,45 @@ var Easy3wUploadM = function (_Component) {
|
|
|
164
154
|
wrapperCol = _props.wrapperCol,
|
|
165
155
|
extend = _props.extend,
|
|
166
156
|
extendBack = _props.extendBack,
|
|
157
|
+
uploadDoneCallback = _props.uploadDoneCallback,
|
|
158
|
+
removeCallback = _props.removeCallback,
|
|
167
159
|
downloadAllFlag = _props.downloadAllFlag,
|
|
168
160
|
propsAFlag = _props.propsAFlag,
|
|
169
|
-
fileViewFlag = _props.fileViewFlag
|
|
170
|
-
|
|
161
|
+
fileViewFlag = _props.fileViewFlag;
|
|
162
|
+
var warnMessage = this.props.warnMessage;
|
|
163
|
+
|
|
164
|
+
var iniVal = [];
|
|
165
|
+
var allivaule = '';
|
|
166
|
+
if (initialValue) {
|
|
167
|
+
iniVal = initialValue.map(function (obj) {
|
|
168
|
+
var uid = obj.uid,
|
|
169
|
+
name = obj.name,
|
|
170
|
+
status = obj.status;
|
|
171
|
+
|
|
172
|
+
if (allivaule === '') {
|
|
173
|
+
allivaule = uid;
|
|
174
|
+
} else {
|
|
175
|
+
allivaule = allivaule + ',' + uid;
|
|
176
|
+
}
|
|
177
|
+
var url = _this2.urlDeal(urlDownloadFile, uid);
|
|
178
|
+
return { uid: uid, name: name, url: url, status: status || 'done' };
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
if (!warnMessage) {
|
|
182
|
+
warnMessage = help;
|
|
183
|
+
}
|
|
171
184
|
var getFieldDecorator = form.getFieldDecorator;
|
|
172
185
|
|
|
186
|
+
var extendShowFlag = false;
|
|
187
|
+
var extendBackShowFlag = false;
|
|
188
|
+
if (extend) {
|
|
189
|
+
extendShowFlag = true;
|
|
190
|
+
}
|
|
191
|
+
if (extendBack) {
|
|
192
|
+
extendBackShowFlag = true;
|
|
193
|
+
}
|
|
173
194
|
var ENCFlag = '0';
|
|
174
|
-
var authToken = (0,
|
|
195
|
+
var authToken = (0, _Easy3wGetCookie2['default'])('userToken') || 'E3WSAFEAPPQWEFGHYI7I483S';
|
|
175
196
|
var upProps = {
|
|
176
197
|
name: uploadName,
|
|
177
198
|
action: urlUpFileService,
|
|
@@ -200,6 +221,167 @@ var Easy3wUploadM = function (_Component) {
|
|
|
200
221
|
if (previewFileFlag && fileViewFlag !== false) {
|
|
201
222
|
upProps.onPreview = this.onPreview;
|
|
202
223
|
}
|
|
224
|
+
var beforeUpload = function beforeUpload(file) {
|
|
225
|
+
// 限制上传大小
|
|
226
|
+
var fileSize = file.size / 1024 / 1024;
|
|
227
|
+
var isLimitSize = fileSize < limitSize;
|
|
228
|
+
var fileTypePass = true;
|
|
229
|
+
var name = file.name;
|
|
230
|
+
|
|
231
|
+
var fileNameArr = name.toLowerCase().split('.');
|
|
232
|
+
var fileType = fileNameArr[fileNameArr.length - 1];
|
|
233
|
+
var acceptDefault = '.rplib,.xls,.doc,.jpg,.pdf,.png,.zip,.bmp,.rar,.txt,.docx,.ico,.bid,.xlsx,.jpeg,.json,.xml,.ebid,.dwg,.pptx,.xmind,.xps,.crx,.7z,.ppt,.svg,.pdm,.xlsm,.vsd,.gif,.tif,.docm,.csv,.ttf,.wps,.psd,.mp4,.tiff,.rtf,.tlb,.xlsb';
|
|
234
|
+
if (name.length > 100) {
|
|
235
|
+
_modal2['default'].info({
|
|
236
|
+
style: { top: '38%' },
|
|
237
|
+
okText: '知道了',
|
|
238
|
+
content: '文件名称至多100个字符'
|
|
239
|
+
});
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
if (accept && accept.length > 0) {
|
|
243
|
+
acceptDefault = accept;
|
|
244
|
+
}
|
|
245
|
+
if (acceptDefault.indexOf(fileType) < 0) {
|
|
246
|
+
fileTypePass = false;
|
|
247
|
+
}
|
|
248
|
+
if (!fileTypePass) {
|
|
249
|
+
_modal2['default'].error({
|
|
250
|
+
style: { top: '38%' },
|
|
251
|
+
content: '\u4E0D\u652F\u6301' + fileType + '\u7C7B\u578B\u7684\u6587\u4EF6!'
|
|
252
|
+
});
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
if (!isLimitSize) {
|
|
256
|
+
_modal2['default'].error({
|
|
257
|
+
style: { top: '38%' },
|
|
258
|
+
content: '\u9644\u4EF6\u5FC5\u987B\u5C0F\u4E8E' + limitSize + 'MB!'
|
|
259
|
+
});
|
|
260
|
+
return false;
|
|
261
|
+
} else if (fileSize === 0) {
|
|
262
|
+
_modal2['default'].error({
|
|
263
|
+
style: { top: '38%' },
|
|
264
|
+
content: '附件必须大于0MB!'
|
|
265
|
+
});
|
|
266
|
+
return false;
|
|
267
|
+
} else {
|
|
268
|
+
return true;
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
var handleRemove = function handleRemove(file) {
|
|
272
|
+
if (removeCallback) {
|
|
273
|
+
removeCallback(uploadName, file);
|
|
274
|
+
}
|
|
275
|
+
return true;
|
|
276
|
+
};
|
|
277
|
+
var handleFileChange = function handleFileChange(e) {
|
|
278
|
+
var fileList = e.fileList;
|
|
279
|
+
// 移除大小不符、类型不符的文件
|
|
280
|
+
|
|
281
|
+
fileList = fileList.filter(function (f1) {
|
|
282
|
+
var size = f1.size,
|
|
283
|
+
name = f1.name;
|
|
284
|
+
|
|
285
|
+
if (size >= 0) {
|
|
286
|
+
var correctSizeFlag = size > 0 && size / 1024 / 1024 < limitSize;
|
|
287
|
+
var correctTypeFlag = true;
|
|
288
|
+
var fileNameArr = name.toLowerCase().split('.');
|
|
289
|
+
var fileType = fileNameArr[fileNameArr.length - 1];
|
|
290
|
+
var acceptDefault = '.xls,.doc,.jpg,.pdf,.png,.zip,.bmp,.rar,.txt,.docx,.ico,.bid,.xlsx,.jpeg,.json,.xml,.ebid,.dwg,.pptx,.xmind,.xps,.crx,.7z,.ppt,.svg,.pdm,.xlsm,.vsd,.gif,.tif,.docm,.csv,.ttf,.wps,.psd,.mp4,.tiff,.rtf,.tlb,.xlsb';
|
|
291
|
+
if (name.length > 100) {
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
if (accept && accept.length > 0) {
|
|
295
|
+
acceptDefault = accept;
|
|
296
|
+
}
|
|
297
|
+
if (acceptDefault.indexOf(fileType) < 0) {
|
|
298
|
+
correctTypeFlag = false;
|
|
299
|
+
}
|
|
300
|
+
if (!correctSizeFlag || !correctTypeFlag) {
|
|
301
|
+
return false;
|
|
302
|
+
} else {
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
} else {
|
|
306
|
+
return true;
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
// 2. read from response and show file link
|
|
310
|
+
fileList = fileList.map(function (f2) {
|
|
311
|
+
var nFile = f2;
|
|
312
|
+
if (nFile.response && nFile.response.data) {
|
|
313
|
+
var id = nFile.response.data.fileId;
|
|
314
|
+
nFile.uid = id;
|
|
315
|
+
var url = _this2.urlDeal(urlDownloadFile, id);
|
|
316
|
+
nFile.url = url;
|
|
317
|
+
}
|
|
318
|
+
return nFile;
|
|
319
|
+
});
|
|
320
|
+
// 3. filter successfully uploaded files according to response from server
|
|
321
|
+
fileList = fileList.filter(function (file) {
|
|
322
|
+
var status = file.status,
|
|
323
|
+
name = file.name;
|
|
324
|
+
|
|
325
|
+
if (status === 'error') {
|
|
326
|
+
_modal2['default'].error({
|
|
327
|
+
style: { top: '38%' },
|
|
328
|
+
content: '\u9644\u4EF6' + name + '\u4E0A\u4F20\u5931\u8D25!'
|
|
329
|
+
});
|
|
330
|
+
return false; // 上传失败
|
|
331
|
+
}
|
|
332
|
+
if (file.response) {
|
|
333
|
+
if (file.response.rspCode === '0000') {
|
|
334
|
+
if (uploadDoneCallback) {
|
|
335
|
+
uploadDoneCallback(uploadName, fileList, file);
|
|
336
|
+
}
|
|
337
|
+
return true;
|
|
338
|
+
}
|
|
339
|
+
if (file.response.rspMsg) {
|
|
340
|
+
_modal2['default'].error({
|
|
341
|
+
style: { top: '38%' },
|
|
342
|
+
content: file.response.rspMsg
|
|
343
|
+
});
|
|
344
|
+
} else {
|
|
345
|
+
_modal2['default'].error({
|
|
346
|
+
style: { top: '38%' },
|
|
347
|
+
content: '\u9644\u4EF6' + name + '\u4E0A\u4F20\u5931\u8D25!'
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
return false;
|
|
351
|
+
// return file.response.rspCode === '0000';// 上传成功
|
|
352
|
+
}
|
|
353
|
+
return true;
|
|
354
|
+
});
|
|
355
|
+
allivaule = '';
|
|
356
|
+
iniVal = fileList.map(function (obj) {
|
|
357
|
+
var uid = obj.uid;
|
|
358
|
+
|
|
359
|
+
if (allivaule === '') {
|
|
360
|
+
allivaule = uid;
|
|
361
|
+
} else {
|
|
362
|
+
allivaule = allivaule + ',' + uid;
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
_this2.setState({ fileList: fileList });
|
|
366
|
+
return fileList;
|
|
367
|
+
};
|
|
368
|
+
var checkFile = function checkFile(rule, value, callback) {
|
|
369
|
+
var str = void 0;
|
|
370
|
+
if (value && value instanceof Array) {
|
|
371
|
+
for (var i = 0; i < value.length; i += 1) {
|
|
372
|
+
var status = value[i].status;
|
|
373
|
+
|
|
374
|
+
if (status === 'uploading') {
|
|
375
|
+
str = ' ';
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
} else {
|
|
380
|
+
str = ' ';
|
|
381
|
+
}
|
|
382
|
+
callback(str);
|
|
383
|
+
};
|
|
384
|
+
var showFlag = initialValue && initialValue.length > 1 || this.state.fileList.length > 1;
|
|
203
385
|
return isRead ? _react2['default'].createElement(
|
|
204
386
|
_form2['default'].Item,
|
|
205
387
|
{
|
|
@@ -209,8 +391,8 @@ var Easy3wUploadM = function (_Component) {
|
|
|
209
391
|
wrapperCol: wrapperCol,
|
|
210
392
|
style: formItemStyle
|
|
211
393
|
},
|
|
212
|
-
extend
|
|
213
|
-
getFieldDecorator('' + uploadName, {})(_react2['default'].createElement(
|
|
394
|
+
extendShowFlag ? extend : '',
|
|
395
|
+
getFieldDecorator('' + uploadName, {})(_react2['default'].createElement(_Easy3wDownLoad2['default'], {
|
|
214
396
|
pdfViewFlag: true,
|
|
215
397
|
imgVisible: true,
|
|
216
398
|
urlDownloadFile: urlDownloadFile,
|
|
@@ -218,7 +400,7 @@ var Easy3wUploadM = function (_Component) {
|
|
|
218
400
|
propsAFlag: propsAFlag,
|
|
219
401
|
fileViewFlag: fileViewFlag
|
|
220
402
|
})),
|
|
221
|
-
extendBack
|
|
403
|
+
extendBackShowFlag ? extendBack : ''
|
|
222
404
|
) : _react2['default'].createElement(
|
|
223
405
|
_form2['default'].Item,
|
|
224
406
|
{
|
|
@@ -228,21 +410,20 @@ var Easy3wUploadM = function (_Component) {
|
|
|
228
410
|
wrapperCol: wrapperCol,
|
|
229
411
|
style: formItemStyle
|
|
230
412
|
},
|
|
231
|
-
extend
|
|
413
|
+
extendShowFlag ? extend : '',
|
|
232
414
|
getFieldDecorator('' + uploadName, {
|
|
233
|
-
initialValue:
|
|
234
|
-
getValueFromEvent:
|
|
415
|
+
initialValue: iniVal || undefined,
|
|
416
|
+
getValueFromEvent: handleFileChange,
|
|
235
417
|
valuePropName: 'fileList',
|
|
236
|
-
rules: [{ validator:
|
|
418
|
+
rules: [{ validator: checkFile }, { required: required, message: warnMessage }]
|
|
237
419
|
})(_react2['default'].createElement(
|
|
238
420
|
_upload2['default'],
|
|
239
421
|
(0, _extends3['default'])({
|
|
240
|
-
beforeUpload:
|
|
422
|
+
beforeUpload: beforeUpload
|
|
241
423
|
}, upProps, {
|
|
242
|
-
fileList: fileList,
|
|
243
|
-
onRemove:
|
|
244
|
-
|
|
245
|
-
, multiple: true
|
|
424
|
+
fileList: this.state.fileList,
|
|
425
|
+
onRemove: handleRemove,
|
|
426
|
+
multiple: true
|
|
246
427
|
}),
|
|
247
428
|
isRead ? '' : _react2['default'].createElement(
|
|
248
429
|
_popover2['default'],
|
|
@@ -269,12 +450,12 @@ var Easy3wUploadM = function (_Component) {
|
|
|
269
450
|
)
|
|
270
451
|
)
|
|
271
452
|
)),
|
|
272
|
-
extendBack
|
|
273
|
-
downloadAllFlag &&
|
|
453
|
+
extendBackShowFlag ? extendBack : '',
|
|
454
|
+
showFlag ? downloadAllFlag && allivaule !== '' ? _react2['default'].createElement(
|
|
274
455
|
_button2['default'],
|
|
275
|
-
{ icon: 'download', size: 'normal', target: '_blank', href: this.urlDeal(urlDownloadFile,
|
|
456
|
+
{ icon: 'download', size: 'normal', target: '_blank', href: this.urlDeal(urlDownloadFile, allivaule) },
|
|
276
457
|
'\u4E0B\u8F7D\u5168\u90E8\u9644\u4EF6'
|
|
277
|
-
) : ''
|
|
458
|
+
) : '' : ''
|
|
278
459
|
);
|
|
279
460
|
};
|
|
280
461
|
|
|
@@ -317,232 +498,5 @@ Easy3wUploadM.defaultProps = {
|
|
|
317
498
|
labelCol: {},
|
|
318
499
|
wrapperCol: {}
|
|
319
500
|
};
|
|
320
|
-
|
|
321
|
-
var _initialiseProps = function _initialiseProps() {
|
|
322
|
-
var _this2 = this;
|
|
323
|
-
|
|
324
|
-
this.touchCompareList = function (arrFileList, arrFileListNew) {
|
|
325
|
-
if (!arrFileList || !arrFileListNew || arrFileList.length !== arrFileListNew.length) {
|
|
326
|
-
return false;
|
|
327
|
-
}
|
|
328
|
-
for (var i = 0; i < arrFileList.length; i += 1) {
|
|
329
|
-
var uid = arrFileList[i].uid;
|
|
330
|
-
var uidNew = arrFileListNew[i].uid;
|
|
331
|
-
|
|
332
|
-
if (uid !== uidNew) {
|
|
333
|
-
return false;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
return true;
|
|
337
|
-
};
|
|
338
|
-
|
|
339
|
-
this.updateFileList = function (initialValue) {
|
|
340
|
-
var urlDownloadFile = _this2.props.urlDownloadFile;
|
|
341
|
-
|
|
342
|
-
var fileList = [];
|
|
343
|
-
var fileIds = '';
|
|
344
|
-
if (initialValue && initialValue.length > 0) {
|
|
345
|
-
fileList = initialValue.map(function (obj) {
|
|
346
|
-
var uid = obj.uid,
|
|
347
|
-
name = obj.name,
|
|
348
|
-
status = obj.status;
|
|
349
|
-
|
|
350
|
-
if (fileIds === '') {
|
|
351
|
-
fileIds = uid;
|
|
352
|
-
} else {
|
|
353
|
-
fileIds = fileIds + ',' + uid;
|
|
354
|
-
}
|
|
355
|
-
var url = _this2.urlDeal(urlDownloadFile, uid);
|
|
356
|
-
return { uid: uid, name: name, url: url, status: status || 'done' };
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
// return {
|
|
360
|
-
// fileList, // 文件列表
|
|
361
|
-
// fileIds, // 文件ID
|
|
362
|
-
// };
|
|
363
|
-
console.log('updateFileList', initialValue, fileList, fileIds);
|
|
364
|
-
_this2.setState({
|
|
365
|
-
fileList: fileList, // 文件列表
|
|
366
|
-
fileIds: fileIds // 文件ID
|
|
367
|
-
});
|
|
368
|
-
};
|
|
369
|
-
|
|
370
|
-
this.onPreview = function (file) {
|
|
371
|
-
var objPreviewFileNew = (0, _extends3['default'])({}, _comonConfig.objPreviewFile, _this2.props.objPreviewFile);
|
|
372
|
-
var previewFileUrl = objPreviewFileNew.previewFileUrl,
|
|
373
|
-
previewFileType = objPreviewFileNew.previewFileType;
|
|
374
|
-
var uid = file.uid,
|
|
375
|
-
url = file.url,
|
|
376
|
-
name = file.name;
|
|
377
|
-
|
|
378
|
-
var fileNameArr = name.toLowerCase().split('.');
|
|
379
|
-
var fileType = fileNameArr[fileNameArr.length - 1];
|
|
380
|
-
if (previewFileType.indexOf(fileType) >= 0) {
|
|
381
|
-
var src = _this2.urlDeal(previewFileUrl, uid);
|
|
382
|
-
window.open(src, '_blank');
|
|
383
|
-
} else {
|
|
384
|
-
window.open(url);
|
|
385
|
-
}
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
this.urlDeal = function (urlDownloadFile, uid) {
|
|
389
|
-
var propsAFlag = _this2.props.propsAFlag; // propsAFlag 加密标识 从引用组件处传入 '1':加密 '0':不加密
|
|
390
|
-
|
|
391
|
-
var retUrl = '';
|
|
392
|
-
if (uid !== '' && propsAFlag === '1' || uid !== '' && propsAFlag !== '0' && (_comonConfig.aFlag === '1' || _comonConfig.aFlag === '2')) {
|
|
393
|
-
var authToken = (0, _easy3wui.Easy3wGetCookie)('userToken') || 'E3WSAFEAPPQWEFGHYI7I483S';
|
|
394
|
-
var nowStr = _.now();
|
|
395
|
-
var encUrl = (0, _easy3wui.Easy3wAESEncrypt)(uid + '@#' + nowStr + '@#' + authToken, _comonConfig.a, _comonConfig.b);
|
|
396
|
-
return '' + urlDownloadFile + encUrl;
|
|
397
|
-
} else {
|
|
398
|
-
retUrl = '' + urlDownloadFile + uid;
|
|
399
|
-
return retUrl;
|
|
400
|
-
}
|
|
401
|
-
};
|
|
402
|
-
|
|
403
|
-
this.handleRemove = function (file) {
|
|
404
|
-
var _props2 = _this2.props,
|
|
405
|
-
removeCallback = _props2.removeCallback,
|
|
406
|
-
uploadName = _props2.uploadName;
|
|
407
|
-
|
|
408
|
-
if (removeCallback) {
|
|
409
|
-
removeCallback(uploadName, file);
|
|
410
|
-
}
|
|
411
|
-
return true;
|
|
412
|
-
};
|
|
413
|
-
|
|
414
|
-
this.checkFile = function (rule, value, callback) {
|
|
415
|
-
var str = void 0;
|
|
416
|
-
if (value && value instanceof Array) {
|
|
417
|
-
for (var i = 0; i < value.length; i += 1) {
|
|
418
|
-
var status = value[i].status;
|
|
419
|
-
|
|
420
|
-
if (status !== 'done') {
|
|
421
|
-
str = ' ';
|
|
422
|
-
break;
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
} else {
|
|
426
|
-
str = ' ';
|
|
427
|
-
}
|
|
428
|
-
callback(str);
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
this.beforeUpload = function (file) {
|
|
432
|
-
// 限制上传大小
|
|
433
|
-
var _props3 = _this2.props,
|
|
434
|
-
limitSize = _props3.limitSize,
|
|
435
|
-
accept = _props3.accept;
|
|
436
|
-
var name = file.name;
|
|
437
|
-
|
|
438
|
-
var fileNameArr = name.toLowerCase().split('.');
|
|
439
|
-
var fileType = fileNameArr[fileNameArr.length - 1];
|
|
440
|
-
if (name.length > 100) {
|
|
441
|
-
// 判断文件名称是否超过100个字符
|
|
442
|
-
_modal2['default'].info({
|
|
443
|
-
style: { top: '38%' },
|
|
444
|
-
okText: '知道了',
|
|
445
|
-
content: '文件名称至多100个字符'
|
|
446
|
-
});
|
|
447
|
-
return false;
|
|
448
|
-
}
|
|
449
|
-
var acceptDefault = accept || '.rplib,.xls,.doc,.jpg,.pdf,.png,.zip,.bmp,.rar,.txt,.docx,.ico,.bid,.xlsx,.jpeg,.json,.xml,.ebid,.dwg,.pptx,.xmind,.xps,.crx,.7z,.ppt,.svg,.pdm,.xlsm,.vsd,.gif,.tif,.docm,.csv,.ttf,.wps,.psd,.mp4,.tiff,.rtf,.tlb,.xlsb';
|
|
450
|
-
if (acceptDefault.indexOf(fileType) < 0) {
|
|
451
|
-
// 判断文件类型是否符合
|
|
452
|
-
_modal2['default'].error({
|
|
453
|
-
style: { top: '38%' },
|
|
454
|
-
content: '\u4E0D\u652F\u6301' + fileType + '\u7C7B\u578B\u7684\u6587\u4EF6!'
|
|
455
|
-
});
|
|
456
|
-
return false;
|
|
457
|
-
}
|
|
458
|
-
var fileSize = file.size / 1024 / 1024; // 文件大小MB
|
|
459
|
-
if (fileSize >= limitSize) {
|
|
460
|
-
// 判断文件大小是否符合
|
|
461
|
-
_modal2['default'].error({
|
|
462
|
-
style: { top: '38%' },
|
|
463
|
-
content: '\u9644\u4EF6\u5FC5\u987B\u5C0F\u4E8E' + limitSize + 'MB!'
|
|
464
|
-
});
|
|
465
|
-
return false;
|
|
466
|
-
} else if (fileSize === 0) {
|
|
467
|
-
_modal2['default'].error({
|
|
468
|
-
style: { top: '38%' },
|
|
469
|
-
content: '附件必须大于0MB!'
|
|
470
|
-
});
|
|
471
|
-
return false;
|
|
472
|
-
} else {
|
|
473
|
-
return true;
|
|
474
|
-
}
|
|
475
|
-
};
|
|
476
|
-
|
|
477
|
-
this.handleFileChange = function (info) {
|
|
478
|
-
var _props4 = _this2.props,
|
|
479
|
-
urlDownloadFile = _props4.urlDownloadFile,
|
|
480
|
-
uploadDoneCallback = _props4.uploadDoneCallback,
|
|
481
|
-
uploadName = _props4.uploadName;
|
|
482
|
-
|
|
483
|
-
var fileListNew = [];
|
|
484
|
-
var fileIdsNew = '';
|
|
485
|
-
var fileList = info.fileList;
|
|
486
|
-
|
|
487
|
-
fileList.map(function (objFile) {
|
|
488
|
-
var fileNew = (0, _extends3['default'])({}, objFile);
|
|
489
|
-
var status = objFile.status,
|
|
490
|
-
response = objFile.response,
|
|
491
|
-
name = objFile.name;
|
|
492
|
-
|
|
493
|
-
if (response && response.data) {
|
|
494
|
-
var id = response.data.fileId;
|
|
495
|
-
fileNew.uid = id;
|
|
496
|
-
var url = _this2.urlDeal(urlDownloadFile, id);
|
|
497
|
-
fileNew.url = url;
|
|
498
|
-
}
|
|
499
|
-
var uid = fileNew.uid;
|
|
500
|
-
|
|
501
|
-
if (status === 'done') {
|
|
502
|
-
if (fileIdsNew === '') {
|
|
503
|
-
fileIdsNew = uid;
|
|
504
|
-
} else {
|
|
505
|
-
fileIdsNew = fileIdsNew + ',' + uid;
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
fileListNew.push(fileNew);
|
|
509
|
-
if (response && response.rspCode !== '0000') {
|
|
510
|
-
if (response.rspMsg) {
|
|
511
|
-
_modal2['default'].error({
|
|
512
|
-
style: { top: '38%' },
|
|
513
|
-
content: response.rspMsg
|
|
514
|
-
});
|
|
515
|
-
return false;
|
|
516
|
-
} else {
|
|
517
|
-
_modal2['default'].error({
|
|
518
|
-
style: { top: '38%' },
|
|
519
|
-
content: '\u9644\u4EF6' + name + '\u4E0A\u4F20\u5931\u8D25!'
|
|
520
|
-
});
|
|
521
|
-
return false;
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
if (status === 'done') {
|
|
525
|
-
if (response && response.rspCode === '0000') {
|
|
526
|
-
if (uploadDoneCallback && typeof uploadDoneCallback === 'function') {
|
|
527
|
-
uploadDoneCallback(uploadName, fileListNew);
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
} else if (status === 'error') {
|
|
531
|
-
_modal2['default'].error({
|
|
532
|
-
style: { top: '38%' },
|
|
533
|
-
content: '\u9644\u4EF6' + name + '\u4E0A\u4F20\u5931\u8D25!'
|
|
534
|
-
});
|
|
535
|
-
return false; // 上传失败
|
|
536
|
-
}
|
|
537
|
-
return true;
|
|
538
|
-
});
|
|
539
|
-
_this2.setState({
|
|
540
|
-
fileList: fileListNew,
|
|
541
|
-
fileIds: fileIdsNew
|
|
542
|
-
});
|
|
543
|
-
return fileListNew;
|
|
544
|
-
};
|
|
545
|
-
};
|
|
546
|
-
|
|
547
501
|
exports['default'] = Easy3wUploadM;
|
|
548
502
|
module.exports = exports['default'];
|