coolcare-lite-scada-component 1.0.39 → 1.0.41
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.
|
@@ -13,8 +13,6 @@ import React from "react";
|
|
|
13
13
|
import { useCallback, useEffect, useState } from 'react';
|
|
14
14
|
import { Modal, Button, Form, Space, message, Select } from 'antd';
|
|
15
15
|
import { GetDevicePage, GetDevicePoint } from "../../services/gateway/Device";
|
|
16
|
-
import { GetColdChainPermissionDevicePage } from "../../services/project/ProjectUserPermission";
|
|
17
|
-
import { useModel } from 'umi';
|
|
18
16
|
var Option = Select.Option;
|
|
19
17
|
var tailLayout = {
|
|
20
18
|
wrapperCol: {
|
|
@@ -41,15 +39,6 @@ var ModalChoosePoint = function ModalChoosePoint(_ref) {
|
|
|
41
39
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
42
40
|
pointList = _useState4[0],
|
|
43
41
|
setPointList = _useState4[1];
|
|
44
|
-
var _useModel = useModel('@@initialState', function (model) {
|
|
45
|
-
var _model$initialState, _model$initialState2;
|
|
46
|
-
return {
|
|
47
|
-
platform: (_model$initialState = model.initialState) === null || _model$initialState === void 0 ? void 0 : _model$initialState.platform,
|
|
48
|
-
currentProject: (_model$initialState2 = model.initialState) === null || _model$initialState2 === void 0 ? void 0 : _model$initialState2.currentProject
|
|
49
|
-
};
|
|
50
|
-
}),
|
|
51
|
-
platform = _useModel.platform,
|
|
52
|
-
currentProject = _useModel.currentProject;
|
|
53
42
|
var closeModal = function closeModal() {
|
|
54
43
|
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
55
44
|
};
|
|
@@ -98,45 +87,29 @@ var ModalChoosePoint = function ModalChoosePoint(_ref) {
|
|
|
98
87
|
while (1) switch (_context2.prev = _context2.next) {
|
|
99
88
|
case 0:
|
|
100
89
|
_context2.prev = 0;
|
|
101
|
-
|
|
102
|
-
_context2.next = 7;
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
_context2.next = 4;
|
|
106
|
-
return GetColdChainPermissionDevicePage({
|
|
107
|
-
companyId: companyId,
|
|
108
|
-
projectId: currentProject === null || currentProject === void 0 ? void 0 : currentProject.projectId,
|
|
109
|
-
isPermission: true
|
|
110
|
-
});
|
|
111
|
-
case 4:
|
|
112
|
-
res = _context2.sent;
|
|
113
|
-
_context2.next = 10;
|
|
114
|
-
break;
|
|
115
|
-
case 7:
|
|
116
|
-
_context2.next = 9;
|
|
90
|
+
_context2.next = 3;
|
|
117
91
|
return GetDevicePage({
|
|
118
92
|
companyId: companyId
|
|
119
93
|
});
|
|
120
|
-
case
|
|
94
|
+
case 3:
|
|
121
95
|
res = _context2.sent;
|
|
122
|
-
case 10:
|
|
123
96
|
if (res.success) {
|
|
124
97
|
setDeviceList(((_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.list) || []);
|
|
125
98
|
} else {
|
|
126
99
|
message.error(res.message);
|
|
127
100
|
}
|
|
128
|
-
_context2.next =
|
|
101
|
+
_context2.next = 10;
|
|
129
102
|
break;
|
|
130
|
-
case
|
|
131
|
-
_context2.prev =
|
|
103
|
+
case 7:
|
|
104
|
+
_context2.prev = 7;
|
|
132
105
|
_context2.t0 = _context2["catch"](0);
|
|
133
106
|
message.error('获取设备列表失败');
|
|
134
|
-
case
|
|
107
|
+
case 10:
|
|
135
108
|
case "end":
|
|
136
109
|
return _context2.stop();
|
|
137
110
|
}
|
|
138
|
-
}, _callee2, null, [[0,
|
|
139
|
-
})), [companyId
|
|
111
|
+
}, _callee2, null, [[0, 7]]);
|
|
112
|
+
})), [companyId]);
|
|
140
113
|
|
|
141
114
|
/** 提交表单且数据验证成功后回调事件 */
|
|
142
115
|
var onFinish = /*#__PURE__*/function () {
|
|
@@ -104,93 +104,100 @@ export function pointWrite(_x4) {
|
|
|
104
104
|
}
|
|
105
105
|
function _pointWrite() {
|
|
106
106
|
_pointWrite = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
107
|
-
var
|
|
107
|
+
var _query$premission;
|
|
108
|
+
var query, deviceId, value, pointId, deviceInfo, pointInfo, writeFunction, res;
|
|
108
109
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
109
110
|
while (1) switch (_context3.prev = _context3.next) {
|
|
110
111
|
case 0:
|
|
111
|
-
|
|
112
|
-
deviceId = params.deviceId, value = params.value, pointId = params.pointId;
|
|
113
|
-
query = queryToObject(window.location.href); // 产品组态不能点位写入
|
|
112
|
+
query = queryToObject(window.location.href);
|
|
114
113
|
if (!(query.scene === 'product')) {
|
|
115
|
-
_context3.next =
|
|
114
|
+
_context3.next = 3;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
return _context3.abrupt("return");
|
|
118
|
+
case 3:
|
|
119
|
+
if (!((_query$premission = query.premission) === null || _query$premission === void 0 ? void 0 : _query$premission.split(',').includes('49'))) {
|
|
120
|
+
_context3.next = 6;
|
|
116
121
|
break;
|
|
117
122
|
}
|
|
123
|
+
message.error('您没有点位写入权限');
|
|
118
124
|
return _context3.abrupt("return");
|
|
119
|
-
case
|
|
120
|
-
//
|
|
125
|
+
case 6:
|
|
126
|
+
// eslint-disable-next-line prefer-const
|
|
127
|
+
deviceId = params.deviceId, value = params.value, pointId = params.pointId; // 如果没有 deviceId(device 场景下),则从 url query 里获取
|
|
121
128
|
if (!deviceId) {
|
|
122
129
|
if (query.scene === 'device') {
|
|
123
130
|
deviceId = parseInt(query.deviceId, 10);
|
|
124
131
|
}
|
|
125
132
|
}
|
|
126
|
-
_context3.next =
|
|
133
|
+
_context3.next = 10;
|
|
127
134
|
return fetchDeviceInfo(deviceId);
|
|
128
|
-
case
|
|
135
|
+
case 10:
|
|
129
136
|
deviceInfo = _context3.sent;
|
|
130
137
|
if (deviceInfo) {
|
|
131
|
-
_context3.next =
|
|
138
|
+
_context3.next = 13;
|
|
132
139
|
break;
|
|
133
140
|
}
|
|
134
141
|
return _context3.abrupt("return", false);
|
|
135
|
-
case
|
|
142
|
+
case 13:
|
|
136
143
|
if ([0, 1].includes(deviceInfo.protocol)) {
|
|
137
|
-
_context3.next =
|
|
144
|
+
_context3.next = 16;
|
|
138
145
|
break;
|
|
139
146
|
}
|
|
140
147
|
message.info('暂不支持该协议网关的写入');
|
|
141
148
|
return _context3.abrupt("return", false);
|
|
142
|
-
case
|
|
149
|
+
case 16:
|
|
143
150
|
if (params.pointId) {
|
|
144
|
-
_context3.next =
|
|
151
|
+
_context3.next = 21;
|
|
145
152
|
break;
|
|
146
153
|
}
|
|
147
|
-
_context3.next =
|
|
154
|
+
_context3.next = 19;
|
|
148
155
|
return getDevicePoint(deviceId, params.identifierName);
|
|
149
|
-
case
|
|
156
|
+
case 19:
|
|
150
157
|
pointInfo = _context3.sent;
|
|
151
158
|
if (pointInfo) {
|
|
152
159
|
pointId = pointInfo.pointId;
|
|
153
160
|
}
|
|
154
|
-
case
|
|
161
|
+
case 21:
|
|
155
162
|
writeFunction = deviceInfo.protocol === 0 ? ModbusMqttWritePointData : CommonMqttWritePointData;
|
|
156
|
-
_context3.prev =
|
|
157
|
-
_context3.next =
|
|
163
|
+
_context3.prev = 22;
|
|
164
|
+
_context3.next = 25;
|
|
158
165
|
return writeFunction(_defineProperty({}, pointId, value));
|
|
159
|
-
case
|
|
166
|
+
case 25:
|
|
160
167
|
res = _context3.sent;
|
|
161
168
|
if (!(res.data === '指令已下发')) {
|
|
162
|
-
_context3.next =
|
|
169
|
+
_context3.next = 29;
|
|
163
170
|
break;
|
|
164
171
|
}
|
|
165
172
|
message.success('指令已下发');
|
|
166
173
|
return _context3.abrupt("return", true);
|
|
167
|
-
case
|
|
174
|
+
case 29:
|
|
168
175
|
if (res.success) {
|
|
169
|
-
_context3.next =
|
|
176
|
+
_context3.next = 32;
|
|
170
177
|
break;
|
|
171
178
|
}
|
|
172
179
|
message.error(res.message);
|
|
173
180
|
return _context3.abrupt("return", false);
|
|
174
|
-
case
|
|
181
|
+
case 32:
|
|
175
182
|
if (!(res.data && pointId in res.data)) {
|
|
176
|
-
_context3.next =
|
|
183
|
+
_context3.next = 35;
|
|
177
184
|
break;
|
|
178
185
|
}
|
|
179
186
|
message.error('写入失败');
|
|
180
187
|
return _context3.abrupt("return", false);
|
|
181
|
-
case
|
|
182
|
-
_context3.next =
|
|
188
|
+
case 35:
|
|
189
|
+
_context3.next = 41;
|
|
183
190
|
break;
|
|
184
|
-
case
|
|
185
|
-
_context3.prev =
|
|
186
|
-
_context3.t0 = _context3["catch"](
|
|
191
|
+
case 37:
|
|
192
|
+
_context3.prev = 37;
|
|
193
|
+
_context3.t0 = _context3["catch"](22);
|
|
187
194
|
console.error(_context3.t0);
|
|
188
195
|
return _context3.abrupt("return", false);
|
|
189
|
-
case
|
|
196
|
+
case 41:
|
|
190
197
|
case "end":
|
|
191
198
|
return _context3.stop();
|
|
192
199
|
}
|
|
193
|
-
}, _callee3, null, [[
|
|
200
|
+
}, _callee3, null, [[22, 37]]);
|
|
194
201
|
}));
|
|
195
202
|
return _pointWrite.apply(this, arguments);
|
|
196
203
|
}
|
package/es/typings.d.ts
CHANGED