coolcare-lite-scada-component 1.0.40 → 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.
@@ -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 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
+ 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 4:
120
- // 如果没有 deviceId(device 场景下),则从 url query 里获取
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 = 7;
133
+ _context3.next = 10;
127
134
  return fetchDeviceInfo(deviceId);
128
- case 7:
135
+ case 10:
129
136
  deviceInfo = _context3.sent;
130
137
  if (deviceInfo) {
131
- _context3.next = 10;
138
+ _context3.next = 13;
132
139
  break;
133
140
  }
134
141
  return _context3.abrupt("return", false);
135
- case 10:
142
+ case 13:
136
143
  if ([0, 1].includes(deviceInfo.protocol)) {
137
- _context3.next = 13;
144
+ _context3.next = 16;
138
145
  break;
139
146
  }
140
147
  message.info('暂不支持该协议网关的写入');
141
148
  return _context3.abrupt("return", false);
142
- case 13:
149
+ case 16:
143
150
  if (params.pointId) {
144
- _context3.next = 18;
151
+ _context3.next = 21;
145
152
  break;
146
153
  }
147
- _context3.next = 16;
154
+ _context3.next = 19;
148
155
  return getDevicePoint(deviceId, params.identifierName);
149
- case 16:
156
+ case 19:
150
157
  pointInfo = _context3.sent;
151
158
  if (pointInfo) {
152
159
  pointId = pointInfo.pointId;
153
160
  }
154
- case 18:
161
+ case 21:
155
162
  writeFunction = deviceInfo.protocol === 0 ? ModbusMqttWritePointData : CommonMqttWritePointData;
156
- _context3.prev = 19;
157
- _context3.next = 22;
163
+ _context3.prev = 22;
164
+ _context3.next = 25;
158
165
  return writeFunction(_defineProperty({}, pointId, value));
159
- case 22:
166
+ case 25:
160
167
  res = _context3.sent;
161
168
  if (!(res.data === '指令已下发')) {
162
- _context3.next = 26;
169
+ _context3.next = 29;
163
170
  break;
164
171
  }
165
172
  message.success('指令已下发');
166
173
  return _context3.abrupt("return", true);
167
- case 26:
174
+ case 29:
168
175
  if (res.success) {
169
- _context3.next = 29;
176
+ _context3.next = 32;
170
177
  break;
171
178
  }
172
179
  message.error(res.message);
173
180
  return _context3.abrupt("return", false);
174
- case 29:
181
+ case 32:
175
182
  if (!(res.data && pointId in res.data)) {
176
- _context3.next = 32;
183
+ _context3.next = 35;
177
184
  break;
178
185
  }
179
186
  message.error('写入失败');
180
187
  return _context3.abrupt("return", false);
181
- case 32:
182
- _context3.next = 38;
188
+ case 35:
189
+ _context3.next = 41;
183
190
  break;
184
- case 34:
185
- _context3.prev = 34;
186
- _context3.t0 = _context3["catch"](19);
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 38:
196
+ case 41:
190
197
  case "end":
191
198
  return _context3.stop();
192
199
  }
193
- }, _callee3, null, [[19, 34]]);
200
+ }, _callee3, null, [[22, 37]]);
194
201
  }));
195
202
  return _pointWrite.apply(this, arguments);
196
203
  }
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.41",
4
4
  "scripts": {
5
5
  "start": " umi dev",
6
6
  "build:prod": "UMI_ENV=prod umi build",