coolcare-lite-scada-component 1.0.66 → 1.0.68

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,10 +17,11 @@ 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
+ import { saveAs } from 'file-saver';
24
25
  import styles from "./index.css";
25
26
  import ModalChoosePoint from "../ModalChoosePoint";
26
27
  import { dateDiff } from "../../utils/date";
@@ -94,6 +95,78 @@ 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;
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
+ debugger;
139
+ blobUrl = window.URL.createObjectURL(res);
140
+ saveAs(blobUrl, "history_".concat(moment(dateRange[0]).format('YYYY-MM-DD HH:mm:ss'), "_").concat(moment(dateRange[1]).format('YYYY-MM-DD HH:mm:ss'), ".zip"));
141
+ setExcelDownloading(false);
142
+ _context.next = 18;
143
+ break;
144
+ case 13:
145
+ _context.prev = 13;
146
+ _context.t0 = _context["catch"](0);
147
+ console.log(_context.t0);
148
+ message.error('下载excel失败');
149
+ setExcelDownloading(false);
150
+ case 18:
151
+ case "end":
152
+ return _context.stop();
153
+ }
154
+ }, _callee, null, [[0, 13]]);
155
+ }));
156
+ return function downloadExcel() {
157
+ return _ref2.apply(this, arguments);
158
+ };
159
+ }();
160
+
161
+ /** 下载图表 */
162
+ var downloadImg = function downloadImg() {
163
+ var _chart$current, _chart$current$getEch;
164
+ // @ts-ignore
165
+ 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);
166
+ saveAs(base64ToBlob(_myChart.getDataURL({
167
+ backgroundColor: '#fff'
168
+ })), 'chart.jpg');
169
+ };
97
170
  var closeModal = function closeModal() {
98
171
  form.resetFields();
99
172
  setLoading(false);
@@ -106,49 +179,49 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
106
179
 
107
180
  /** 获取点位历史数据 */
108
181
  var fetchPointHistory = useCallback(/*#__PURE__*/function () {
109
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(idList, indicatorNo, ranges, interval) {
182
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(idList, indicatorNo, ranges, interval) {
110
183
  var diff, fun, res, data, series, yAxisData;
111
- return _regeneratorRuntime().wrap(function _callee$(_context) {
112
- while (1) switch (_context.prev = _context.next) {
184
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
185
+ while (1) switch (_context2.prev = _context2.next) {
113
186
  case 0:
114
187
  if (!(!(idList === null || idList === void 0 ? void 0 : idList.length) && !(indicatorNo === null || indicatorNo === void 0 ? void 0 : indicatorNo.length))) {
115
- _context.next = 2;
188
+ _context2.next = 2;
116
189
  break;
117
190
  }
118
- return _context.abrupt("return");
191
+ return _context2.abrupt("return");
119
192
  case 2:
120
193
  if (!(ranges.length !== 2)) {
121
- _context.next = 5;
194
+ _context2.next = 5;
122
195
  break;
123
196
  }
124
197
  message.info('请选择时间范围');
125
- return _context.abrupt("return");
198
+ return _context2.abrupt("return");
126
199
  case 5:
127
200
  if (!idList.length) {
128
- _context.next = 9;
201
+ _context2.next = 9;
129
202
  break;
130
203
  }
131
204
  if (!(typeof interval !== 'number' || interval < 0)) {
132
- _context.next = 9;
205
+ _context2.next = 9;
133
206
  break;
134
207
  }
135
208
  message.info('请正确输入时间间隔');
136
- return _context.abrupt("return");
209
+ return _context2.abrupt("return");
137
210
  case 9:
138
- _context.prev = 9;
211
+ _context2.prev = 9;
139
212
  diff = moment(ranges[1]).valueOf() - moment(ranges[0]).valueOf();
140
213
  if (!(diff > oneYearTime)) {
141
- _context.next = 14;
214
+ _context2.next = 14;
142
215
  break;
143
216
  }
144
217
  message.error('历史数据最大查询范围是一年');
145
- return _context.abrupt("return");
218
+ return _context2.abrupt("return");
146
219
  case 14:
147
220
  // 获取点位数据
148
221
  setLoading(true);
149
222
  setTagList([]);
150
223
  fun = indicatorNo.length ? GetTdIndicatorHistoryData : GetPointHistoryData;
151
- _context.next = 19;
224
+ _context2.next = 19;
152
225
  return fun({
153
226
  timeQuantum: {
154
227
  startDate: moment(ranges[0]).format('YYYY-MM-DD HH:mm'),
@@ -159,7 +232,7 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
159
232
  interval: interval
160
233
  });
161
234
  case 19:
162
- res = _context.sent;
235
+ res = _context2.sent;
163
236
  if (res.success) {
164
237
  data = res.data;
165
238
  if (!data || !data.length) {
@@ -171,15 +244,15 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
171
244
  yAxisData = [];
172
245
  setDeviceId(data[0].deviceId);
173
246
  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;
247
+ var _ref4;
248
+ return ((_ref4 = v.pointDataList || v.indicatorDataList) === null || _ref4 === void 0 ? void 0 : _ref4.length) === 0 || !v.pointDataList && !v.indicatorDataList;
176
249
  })) {
177
250
  setIsNoData(true);
178
251
  } else {
179
252
  setIsNoData(false);
180
253
  }
181
254
  data.forEach(function (item) {
182
- var _ref4;
255
+ var _ref5;
183
256
  setTagList(function (old) {
184
257
  return [].concat(_toConsumableArray(old), [{
185
258
  name: "".concat(item.deviceName, "-").concat(item.pointName || item.indicatorName),
@@ -257,7 +330,7 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
257
330
  showAllSymbol: true,
258
331
  identifierName: item.identifierName,
259
332
  symbolSize: 1.5,
260
- data: (_ref4 = item.pointDataList || item.indicatorDataList) === null || _ref4 === void 0 ? void 0 : _ref4.map(function (dataItem) {
333
+ data: (_ref5 = item.pointDataList || item.indicatorDataList) === null || _ref5 === void 0 ? void 0 : _ref5.map(function (dataItem) {
261
334
  return [new Date(dataItem.ts).getTime(), dataItem.val];
262
335
  }),
263
336
  markPoint: {
@@ -330,26 +403,26 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
330
403
  setIsNoData(true);
331
404
  message.error(res.message);
332
405
  }
333
- _context.next = 28;
406
+ _context2.next = 28;
334
407
  break;
335
408
  case 23:
336
- _context.prev = 23;
337
- _context.t0 = _context["catch"](9);
338
- console.error(_context.t0);
409
+ _context2.prev = 23;
410
+ _context2.t0 = _context2["catch"](9);
411
+ console.error(_context2.t0);
339
412
  setIsNoData(true);
340
413
  setChartOptions(undefined);
341
414
  case 28:
342
- _context.prev = 28;
415
+ _context2.prev = 28;
343
416
  setLoading(false);
344
- return _context.finish(28);
417
+ return _context2.finish(28);
345
418
  case 31:
346
419
  case "end":
347
- return _context.stop();
420
+ return _context2.stop();
348
421
  }
349
- }, _callee, null, [[9, 23, 28, 31]]);
422
+ }, _callee2, null, [[9, 23, 28, 31]]);
350
423
  }));
351
424
  return function (_x, _x2, _x3, _x4) {
352
- return _ref2.apply(this, arguments);
425
+ return _ref3.apply(this, arguments);
353
426
  };
354
427
  }(), []);
355
428
  var _useDebounceFn = useDebounceFn(fetchPointHistory, {
@@ -357,33 +430,33 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
357
430
  }),
358
431
  fetchPointHistoryDebounce = _useDebounceFn.run;
359
432
  var handleSubmit = /*#__PURE__*/function () {
360
- var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
433
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
361
434
  var _yield$form$validateF, dateRange, interval;
362
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
363
- while (1) switch (_context2.prev = _context2.next) {
435
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
436
+ while (1) switch (_context3.prev = _context3.next) {
364
437
  case 0:
365
- _context2.next = 2;
438
+ _context3.next = 2;
366
439
  return form.validateFields();
367
440
  case 2:
368
- _yield$form$validateF = _context2.sent;
441
+ _yield$form$validateF = _context3.sent;
369
442
  dateRange = _yield$form$validateF.dateRange;
370
443
  interval = _yield$form$validateF.interval;
371
444
  setValueType(indicatorNoList.length ? 'indicator' : 'point');
372
445
  fetchPointHistoryDebounce(indicatorNoList.length ? [] : pointIdList, indicatorNoList.length ? pointIdList : [], dateRange, interval);
373
446
  case 7:
374
447
  case "end":
375
- return _context2.stop();
448
+ return _context3.stop();
376
449
  }
377
- }, _callee2);
450
+ }, _callee3);
378
451
  }));
379
452
  return function handleSubmit() {
380
- return _ref5.apply(this, arguments);
453
+ return _ref6.apply(this, arguments);
381
454
  };
382
455
  }();
383
456
  useEffect(function () {
384
- var _form$getFieldsValue = form.getFieldsValue(),
385
- dateRange = _form$getFieldsValue.dateRange,
386
- interval = _form$getFieldsValue.interval;
457
+ var _form$getFieldsValue2 = form.getFieldsValue(),
458
+ dateRange = _form$getFieldsValue2.dateRange,
459
+ interval = _form$getFieldsValue2.interval;
387
460
  setValueType(indicatorNoList.length ? 'indicator' : 'point');
388
461
  fetchPointHistoryDebounce(indicatorNoList.length ? [] : pointIdList, indicatorNoList.length ? pointIdList : [], dateRange, interval);
389
462
  }, [pointIdList]);
@@ -482,7 +555,16 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
482
555
  onClick: function onClick() {
483
556
  setVisiblePointSet(true);
484
557
  }
485
- }, "\u6DFB\u52A0\u5C5E\u6027")))) : null), tagList.map(function (item) {
558
+ }, "\u6DFB\u52A0\u5C5E\u6027")), /*#__PURE__*/React.createElement(Form.Item, {
559
+ label: "\u6570\u636E\u64CD\u4F5C"
560
+ }, /*#__PURE__*/React.createElement(Space, {
561
+ size: 15
562
+ }, /*#__PURE__*/React.createElement(Button, {
563
+ onClick: downloadExcel,
564
+ loading: excelDownloading
565
+ }, "\u4E0B\u8F7Dexcel"), /*#__PURE__*/React.createElement(Button, {
566
+ onClick: downloadImg
567
+ }, "\u4E0B\u8F7D\u56FE\u8868"))))) : null), tagList.map(function (item) {
486
568
  return /*#__PURE__*/React.createElement(Tag, {
487
569
  key: item.key,
488
570
  closable: true,
@@ -506,9 +588,9 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
506
588
  },
507
589
  onEvents: {
508
590
  datazoom: function datazoom(params) {
509
- var _chart$current, _chart$current$getEch;
591
+ var _chart$current2, _chart$current2$getEc;
510
592
  // 获取当前 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);
593
+ 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
594
  if (!myChart) return;
513
595
 
514
596
  // 获取当前配置
@@ -18,7 +18,7 @@ function usePointWatch(point, namespace) {
18
18
  var eventHandler = function eventHandler(val) {
19
19
  setPointData(val);
20
20
  };
21
- var eventName = "point-update-".concat('pointId' in point ? point.pointId ? point.pointId : point.identifierName ? point.identifierName : point.meterId ? point.meterId : point.indicatorNo : point.indicatorNo, "-").concat(namespace !== null && namespace !== void 0 ? namespace : 0);
21
+ var eventName = "point-update-".concat('pointId' in point ? point.pointId : 'identifierName' in point ? point.identifierName : 'meterId' in point ? point.meterId : 'indicatorNo' in point ? point.indicatorNo : '', "-").concat(namespace !== null && namespace !== void 0 ? namespace : 0);
22
22
  emitter.on(eventName, eventHandler);
23
23
  return function () {
24
24
  // TODO x6 react 组件的 unmount 没有被触发
@@ -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.66",
3
+ "version": "1.0.68",
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",