coolcare-lite-scada-component 1.0.67 → 1.0.69

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.
@@ -1,9 +1,9 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return r; }; var t, r = {}, e = Object.prototype, n = e.hasOwnProperty, o = "function" == typeof Symbol ? Symbol : {}, i = o.iterator || "@@iterator", a = o.asyncIterator || "@@asyncIterator", u = o.toStringTag || "@@toStringTag"; function c(t, r, e, n) { return Object.defineProperty(t, r, { value: e, enumerable: !n, configurable: !n, writable: !n }); } try { c({}, ""); } catch (t) { c = function c(t, r, e) { return t[r] = e; }; } function h(r, e, n, o) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype); return c(a, "_invoke", function (r, e, n) { var o = 1; return function (i, a) { if (3 === o) throw Error("Generator is already running"); if (4 === o) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var u = n.delegate; if (u) { var c = d(u, n); if (c) { if (c === f) continue; return c; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (1 === o) throw o = 4, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = 3; var h = s(r, e, n); if ("normal" === h.type) { if (o = n.done ? 4 : 2, h.arg === f) continue; return { value: h.arg, done: n.done }; } "throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg); } }; }(r, n, new Context(o || [])), !0), a; } function s(t, r, e) { try { return { type: "normal", arg: t.call(r, e) }; } catch (t) { return { type: "throw", arg: t }; } } r.wrap = h; var f = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var l = {}; c(l, i, function () { return this; }); var p = Object.getPrototypeOf, y = p && p(p(x([]))); y && y !== e && n.call(y, i) && (l = y); var v = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(l); function g(t) { ["next", "throw", "return"].forEach(function (r) { c(t, r, function (t) { return this._invoke(r, t); }); }); } function AsyncIterator(t, r) { function e(o, i, a, u) { var c = s(t[o], t, i); if ("throw" !== c.type) { var h = c.arg, f = h.value; return f && "object" == _typeof(f) && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) { e("next", t, a, u); }, function (t) { e("throw", t, a, u); }) : r.resolve(f).then(function (t) { h.value = t, a(h); }, function (t) { return e("throw", t, a, u); }); } u(c.arg); } var o; c(this, "_invoke", function (t, n) { function i() { return new r(function (r, o) { e(t, n, r, o); }); } return o = o ? o.then(i, i) : i(); }, !0); } function d(r, e) { var n = e.method, o = r.i[n]; if (o === t) return e.delegate = null, "throw" === n && r.i.return && (e.method = "return", e.arg = t, d(r, e), "throw" === e.method) || "return" !== n && (e.method = "throw", e.arg = new TypeError("The iterator does not provide a '" + n + "' method")), f; var i = s(o, r.i, e.arg); if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f; var a = i.arg; return a ? a.done ? (e[r.r] = a.value, e.next = r.n, "return" !== e.method && (e.method = "next", e.arg = t), e.delegate = null, f) : a : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, f); } function w(t) { this.tryEntries.push(t); } function m(r) { var e = r[4] || {}; e.type = "normal", e.arg = t, r[4] = e; } function Context(t) { this.tryEntries = [[-1]], t.forEach(w, this), this.reset(!0); } function x(r) { if (null != r) { var e = r[i]; if (e) return e.call(r); if ("function" == typeof r.next) return r; if (!isNaN(r.length)) { var o = -1, a = function e() { for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = !1, e; return e.value = t, e.done = !0, e; }; return a.next = a; } } throw new TypeError(_typeof(r) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, c(v, "constructor", GeneratorFunctionPrototype), c(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = c(GeneratorFunctionPrototype, u, "GeneratorFunction"), r.isGeneratorFunction = function (t) { var r = "function" == typeof t && t.constructor; return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name)); }, r.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = Object.create(v), t; }, r.awrap = function (t) { return { __await: t }; }, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () { return this; }), r.AsyncIterator = AsyncIterator, r.async = function (t, e, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(h(t, e, n, o), i); return r.isGeneratorFunction(e) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, g(v), c(v, u, "Generator"), c(v, i, function () { return this; }), c(v, "toString", function () { return "[object Generator]"; }), r.keys = function (t) { var r = Object(t), e = []; for (var n in r) e.unshift(n); return function t() { for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = !1, t; return t.done = !0, t; }; }, r.values = x, Context.prototype = { constructor: Context, reset: function reset(r) { if (this.prev = this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(m), !r) for (var e in this) "t" === e.charAt(0) && n.call(this, e) && !isNaN(+e.slice(1)) && (this[e] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0][4]; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(r) { if (this.done) throw r; var e = this; function n(t) { a.type = "throw", a.arg = r, e.next = t; } for (var o = e.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i[4], u = this.prev, c = i[1], h = i[2]; if (-1 === i[0]) return n("end"), !1; if (!c && !h) throw Error("try statement without catch or finally"); if (null != i[0] && i[0] <= u) { if (u < c) return this.method = "next", this.arg = t, n(c), !0; if (u < h) return n(h), !1; } } }, abrupt: function abrupt(t, r) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var n = this.tryEntries[e]; if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) { var o = n; break; } } o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null); var i = o ? o[4] : {}; return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i); }, complete: function complete(t, r) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && r && (this.next = r), f; }, finish: function finish(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[2] === t) return this.complete(e[4], e[3]), m(e), f; } }, catch: function _catch(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[0] === t) { var n = e[4]; if ("throw" === n.type) { var o = n.arg; m(e); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(r, e, n) { return this.delegate = { i: x(r), r: e, n: n }, "next" === this.method && (this.arg = t), f; } }, r; }
3
2
  function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
4
3
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
4
  function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
6
5
  function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
6
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return r; }; var t, r = {}, e = Object.prototype, n = e.hasOwnProperty, o = "function" == typeof Symbol ? Symbol : {}, i = o.iterator || "@@iterator", a = o.asyncIterator || "@@asyncIterator", u = o.toStringTag || "@@toStringTag"; function c(t, r, e, n) { return Object.defineProperty(t, r, { value: e, enumerable: !n, configurable: !n, writable: !n }); } try { c({}, ""); } catch (t) { c = function c(t, r, e) { return t[r] = e; }; } function h(r, e, n, o) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype); return c(a, "_invoke", function (r, e, n) { var o = 1; return function (i, a) { if (3 === o) throw Error("Generator is already running"); if (4 === o) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var u = n.delegate; if (u) { var c = d(u, n); if (c) { if (c === f) continue; return c; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (1 === o) throw o = 4, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = 3; var h = s(r, e, n); if ("normal" === h.type) { if (o = n.done ? 4 : 2, h.arg === f) continue; return { value: h.arg, done: n.done }; } "throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg); } }; }(r, n, new Context(o || [])), !0), a; } function s(t, r, e) { try { return { type: "normal", arg: t.call(r, e) }; } catch (t) { return { type: "throw", arg: t }; } } r.wrap = h; var f = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var l = {}; c(l, i, function () { return this; }); var p = Object.getPrototypeOf, y = p && p(p(x([]))); y && y !== e && n.call(y, i) && (l = y); var v = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(l); function g(t) { ["next", "throw", "return"].forEach(function (r) { c(t, r, function (t) { return this._invoke(r, t); }); }); } function AsyncIterator(t, r) { function e(o, i, a, u) { var c = s(t[o], t, i); if ("throw" !== c.type) { var h = c.arg, f = h.value; return f && "object" == _typeof(f) && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) { e("next", t, a, u); }, function (t) { e("throw", t, a, u); }) : r.resolve(f).then(function (t) { h.value = t, a(h); }, function (t) { return e("throw", t, a, u); }); } u(c.arg); } var o; c(this, "_invoke", function (t, n) { function i() { return new r(function (r, o) { e(t, n, r, o); }); } return o = o ? o.then(i, i) : i(); }, !0); } function d(r, e) { var n = e.method, o = r.i[n]; if (o === t) return e.delegate = null, "throw" === n && r.i.return && (e.method = "return", e.arg = t, d(r, e), "throw" === e.method) || "return" !== n && (e.method = "throw", e.arg = new TypeError("The iterator does not provide a '" + n + "' method")), f; var i = s(o, r.i, e.arg); if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f; var a = i.arg; return a ? a.done ? (e[r.r] = a.value, e.next = r.n, "return" !== e.method && (e.method = "next", e.arg = t), e.delegate = null, f) : a : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, f); } function w(t) { this.tryEntries.push(t); } function m(r) { var e = r[4] || {}; e.type = "normal", e.arg = t, r[4] = e; } function Context(t) { this.tryEntries = [[-1]], t.forEach(w, this), this.reset(!0); } function x(r) { if (null != r) { var e = r[i]; if (e) return e.call(r); if ("function" == typeof r.next) return r; if (!isNaN(r.length)) { var o = -1, a = function e() { for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = !1, e; return e.value = t, e.done = !0, e; }; return a.next = a; } } throw new TypeError(_typeof(r) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, c(v, "constructor", GeneratorFunctionPrototype), c(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = c(GeneratorFunctionPrototype, u, "GeneratorFunction"), r.isGeneratorFunction = function (t) { var r = "function" == typeof t && t.constructor; return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name)); }, r.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = Object.create(v), t; }, r.awrap = function (t) { return { __await: t }; }, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () { return this; }), r.AsyncIterator = AsyncIterator, r.async = function (t, e, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(h(t, e, n, o), i); return r.isGeneratorFunction(e) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, g(v), c(v, u, "Generator"), c(v, i, function () { return this; }), c(v, "toString", function () { return "[object Generator]"; }), r.keys = function (t) { var r = Object(t), e = []; for (var n in r) e.unshift(n); return function t() { for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = !1, t; return t.done = !0, t; }; }, r.values = x, Context.prototype = { constructor: Context, reset: function reset(r) { if (this.prev = this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(m), !r) for (var e in this) "t" === e.charAt(0) && n.call(this, e) && !isNaN(+e.slice(1)) && (this[e] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0][4]; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(r) { if (this.done) throw r; var e = this; function n(t) { a.type = "throw", a.arg = r, e.next = t; } for (var o = e.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i[4], u = this.prev, c = i[1], h = i[2]; if (-1 === i[0]) return n("end"), !1; if (!c && !h) throw Error("try statement without catch or finally"); if (null != i[0] && i[0] <= u) { if (u < c) return this.method = "next", this.arg = t, n(c), !0; if (u < h) return n(h), !1; } } }, abrupt: function abrupt(t, r) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var n = this.tryEntries[e]; if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) { var o = n; break; } } o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null); var i = o ? o[4] : {}; return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i); }, complete: function complete(t, r) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && r && (this.next = r), f; }, finish: function finish(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[2] === t) return this.complete(e[4], e[3]), m(e), f; } }, catch: function _catch(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[0] === t) { var n = e[4]; if ("throw" === n.type) { var o = n.arg; m(e); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(r, e, n) { return this.delegate = { i: x(r), r: e, n: n }, "next" === this.method && (this.arg = t), f; } }, r; }
7
7
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
8
8
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
9
9
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
@@ -17,8 +17,9 @@ import { useCallback, useEffect, useState, useRef } from 'react';
17
17
  import { Modal, Form, message, InputNumber, DatePicker, Empty, Typography, Button, Space, Tag } from 'antd';
18
18
  import moment from 'moment';
19
19
  import { useDebounceFn } from 'ahooks';
20
- import { GetPointHistoryData, GetTdIndicatorHistoryData } from "../../services/gateway/Point";
20
+ import { DownHistoryDataToExcelOrPdf, GetPointHistoryData, GetTdIndicatorHistoryData } from "../../services/gateway/Point";
21
21
  import Echarts from "../ECharts";
22
+ import base64ToBlob from "../../utils/dataURItoBlob";
22
23
  // @ts-ignore
23
24
 
24
25
  import styles from "./index.css";
@@ -94,6 +95,93 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
94
95
  _useState18 = _slicedToArray(_useState17, 2),
95
96
  valueType = _useState18[0],
96
97
  setValueType = _useState18[1];
98
+ var _useState19 = useState(false),
99
+ _useState20 = _slicedToArray(_useState19, 2),
100
+ excelDownloading = _useState20[0],
101
+ setExcelDownloading = _useState20[1];
102
+
103
+ /** 下载excel、pdf */
104
+ var downloadExcel = /*#__PURE__*/function () {
105
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
106
+ var _form$getFieldsValue, dateRange, interval, res, blobUrl, link;
107
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
108
+ while (1) switch (_context.prev = _context.next) {
109
+ case 0:
110
+ _context.prev = 0;
111
+ setExcelDownloading(true);
112
+ _form$getFieldsValue = form.getFieldsValue(), dateRange = _form$getFieldsValue.dateRange, interval = _form$getFieldsValue.interval;
113
+ debugger;
114
+ _context.next = 6;
115
+ return DownHistoryDataToExcelOrPdf({
116
+ pointIdList: pointIdList,
117
+ timeInterval: interval,
118
+ fileType: 1,
119
+ isAlarmLacy: false,
120
+ timeQuantumList: [{
121
+ // @ts-ignore
122
+ startDate: moment(dateRange[0]).format('YYYY-MM-DD HH:mm:ss'),
123
+ // @ts-ignore
124
+ endDate: moment(dateRange[1]).format('YYYY-MM-DD HH:mm:ss')
125
+ }],
126
+ isMerge: false,
127
+ isBack: false,
128
+ isZip: true,
129
+ zipFileList: []
130
+ }, {
131
+ responseType: 'blob',
132
+ headers: {
133
+ 'Content-Type': 'application/json'
134
+ }
135
+ });
136
+ case 6:
137
+ res = _context.sent;
138
+ blobUrl = window.URL.createObjectURL(res); // 使用原生方式下载,兼容 npm 插件环境
139
+ link = document.createElement('a');
140
+ link.href = blobUrl;
141
+ link.download = "history_".concat(moment(dateRange[0]).format('YYYY-MM-DD HH:mm:ss'), "_").concat(moment(dateRange[1]).format('YYYY-MM-DD HH:mm:ss'), ".zip");
142
+ document.body.appendChild(link);
143
+ link.click();
144
+ document.body.removeChild(link);
145
+ window.URL.revokeObjectURL(blobUrl);
146
+ setExcelDownloading(false);
147
+ _context.next = 23;
148
+ break;
149
+ case 18:
150
+ _context.prev = 18;
151
+ _context.t0 = _context["catch"](0);
152
+ console.log(_context.t0);
153
+ message.error('下载excel失败');
154
+ setExcelDownloading(false);
155
+ case 23:
156
+ case "end":
157
+ return _context.stop();
158
+ }
159
+ }, _callee, null, [[0, 18]]);
160
+ }));
161
+ return function downloadExcel() {
162
+ return _ref2.apply(this, arguments);
163
+ };
164
+ }();
165
+
166
+ /** 下载图表 */
167
+ var downloadImg = function downloadImg() {
168
+ var _chart$current, _chart$current$getEch;
169
+ // @ts-ignore
170
+ 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);
171
+ var blob = base64ToBlob(_myChart.getDataURL({
172
+ backgroundColor: '#fff'
173
+ }));
174
+ var blobUrl = window.URL.createObjectURL(blob);
175
+
176
+ // 使用原生方式下载,兼容 npm 插件环境
177
+ var link = document.createElement('a');
178
+ link.href = blobUrl;
179
+ link.download = 'chart.jpg';
180
+ document.body.appendChild(link);
181
+ link.click();
182
+ document.body.removeChild(link);
183
+ window.URL.revokeObjectURL(blobUrl);
184
+ };
97
185
  var closeModal = function closeModal() {
98
186
  form.resetFields();
99
187
  setLoading(false);
@@ -106,49 +194,49 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
106
194
 
107
195
  /** 获取点位历史数据 */
108
196
  var fetchPointHistory = useCallback(/*#__PURE__*/function () {
109
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(idList, indicatorNo, ranges, interval) {
197
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(idList, indicatorNo, ranges, interval) {
110
198
  var diff, fun, res, data, series, yAxisData;
111
- return _regeneratorRuntime().wrap(function _callee$(_context) {
112
- while (1) switch (_context.prev = _context.next) {
199
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
200
+ while (1) switch (_context2.prev = _context2.next) {
113
201
  case 0:
114
202
  if (!(!(idList === null || idList === void 0 ? void 0 : idList.length) && !(indicatorNo === null || indicatorNo === void 0 ? void 0 : indicatorNo.length))) {
115
- _context.next = 2;
203
+ _context2.next = 2;
116
204
  break;
117
205
  }
118
- return _context.abrupt("return");
206
+ return _context2.abrupt("return");
119
207
  case 2:
120
208
  if (!(ranges.length !== 2)) {
121
- _context.next = 5;
209
+ _context2.next = 5;
122
210
  break;
123
211
  }
124
212
  message.info('请选择时间范围');
125
- return _context.abrupt("return");
213
+ return _context2.abrupt("return");
126
214
  case 5:
127
215
  if (!idList.length) {
128
- _context.next = 9;
216
+ _context2.next = 9;
129
217
  break;
130
218
  }
131
219
  if (!(typeof interval !== 'number' || interval < 0)) {
132
- _context.next = 9;
220
+ _context2.next = 9;
133
221
  break;
134
222
  }
135
223
  message.info('请正确输入时间间隔');
136
- return _context.abrupt("return");
224
+ return _context2.abrupt("return");
137
225
  case 9:
138
- _context.prev = 9;
226
+ _context2.prev = 9;
139
227
  diff = moment(ranges[1]).valueOf() - moment(ranges[0]).valueOf();
140
228
  if (!(diff > oneYearTime)) {
141
- _context.next = 14;
229
+ _context2.next = 14;
142
230
  break;
143
231
  }
144
232
  message.error('历史数据最大查询范围是一年');
145
- return _context.abrupt("return");
233
+ return _context2.abrupt("return");
146
234
  case 14:
147
235
  // 获取点位数据
148
236
  setLoading(true);
149
237
  setTagList([]);
150
238
  fun = indicatorNo.length ? GetTdIndicatorHistoryData : GetPointHistoryData;
151
- _context.next = 19;
239
+ _context2.next = 19;
152
240
  return fun({
153
241
  timeQuantum: {
154
242
  startDate: moment(ranges[0]).format('YYYY-MM-DD HH:mm'),
@@ -159,7 +247,7 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
159
247
  interval: interval
160
248
  });
161
249
  case 19:
162
- res = _context.sent;
250
+ res = _context2.sent;
163
251
  if (res.success) {
164
252
  data = res.data;
165
253
  if (!data || !data.length) {
@@ -171,15 +259,15 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
171
259
  yAxisData = [];
172
260
  setDeviceId(data[0].deviceId);
173
261
  if (data.every(function (v) {
174
- var _ref3;
175
- return ((_ref3 = v.pointDataList || v.indicatorDataList) === null || _ref3 === void 0 ? void 0 : _ref3.length) === 0 || !v.pointDataList && !v.indicatorDataList;
262
+ var _ref4;
263
+ return ((_ref4 = v.pointDataList || v.indicatorDataList) === null || _ref4 === void 0 ? void 0 : _ref4.length) === 0 || !v.pointDataList && !v.indicatorDataList;
176
264
  })) {
177
265
  setIsNoData(true);
178
266
  } else {
179
267
  setIsNoData(false);
180
268
  }
181
269
  data.forEach(function (item) {
182
- var _ref4;
270
+ var _ref5;
183
271
  setTagList(function (old) {
184
272
  return [].concat(_toConsumableArray(old), [{
185
273
  name: "".concat(item.deviceName, "-").concat(item.pointName || item.indicatorName),
@@ -257,7 +345,7 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
257
345
  showAllSymbol: true,
258
346
  identifierName: item.identifierName,
259
347
  symbolSize: 1.5,
260
- data: (_ref4 = item.pointDataList || item.indicatorDataList) === null || _ref4 === void 0 ? void 0 : _ref4.map(function (dataItem) {
348
+ data: (_ref5 = item.pointDataList || item.indicatorDataList) === null || _ref5 === void 0 ? void 0 : _ref5.map(function (dataItem) {
261
349
  return [new Date(dataItem.ts).getTime(), dataItem.val];
262
350
  }),
263
351
  markPoint: {
@@ -330,26 +418,26 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
330
418
  setIsNoData(true);
331
419
  message.error(res.message);
332
420
  }
333
- _context.next = 28;
421
+ _context2.next = 28;
334
422
  break;
335
423
  case 23:
336
- _context.prev = 23;
337
- _context.t0 = _context["catch"](9);
338
- console.error(_context.t0);
424
+ _context2.prev = 23;
425
+ _context2.t0 = _context2["catch"](9);
426
+ console.error(_context2.t0);
339
427
  setIsNoData(true);
340
428
  setChartOptions(undefined);
341
429
  case 28:
342
- _context.prev = 28;
430
+ _context2.prev = 28;
343
431
  setLoading(false);
344
- return _context.finish(28);
432
+ return _context2.finish(28);
345
433
  case 31:
346
434
  case "end":
347
- return _context.stop();
435
+ return _context2.stop();
348
436
  }
349
- }, _callee, null, [[9, 23, 28, 31]]);
437
+ }, _callee2, null, [[9, 23, 28, 31]]);
350
438
  }));
351
439
  return function (_x, _x2, _x3, _x4) {
352
- return _ref2.apply(this, arguments);
440
+ return _ref3.apply(this, arguments);
353
441
  };
354
442
  }(), []);
355
443
  var _useDebounceFn = useDebounceFn(fetchPointHistory, {
@@ -357,33 +445,33 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
357
445
  }),
358
446
  fetchPointHistoryDebounce = _useDebounceFn.run;
359
447
  var handleSubmit = /*#__PURE__*/function () {
360
- var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
448
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
361
449
  var _yield$form$validateF, dateRange, interval;
362
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
363
- while (1) switch (_context2.prev = _context2.next) {
450
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
451
+ while (1) switch (_context3.prev = _context3.next) {
364
452
  case 0:
365
- _context2.next = 2;
453
+ _context3.next = 2;
366
454
  return form.validateFields();
367
455
  case 2:
368
- _yield$form$validateF = _context2.sent;
456
+ _yield$form$validateF = _context3.sent;
369
457
  dateRange = _yield$form$validateF.dateRange;
370
458
  interval = _yield$form$validateF.interval;
371
459
  setValueType(indicatorNoList.length ? 'indicator' : 'point');
372
460
  fetchPointHistoryDebounce(indicatorNoList.length ? [] : pointIdList, indicatorNoList.length ? pointIdList : [], dateRange, interval);
373
461
  case 7:
374
462
  case "end":
375
- return _context2.stop();
463
+ return _context3.stop();
376
464
  }
377
- }, _callee2);
465
+ }, _callee3);
378
466
  }));
379
467
  return function handleSubmit() {
380
- return _ref5.apply(this, arguments);
468
+ return _ref6.apply(this, arguments);
381
469
  };
382
470
  }();
383
471
  useEffect(function () {
384
- var _form$getFieldsValue = form.getFieldsValue(),
385
- dateRange = _form$getFieldsValue.dateRange,
386
- interval = _form$getFieldsValue.interval;
472
+ var _form$getFieldsValue2 = form.getFieldsValue(),
473
+ dateRange = _form$getFieldsValue2.dateRange,
474
+ interval = _form$getFieldsValue2.interval;
387
475
  setValueType(indicatorNoList.length ? 'indicator' : 'point');
388
476
  fetchPointHistoryDebounce(indicatorNoList.length ? [] : pointIdList, indicatorNoList.length ? pointIdList : [], dateRange, interval);
389
477
  }, [pointIdList]);
@@ -482,7 +570,16 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
482
570
  onClick: function onClick() {
483
571
  setVisiblePointSet(true);
484
572
  }
485
- }, "\u6DFB\u52A0\u5C5E\u6027")))) : null), tagList.map(function (item) {
573
+ }, "\u6DFB\u52A0\u5C5E\u6027")), /*#__PURE__*/React.createElement(Form.Item, {
574
+ label: "\u6570\u636E\u64CD\u4F5C"
575
+ }, /*#__PURE__*/React.createElement(Space, {
576
+ size: 15
577
+ }, /*#__PURE__*/React.createElement(Button, {
578
+ onClick: downloadExcel,
579
+ loading: excelDownloading
580
+ }, "\u4E0B\u8F7Dexcel"), /*#__PURE__*/React.createElement(Button, {
581
+ onClick: downloadImg
582
+ }, "\u4E0B\u8F7D\u56FE\u8868"))))) : null), tagList.map(function (item) {
486
583
  return /*#__PURE__*/React.createElement(Tag, {
487
584
  key: item.key,
488
585
  closable: true,
@@ -506,9 +603,9 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
506
603
  },
507
604
  onEvents: {
508
605
  datazoom: function datazoom(params) {
509
- var _chart$current, _chart$current$getEch;
606
+ var _chart$current2, _chart$current2$getEc;
510
607
  // 获取当前 echarts 实例
511
- 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);
608
+ var myChart = chart === null || chart === void 0 ? void 0 : (_chart$current2 = chart.current) === null || _chart$current2 === void 0 ? void 0 : (_chart$current2$getEc = _chart$current2.getEchartsInstance) === null || _chart$current2$getEc === void 0 ? void 0 : _chart$current2$getEc.call(_chart$current2);
512
609
  if (!myChart) return;
513
610
 
514
611
  // 获取当前配置
@@ -164,7 +164,7 @@ export function GetTdIndicatorAggregateData(_x11, _x12) {
164
164
  return _GetTdIndicatorAggregateData.apply(this, arguments);
165
165
  }
166
166
 
167
- /** 历史数据导出xlsxpdf(支持进度条) POST /api/GatewayMicro/Point/DownHistoryDataToExcelOrPdf */
167
+ /** 历史数据导出xlsxpdf(支持进度条) POST /api/GatewayMicro/Point/DownHistoryDataToExcelOrPdf */
168
168
  function _GetTdIndicatorAggregateData() {
169
169
  _GetTdIndicatorAggregateData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(body, options) {
170
170
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
@@ -154,13 +154,13 @@ requestClient.interceptors.request.use(function (url, options) {
154
154
 
155
155
  /** 响应拦截器 */
156
156
  requestClient.interceptors.response.use(/*#__PURE__*/function () {
157
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(response) {
157
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(response, options) {
158
158
  var xAccessToken, accessToken, data, _data$code, errorText;
159
159
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
160
160
  while (1) switch (_context2.prev = _context2.next) {
161
161
  case 0:
162
162
  if (!(response.status >= 200 && response.status < 300)) {
163
- _context2.next = 9;
163
+ _context2.next = 13;
164
164
  break;
165
165
  }
166
166
  // 如果 response header 里面有 x-access-token 和 access-token, 那么保存到 cookies 中
@@ -169,9 +169,18 @@ requestClient.interceptors.response.use(/*#__PURE__*/function () {
169
169
  if (accessToken && xAccessToken) {
170
170
  storeToken(accessToken, xAccessToken);
171
171
  }
172
- _context2.next = 6;
172
+ if (!(options.responseType === 'blob')) {
173
+ _context2.next = 8;
174
+ break;
175
+ }
176
+ _context2.next = 7;
177
+ return response.clone().blob();
178
+ case 7:
179
+ return _context2.abrupt("return", _context2.sent);
180
+ case 8:
181
+ _context2.next = 10;
173
182
  return response.clone().json();
174
- case 6:
183
+ case 10:
175
184
  data = _context2.sent;
176
185
  if (!data.success) {
177
186
  if (Object.keys(codeMessage).includes((_data$code = data.code) === null || _data$code === void 0 ? void 0 : _data$code.toString())) {
@@ -184,17 +193,17 @@ requestClient.interceptors.response.use(/*#__PURE__*/function () {
184
193
  }
185
194
  }
186
195
  return _context2.abrupt("return", response);
187
- case 9:
196
+ case 13:
188
197
  throw {
189
198
  response: response
190
199
  };
191
- case 10:
200
+ case 14:
192
201
  case "end":
193
202
  return _context2.stop();
194
203
  }
195
204
  }, _callee2);
196
205
  }));
197
- return function (_x3) {
206
+ return function (_x3, _x4) {
198
207
  return _ref2.apply(this, arguments);
199
208
  };
200
209
  }());
@@ -0,0 +1,25 @@
1
+ export default function dataURItoBlob(dataURI) {
2
+ // convert base64 to raw binary data held in a string
3
+ // doesn't handle URLEncoded DataURIs - see SO answer #6850276 for code that does this
4
+ var byteString = atob(dataURI.split(',')[1]);
5
+
6
+ // separate out the mime component
7
+ var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
8
+
9
+ // write the bytes of the string to an ArrayBuffer
10
+ var ab = new ArrayBuffer(byteString.length);
11
+
12
+ // create a view into the buffer
13
+ var ia = new Uint8Array(ab);
14
+
15
+ // set the bytes of the buffer to the correct values
16
+ for (var i = 0; i < byteString.length; i += 1) {
17
+ ia[i] = byteString.charCodeAt(i);
18
+ }
19
+
20
+ // write the ArrayBuffer to a blob, and you're done
21
+ var blob = new Blob([ab], {
22
+ type: mimeString
23
+ });
24
+ return blob;
25
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coolcare-lite-scada-component",
3
- "version": "1.0.67",
3
+ "version": "1.0.69",
4
4
  "scripts": {
5
5
  "start": " PORT=8000 UMI_ENV=prod umi dev",
6
6
  "build:prod": "UMI_ENV=prod umi build",
@@ -53,6 +53,7 @@
53
53
  "classnames": "^2.3.1",
54
54
  "dayjs": "^1.10.6",
55
55
  "echarts": "^5.2.2",
56
+ "file-saver": "^2.0.5",
56
57
  "lodash-es": "^4.17.21",
57
58
  "mitt": "^3.0.0",
58
59
  "number-precision": "^1.5.1",