easy3wui 4.0.33 → 4.0.35
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 +107 -62
- 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
|
@@ -32,8 +32,6 @@ var _react = require('react');
|
|
|
32
32
|
|
|
33
33
|
var _react2 = _interopRequireDefault(_react);
|
|
34
34
|
|
|
35
|
-
var _dva = require('dva');
|
|
36
|
-
|
|
37
35
|
var _antd = require('antd');
|
|
38
36
|
|
|
39
37
|
var _modal = require('antd/lib/modal');
|
|
@@ -42,6 +40,8 @@ var _modal2 = _interopRequireDefault(_modal);
|
|
|
42
40
|
|
|
43
41
|
require('antd/lib/modal/style');
|
|
44
42
|
|
|
43
|
+
var _dva = require('dva');
|
|
44
|
+
|
|
45
45
|
var _button = require('antd/lib/button');
|
|
46
46
|
|
|
47
47
|
var _button2 = _interopRequireDefault(_button);
|
|
@@ -81,12 +81,12 @@ var Easy3wModal = function (_Component) {
|
|
|
81
81
|
return _react2['default'].createElement(
|
|
82
82
|
_button2['default'],
|
|
83
83
|
{
|
|
84
|
-
onClick: function onClick(e) {
|
|
85
|
-
return _this.onClickFunc(e, obj.func);
|
|
86
|
-
},
|
|
87
84
|
type: 'primary',
|
|
88
85
|
className: (0, _classnames2['default'])(['e3wFootBtn']),
|
|
89
|
-
loading: obj.loading
|
|
86
|
+
loading: obj.loading,
|
|
87
|
+
onClick: function onClick(e) {
|
|
88
|
+
return _this.onClickFunc(e, obj.func);
|
|
89
|
+
}
|
|
90
90
|
},
|
|
91
91
|
obj.cName
|
|
92
92
|
);
|
|
@@ -110,22 +110,25 @@ var Easy3wModal = function (_Component) {
|
|
|
110
110
|
Easy3wModal.setGetLoading = function setGetLoading(fn) {
|
|
111
111
|
Easy3wModal.getLoading = fn;
|
|
112
112
|
};
|
|
113
|
-
//
|
|
113
|
+
// 返回一个promise
|
|
114
114
|
|
|
115
115
|
|
|
116
|
-
Easy3wModal.
|
|
117
|
-
var
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
+
});
|
|
129
132
|
};
|
|
130
133
|
// confirm
|
|
131
134
|
|
|
@@ -133,10 +136,18 @@ var Easy3wModal = function (_Component) {
|
|
|
133
136
|
Easy3wModal.confirm = function confirm() {
|
|
134
137
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
135
138
|
var _onOk = props.onOk,
|
|
136
|
-
|
|
139
|
+
_onCancel = props.onCancel,
|
|
140
|
+
restProps = (0, _objectWithoutProperties3['default'])(props, ['onOk', 'onCancel']);
|
|
137
141
|
|
|
138
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
|
+
},
|
|
139
149
|
onOk: function onOk() {
|
|
150
|
+
// 1. 检查全局 loading 状态,阻止重复操作
|
|
140
151
|
var loadingFlag = Easy3wModal.getLoading();
|
|
141
152
|
if (loadingFlag) {
|
|
142
153
|
_notification3['default'].warning({
|
|
@@ -146,80 +157,113 @@ var Easy3wModal = function (_Component) {
|
|
|
146
157
|
});
|
|
147
158
|
return Promise.reject(); // 阻止 Modal 自动关闭
|
|
148
159
|
}
|
|
149
|
-
|
|
150
|
-
|
|
160
|
+
|
|
161
|
+
// 2. onOk不是函数,关闭
|
|
162
|
+
if (typeof _onOk !== 'function') {
|
|
163
|
+
return true; // 直接关闭 Modal
|
|
151
164
|
}
|
|
152
|
-
|
|
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
|
+
});
|
|
153
180
|
}
|
|
154
181
|
}));
|
|
155
182
|
};
|
|
156
|
-
// info
|
|
157
183
|
|
|
184
|
+
// 展示modal
|
|
158
185
|
|
|
159
|
-
Easy3wModal.info = function info() {
|
|
160
|
-
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
161
186
|
|
|
162
|
-
|
|
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. 判断参数类型
|
|
163
193
|
var options = typeof props === 'string' || typeof props === 'number' ? { content: props } : props;
|
|
194
|
+
|
|
164
195
|
var _onOk2 = options.onOk,
|
|
165
|
-
|
|
196
|
+
_onCancel2 = options.onCancel,
|
|
197
|
+
restProps = (0, _objectWithoutProperties3['default'])(options, ['onOk', 'onCancel']);
|
|
166
198
|
|
|
167
|
-
|
|
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
|
+
},
|
|
168
213
|
onOk: function onOk() {
|
|
169
|
-
|
|
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
|
+
}
|
|
170
229
|
}
|
|
171
230
|
}));
|
|
172
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
|
+
|
|
173
242
|
// success
|
|
174
243
|
|
|
175
244
|
|
|
176
245
|
Easy3wModal.success = function success() {
|
|
177
246
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
178
247
|
|
|
179
|
-
|
|
180
|
-
var options = typeof props === 'string' || typeof props === 'number' ? { content: props } : props;
|
|
181
|
-
var _onOk3 = options.onOk,
|
|
182
|
-
restProps = (0, _objectWithoutProperties3['default'])(options, ['onOk']);
|
|
183
|
-
|
|
184
|
-
return _modal2['default'].success((0, _extends3['default'])({}, restProps, {
|
|
185
|
-
onOk: function onOk() {
|
|
186
|
-
return Easy3wModal.checkLoadingAndRun(_onOk3);
|
|
187
|
-
}
|
|
188
|
-
}));
|
|
248
|
+
return this.showModal('success', props);
|
|
189
249
|
};
|
|
250
|
+
|
|
190
251
|
// error
|
|
191
252
|
|
|
192
253
|
|
|
193
254
|
Easy3wModal.error = function error() {
|
|
194
255
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
195
256
|
|
|
196
|
-
|
|
197
|
-
var options = typeof props === 'string' || typeof props === 'number' ? { content: props } : props;
|
|
198
|
-
var _onOk4 = options.onOk,
|
|
199
|
-
restProps = (0, _objectWithoutProperties3['default'])(options, ['onOk']);
|
|
200
|
-
|
|
201
|
-
return _modal2['default'].error((0, _extends3['default'])({}, restProps, {
|
|
202
|
-
onOk: function onOk() {
|
|
203
|
-
return Easy3wModal.checkLoadingAndRun(_onOk4);
|
|
204
|
-
}
|
|
205
|
-
}));
|
|
257
|
+
return this.showModal('error', props);
|
|
206
258
|
};
|
|
259
|
+
|
|
207
260
|
// warning
|
|
208
261
|
|
|
209
262
|
|
|
210
263
|
Easy3wModal.warning = function warning() {
|
|
211
264
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
212
265
|
|
|
213
|
-
|
|
214
|
-
var options = typeof props === 'string' || typeof props === 'number' ? { content: props } : props;
|
|
215
|
-
var _onOk5 = options.onOk,
|
|
216
|
-
restProps = (0, _objectWithoutProperties3['default'])(options, ['onOk']);
|
|
217
|
-
|
|
218
|
-
return _modal2['default'].warning((0, _extends3['default'])({}, restProps, {
|
|
219
|
-
onOk: function onOk() {
|
|
220
|
-
return Easy3wModal.checkLoadingAndRun(_onOk5);
|
|
221
|
-
}
|
|
222
|
-
}));
|
|
266
|
+
return this.showModal('warning', props);
|
|
223
267
|
};
|
|
224
268
|
|
|
225
269
|
Easy3wModal.prototype.render = function render() {
|
|
@@ -231,9 +275,10 @@ var Easy3wModal = function (_Component) {
|
|
|
231
275
|
cancelHandler = _props.cancelHandler,
|
|
232
276
|
onOk = _props.onOk,
|
|
233
277
|
width = _props.width,
|
|
278
|
+
footer = _props.footer,
|
|
234
279
|
footBtnArr = _props.footBtnArr;
|
|
235
280
|
|
|
236
|
-
var btnObj = footBtnArr && footBtnArr.length ? this.getBtnObj() : null;
|
|
281
|
+
var btnObj = footer && footer.length ? footer : footBtnArr && footBtnArr.length ? this.getBtnObj() : null;
|
|
237
282
|
return _react2['default'].createElement(
|
|
238
283
|
_modal2['default'],
|
|
239
284
|
(0, _extends3['default'])({
|