coolcare-lite-scada-component 1.0.69 → 1.0.71
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,15 +103,14 @@ 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, 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:
|
|
110
110
|
_context.prev = 0;
|
|
111
111
|
setExcelDownloading(true);
|
|
112
112
|
_form$getFieldsValue = form.getFieldsValue(), dateRange = _form$getFieldsValue.dateRange, interval = _form$getFieldsValue.interval;
|
|
113
|
-
|
|
114
|
-
_context.next = 6;
|
|
113
|
+
_context.next = 5;
|
|
115
114
|
return DownHistoryDataToExcelOrPdf({
|
|
116
115
|
pointIdList: pointIdList,
|
|
117
116
|
timeInterval: interval,
|
|
@@ -133,30 +132,65 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
|
|
|
133
132
|
'Content-Type': 'application/json'
|
|
134
133
|
}
|
|
135
134
|
});
|
|
136
|
-
case
|
|
135
|
+
case 5:
|
|
137
136
|
res = _context.sent;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
137
|
+
if (!(!res || res.size === 0)) {
|
|
138
|
+
_context.next = 10;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
message.error('服务器返回空文件,请稍后重试');
|
|
142
|
+
setExcelDownloading(false);
|
|
143
|
+
return _context.abrupt("return");
|
|
144
|
+
case 10:
|
|
145
|
+
// 安全的下载方式,避免权限问题
|
|
146
|
+
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");
|
|
147
|
+
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
|
|
148
|
+
// IE浏览器
|
|
149
|
+
window.navigator.msSaveOrOpenBlob(res, fileName);
|
|
150
|
+
} else {
|
|
151
|
+
blobUrl = window.URL.createObjectURL(res);
|
|
152
|
+
link = document.createElement('a');
|
|
153
|
+
link.style.display = 'none';
|
|
154
|
+
link.href = blobUrl;
|
|
155
|
+
link.download = fileName;
|
|
156
|
+
link.target = '_blank';
|
|
157
|
+
|
|
158
|
+
// 确保在用户交互上下文中执行
|
|
159
|
+
document.body.appendChild(link);
|
|
160
|
+
|
|
161
|
+
// 使用 setTimeout 确保在下一个事件循环中执行
|
|
162
|
+
setTimeout(function () {
|
|
163
|
+
try {
|
|
164
|
+
link.click();
|
|
165
|
+
} catch (clickError) {
|
|
166
|
+
// 如果点击失败,尝试打开新窗口
|
|
167
|
+
window.open(blobUrl, '_blank');
|
|
168
|
+
}
|
|
169
|
+
document.body.removeChild(link);
|
|
170
|
+
window.URL.revokeObjectURL(blobUrl);
|
|
171
|
+
}, 100);
|
|
172
|
+
}
|
|
146
173
|
setExcelDownloading(false);
|
|
147
|
-
_context.next =
|
|
174
|
+
_context.next = 20;
|
|
148
175
|
break;
|
|
149
|
-
case
|
|
150
|
-
_context.prev =
|
|
176
|
+
case 15:
|
|
177
|
+
_context.prev = 15;
|
|
151
178
|
_context.t0 = _context["catch"](0);
|
|
152
179
|
console.log(_context.t0);
|
|
153
|
-
|
|
180
|
+
// 检查是否是网络错误或API错误
|
|
181
|
+
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) {
|
|
182
|
+
message.error("\u4E0B\u8F7D\u5931\u8D25: HTTP ".concat(_context.t0.response.status));
|
|
183
|
+
} 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')) {
|
|
184
|
+
message.error('服务器响应异常,请检查网络连接');
|
|
185
|
+
} else {
|
|
186
|
+
message.error('下载excel失败');
|
|
187
|
+
}
|
|
154
188
|
setExcelDownloading(false);
|
|
155
|
-
case
|
|
189
|
+
case 20:
|
|
156
190
|
case "end":
|
|
157
191
|
return _context.stop();
|
|
158
192
|
}
|
|
159
|
-
}, _callee, null, [[0,
|
|
193
|
+
}, _callee, null, [[0, 15]]);
|
|
160
194
|
}));
|
|
161
195
|
return function downloadExcel() {
|
|
162
196
|
return _ref2.apply(this, arguments);
|
|
@@ -165,22 +199,38 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
|
|
|
165
199
|
|
|
166
200
|
/** 下载图表 */
|
|
167
201
|
var downloadImg = function downloadImg() {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
202
|
+
try {
|
|
203
|
+
var _chart$current, _chart$current$getEch;
|
|
204
|
+
// @ts-ignore
|
|
205
|
+
var _myChart = chart === null || chart === void 0 ? void 0 : (_chart$current = chart.current) === null || _chart$current === void 0 ? void 0 : (_chart$current$getEch = _chart$current.getEchartsInstance) === null || _chart$current$getEch === void 0 ? void 0 : _chart$current$getEch.call(_chart$current);
|
|
206
|
+
var blob = base64ToBlob(_myChart.getDataURL({
|
|
207
|
+
backgroundColor: '#fff'
|
|
208
|
+
}));
|
|
209
|
+
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
|
|
210
|
+
// IE浏览器
|
|
211
|
+
window.navigator.msSaveOrOpenBlob(blob, 'chart.jpg');
|
|
212
|
+
} else {
|
|
213
|
+
var blobUrl = window.URL.createObjectURL(blob);
|
|
214
|
+
var link = document.createElement('a');
|
|
215
|
+
link.style.display = 'none';
|
|
216
|
+
link.href = blobUrl;
|
|
217
|
+
link.download = 'chart.jpg';
|
|
218
|
+
link.target = '_blank';
|
|
219
|
+
document.body.appendChild(link);
|
|
220
|
+
setTimeout(function () {
|
|
221
|
+
try {
|
|
222
|
+
link.click();
|
|
223
|
+
} catch (clickError) {
|
|
224
|
+
window.open(blobUrl, '_blank');
|
|
225
|
+
}
|
|
226
|
+
document.body.removeChild(link);
|
|
227
|
+
window.URL.revokeObjectURL(blobUrl);
|
|
228
|
+
}, 100);
|
|
229
|
+
}
|
|
230
|
+
} catch (e) {
|
|
231
|
+
console.error('下载图表失败:', e);
|
|
232
|
+
message.error('下载图表失败');
|
|
233
|
+
}
|
|
184
234
|
};
|
|
185
235
|
var closeModal = function closeModal() {
|
|
186
236
|
form.resetFields();
|
package/es/services/request.js
CHANGED