coolcare-lite-scada-component 1.0.40 → 1.0.42

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.
@@ -104,93 +104,101 @@ export function pointWrite(_x4) {
104
104
  }
105
105
  function _pointWrite() {
106
106
  _pointWrite = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
107
- var deviceId, value, pointId, query, deviceInfo, pointInfo, writeFunction, res;
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
- // eslint-disable-next-line prefer-const
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 = 4;
114
+ _context3.next = 3;
115
+ break;
116
+ }
117
+ return _context3.abrupt("return");
118
+ case 3:
119
+ console.log(query.premission);
120
+ if (!((_query$premission = query.premission) === null || _query$premission === void 0 ? void 0 : _query$premission.split(',').includes('49'))) {
121
+ _context3.next = 7;
116
122
  break;
117
123
  }
124
+ message.error('您没有点位写入权限');
118
125
  return _context3.abrupt("return");
119
- case 4:
120
- // 如果没有 deviceId(device 场景下),则从 url query 里获取
126
+ case 7:
127
+ // eslint-disable-next-line prefer-const
128
+ deviceId = params.deviceId, value = params.value, pointId = params.pointId; // 如果没有 deviceId(device 场景下),则从 url query 里获取
121
129
  if (!deviceId) {
122
130
  if (query.scene === 'device') {
123
131
  deviceId = parseInt(query.deviceId, 10);
124
132
  }
125
133
  }
126
- _context3.next = 7;
134
+ _context3.next = 11;
127
135
  return fetchDeviceInfo(deviceId);
128
- case 7:
136
+ case 11:
129
137
  deviceInfo = _context3.sent;
130
138
  if (deviceInfo) {
131
- _context3.next = 10;
139
+ _context3.next = 14;
132
140
  break;
133
141
  }
134
142
  return _context3.abrupt("return", false);
135
- case 10:
143
+ case 14:
136
144
  if ([0, 1].includes(deviceInfo.protocol)) {
137
- _context3.next = 13;
145
+ _context3.next = 17;
138
146
  break;
139
147
  }
140
148
  message.info('暂不支持该协议网关的写入');
141
149
  return _context3.abrupt("return", false);
142
- case 13:
150
+ case 17:
143
151
  if (params.pointId) {
144
- _context3.next = 18;
152
+ _context3.next = 22;
145
153
  break;
146
154
  }
147
- _context3.next = 16;
155
+ _context3.next = 20;
148
156
  return getDevicePoint(deviceId, params.identifierName);
149
- case 16:
157
+ case 20:
150
158
  pointInfo = _context3.sent;
151
159
  if (pointInfo) {
152
160
  pointId = pointInfo.pointId;
153
161
  }
154
- case 18:
162
+ case 22:
155
163
  writeFunction = deviceInfo.protocol === 0 ? ModbusMqttWritePointData : CommonMqttWritePointData;
156
- _context3.prev = 19;
157
- _context3.next = 22;
164
+ _context3.prev = 23;
165
+ _context3.next = 26;
158
166
  return writeFunction(_defineProperty({}, pointId, value));
159
- case 22:
167
+ case 26:
160
168
  res = _context3.sent;
161
169
  if (!(res.data === '指令已下发')) {
162
- _context3.next = 26;
170
+ _context3.next = 30;
163
171
  break;
164
172
  }
165
173
  message.success('指令已下发');
166
174
  return _context3.abrupt("return", true);
167
- case 26:
175
+ case 30:
168
176
  if (res.success) {
169
- _context3.next = 29;
177
+ _context3.next = 33;
170
178
  break;
171
179
  }
172
180
  message.error(res.message);
173
181
  return _context3.abrupt("return", false);
174
- case 29:
182
+ case 33:
175
183
  if (!(res.data && pointId in res.data)) {
176
- _context3.next = 32;
184
+ _context3.next = 36;
177
185
  break;
178
186
  }
179
187
  message.error('写入失败');
180
188
  return _context3.abrupt("return", false);
181
- case 32:
182
- _context3.next = 38;
189
+ case 36:
190
+ _context3.next = 42;
183
191
  break;
184
- case 34:
185
- _context3.prev = 34;
186
- _context3.t0 = _context3["catch"](19);
192
+ case 38:
193
+ _context3.prev = 38;
194
+ _context3.t0 = _context3["catch"](23);
187
195
  console.error(_context3.t0);
188
196
  return _context3.abrupt("return", false);
189
- case 38:
197
+ case 42:
190
198
  case "end":
191
199
  return _context3.stop();
192
200
  }
193
- }, _callee3, null, [[19, 34]]);
201
+ }, _callee3, null, [[23, 38]]);
194
202
  }));
195
203
  return _pointWrite.apply(this, arguments);
196
204
  }
package/es/typings.d.ts CHANGED
@@ -59,6 +59,8 @@ type EditorQuery =
59
59
  companyId: string;
60
60
  /** 项目 id */
61
61
  projectId?: string;
62
+ // 权限
63
+ premission?: string;
62
64
  };
63
65
 
64
66
  type PlayerQuery =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coolcare-lite-scada-component",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "scripts": {
5
5
  "start": " umi dev",
6
6
  "build:prod": "UMI_ENV=prod umi build",