easy3wui 4.0.31-beta2 → 4.0.33
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/Easy3wModal/index.js +133 -5
- package/package.json +1 -1
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);
|
|
@@ -99,30 +103,150 @@ 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
|
+
// 统一的 loading 检查
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
Easy3wModal.checkLoadingAndRun = function checkLoadingAndRun(callback) {
|
|
117
|
+
var loadingFlag = Easy3wModal.getLoading();
|
|
118
|
+
if (loadingFlag) {
|
|
119
|
+
_notification3['default'].warning({
|
|
120
|
+
message: '温馨提示',
|
|
121
|
+
description: '操作正在进行中,请稍后!',
|
|
122
|
+
duration: 3
|
|
123
|
+
});
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (typeof callback === 'function') {
|
|
127
|
+
return callback();
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
// confirm
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
Easy3wModal.confirm = function confirm() {
|
|
134
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
135
|
+
var _onOk = props.onOk,
|
|
136
|
+
restProps = (0, _objectWithoutProperties3['default'])(props, ['onOk']);
|
|
137
|
+
|
|
138
|
+
return _modal2['default'].confirm((0, _extends3['default'])({}, restProps, {
|
|
139
|
+
onOk: function onOk() {
|
|
140
|
+
var loadingFlag = Easy3wModal.getLoading();
|
|
141
|
+
if (loadingFlag) {
|
|
142
|
+
_notification3['default'].warning({
|
|
143
|
+
message: '温馨提示',
|
|
144
|
+
description: '操作正在进行中,请稍后!',
|
|
145
|
+
duration: 3
|
|
146
|
+
});
|
|
147
|
+
return Promise.reject(); // 阻止 Modal 自动关闭
|
|
148
|
+
}
|
|
149
|
+
if (typeof _onOk === 'function') {
|
|
150
|
+
return _onOk();
|
|
151
|
+
}
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
}));
|
|
155
|
+
};
|
|
156
|
+
// info
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
Easy3wModal.info = function info() {
|
|
160
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
161
|
+
|
|
162
|
+
// 判断类型
|
|
163
|
+
var options = typeof props === 'string' || typeof props === 'number' ? { content: props } : props;
|
|
164
|
+
var _onOk2 = options.onOk,
|
|
165
|
+
restProps = (0, _objectWithoutProperties3['default'])(options, ['onOk']);
|
|
166
|
+
|
|
167
|
+
return _modal2['default'].info((0, _extends3['default'])({}, restProps, {
|
|
168
|
+
onOk: function onOk() {
|
|
169
|
+
return Easy3wModal.checkLoadingAndRun(_onOk2);
|
|
170
|
+
}
|
|
171
|
+
}));
|
|
172
|
+
};
|
|
173
|
+
// success
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
Easy3wModal.success = function success() {
|
|
177
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
178
|
+
|
|
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
|
+
}));
|
|
189
|
+
};
|
|
190
|
+
// error
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
Easy3wModal.error = function error() {
|
|
194
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
195
|
+
|
|
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
|
+
}));
|
|
206
|
+
};
|
|
207
|
+
// warning
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
Easy3wModal.warning = function warning() {
|
|
211
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
212
|
+
|
|
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
|
+
}));
|
|
223
|
+
};
|
|
102
224
|
|
|
103
225
|
Easy3wModal.prototype.render = function render() {
|
|
104
226
|
var _props = this.props,
|
|
105
227
|
title = _props.title,
|
|
106
228
|
children = _props.children,
|
|
107
229
|
visible = _props.visible,
|
|
108
|
-
|
|
230
|
+
loadingFlag = _props.loadingFlag,
|
|
109
231
|
cancelHandler = _props.cancelHandler,
|
|
110
232
|
onOk = _props.onOk,
|
|
111
|
-
width = _props.width
|
|
233
|
+
width = _props.width,
|
|
234
|
+
footBtnArr = _props.footBtnArr;
|
|
112
235
|
|
|
113
|
-
var btnObj = this.getBtnObj();
|
|
236
|
+
var btnObj = footBtnArr && footBtnArr.length ? this.getBtnObj() : null;
|
|
114
237
|
return _react2['default'].createElement(
|
|
115
238
|
_modal2['default'],
|
|
116
239
|
(0, _extends3['default'])({
|
|
117
240
|
title: title,
|
|
118
241
|
visible: visible,
|
|
119
|
-
confirmLoading:
|
|
242
|
+
confirmLoading: loadingFlag,
|
|
120
243
|
onCancel: cancelHandler,
|
|
121
244
|
onOk: onOk,
|
|
122
245
|
footer: btnObj,
|
|
123
246
|
width: width,
|
|
124
247
|
destroyOnClose: true,
|
|
125
|
-
|
|
248
|
+
maskClosable: false,
|
|
249
|
+
style: { top: 20, zIndex: 99998 }
|
|
126
250
|
}, this.props, {
|
|
127
251
|
afterClose: function afterClose() {
|
|
128
252
|
document.body.style.overflow = '';
|
|
@@ -135,6 +259,10 @@ var Easy3wModal = function (_Component) {
|
|
|
135
259
|
return Easy3wModal;
|
|
136
260
|
}(_react.Component);
|
|
137
261
|
|
|
262
|
+
Easy3wModal.getLoading = function () {
|
|
263
|
+
return false;
|
|
264
|
+
};
|
|
265
|
+
|
|
138
266
|
exports['default'] = (0, _dva.connect)(function (state) {
|
|
139
267
|
return {
|
|
140
268
|
loadingFlag: state.loading
|