coolcare-lite-scada-component 1.0.29 → 1.0.30

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.
@@ -77,6 +77,10 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
77
77
  _useState12 = _slicedToArray(_useState11, 2),
78
78
  haveAlarm = _useState12[0],
79
79
  setHaveAlarm = _useState12[1];
80
+ var _useState13 = useState(undefined),
81
+ _useState14 = _slicedToArray(_useState13, 2),
82
+ deviceId = _useState14[0],
83
+ setDeviceId = _useState14[1];
80
84
  var closeModal = function closeModal() {
81
85
  form.resetFields();
82
86
  setLoading(false);
@@ -91,7 +95,7 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
91
95
  /** 获取点位历史数据 */
92
96
  var fetchPointHistory = useCallback(/*#__PURE__*/function () {
93
97
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(idList, ranges, interval) {
94
- var diff, res, data, series, yAxisData, xAxisData;
98
+ var diff, res, data, series, yAxisData;
95
99
  return _regeneratorRuntime().wrap(function _callee$(_context) {
96
100
  while (1) switch (_context.prev = _context.next) {
97
101
  case 0:
@@ -147,7 +151,7 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
147
151
  // 图形处理
148
152
  series = [];
149
153
  yAxisData = [];
150
- xAxisData = [];
154
+ setDeviceId(data[0].deviceId);
151
155
  if (data.every(function (v) {
152
156
  var _v$pointDataList;
153
157
  return ((_v$pointDataList = v.pointDataList) === null || _v$pointDataList === void 0 ? void 0 : _v$pointDataList.length) === 0 || !v.pointDataList;
@@ -157,7 +161,7 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
157
161
  setIsNoData(false);
158
162
  }
159
163
  data.forEach(function (item) {
160
- var _item$pointAlarmTimeF, _item$pointDataList, _item$pointDataList2;
164
+ var _item$pointAlarmTimeF, _item$pointDataList;
161
165
  // @ts-ignore
162
166
  if ((_item$pointAlarmTimeF = item.pointAlarmTimeFrameList) === null || _item$pointAlarmTimeF === void 0 ? void 0 : _item$pointAlarmTimeF.length) {
163
167
  setHaveAlarm(true);
@@ -220,12 +224,6 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
220
224
  }
221
225
  yAxisData.push(yAxis);
222
226
  }
223
- // 配置x坐标轴数据
224
- if ((_item$pointDataList = item.pointDataList) === null || _item$pointDataList === void 0 ? void 0 : _item$pointDataList.length) {
225
- xAxisData = item.pointDataList.map(function (pointDataItem) {
226
- return pointDataItem.ts;
227
- });
228
- }
229
227
  // 配置曲线数据
230
228
  series.push({
231
229
  animation: false,
@@ -238,7 +236,7 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
238
236
  smooth: false,
239
237
  showAllSymbol: true,
240
238
  symbolSize: 1.5,
241
- data: (_item$pointDataList2 = item.pointDataList) === null || _item$pointDataList2 === void 0 ? void 0 : _item$pointDataList2.map(function (dataItem) {
239
+ data: (_item$pointDataList = item.pointDataList) === null || _item$pointDataList === void 0 ? void 0 : _item$pointDataList.map(function (dataItem) {
242
240
  return [new Date(dataItem.ts).getTime(), dataItem.val];
243
241
  }),
244
242
  markPoint: {
@@ -303,7 +301,6 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
303
301
  splitLine: {
304
302
  show: false
305
303
  }
306
- // data: xAxisData,
307
304
  },
308
305
  series: series
309
306
  });
@@ -467,6 +464,8 @@ var DialogPointHistory = function DialogPointHistory(_ref) {
467
464
  return _toConsumableArray(new Set([].concat(_toConsumableArray(pre), _toConsumableArray(val))));
468
465
  });
469
466
  },
467
+ currentDeviceId: deviceId,
468
+ currentPointList: pointIdList,
470
469
  companyId: companyId,
471
470
  projectId: projectId,
472
471
  onCancel: function onCancel() {
@@ -12,9 +12,9 @@ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
12
12
  import React from "react";
13
13
  import { useCallback, useEffect, useState } from 'react';
14
14
  import { Modal, Button, Form, Space, message, Select } from 'antd';
15
- import { GetDevicePoint } from "../../services/gateway/Device";
15
+ import { GetDevicePage, GetDevicePoint } from "../../services/gateway/Device";
16
16
  import { GetColdChainPermissionDevicePage } from "../../services/project/ProjectUserPermission";
17
- import { useQuery } from "../../hooks";
17
+ import { useModel } from 'umi';
18
18
  var Option = Select.Option;
19
19
  var tailLayout = {
20
20
  wrapperCol: {
@@ -27,7 +27,8 @@ var ModalChoosePoint = function ModalChoosePoint(_ref) {
27
27
  onSubmit = _ref.onSubmit,
28
28
  onCancel = _ref.onCancel,
29
29
  companyId = _ref.companyId,
30
- projectId = _ref.projectId;
30
+ currentDeviceId = _ref.currentDeviceId,
31
+ currentPointList = _ref.currentPointList;
31
32
  var _Form$useForm = Form.useForm(),
32
33
  _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
33
34
  form = _Form$useForm2[0];
@@ -41,9 +42,16 @@ var ModalChoosePoint = function ModalChoosePoint(_ref) {
41
42
  _useState4 = _slicedToArray(_useState3, 2),
42
43
  pointList = _useState4[0],
43
44
  setPointList = _useState4[1];
44
- var query = useQuery();
45
+ var _useModel = useModel('@@initialState', function (model) {
46
+ var _model$initialState, _model$initialState2;
47
+ return {
48
+ platform: (_model$initialState = model.initialState) === null || _model$initialState === void 0 ? void 0 : _model$initialState.platform,
49
+ currentProject: (_model$initialState2 = model.initialState) === null || _model$initialState2 === void 0 ? void 0 : _model$initialState2.currentProject
50
+ };
51
+ }),
52
+ platform = _useModel.platform,
53
+ currentProject = _useModel.currentProject;
45
54
  var closeModal = function closeModal() {
46
- form.resetFields();
47
55
  onCancel === null || onCancel === void 0 ? void 0 : onCancel();
48
56
  };
49
57
 
@@ -91,31 +99,45 @@ var ModalChoosePoint = function ModalChoosePoint(_ref) {
91
99
  while (1) switch (_context2.prev = _context2.next) {
92
100
  case 0:
93
101
  _context2.prev = 0;
94
- _context2.next = 3;
102
+ if (!(platform === 'project')) {
103
+ _context2.next = 7;
104
+ break;
105
+ }
106
+ _context2.next = 4;
95
107
  return GetColdChainPermissionDevicePage({
96
108
  companyId: companyId,
97
- projectId: projectId,
109
+ projectId: currentProject === null || currentProject === void 0 ? void 0 : currentProject.projectId,
98
110
  isPermission: true
99
111
  });
100
- case 3:
112
+ case 4:
113
+ res = _context2.sent;
114
+ _context2.next = 10;
115
+ break;
116
+ case 7:
117
+ _context2.next = 9;
118
+ return GetDevicePage({
119
+ companyId: companyId
120
+ });
121
+ case 9:
101
122
  res = _context2.sent;
123
+ case 10:
102
124
  if (res.success) {
103
125
  setDeviceList(((_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.list) || []);
104
126
  } else {
105
127
  message.error(res.message);
106
128
  }
107
- _context2.next = 10;
129
+ _context2.next = 16;
108
130
  break;
109
- case 7:
110
- _context2.prev = 7;
131
+ case 13:
132
+ _context2.prev = 13;
111
133
  _context2.t0 = _context2["catch"](0);
112
134
  message.error('获取设备列表失败');
113
- case 10:
135
+ case 16:
114
136
  case "end":
115
137
  return _context2.stop();
116
138
  }
117
- }, _callee2, null, [[0, 7]]);
118
- })), [companyId, projectId]);
139
+ }, _callee2, null, [[0, 13]]);
140
+ })), [companyId, platform, currentProject]);
119
141
 
120
142
  /** 提交表单且数据验证成功后回调事件 */
121
143
  var onFinish = /*#__PURE__*/function () {
@@ -145,6 +167,13 @@ var ModalChoosePoint = function ModalChoosePoint(_ref) {
145
167
  fetchDeviceList();
146
168
  }
147
169
  }, [visible, deviceList.length]);
170
+ useEffect(function () {
171
+ if (currentDeviceId) {
172
+ fetchPointList(currentDeviceId);
173
+ form.setFieldValue("deviceId", currentDeviceId);
174
+ form.setFieldValue("pointIdList", currentPointList);
175
+ }
176
+ }, [currentDeviceId]);
148
177
  return /*#__PURE__*/React.createElement(Modal, {
149
178
  title: '选择属性',
150
179
  closable: false,
@@ -152,8 +181,8 @@ var ModalChoosePoint = function ModalChoosePoint(_ref) {
152
181
  maskClosable: true,
153
182
  footer: null,
154
183
  onCancel: closeModal,
155
- open: visible,
156
- getContainer: false
184
+ visible: visible,
185
+ wrapClassName: 'form-modal'
157
186
  }, /*#__PURE__*/React.createElement(Form, {
158
187
  layout: "vertical",
159
188
  form: form,
@@ -165,22 +194,18 @@ var ModalChoosePoint = function ModalChoosePoint(_ref) {
165
194
  }, /*#__PURE__*/React.createElement(Form.Item, {
166
195
  name: "deviceId",
167
196
  label: "\u8BBE\u5907",
168
- className: "temperatureSelect",
169
197
  rules: [{
170
198
  required: true,
171
199
  message: '请选择'
172
200
  }]
173
201
  }, /*#__PURE__*/React.createElement(Select, {
174
202
  placeholder: "\u8BF7\u9009\u62E9",
203
+ defaultValue: currentDeviceId,
175
204
  onChange: function onChange(value) {
176
205
  fetchPointList(value);
177
206
  form.setFieldsValue({
178
207
  pointIdList: []
179
208
  });
180
- },
181
- showSearch: true,
182
- getPopupContainer: function getPopupContainer() {
183
- return document.querySelector(".temperatureSelect") || document.body;
184
209
  }
185
210
  }, deviceList.map(function (item) {
186
211
  return /*#__PURE__*/React.createElement(Option, {
@@ -199,18 +224,14 @@ var ModalChoosePoint = function ModalChoosePoint(_ref) {
199
224
  rules: [{
200
225
  required: true,
201
226
  message: '请选择'
202
- }],
203
- className: "temperature2Select"
227
+ }]
204
228
  }, /*#__PURE__*/React.createElement(Select, {
205
229
  allowClear: true,
206
230
  mode: 'multiple',
207
231
  showSearch: true,
208
232
  optionFilterProp: "label",
209
233
  placeholder: "\u8BF7\u9009\u62E9",
210
- disabled: !getFieldValue('deviceId'),
211
- getPopupContainer: function getPopupContainer() {
212
- return document.querySelector(".temperature2Select") || document.body;
213
- }
234
+ disabled: !getFieldValue('deviceId')
214
235
  }, pointList.map(function (item) {
215
236
  return /*#__PURE__*/React.createElement(Option, {
216
237
  value: item.pointId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coolcare-lite-scada-component",
3
- "version": "1.0.29",
3
+ "version": "1.0.30",
4
4
  "scripts": {
5
5
  "start": "umi dev",
6
6
  "build:prod": "UMI_ENV=prod umi build",