coolcare-lite-scada-component 1.0.70 → 1.0.72

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.
@@ -103,7 +103,7 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
103
103
  /** 下载excel、pdf */
104
104
  var downloadExcel = /*#__PURE__*/function () {
105
105
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
106
- var _form$getFieldsValue, dateRange, interval, res, fileName, blobUrl, link;
106
+ var _form$getFieldsValue, dateRange, interval, res, fileName, blobUrl, link, _e$response, _e$message;
107
107
  return _regeneratorRuntime().wrap(function _callee$(_context) {
108
108
  while (1) switch (_context.prev = _context.next) {
109
109
  case 0:
@@ -128,12 +128,21 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
128
128
  zipFileList: []
129
129
  }, {
130
130
  responseType: 'blob',
131
+ shouldHandleBlob: false,
131
132
  headers: {
132
133
  'Content-Type': 'application/json'
133
134
  }
134
135
  });
135
136
  case 5:
136
137
  res = _context.sent;
138
+ if (!(!res || res.size === 0)) {
139
+ _context.next = 10;
140
+ break;
141
+ }
142
+ message.error('服务器返回空文件,请稍后重试');
143
+ setExcelDownloading(false);
144
+ return _context.abrupt("return");
145
+ case 10:
137
146
  // 安全的下载方式,避免权限问题
138
147
  fileName = "history_".concat(moment(dateRange[0]).format('YYYY-MM-DD HH:mm:ss'), "_").concat(moment(dateRange[1]).format('YYYY-MM-DD HH:mm:ss'), ".zip");
139
148
  if (window.navigator && window.navigator.msSaveOrOpenBlob) {
@@ -163,19 +172,26 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
163
172
  }, 100);
164
173
  }
165
174
  setExcelDownloading(false);
166
- _context.next = 16;
175
+ _context.next = 20;
167
176
  break;
168
- case 11:
169
- _context.prev = 11;
177
+ case 15:
178
+ _context.prev = 15;
170
179
  _context.t0 = _context["catch"](0);
171
180
  console.log(_context.t0);
172
- message.error('下载excel失败');
181
+ // 检查是否是网络错误或API错误
182
+ if (_context.t0 === null || _context.t0 === void 0 ? void 0 : (_e$response = _context.t0.response) === null || _e$response === void 0 ? void 0 : _e$response.status) {
183
+ message.error("\u4E0B\u8F7D\u5931\u8D25: HTTP ".concat(_context.t0.response.status));
184
+ } else if (_context.t0 === null || _context.t0 === void 0 ? void 0 : (_e$message = _context.t0.message) === null || _e$message === void 0 ? void 0 : _e$message.includes('response')) {
185
+ message.error('服务器响应异常,请检查网络连接');
186
+ } else {
187
+ message.error('下载excel失败');
188
+ }
173
189
  setExcelDownloading(false);
174
- case 16:
190
+ case 20:
175
191
  case "end":
176
192
  return _context.stop();
177
193
  }
178
- }, _callee, null, [[0, 11]]);
194
+ }, _callee, null, [[0, 15]]);
179
195
  }));
180
196
  return function downloadExcel() {
181
197
  return _ref2.apply(this, arguments);
@@ -174,7 +174,7 @@ requestClient.interceptors.response.use(/*#__PURE__*/function () {
174
174
  break;
175
175
  }
176
176
  _context2.next = 7;
177
- return response.clone().blob();
177
+ return response.blob();
178
178
  case 7:
179
179
  return _context2.abrupt("return", _context2.sent);
180
180
  case 8:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coolcare-lite-scada-component",
3
- "version": "1.0.70",
3
+ "version": "1.0.72",
4
4
  "scripts": {
5
5
  "start": " PORT=8000 UMI_ENV=prod umi dev",
6
6
  "build:prod": "UMI_ENV=prod umi build",