coolcare-lite-scada-component 4.1.0 → 4.1.2

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.
Files changed (96) hide show
  1. package/es/app.js +23 -0
  2. package/es/components/BoxShadowPicker/index.less.d.ts +9 -9
  3. package/es/components/ColorPicker/util.js +4 -4
  4. package/es/components/DialogHistory/index.css +22 -0
  5. package/es/components/DialogHistory/index.js +388 -79
  6. package/es/components/DialogImagePicker/GroupPanel/index.js +1 -12
  7. package/es/components/ECharts/index.js +31 -23
  8. package/es/components/FormBindPoint/FreedomScene.js +181 -11
  9. package/es/components/FormBindPoint/ProductionOrDeviceScene.js +12 -5
  10. package/es/components/FormBindPoint/index.js +6 -0
  11. package/es/components/Icon/index.js +1 -1
  12. package/es/components/IconFont/index.js +6 -0
  13. package/es/components/ImageUploader/index.js +8 -7
  14. package/es/components/ModalChangePointValue.js +272 -0
  15. package/es/components/ModalChoosePoint/index.js +53 -16
  16. package/es/components/PointSelect/DeviceIndicatorTable.js +111 -0
  17. package/es/components/PointSelect/IndicatorSelect.js +182 -0
  18. package/es/constant.js +2 -2
  19. package/es/element/BorderBox/util/typings.d.ts +9 -9
  20. package/es/element/Decoration/util/typings.d.ts +9 -9
  21. package/es/element/EleFan/Component.js +1 -1
  22. package/es/element/EleFanBySvg/index.js +3 -3
  23. package/es/element/EleImage/index.js +1 -1
  24. package/es/element/ElePointImage/Component.js +30 -41
  25. package/es/element/ElePointImage/index.js +1 -1
  26. package/es/element/ElePointValue/Component.js +117 -17
  27. package/es/element/ElePointValue/PropsSet/StatisticsPropsSet/index.js +6 -0
  28. package/es/element/ElePointValue/index.css +11 -0
  29. package/es/element/ElePointValue/index.js +6 -0
  30. package/es/element/EleShine/Component.js +133 -23
  31. package/es/element/EleShine/PropsSet/OtherPropsSet/index.js +27 -34
  32. package/es/element/EleShine/PropsSet/PointAlarmTool.js +99 -0
  33. package/es/element/EleShine/PropsSet/index.js +9 -1
  34. package/es/element/EleShine/index.js +2 -1
  35. package/es/element/EleState/index.js +1 -1
  36. package/es/element/EleSwitch/Component.js +2 -12
  37. package/es/element/PipeNodes/NodeBL/index.js +1 -1
  38. package/es/element/PipeNodes/NodeBR/index.js +1 -1
  39. package/es/element/PipeNodes/NodeBottom/index.js +1 -1
  40. package/es/element/PipeNodes/NodeCenter/index.js +1 -1
  41. package/es/element/PipeNodes/NodeHorizontal/index.js +1 -1
  42. package/es/element/PipeNodes/NodeLeft/index.js +1 -1
  43. package/es/element/PipeNodes/NodeRight/index.js +1 -1
  44. package/es/element/PipeNodes/NodeTL/index.js +1 -1
  45. package/es/element/PipeNodes/NodeTR/index.js +1 -1
  46. package/es/element/PipeNodes/NodeTop/index.js +1 -1
  47. package/es/element/PipeNodes/NodeVertical/index.js +1 -1
  48. package/es/element/PointCard/PointListCard/Component.js +3 -2
  49. package/es/element/PointCard/PointListCard/index.js +1 -0
  50. package/es/element/type.d.ts +4 -6
  51. package/es/element/utils/getValueByExpression.js +3 -0
  52. package/es/element/utils/handleEleEvent.js +11 -1
  53. package/es/element/utils/pointWrite.js +4 -5
  54. package/es/hooks/usePointWatch.js +1 -1
  55. package/es/models/useEditor.js +14 -8
  56. package/es/pages/display/Player/index.js +444 -123
  57. package/es/pages/display/index.js +2 -2
  58. package/es/pages/document.ejs +1 -1
  59. package/es/pages/editor/PanelLeft/BasicShapeList/listData.js +8 -8
  60. package/es/pages/editor/PanelLeft/BorderBoxEleList/index.less.d.ts +7 -7
  61. package/es/pages/editor/PanelLeft/DecorationEleList/index.less.d.ts +7 -7
  62. package/es/pages/editor/PanelLeft/GroupManageDialog/index.js +4 -4
  63. package/es/pages/editor/PanelLeft/ImgGroup/index.js +1 -12
  64. package/es/pages/editor/PanelLeft/MetaEleList/listData.js +14 -14
  65. package/es/pages/editor/PanelLeft/PipeEleList/listData.js +11 -11
  66. package/es/pages/editor/PanelLeft/PointCardEleList/listData.js +6 -6
  67. package/es/pages/editor/PanelLeft/RecommendEleList/listData.js +4 -4
  68. package/es/pages/editor/PanelLeft/index.js +3 -3
  69. package/es/pages/editor/PanelRight/components/FormLayer/index.js +3 -1
  70. package/es/pages/editor/PanelRight/index.less.d.ts +7 -7
  71. package/es/pages/editor/PanelTop/HotKeyDescribe/index.js +1 -1
  72. package/es/pages/editor/PanelTop/Save/index.js +120 -67
  73. package/es/pages/editor/index.js +223 -135
  74. package/es/pages/editor/utils/scadaChangeLog.js +237 -0
  75. package/es/services/common/Uploader.js +1 -1
  76. package/es/services/common/typings.d.ts +15 -15
  77. package/es/services/energy/index.js +56 -0
  78. package/es/services/gateway/Device.js +22 -0
  79. package/es/services/gateway/Point.js +46 -25
  80. package/es/services/gateway/typings.d.ts +3 -0
  81. package/es/services/master/typings.d.ts +362 -362
  82. package/es/services/product/typings.d.ts +1045 -1045
  83. package/es/services/project/typings.d.ts +1609 -1609
  84. package/es/services/request.js +126 -13
  85. package/es/shims.x6.d.ts +15 -15
  86. package/es/typings.d.ts +12 -0
  87. package/es/utils/auth.js +6 -2
  88. package/es/utils/cssStyle.js +4 -4
  89. package/es/utils/dataURItoBlob.js +25 -0
  90. package/es/utils/date.js +7 -0
  91. package/es/utils/decomposeMatrix.js +5 -5
  92. package/es/utils/events.js +3 -3
  93. package/es/utils/index.js +34 -34
  94. package/es/utils/pointValueFormat.js +3 -3
  95. package/package.json +16 -15
  96. package/es/elementCss.css +0 -19
@@ -0,0 +1,272 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
3
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
4
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
5
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
6
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
7
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
9
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
10
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
11
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
12
+ import React from "react";
13
+ import { Modal, Form, InputNumber, message, Space, Button, Switch, Select } from 'antd';
14
+ import { CommonMqttWritePointData, ModbusMqttWritePointData } from "../services/gateway/Point";
15
+ import { useState, useEffect } from 'react';
16
+ var Option = Select.Option;
17
+ var layout = {
18
+ labelCol: {
19
+ span: 0
20
+ },
21
+ wrapperCol: {
22
+ span: 24
23
+ }
24
+ };
25
+ var tailLayout = {
26
+ wrapperCol: {
27
+ offset: 2,
28
+ span: 22
29
+ }
30
+ };
31
+ var ModalChangePointValue = function ModalChangePointValue(_ref) {
32
+ var _ref$protocol = _ref.protocol,
33
+ protocol = _ref$protocol === void 0 ? 0 : _ref$protocol,
34
+ pointValue = _ref.pointValue,
35
+ _ref$pointIdList = _ref.pointIdList,
36
+ pointIdList = _ref$pointIdList === void 0 ? [] : _ref$pointIdList,
37
+ _ref$pointEnumItemLis = _ref.pointEnumItemList,
38
+ pointEnumItemList = _ref$pointEnumItemLis === void 0 ? [] : _ref$pointEnumItemLis,
39
+ visible = _ref.visible,
40
+ onSubmit = _ref.onSubmit,
41
+ onCancel = _ref.onCancel;
42
+ var _Form$useForm = Form.useForm(),
43
+ _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
44
+ form = _Form$useForm2[0];
45
+ /** 点位写入弹框 */
46
+ var _useState = useState(false),
47
+ _useState2 = _slicedToArray(_useState, 2),
48
+ loading = _useState2[0],
49
+ setLoading = _useState2[1];
50
+ /** 点位类型 1:数值类型 */
51
+ var _useState3 = useState(1),
52
+ _useState4 = _slicedToArray(_useState3, 2),
53
+ pointEnumId = _useState4[0],
54
+ setPointEnumId = _useState4[1];
55
+ /** 枚举类型选择方式是否为开关 */
56
+ var _useState5 = useState(false),
57
+ _useState6 = _slicedToArray(_useState5, 2),
58
+ isSwitch = _useState6[0],
59
+ setIsSwitch = _useState6[1];
60
+ var closeModal = function closeModal() {
61
+ setPointEnumId(1);
62
+ setIsSwitch(false);
63
+ form.resetFields();
64
+ onCancel === null || onCancel === void 0 ? void 0 : onCancel();
65
+ };
66
+ useEffect(function () {
67
+ if (visible && form) {
68
+ var switchFlag = false;
69
+ if (pointEnumItemList.length) {
70
+ var _pointEnumItemList$;
71
+ // 如果点位是枚举类型,并且为0:关,1:开,表单交互为开关
72
+ switchFlag = Boolean(pointEnumItemList[0].pointEnumId !== 1 && (pointEnumItemList[0].pointEnumItemKey === '开' && pointEnumItemList[0].pointEnumItemValue === 1 || pointEnumItemList[0].pointEnumItemKey === '关' && pointEnumItemList[0].pointEnumItemValue === 0));
73
+ setIsSwitch(switchFlag);
74
+
75
+ // 设置点位枚举id
76
+ setPointEnumId((pointEnumItemList === null || pointEnumItemList === void 0 ? void 0 : (_pointEnumItemList$ = pointEnumItemList[0]) === null || _pointEnumItemList$ === void 0 ? void 0 : _pointEnumItemList$.pointEnumId) || 1);
77
+ }
78
+ // 设置初始值
79
+ if (typeof pointValue === 'number') {
80
+ var _pointEnumItemList$2;
81
+ if ((pointEnumItemList === null || pointEnumItemList === void 0 ? void 0 : (_pointEnumItemList$2 = pointEnumItemList[0]) === null || _pointEnumItemList$2 === void 0 ? void 0 : _pointEnumItemList$2.pointEnumId) === 1) {
82
+ form.setFieldsValue({
83
+ value1: pointValue
84
+ });
85
+ } else if (switchFlag) {
86
+ form.setFieldsValue({
87
+ value2: Boolean(pointValue)
88
+ });
89
+ } else {
90
+ form.setFieldsValue({
91
+ value3: pointValue
92
+ });
93
+ }
94
+ }
95
+ }
96
+ }, [pointEnumItemList, visible, form, pointValue]);
97
+
98
+ /** 提交表单且数据验证成功后回调事件 */
99
+ var onFinish = /*#__PURE__*/function () {
100
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(values) {
101
+ var value1, value2, value3, data, value, res, _res$data, _res$data2, _res, _res$data3, _res$data4, _t;
102
+ return _regenerator().w(function (_context) {
103
+ while (1) switch (_context.p = _context.n) {
104
+ case 0:
105
+ value1 = values.value1, value2 = values.value2, value3 = values.value3;
106
+ data = {};
107
+ if (pointEnumId === 1) {
108
+ value = value1;
109
+ } else if (isSwitch) {
110
+ value = value2 ? 1 : 0;
111
+ } else {
112
+ value = value3;
113
+ }
114
+ if (!(typeof value !== 'number')) {
115
+ _context.n = 1;
116
+ break;
117
+ }
118
+ message.error('写入数据只能为数值类型');
119
+ return _context.a(2);
120
+ case 1:
121
+ pointIdList.forEach(function (item) {
122
+ data[item] = value;
123
+ });
124
+ setLoading(true);
125
+ _context.p = 2;
126
+ if (!(protocol === 0)) {
127
+ _context.n = 4;
128
+ break;
129
+ }
130
+ _context.n = 3;
131
+ return ModbusMqttWritePointData(data);
132
+ case 3:
133
+ res = _context.v;
134
+ if (res.success) {
135
+ if ((_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.key) {
136
+ message.info((_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.key);
137
+ } else {
138
+ message.success(res.data);
139
+ }
140
+ message.success('写入成功,请等待下轮数据刷新');
141
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(Number(value));
142
+ closeModal();
143
+ } else {
144
+ message.error(res.message);
145
+ }
146
+ setLoading(false);
147
+ _context.n = 7;
148
+ break;
149
+ case 4:
150
+ if (!(protocol === 1)) {
151
+ _context.n = 6;
152
+ break;
153
+ }
154
+ _context.n = 5;
155
+ return CommonMqttWritePointData(data);
156
+ case 5:
157
+ _res = _context.v;
158
+ if (_res.success) {
159
+ if ((_res$data3 = _res.data) === null || _res$data3 === void 0 ? void 0 : _res$data3.key) {
160
+ message.info((_res$data4 = _res.data) === null || _res$data4 === void 0 ? void 0 : _res$data4.key);
161
+ } else {
162
+ message.success(_res.data);
163
+ }
164
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(Number(value));
165
+ message.success('写入成功,请等待下轮数据刷新');
166
+ closeModal();
167
+ } else {
168
+ message.error(_res.message);
169
+ }
170
+ setLoading(false);
171
+ _context.n = 7;
172
+ break;
173
+ case 6:
174
+ message.info('暂不支持该协议网关的写入');
175
+ case 7:
176
+ _context.n = 9;
177
+ break;
178
+ case 8:
179
+ _context.p = 8;
180
+ _t = _context.v;
181
+ message.error('写入数据失败');
182
+ setLoading(false);
183
+ case 9:
184
+ return _context.a(2);
185
+ }
186
+ }, _callee, null, [[2, 8]]);
187
+ }));
188
+ return function onFinish(_x) {
189
+ return _ref2.apply(this, arguments);
190
+ };
191
+ }();
192
+ return /*#__PURE__*/React.createElement(Modal, {
193
+ title: "\u5199\u5165\u6570\u636E",
194
+ visible: visible,
195
+ closable: false,
196
+ width: 330,
197
+ maskClosable: true,
198
+ footer: null,
199
+ onCancel: closeModal,
200
+ afterClose: closeModal,
201
+ wrapClassName: 'form-modal'
202
+ }, /*#__PURE__*/React.createElement(Form, _extends({}, layout, {
203
+ form: form,
204
+ name: "form",
205
+ onFinish: onFinish,
206
+ initialValues: {
207
+ value1: undefined,
208
+ value2: false,
209
+ value3: undefined
210
+ }
211
+ }), pointEnumId === 1 ? /*#__PURE__*/React.createElement(Form.Item, {
212
+ name: "value1",
213
+ rules: [{
214
+ required: true,
215
+ message: '请输入'
216
+ }]
217
+ }, /*#__PURE__*/React.createElement(InputNumber, {
218
+ placeholder: "\u8BF7\u8F93\u5165\u8981\u5199\u5165\u7684\u503C",
219
+ disabled: loading,
220
+ style: {
221
+ width: '100%'
222
+ }
223
+ })) : isSwitch ? /*#__PURE__*/React.createElement(Form.Item, {
224
+ name: "value2",
225
+ valuePropName: "checked",
226
+ rules: [{
227
+ required: true,
228
+ message: '请选择'
229
+ }]
230
+ }, /*#__PURE__*/React.createElement(Switch, {
231
+ checkedChildren: "\u5F00",
232
+ unCheckedChildren: "\u5173"
233
+ })) : /*#__PURE__*/React.createElement(Form.Item, {
234
+ name: "value3",
235
+ rules: [{
236
+ required: true,
237
+ message: '请选择'
238
+ }]
239
+ }, /*#__PURE__*/React.createElement(Select, {
240
+ style: {
241
+ width: '100%'
242
+ },
243
+ placeholder: '请选择'
244
+ }, pointEnumItemList === null || pointEnumItemList === void 0 ? void 0 : pointEnumItemList.map(function (item) {
245
+ return /*#__PURE__*/React.createElement(Option, {
246
+ value: item.pointEnumItemValue,
247
+ key: item.pointEnumItemValue
248
+ }, item.pointEnumItemKey);
249
+ }))), /*#__PURE__*/React.createElement(Form.Item, _extends({}, tailLayout, {
250
+ noStyle: true,
251
+ className: "modelFooterItem"
252
+ }), /*#__PURE__*/React.createElement("div", {
253
+ className: "form-modal-footer"
254
+ }, /*#__PURE__*/React.createElement(Space, {
255
+ align: "center",
256
+ size: 15
257
+ }, /*#__PURE__*/React.createElement(Button, {
258
+ onClick: onCancel,
259
+ htmlType: "button",
260
+ style: {
261
+ float: 'right'
262
+ }
263
+ }, "\u53D6\u6D88"), /*#__PURE__*/React.createElement(Button, {
264
+ loading: loading,
265
+ type: "primary",
266
+ htmlType: "submit",
267
+ style: {
268
+ float: 'right'
269
+ }
270
+ }, "\u786E\u5B9A"))))));
271
+ };
272
+ export default ModalChangePointValue;
@@ -12,7 +12,7 @@ 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 { GetDevicePage, GetDevicePoint } from "../../services/gateway/Device";
15
+ import { GetDeviceIndicator, GetDevicePage, GetDevicePoint } from "../../services/gateway/Device";
16
16
  var Option = Select.Option;
17
17
  var tailLayout = {
18
18
  wrapperCol: {
@@ -25,7 +25,9 @@ var ModalChoosePoint = function ModalChoosePoint(_ref) {
25
25
  onSubmit = _ref.onSubmit,
26
26
  onCancel = _ref.onCancel,
27
27
  companyId = _ref.companyId,
28
- currentDeviceId = _ref.currentDeviceId;
28
+ projectId = _ref.projectId,
29
+ currentDeviceId = _ref.currentDeviceId,
30
+ valueType = _ref.valueType;
29
31
  var _Form$useForm = Form.useForm(),
30
32
  _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
31
33
  form = _Form$useForm2[0];
@@ -46,11 +48,15 @@ var ModalChoosePoint = function ModalChoosePoint(_ref) {
46
48
  /** 获取产品最新发布版本点位列表 */
47
49
  var fetchPointList = useCallback(/*#__PURE__*/function () {
48
50
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(val) {
49
- var res, _t;
51
+ var res, _yield$GetDeviceIndic, success, data, _message, _t;
50
52
  return _regenerator().w(function (_context) {
51
53
  while (1) switch (_context.p = _context.n) {
52
54
  case 0:
53
55
  _context.p = 0;
56
+ if (!(valueType == 'point')) {
57
+ _context.n = 2;
58
+ break;
59
+ }
54
60
  _context.n = 1;
55
61
  return GetDevicePoint({
56
62
  deviceIdList: [val]
@@ -62,17 +68,35 @@ var ModalChoosePoint = function ModalChoosePoint(_ref) {
62
68
  } else {
63
69
  message.error(res.message);
64
70
  }
65
- _context.n = 3;
71
+ _context.n = 4;
66
72
  break;
67
73
  case 2:
68
- _context.p = 2;
74
+ _context.n = 3;
75
+ return GetDeviceIndicator({
76
+ deviceIdList: [val]
77
+ });
78
+ case 3:
79
+ _yield$GetDeviceIndic = _context.v;
80
+ success = _yield$GetDeviceIndic.success;
81
+ data = _yield$GetDeviceIndic.data;
82
+ _message = _yield$GetDeviceIndic.message;
83
+ if (success) {
84
+ setPointList(data || []);
85
+ } else {
86
+ _message.error(_message);
87
+ }
88
+ case 4:
89
+ _context.n = 6;
90
+ break;
91
+ case 5:
92
+ _context.p = 5;
69
93
  _t = _context.v;
70
94
  console.error(_t);
71
95
  message.error('获取属性列表失败');
72
- case 3:
96
+ case 6:
73
97
  return _context.a(2);
74
98
  }
75
- }, _callee, null, [[0, 2]]);
99
+ }, _callee, null, [[0, 5]]);
76
100
  }));
77
101
  return function (_x) {
78
102
  return _ref2.apply(this, arguments);
@@ -88,7 +112,8 @@ var ModalChoosePoint = function ModalChoosePoint(_ref) {
88
112
  _context2.p = 0;
89
113
  _context2.n = 1;
90
114
  return GetDevicePage({
91
- companyId: companyId
115
+ companyId: companyId,
116
+ projectIdList: isNaN(projectId) ? undefined : [projectId]
92
117
  });
93
118
  case 1:
94
119
  res = _context2.v;
@@ -143,14 +168,18 @@ var ModalChoosePoint = function ModalChoosePoint(_ref) {
143
168
  }
144
169
  }, [currentDeviceId]);
145
170
  return /*#__PURE__*/React.createElement(Modal, {
146
- title: '选择属性',
171
+ title: "\u9009\u62E9".concat(valueType == 'point' ? '点位' : '指标'),
147
172
  closable: false,
148
173
  width: 300,
149
174
  maskClosable: true,
150
175
  footer: null,
151
176
  onCancel: closeModal,
152
177
  visible: visible,
153
- wrapClassName: 'form-modal'
178
+ zIndex: 9999,
179
+ wrapClassName: 'form-modal',
180
+ getContainer: function getContainer() {
181
+ return document.getElementById("scada-body");
182
+ }
154
183
  }, /*#__PURE__*/React.createElement(Form, {
155
184
  layout: "vertical",
156
185
  form: form,
@@ -161,6 +190,7 @@ var ModalChoosePoint = function ModalChoosePoint(_ref) {
161
190
  }
162
191
  }, /*#__PURE__*/React.createElement(Form.Item, {
163
192
  name: "deviceId",
193
+ className: "temperatureDeviceSelect",
164
194
  label: "\u8BBE\u5907",
165
195
  rules: [{
166
196
  required: true,
@@ -174,6 +204,9 @@ var ModalChoosePoint = function ModalChoosePoint(_ref) {
174
204
  form.setFieldsValue({
175
205
  pointIdList: []
176
206
  });
207
+ },
208
+ getPopupContainer: function getPopupContainer() {
209
+ return document.querySelector('.temperatureDeviceSelect') || document.body;
177
210
  }
178
211
  }, deviceList.map(function (item) {
179
212
  return /*#__PURE__*/React.createElement(Option, {
@@ -192,20 +225,24 @@ var ModalChoosePoint = function ModalChoosePoint(_ref) {
192
225
  rules: [{
193
226
  required: true,
194
227
  message: '请选择'
195
- }]
228
+ }],
229
+ className: "temperaturePointSelect"
196
230
  }, /*#__PURE__*/React.createElement(Select, {
197
231
  allowClear: true,
198
232
  mode: 'multiple',
199
233
  showSearch: true,
200
234
  optionFilterProp: "label",
201
235
  placeholder: "\u8BF7\u9009\u62E9",
202
- disabled: !getFieldValue('deviceId')
236
+ disabled: !getFieldValue('deviceId'),
237
+ getPopupContainer: function getPopupContainer() {
238
+ return document.querySelector('.temperaturePointSelect') || document.body;
239
+ }
203
240
  }, pointList.map(function (item) {
204
241
  return /*#__PURE__*/React.createElement(Option, {
205
- value: item.pointId,
206
- label: item.pointName,
207
- key: item.pointId
208
- }, item.pointName);
242
+ value: item.pointId || item.indicatorNo,
243
+ label: item.pointName || item.indicatorName,
244
+ key: item.pointId || item.indicatorNo
245
+ }, item.pointName || item.indicatorName);
209
246
  })));
210
247
  }), /*#__PURE__*/React.createElement(Form.Item, _extends({}, tailLayout, {
211
248
  noStyle: true,
@@ -0,0 +1,111 @@
1
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
7
+ import React from "react";
8
+ import { Table, Input, Space } from 'antd';
9
+ import { useState, useMemo } from 'react';
10
+ import { CloseOutlined } from '@ant-design/icons';
11
+ import styles from "./index.css";
12
+ var Search = Input.Search;
13
+ var ProductIndicatorTypeEnum = ['能耗', '温度', '库门', '制冷', '化霜', '过热度', '膨胀阀', '压缩机', '自定义', '单位库容能耗', '用水量', '用气量'];
14
+ var columns = [{
15
+ title: '指标名称',
16
+ dataIndex: 'indicatorName',
17
+ key: 'indicatorName'
18
+ }, {
19
+ title: '最近值',
20
+ dataIndex: 'value',
21
+ key: 'value',
22
+ width: 70,
23
+ render: function render(value, record, index) {
24
+ return record.indicatorData ? record.indicatorData.val : 0;
25
+ }
26
+ }, {
27
+ title: '数据更新时间',
28
+ dataIndex: 'updateTime',
29
+ key: 'updateTime',
30
+ width: 150,
31
+ render: function render(value, record, index) {
32
+ return record.indicatorData ? record.indicatorData.ts : '--/--';
33
+ }
34
+ }, {
35
+ title: '指标类型',
36
+ dataIndex: 'indicatorType',
37
+ render: function render(value, record, index) {
38
+ return ProductIndicatorTypeEnum[value];
39
+ }
40
+ }];
41
+ var DeviceIndicatorTable = function DeviceIndicatorTable(_ref) {
42
+ var _onChange = _ref.onChange,
43
+ onClose = _ref.onClose,
44
+ data = _ref.data,
45
+ indicatorId = _ref.indicatorId,
46
+ loading = _ref.loading;
47
+ var _useState = useState(''),
48
+ _useState2 = _slicedToArray(_useState, 2),
49
+ filterText = _useState2[0],
50
+ setFilterText = _useState2[1];
51
+ var onSearch = function onSearch(value) {
52
+ setFilterText(value);
53
+ };
54
+ var tableData = useMemo(function () {
55
+ if (!data) {
56
+ return [];
57
+ }
58
+ return data.filter(function (v) {
59
+ var _v$indicatorName, _v$indicatorIdentifie;
60
+ return !filterText || ((_v$indicatorName = v.indicatorName) === null || _v$indicatorName === void 0 ? void 0 : _v$indicatorName.toLocaleLowerCase().includes(filterText.toLocaleLowerCase())) || ((_v$indicatorIdentifie = v.indicatorIdentifier) === null || _v$indicatorIdentifie === void 0 ? void 0 : _v$indicatorIdentifie.toLocaleLowerCase().includes(filterText.toLocaleLowerCase()));
61
+ });
62
+ }, [data, filterText]);
63
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
64
+ className: "mb-4 flex justify-between items-center"
65
+ }, /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Search, {
66
+ size: "small",
67
+ placeholder: "\u641C\u7D22\u6307\u6807\u540D\u79F0\u6216\u6807\u8BC6\u7B26",
68
+ allowClear: true,
69
+ onSearch: onSearch,
70
+ style: {
71
+ width: 210
72
+ }
73
+ })), /*#__PURE__*/React.createElement(CloseOutlined, {
74
+ onClick: onClose,
75
+ className: "cursor-pointer"
76
+ })), /*#__PURE__*/React.createElement(Table, {
77
+ columns: columns,
78
+ dataSource: tableData,
79
+ size: "small",
80
+ rowKey: "indicatorIdentifier",
81
+ loading: loading,
82
+ rowClassName: styles.row,
83
+ onRow: function onRow(record) {
84
+ return {
85
+ onClick: function onClick() {
86
+ _onChange(record);
87
+ }
88
+ };
89
+ },
90
+ pagination: false,
91
+ scroll: {
92
+ y: 340
93
+ },
94
+ rowSelection: {
95
+ type: 'radio',
96
+ getCheckboxProps: function getCheckboxProps(record) {
97
+ return {
98
+ name: "".concat(record.indicatorId),
99
+ disabled: false
100
+ };
101
+ },
102
+ selectedRowKeys: indicatorId ? [indicatorId] : [],
103
+ onChange: function onChange(selectedRowKeys, _ref2) {
104
+ var _ref3 = _slicedToArray(_ref2, 1),
105
+ selectedRow = _ref3[0];
106
+ _onChange(selectedRow);
107
+ }
108
+ }
109
+ }));
110
+ };
111
+ export default DeviceIndicatorTable;