coolcare-lite-scada-component 1.0.22 → 1.0.24

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.
@@ -17,11 +17,11 @@ import { useCallback, useEffect, useState, useRef } from 'react';
17
17
  import { Modal, Form, message, InputNumber, DatePicker, Empty, Typography, Button, Space } from 'antd';
18
18
  import moment from 'moment';
19
19
  import { useDebounceFn } from 'ahooks';
20
- import { DownHistoryDataToExcelOrPdf, GetPointHistoryData } from "../../services/gateway/Point";
20
+ import { GetPointHistoryData } from "../../services/gateway/Point";
21
21
  import ModalChoosePoint from "../ModalChoosePoint";
22
22
  import Echarts from "../ECharts";
23
23
  // @ts-ignore
24
- import { saveAs } from 'file-saver';
24
+
25
25
  import styles from "./index.css";
26
26
  var Link = Typography.Link;
27
27
  var RangePicker = DatePicker.RangePicker;
@@ -43,7 +43,8 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
43
43
  visible = _ref.visible,
44
44
  onCancel = _ref.onCancel,
45
45
  getContainer = _ref.getContainer,
46
- companyId = _ref.companyId;
46
+ companyId = _ref.companyId,
47
+ projectId = _ref.projectId;
47
48
  var _Form$useForm = Form.useForm(),
48
49
  _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
49
50
  form = _Form$useForm2[0];
@@ -57,35 +58,26 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
57
58
  _useState4 = _slicedToArray(_useState3, 2),
58
59
  loading = _useState4[0],
59
60
  setLoading = _useState4[1];
61
+ /** 添加对比点位弹框 */
60
62
  var _useState5 = useState(false),
61
63
  _useState6 = _slicedToArray(_useState5, 2),
62
- excelDownloading = _useState6[0],
63
- setExcelDownloading = _useState6[1];
64
- /** 添加对比点位弹框 */
65
- var _useState7 = useState(false),
66
- _useState8 = _slicedToArray(_useState7, 2),
67
- visiblePointSet = _useState8[0],
68
- setVisiblePointSet = _useState8[1];
64
+ visiblePointSet = _useState6[0],
65
+ setVisiblePointSet = _useState6[1];
69
66
  /** 曲线图配置 */
70
- var _useState9 = useState(undefined),
71
- _useState10 = _slicedToArray(_useState9, 2),
72
- chartOptions = _useState10[0],
73
- setChartOptions = _useState10[1];
67
+ var _useState7 = useState(undefined),
68
+ _useState8 = _slicedToArray(_useState7, 2),
69
+ chartOptions = _useState8[0],
70
+ setChartOptions = _useState8[1];
74
71
  /** 当前点位列表 */
75
- var _useState11 = useState([]),
76
- _useState12 = _slicedToArray(_useState11, 2),
77
- pointIdList = _useState12[0],
78
- setPointIdList = _useState12[1];
72
+ var _useState9 = useState([]),
73
+ _useState10 = _slicedToArray(_useState9, 2),
74
+ pointIdList = _useState10[0],
75
+ setPointIdList = _useState10[1];
79
76
  /** 当前点位时间段内是否有报警 */
80
- var _useState13 = useState(false),
81
- _useState14 = _slicedToArray(_useState13, 2),
82
- haveAlarm = _useState14[0],
83
- setHaveAlarm = _useState14[1];
84
- /** 是否已查看原始数据 */
85
- var _useState15 = useState(false),
86
- _useState16 = _slicedToArray(_useState15, 2),
87
- isCheckAlarm = _useState16[0],
88
- setIsCheckAlarm = _useState16[1];
77
+ var _useState11 = useState(false),
78
+ _useState12 = _slicedToArray(_useState11, 2),
79
+ haveAlarm = _useState12[0],
80
+ setHaveAlarm = _useState12[1];
89
81
  var closeModal = function closeModal() {
90
82
  form.resetFields();
91
83
  setLoading(false);
@@ -93,106 +85,50 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
93
85
  setIsNoData(false);
94
86
  setVisiblePointSet(false);
95
87
  setHaveAlarm(false);
96
- setIsCheckAlarm(false);
97
88
  setPointIdList([]);
98
89
  onCancel === null || onCancel === void 0 ? void 0 : onCancel();
99
90
  };
100
91
 
101
- /** 下载excel、pdf */
102
- var downloadExcel = /*#__PURE__*/function () {
103
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
104
- var _form$getFieldsValue, dateRange, interval, res, blobUrl;
105
- return _regeneratorRuntime().wrap(function _callee$(_context) {
106
- while (1) switch (_context.prev = _context.next) {
107
- case 0:
108
- _context.prev = 0;
109
- setExcelDownloading(true);
110
- _form$getFieldsValue = form.getFieldsValue(), dateRange = _form$getFieldsValue.dateRange, interval = _form$getFieldsValue.interval;
111
- _context.next = 5;
112
- return DownHistoryDataToExcelOrPdf({
113
- pointIdList: pointIdList,
114
- timeInterval: interval,
115
- fileType: 1,
116
- isAlarmLacy: false,
117
- timeQuantumList: [{
118
- // @ts-ignore
119
- startDate: moment(dateRange[0]).format('YYYY-MM-DD HH:mm:ss'),
120
- // @ts-ignore
121
- endDate: moment(dateRange[1]).format('YYYY-MM-DD HH:mm:ss')
122
- }],
123
- isMerge: false,
124
- isBack: false,
125
- isZip: true,
126
- zipFileList: []
127
- }, {
128
- responseType: 'blob',
129
- headers: {
130
- 'Content-Type': 'application/json'
131
- }
132
- });
133
- case 5:
134
- res = _context.sent;
135
- blobUrl = window.URL.createObjectURL(res);
136
- 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"));
137
- setExcelDownloading(false);
138
- _context.next = 15;
139
- break;
140
- case 11:
141
- _context.prev = 11;
142
- _context.t0 = _context["catch"](0);
143
- message.error('下载excel失败');
144
- setExcelDownloading(false);
145
- case 15:
146
- case "end":
147
- return _context.stop();
148
- }
149
- }, _callee, null, [[0, 11]]);
150
- }));
151
- return function downloadExcel() {
152
- return _ref2.apply(this, arguments);
153
- };
154
- }();
155
-
156
92
  /** 获取点位历史数据 */
157
93
  var fetchPointHistory = useCallback(/*#__PURE__*/function () {
158
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(idList, ranges, interval) {
94
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(idList, ranges, interval) {
159
95
  var diff, res, data, series, yAxisData, xAxisData;
160
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
161
- while (1) switch (_context2.prev = _context2.next) {
96
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
97
+ while (1) switch (_context.prev = _context.next) {
162
98
  case 0:
163
99
  if (idList === null || idList === void 0 ? void 0 : idList.length) {
164
- _context2.next = 3;
100
+ _context.next = 3;
165
101
  break;
166
102
  }
167
103
  message.info('请至少查询一个点位');
168
- return _context2.abrupt("return");
104
+ return _context.abrupt("return");
169
105
  case 3:
170
106
  if (!(ranges.length !== 2)) {
171
- _context2.next = 6;
107
+ _context.next = 6;
172
108
  break;
173
109
  }
174
110
  message.info('请选择时间范围');
175
- return _context2.abrupt("return");
111
+ return _context.abrupt("return");
176
112
  case 6:
177
113
  if (!(typeof interval !== 'number' || interval < 0)) {
178
- _context2.next = 9;
114
+ _context.next = 9;
179
115
  break;
180
116
  }
181
117
  message.info('请正确输入时间间隔');
182
- return _context2.abrupt("return");
118
+ return _context.abrupt("return");
183
119
  case 9:
184
- _context2.prev = 9;
120
+ _context.prev = 9;
185
121
  diff = moment(ranges[1]).valueOf() - moment(ranges[0]).valueOf();
186
122
  if (!(diff > oneYearTime)) {
187
- _context2.next = 14;
123
+ _context.next = 14;
188
124
  break;
189
125
  }
190
126
  message.error('历史数据最大查询范围是一年');
191
- return _context2.abrupt("return");
127
+ return _context.abrupt("return");
192
128
  case 14:
193
129
  // 获取点位数据
194
130
  setLoading(true);
195
- _context2.next = 17;
131
+ _context.next = 17;
196
132
  return GetPointHistoryData({
197
133
  timeQuantum: {
198
134
  startDate: moment(ranges[0]).format('YYYY-MM-DD HH:mm'),
@@ -202,7 +138,7 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
202
138
  interval: interval
203
139
  });
204
140
  case 17:
205
- res = _context2.sent;
141
+ res = _context.sent;
206
142
  if (res.success) {
207
143
  data = res.data;
208
144
  if (!data || !data.length) {
@@ -377,26 +313,26 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
377
313
  setIsNoData(true);
378
314
  message.error(res.message);
379
315
  }
380
- _context2.next = 26;
316
+ _context.next = 26;
381
317
  break;
382
318
  case 21:
383
- _context2.prev = 21;
384
- _context2.t0 = _context2["catch"](9);
385
- console.error(_context2.t0);
319
+ _context.prev = 21;
320
+ _context.t0 = _context["catch"](9);
321
+ console.error(_context.t0);
386
322
  setIsNoData(true);
387
323
  setChartOptions(undefined);
388
324
  case 26:
389
- _context2.prev = 26;
325
+ _context.prev = 26;
390
326
  setLoading(false);
391
- return _context2.finish(26);
327
+ return _context.finish(26);
392
328
  case 29:
393
329
  case "end":
394
- return _context2.stop();
330
+ return _context.stop();
395
331
  }
396
- }, _callee2, null, [[9, 21, 26, 29]]);
332
+ }, _callee, null, [[9, 21, 26, 29]]);
397
333
  }));
398
334
  return function (_x, _x2, _x3) {
399
- return _ref3.apply(this, arguments);
335
+ return _ref2.apply(this, arguments);
400
336
  };
401
337
  }(), []);
402
338
  var _useDebounceFn = useDebounceFn(fetchPointHistory, {
@@ -404,41 +340,29 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
404
340
  }),
405
341
  fetchPointHistoryDebounce = _useDebounceFn.run;
406
342
  var handleSubmit = /*#__PURE__*/function () {
407
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
343
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
408
344
  var _yield$form$validateF, dateRange, interval;
409
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
410
- while (1) switch (_context3.prev = _context3.next) {
345
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
346
+ while (1) switch (_context2.prev = _context2.next) {
411
347
  case 0:
412
- _context3.next = 2;
348
+ _context2.next = 2;
413
349
  return form.validateFields();
414
350
  case 2:
415
- _yield$form$validateF = _context3.sent;
351
+ _yield$form$validateF = _context2.sent;
416
352
  dateRange = _yield$form$validateF.dateRange;
417
353
  interval = _yield$form$validateF.interval;
418
354
  fetchPointHistoryDebounce(pointIdList, dateRange, interval);
419
355
  case 6:
420
356
  case "end":
421
- return _context3.stop();
357
+ return _context2.stop();
422
358
  }
423
- }, _callee3);
359
+ }, _callee2);
424
360
  }));
425
361
  return function handleSubmit() {
426
- return _ref4.apply(this, arguments);
362
+ return _ref3.apply(this, arguments);
427
363
  };
428
364
  }();
429
365
 
430
- /** 查看原始数据 */
431
- var checkOriginalData = function checkOriginalData() {
432
- form.setFieldsValue({
433
- interval: 0
434
- });
435
- setIsCheckAlarm(true);
436
- var _form$getFieldsValue2 = form.getFieldsValue(),
437
- dateRange = _form$getFieldsValue2.dateRange,
438
- interval = _form$getFieldsValue2.interval;
439
- fetchPointHistoryDebounce(pointIdList, dateRange, interval);
440
- };
441
-
442
366
  /** 打开弹框,初始化数据,获取曲线图形 */
443
367
  useEffect(function () {
444
368
  if (visible && (pointIdListProp === null || pointIdListProp === void 0 ? void 0 : pointIdListProp.length)) {
@@ -460,7 +384,9 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
460
384
  footer: null,
461
385
  onCancel: closeModal,
462
386
  afterClose: closeModal,
463
- getContainer: getContainer
387
+ getContainer: function getContainer() {
388
+ return document.body;
389
+ }
464
390
  }, /*#__PURE__*/React.createElement(Form, {
465
391
  requiredMark: false,
466
392
  form: form,
@@ -538,6 +464,7 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
538
464
  });
539
465
  },
540
466
  companyId: companyId,
467
+ projectId: projectId,
541
468
  onCancel: function onCancel() {
542
469
  setVisiblePointSet(false);
543
470
  }
@@ -26,7 +26,8 @@ var ModalChoosePoint = function ModalChoosePoint(_ref) {
26
26
  var visible = _ref.visible,
27
27
  onSubmit = _ref.onSubmit,
28
28
  onCancel = _ref.onCancel,
29
- companyId = _ref.companyId;
29
+ companyId = _ref.companyId,
30
+ projectId = _ref.projectId;
30
31
  var _Form$useForm = Form.useForm(),
31
32
  _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
32
33
  form = _Form$useForm2[0];
@@ -92,8 +93,8 @@ var ModalChoosePoint = function ModalChoosePoint(_ref) {
92
93
  _context2.prev = 0;
93
94
  _context2.next = 3;
94
95
  return GetColdChainPermissionDevicePage({
95
- companyId: Number(query.companyId),
96
- projectId: Number(query.projectId),
96
+ companyId: companyId,
97
+ projectId: projectId,
97
98
  isPermission: true
98
99
  });
99
100
  case 3:
@@ -114,7 +115,7 @@ var ModalChoosePoint = function ModalChoosePoint(_ref) {
114
115
  return _context2.stop();
115
116
  }
116
117
  }, _callee2, null, [[0, 7]]);
117
- })), [query]);
118
+ })), [companyId, projectId]);
118
119
 
119
120
  /** 提交表单且数据验证成功后回调事件 */
120
121
  var onFinish = /*#__PURE__*/function () {
@@ -510,7 +510,9 @@ var Player = function Player(_ref) {
510
510
  onCancel: function onCancel() {
511
511
  return setVisibleDialogHistory(false);
512
512
  },
513
- pointIdListProp: activePointIds
513
+ pointIdListProp: activePointIds,
514
+ companyId: query.companyId,
515
+ projectId: query.projectId
514
516
  }), /*#__PURE__*/React.createElement(DialogPointWrite, {
515
517
  visible: visibleDialogPointWrite,
516
518
  points: activePoints,
package/es/typings.d.ts CHANGED
@@ -88,6 +88,10 @@ type PlayerQuery =
88
88
  token?: string;
89
89
  /** 刷新token */
90
90
  xToken?: string;
91
+ /** 公司 id */
92
+ companyId: string;
93
+ /** 项目 id */
94
+ projectId?: string;
91
95
  }
92
96
  | {
93
97
  /** 通过输入的环境名 env, 决定接口调用的地址,默认是 prod */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coolcare-lite-scada-component",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "scripts": {
5
5
  "start": "umi dev",
6
6
  "build:prod": "UMI_ENV=prod umi build",