easy3wui 4.0.31-beta2 → 4.0.33-beta.1
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/Easy3wDownLoad/index.js +27 -12
- package/lib/Easy3wModal/index.js +184 -11
- package/package.json +1 -1
|
@@ -68,7 +68,8 @@ var Easy3wDownLoad = function (_Component) {
|
|
|
68
68
|
|
|
69
69
|
var _this = (0, _possibleConstructorReturn3['default'])(this, _Component.call(this, props));
|
|
70
70
|
|
|
71
|
-
_this.onPreview = function (file, url) {
|
|
71
|
+
_this.onPreview = function (e, file, url) {
|
|
72
|
+
e.preventDefault();
|
|
72
73
|
var objPreviewFileNew = (0, _extends3['default'])({}, _comonConfig.objPreviewFile, _this.props.objPreviewFile);
|
|
73
74
|
var previewFileUrl = objPreviewFileNew.previewFileUrl,
|
|
74
75
|
previewFileType = objPreviewFileNew.previewFileType;
|
|
@@ -115,7 +116,8 @@ var Easy3wDownLoad = function (_Component) {
|
|
|
115
116
|
}
|
|
116
117
|
};
|
|
117
118
|
|
|
118
|
-
_this.showFileView = function (uid, name, apiKey, fileViewURL, fileCallURL) {
|
|
119
|
+
_this.showFileView = function (e, uid, name, apiKey, fileViewURL, fileCallURL) {
|
|
120
|
+
e.preventDefault();
|
|
119
121
|
var callURl = fileCallURL + '?fileId=' + uid;
|
|
120
122
|
var crypto = require('crypto');
|
|
121
123
|
var hmac = crypto.createHmac('md5', apiKey);
|
|
@@ -126,6 +128,11 @@ var Easy3wDownLoad = function (_Component) {
|
|
|
126
128
|
_this.setState({ fileId: uid, fileName: name, fileViewFlag: true, viewFileUrl: viewFileUrl });
|
|
127
129
|
};
|
|
128
130
|
|
|
131
|
+
_this.showPdfView = function (e, uid, url, name) {
|
|
132
|
+
e.preventDefault();
|
|
133
|
+
_this.setState({ pdfViewFlag: true, fileId: uid, fileURL: url, fileName: name });
|
|
134
|
+
};
|
|
135
|
+
|
|
129
136
|
_this.hidePDFModal = function () {
|
|
130
137
|
_this.setState({ fileId: '', fileURL: '', fileName: '', pdfViewFlag: false });
|
|
131
138
|
};
|
|
@@ -138,7 +145,8 @@ var Easy3wDownLoad = function (_Component) {
|
|
|
138
145
|
_this.setState({ fileId: '', fileURL: '', fileName: '' });
|
|
139
146
|
};
|
|
140
147
|
|
|
141
|
-
_this.showImageView = function (url) {
|
|
148
|
+
_this.showImageView = function (e, url) {
|
|
149
|
+
e.preventDefault();
|
|
142
150
|
_this.setState({ imageViewURL: url });
|
|
143
151
|
};
|
|
144
152
|
|
|
@@ -158,6 +166,12 @@ var Easy3wDownLoad = function (_Component) {
|
|
|
158
166
|
|
|
159
167
|
// url处理
|
|
160
168
|
|
|
169
|
+
// 显示文件预览
|
|
170
|
+
|
|
171
|
+
// 显示pdf预览
|
|
172
|
+
|
|
173
|
+
// 图片预览
|
|
174
|
+
|
|
161
175
|
|
|
162
176
|
Easy3wDownLoad.prototype.render = function render() {
|
|
163
177
|
var _this2 = this;
|
|
@@ -173,7 +187,8 @@ var Easy3wDownLoad = function (_Component) {
|
|
|
173
187
|
|
|
174
188
|
var objPreviewFileNew = (0, _extends3['default'])({}, _comonConfig.objPreviewFile, this.props.objPreviewFile);
|
|
175
189
|
var previewFileFlag = objPreviewFileNew.previewFileFlag,
|
|
176
|
-
|
|
190
|
+
_objPreviewFileNew$do = objPreviewFileNew.downloadFileFlag,
|
|
191
|
+
downloadFileFlag = _objPreviewFileNew$do === undefined ? '' : _objPreviewFileNew$do,
|
|
177
192
|
previewFileType = objPreviewFileNew.previewFileType;
|
|
178
193
|
|
|
179
194
|
var retObj = '';
|
|
@@ -196,8 +211,8 @@ var Easy3wDownLoad = function (_Component) {
|
|
|
196
211
|
{ placement: 'topLeft', title: name, style: { whiteSpace: 'pre-wrap', wordWrap: 'break-word' } },
|
|
197
212
|
_react2['default'].createElement(
|
|
198
213
|
'a',
|
|
199
|
-
{ onClick: function onClick() {
|
|
200
|
-
return _this2.onPreview(obj, url);
|
|
214
|
+
{ href: url, onClick: function onClick(e) {
|
|
215
|
+
return _this2.onPreview(e, obj, url);
|
|
201
216
|
}, style: { overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis', paddingRight: '12px' } },
|
|
202
217
|
name
|
|
203
218
|
)
|
|
@@ -214,8 +229,8 @@ var Easy3wDownLoad = function (_Component) {
|
|
|
214
229
|
null,
|
|
215
230
|
_react2['default'].createElement(
|
|
216
231
|
'a',
|
|
217
|
-
{ onClick: function onClick() {
|
|
218
|
-
return _this2.
|
|
232
|
+
{ href: url, onClick: function onClick(e) {
|
|
233
|
+
return _this2.showPdfView(e, uid, url, name);
|
|
219
234
|
} },
|
|
220
235
|
name
|
|
221
236
|
)
|
|
@@ -226,8 +241,8 @@ var Easy3wDownLoad = function (_Component) {
|
|
|
226
241
|
null,
|
|
227
242
|
_react2['default'].createElement(
|
|
228
243
|
'a',
|
|
229
|
-
{ onClick: function onClick() {
|
|
230
|
-
return _this2.showFileView(uid, name, apiKey, fileViewURL, fileCallURL);
|
|
244
|
+
{ href: url, onClick: function onClick(e) {
|
|
245
|
+
return _this2.showFileView(e, uid, name, apiKey, fileViewURL, fileCallURL);
|
|
231
246
|
} },
|
|
232
247
|
name
|
|
233
248
|
)
|
|
@@ -238,8 +253,8 @@ var Easy3wDownLoad = function (_Component) {
|
|
|
238
253
|
{ style: { width: '100%', display: 'flex', alignItems: 'center' } },
|
|
239
254
|
_react2['default'].createElement(
|
|
240
255
|
'a',
|
|
241
|
-
{ onClick: function onClick() {
|
|
242
|
-
return _this2.showImageView(url);
|
|
256
|
+
{ href: url, onClick: function onClick(e) {
|
|
257
|
+
return _this2.showImageView(e, url);
|
|
243
258
|
}, style: { overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis', paddingRight: '12px' } },
|
|
244
259
|
name
|
|
245
260
|
),
|
package/lib/Easy3wModal/index.js
CHANGED
|
@@ -6,6 +6,10 @@ var _extends2 = require('babel-runtime/helpers/extends');
|
|
|
6
6
|
|
|
7
7
|
var _extends3 = _interopRequireDefault(_extends2);
|
|
8
8
|
|
|
9
|
+
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
|
|
10
|
+
|
|
11
|
+
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
|
|
12
|
+
|
|
9
13
|
var _notification2 = require('antd/lib/notification');
|
|
10
14
|
|
|
11
15
|
var _notification3 = _interopRequireDefault(_notification2);
|
|
@@ -28,8 +32,6 @@ var _react = require('react');
|
|
|
28
32
|
|
|
29
33
|
var _react2 = _interopRequireDefault(_react);
|
|
30
34
|
|
|
31
|
-
var _dva = require('dva');
|
|
32
|
-
|
|
33
35
|
var _antd = require('antd');
|
|
34
36
|
|
|
35
37
|
var _modal = require('antd/lib/modal');
|
|
@@ -38,6 +40,8 @@ var _modal2 = _interopRequireDefault(_modal);
|
|
|
38
40
|
|
|
39
41
|
require('antd/lib/modal/style');
|
|
40
42
|
|
|
43
|
+
var _dva = require('dva');
|
|
44
|
+
|
|
41
45
|
var _button = require('antd/lib/button');
|
|
42
46
|
|
|
43
47
|
var _button2 = _interopRequireDefault(_button);
|
|
@@ -77,12 +81,12 @@ var Easy3wModal = function (_Component) {
|
|
|
77
81
|
return _react2['default'].createElement(
|
|
78
82
|
_button2['default'],
|
|
79
83
|
{
|
|
80
|
-
onClick: function onClick(e) {
|
|
81
|
-
return _this.onClickFunc(e, obj.func);
|
|
82
|
-
},
|
|
83
84
|
type: 'primary',
|
|
84
85
|
className: (0, _classnames2['default'])(['e3wFootBtn']),
|
|
85
|
-
loading: obj.loading
|
|
86
|
+
loading: obj.loading,
|
|
87
|
+
onClick: function onClick(e) {
|
|
88
|
+
return _this.onClickFunc(e, obj.func);
|
|
89
|
+
}
|
|
86
90
|
},
|
|
87
91
|
obj.cName
|
|
88
92
|
);
|
|
@@ -99,30 +103,195 @@ var Easy3wModal = function (_Component) {
|
|
|
99
103
|
);
|
|
100
104
|
}, _temp), (0, _possibleConstructorReturn3['default'])(_this, _ret);
|
|
101
105
|
}
|
|
106
|
+
// 获取loading状态
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
// 供脚手架index存store
|
|
110
|
+
Easy3wModal.setGetLoading = function setGetLoading(fn) {
|
|
111
|
+
Easy3wModal.getLoading = fn;
|
|
112
|
+
};
|
|
113
|
+
// 返回一个promise
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
Easy3wModal.returnPromise = function returnPromise() {
|
|
117
|
+
var onOk = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {};
|
|
118
|
+
|
|
119
|
+
return new Promise(function (resolve) {
|
|
120
|
+
try {
|
|
121
|
+
onOk();
|
|
122
|
+
setTimeout(function () {
|
|
123
|
+
resolve(); // 300ms 后关闭 Modal
|
|
124
|
+
document.body.style.overflow = '';
|
|
125
|
+
}, 300);
|
|
126
|
+
} catch (e) {
|
|
127
|
+
console.error('onOk 执行报错:', e);
|
|
128
|
+
resolve(); // 出错时不关闭
|
|
129
|
+
document.body.style.overflow = '';
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
// confirm
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
Easy3wModal.confirm = function confirm() {
|
|
137
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
138
|
+
var _onOk = props.onOk,
|
|
139
|
+
_onCancel = props.onCancel,
|
|
140
|
+
restProps = (0, _objectWithoutProperties3['default'])(props, ['onOk', 'onCancel']);
|
|
141
|
+
|
|
142
|
+
return _modal2['default'].confirm((0, _extends3['default'])({}, restProps, {
|
|
143
|
+
onCancel: function onCancel() {
|
|
144
|
+
if (_onCancel) {
|
|
145
|
+
_onCancel();
|
|
146
|
+
}
|
|
147
|
+
document.body.style.overflow = '';
|
|
148
|
+
},
|
|
149
|
+
onOk: function onOk() {
|
|
150
|
+
// 1. 检查全局 loading 状态,阻止重复操作
|
|
151
|
+
var loadingFlag = Easy3wModal.getLoading();
|
|
152
|
+
if (loadingFlag) {
|
|
153
|
+
_notification3['default'].warning({
|
|
154
|
+
message: '温馨提示',
|
|
155
|
+
description: '操作正在进行中,请稍后!',
|
|
156
|
+
duration: 3
|
|
157
|
+
});
|
|
158
|
+
return Promise.reject(); // 阻止 Modal 自动关闭
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// 2. onOk不是函数,关闭
|
|
162
|
+
if (typeof _onOk !== 'function') {
|
|
163
|
+
return true; // 直接关闭 Modal
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// 3. 执行onOk
|
|
167
|
+
return new Promise(function (resolve) {
|
|
168
|
+
try {
|
|
169
|
+
_onOk();
|
|
170
|
+
setTimeout(function () {
|
|
171
|
+
resolve(); // 300ms 后关闭 Modal
|
|
172
|
+
document.body.style.overflow = '';
|
|
173
|
+
}, 300);
|
|
174
|
+
} catch (e) {
|
|
175
|
+
console.error('onOk 执行报错:', e);
|
|
176
|
+
resolve(); // 出错时不关闭
|
|
177
|
+
document.body.style.overflow = '';
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}));
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
// 展示modal
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
Easy3wModal.showModal = function showModal(type) {
|
|
188
|
+
var _this2 = this;
|
|
189
|
+
|
|
190
|
+
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
191
|
+
|
|
192
|
+
// 1. 判断参数类型
|
|
193
|
+
var options = typeof props === 'string' || typeof props === 'number' ? { content: props } : props;
|
|
194
|
+
|
|
195
|
+
var _onOk2 = options.onOk,
|
|
196
|
+
_onCancel2 = options.onCancel,
|
|
197
|
+
restProps = (0, _objectWithoutProperties3['default'])(options, ['onOk', 'onCancel']);
|
|
198
|
+
|
|
199
|
+
// 2. 定义统一的关闭逻辑
|
|
200
|
+
|
|
201
|
+
var resetBodyOverflow = function resetBodyOverflow() {
|
|
202
|
+
document.body.style.overflow = '';
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
// 3. 调用对应类型的 Modal 方法
|
|
206
|
+
return _modal2['default'][type]((0, _extends3['default'])({}, restProps, {
|
|
207
|
+
onCancel: function onCancel() {
|
|
208
|
+
if (_onCancel2) {
|
|
209
|
+
_onCancel2();
|
|
210
|
+
}
|
|
211
|
+
resetBodyOverflow();
|
|
212
|
+
},
|
|
213
|
+
onOk: function onOk() {
|
|
214
|
+
if (_onOk2) {
|
|
215
|
+
var loadingFlag = Easy3wModal.getLoading();
|
|
216
|
+
if (loadingFlag) {
|
|
217
|
+
_notification3['default'].warning({
|
|
218
|
+
message: '温馨提示',
|
|
219
|
+
description: '操作正在进行中,请稍后!',
|
|
220
|
+
duration: 3
|
|
221
|
+
});
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
if (typeof _onOk2 !== 'function') {
|
|
225
|
+
return true; // 直接关闭 Modal
|
|
226
|
+
}
|
|
227
|
+
_this2.returnPromise(_onOk2).then(function () {});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}));
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
// info
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
Easy3wModal.info = function info() {
|
|
237
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
238
|
+
|
|
239
|
+
return this.showModal('info', props);
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
// success
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
Easy3wModal.success = function success() {
|
|
246
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
247
|
+
|
|
248
|
+
return this.showModal('success', props);
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
// error
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
Easy3wModal.error = function error() {
|
|
255
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
256
|
+
|
|
257
|
+
return this.showModal('error', props);
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
// warning
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
Easy3wModal.warning = function warning() {
|
|
264
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
265
|
+
|
|
266
|
+
return this.showModal('warning', props);
|
|
267
|
+
};
|
|
102
268
|
|
|
103
269
|
Easy3wModal.prototype.render = function render() {
|
|
104
270
|
var _props = this.props,
|
|
105
271
|
title = _props.title,
|
|
106
272
|
children = _props.children,
|
|
107
273
|
visible = _props.visible,
|
|
108
|
-
|
|
274
|
+
loadingFlag = _props.loadingFlag,
|
|
109
275
|
cancelHandler = _props.cancelHandler,
|
|
110
276
|
onOk = _props.onOk,
|
|
111
|
-
width = _props.width
|
|
277
|
+
width = _props.width,
|
|
278
|
+
footer = _props.footer,
|
|
279
|
+
footBtnArr = _props.footBtnArr;
|
|
112
280
|
|
|
113
|
-
var btnObj = this.getBtnObj();
|
|
281
|
+
var btnObj = footer && footer.length ? footer : footBtnArr && footBtnArr.length ? this.getBtnObj() : null;
|
|
114
282
|
return _react2['default'].createElement(
|
|
115
283
|
_modal2['default'],
|
|
116
284
|
(0, _extends3['default'])({
|
|
117
285
|
title: title,
|
|
118
286
|
visible: visible,
|
|
119
|
-
confirmLoading:
|
|
287
|
+
confirmLoading: loadingFlag,
|
|
120
288
|
onCancel: cancelHandler,
|
|
121
289
|
onOk: onOk,
|
|
122
290
|
footer: btnObj,
|
|
123
291
|
width: width,
|
|
124
292
|
destroyOnClose: true,
|
|
125
|
-
|
|
293
|
+
maskClosable: false,
|
|
294
|
+
style: { top: 20, zIndex: 99998 }
|
|
126
295
|
}, this.props, {
|
|
127
296
|
afterClose: function afterClose() {
|
|
128
297
|
document.body.style.overflow = '';
|
|
@@ -135,6 +304,10 @@ var Easy3wModal = function (_Component) {
|
|
|
135
304
|
return Easy3wModal;
|
|
136
305
|
}(_react.Component);
|
|
137
306
|
|
|
307
|
+
Easy3wModal.getLoading = function () {
|
|
308
|
+
return false;
|
|
309
|
+
};
|
|
310
|
+
|
|
138
311
|
exports['default'] = (0, _dva.connect)(function (state) {
|
|
139
312
|
return {
|
|
140
313
|
loadingFlag: state.loading
|