@zgfe/modules-settings 2.0.0-zhongyuan.2 → 2.0.0-zhongyuan.20

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.
@@ -14,6 +14,8 @@ declare let apis: {
14
14
  editVirtualSourceApp: string;
15
15
  };
16
16
  setting: {
17
+ queryRealTimeData: string;
18
+ updateStatus: string;
17
19
  updateCompanyName: string;
18
20
  updateLicense: string;
19
21
  groupInfos: string;
@@ -16,6 +16,8 @@ var apis = {
16
16
  editVirtualSourceApp: '/user/editSourceApp.jsp' // 修改虚拟应用的来源应用配置
17
17
  },
18
18
  setting: {
19
+ queryRealTimeData: '/zg/web/v2/newapp/delay',
20
+ updateStatus: '/zg/web/v2/newapp/status',
19
21
  updateCompanyName: '/company/v2updateInfo.jsp',
20
22
  updateLicense: apiPrefix + '/system/license',
21
23
  groupInfos: '/auth/groupInfos.jsp',
@@ -7,6 +7,19 @@ export interface ApplicationItem {
7
7
  appVersion: number;
8
8
  appVersionName: string;
9
9
  platform: number[];
10
+ children?: ApplicationListChildren[];
11
+ status?: number;
12
+ joinDatabaseDelay: string;
13
+ realTimeDelay: string;
14
+ startTime: string;
15
+ stopTime: string;
16
+ }
17
+ export interface ApplicationListChildren {
18
+ label: string;
19
+ key: 'appVersionName' | 'name' | 'platform' | 'status' | 'realTimeDelay' | 'joinDatabaseDelay' | 'startTime' | 'stopTime';
20
+ type: string;
21
+ style?: any;
22
+ list?: number[];
10
23
  }
11
24
  declare const Application: React.FC<{
12
25
  companyId: number;
@@ -16,9 +16,8 @@ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
16
16
  import React, { useEffect, useState, useRef, useContext } from 'react';
17
17
  import request from '../../../utils/ajax';
18
18
  import apis from '../../../constants/api';
19
- import { notification, Tooltip, Modal, Row, Col, Drawer, Button, Divider, message } from 'antd';
20
- import Card from '../../../components/card';
21
- import { BizGlobalDataContext, BizLoading, IconFont } from '@zgfe/business-lib';
19
+ import { notification, Tooltip, Modal, Drawer, Button, Divider, message, Table, Spin } from 'antd';
20
+ import { BizGlobalDataContext, IconFont } from '@zgfe/business-lib';
22
21
  import ApplicationForm from './applicationForm';
23
22
  import './index.less';
24
23
  import ApplicationSetting from './applicationSetting';
@@ -63,9 +62,131 @@ var Application = function Application(_ref) {
63
62
  setLoading = _useState8[1];
64
63
  var formRef = useRef();
65
64
  var settingRef = useRef();
65
+ var columns = [{
66
+ title: '应用名称',
67
+ dataIndex: 'name',
68
+ width: 220,
69
+ ellipsis: true,
70
+ render: function render(data) {
71
+ return /*#__PURE__*/React.createElement(Tooltip, {
72
+ title: data,
73
+ placement: "top"
74
+ }, /*#__PURE__*/React.createElement("span", {
75
+ className: "".concat(classPrefix, "-contentList-item-name")
76
+ }, data));
77
+ }
78
+ }, {
79
+ title: '应用Id',
80
+ dataIndex: 'appId',
81
+ ellipsis: true,
82
+ width: 120,
83
+ render: function render(data) {
84
+ return data || '-';
85
+ }
86
+ }, {
87
+ title: '入库数据延迟',
88
+ dataIndex: 'joinDatabaseDelay',
89
+ ellipsis: true,
90
+ width: 150,
91
+ render: function render(data) {
92
+ return data || '-';
93
+ }
94
+ }, {
95
+ title: '接入平台',
96
+ dataIndex: 'platform',
97
+ withh: 110,
98
+ render: function render(data) {
99
+ return data && (data === null || data === void 0 ? void 0 : data.length) > 0 ? data === null || data === void 0 ? void 0 : data.map(function (plat) {
100
+ return /*#__PURE__*/React.createElement(Tooltip, {
101
+ title: getPlatText(plat),
102
+ placement: "top"
103
+ }, /*#__PURE__*/React.createElement("span", {
104
+ key: plat,
105
+ className: "icon-".concat(getPlatIcon(plat))
106
+ }));
107
+ }) : '未接入平台';
108
+ }
109
+ }, {
110
+ title: '版本',
111
+ dataIndex: 'appVersionName',
112
+ width: 100
113
+ }, {
114
+ title: '状态切换时间',
115
+ dataIndex: 'stopTime',
116
+ ellipsis: true,
117
+ width: 170,
118
+ render: function render(data) {
119
+ return data || '-';
120
+ }
121
+ }, {
122
+ title: '状态',
123
+ dataIndex: 'status',
124
+ width: 100,
125
+ render: function render(data) {
126
+ return /*#__PURE__*/React.createElement("span", {
127
+ className: "".concat(classPrefix, "-contentList-item-status")
128
+ }, /*#__PURE__*/React.createElement("span", {
129
+ className: "".concat(classPrefix, "-contentList-item-status-icon").concat(data || 0)
130
+ }), data ? '运行中' : '关闭');
131
+ }
132
+ }, {
133
+ title: '操作',
134
+ dataIndex: 'operation',
135
+ width: 300,
136
+ render: function render(text, record) {
137
+ return /*#__PURE__*/React.createElement("div", {
138
+ className: "".concat(classPrefix, "-contentList-btn")
139
+ }, /*#__PURE__*/React.createElement(Button, {
140
+ type: "link",
141
+ style: {
142
+ padding: '0 10px'
143
+ },
144
+ disabled: !authority[1716284934],
145
+ onClick: function onClick() {
146
+ return authority[1716284934] && landleStatusClick(record);
147
+ }
148
+ }, record.status ? '关闭' : '开启'), /*#__PURE__*/React.createElement(Button, {
149
+ type: "link",
150
+ style: {
151
+ padding: '0 10px'
152
+ },
153
+ disabled: !authority[1716284360],
154
+ onClick: function onClick() {
155
+ return authority[1716284360] && handleEditClick(record);
156
+ }
157
+ }, "\u4FEE\u6539\u540D\u79F0"), /*#__PURE__*/React.createElement(Button, {
158
+ type: "link",
159
+ style: {
160
+ padding: '0 10px'
161
+ },
162
+ disabled: !authority[10101],
163
+ onClick: function onClick() {
164
+ return authority[10101] && handleDeleteClick(record);
165
+ }
166
+ }, "\u5220\u9664"), !isOpen && (/*#__PURE__*/React.createElement(Button, {
167
+ type: "link",
168
+ style: {
169
+ padding: '0 10px'
170
+ },
171
+ disabled: !authority[1716285396],
172
+ onClick: function onClick() {
173
+ return authority[1716285396] && handleSettingClick(record);
174
+ }
175
+ }, "\u8BBE\u7F6E")), isOpen && (/*#__PURE__*/React.createElement(Button, {
176
+ type: "link",
177
+ style: {
178
+ padding: '0 10px'
179
+ },
180
+ disabled: !authority[1716284934],
181
+ onClick: function onClick() {
182
+ return authority[1716284934] && openMainPart && openMainPart(record.id, record.name);
183
+ }
184
+ }, "\u4E3B\u4F53\u7BA1\u7406")));
185
+ }
186
+ }];
66
187
  var handleQueryList = /*#__PURE__*/function () {
67
188
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
68
- var _res$data, _res$data2, _res$data4, _res$data5, res, _res$data3;
189
+ var _res$data, _res$data2, _res$data4, _res$data5, _res$data6, res, _res$data3;
69
190
  return _regeneratorRuntime().wrap(function _callee$(_context) {
70
191
  while (1) switch (_context.prev = _context.next) {
71
192
  case 0:
@@ -98,20 +219,22 @@ var Application = function Application(_ref) {
98
219
  if (!(res === null || res === void 0 ? void 0 : (_res$data5 = res.data) === null || _res$data5 === void 0 ? void 0 : _res$data5.list)) {
99
220
  handleAddClick();
100
221
  }
101
- _context.next = 17;
222
+ //对实时渲染数据进行处理
223
+ getRealTimeData((res === null || res === void 0 ? void 0 : (_res$data6 = res.data) === null || _res$data6 === void 0 ? void 0 : _res$data6.list) || []);
224
+ _context.next = 18;
102
225
  break;
103
- case 13:
104
- _context.prev = 13;
226
+ case 14:
227
+ _context.prev = 14;
105
228
  _context.t0 = _context["catch"](1);
106
229
  setLoading(false);
107
230
  notification.error({
108
231
  message: _context.t0
109
232
  });
110
- case 17:
233
+ case 18:
111
234
  case "end":
112
235
  return _context.stop();
113
236
  }
114
- }, _callee, null, [[1, 13]]);
237
+ }, _callee, null, [[1, 14]]);
115
238
  }));
116
239
  return function handleQueryList() {
117
240
  return _ref2.apply(this, arguments);
@@ -120,52 +243,6 @@ var Application = function Application(_ref) {
120
243
  useEffect(function () {
121
244
  handleQueryList();
122
245
  }, []);
123
- var btnNodes = function btnNodes() {
124
- var array = [{
125
- Element: function Element(props) {
126
- return /*#__PURE__*/React.createElement(Tooltip, {
127
- title: "\u7F16\u8F91",
128
- placement: "top"
129
- }, /*#__PURE__*/React.createElement("span", _objectSpread({}, props)));
130
- },
131
- options: {
132
- className: "zhuge icon-bianji2 ".concat(!authority[1716284360] ? classPrefix + '-disabled' : ''),
133
- onClick: function onClick(props) {
134
- return authority[1716284360] && handleEditClick(props);
135
- }
136
- }
137
- }, {
138
- Element: function Element(props) {
139
- return /*#__PURE__*/React.createElement(Tooltip, {
140
- title: "\u5220\u9664",
141
- placement: "top"
142
- }, /*#__PURE__*/React.createElement("span", _objectSpread({}, props)));
143
- },
144
- options: {
145
- className: "zhuge icon-shanchu ".concat(!authority[10101] ? classPrefix + '-disabled' : ''),
146
- onClick: function onClick(props) {
147
- return authority[10101] && handleDeleteClick(props);
148
- }
149
- }
150
- }];
151
- if (!isOpen) {
152
- return [{
153
- Element: function Element(props) {
154
- return /*#__PURE__*/React.createElement(Tooltip, {
155
- title: "\u8BBE\u7F6E",
156
- placement: "top"
157
- }, /*#__PURE__*/React.createElement("span", _objectSpread({}, props)));
158
- },
159
- options: {
160
- className: "zhuge icon-shezhi ".concat(!authority[1716285396] ? classPrefix + '-disabled' : ''),
161
- onClick: function onClick(props) {
162
- return authority[1716285396] && handleSettingClick(props);
163
- }
164
- }
165
- }].concat(array);
166
- }
167
- return array;
168
- };
169
246
  var handleAddClick = /*#__PURE__*/function () {
170
247
  var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
171
248
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
@@ -177,7 +254,7 @@ var Application = function Application(_ref) {
177
254
  onCancel: function onCancel() {},
178
255
  onOk: function () {
179
256
  var _onOk = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
180
- var _formRef$current, _formRef$current2, _res$data6, data, res;
257
+ var _formRef$current, _formRef$current2, _res$data7, data, res;
181
258
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
182
259
  while (1) switch (_context2.prev = _context2.next) {
183
260
  case 0:
@@ -207,7 +284,7 @@ var Application = function Application(_ref) {
207
284
  message.success('创建成功');
208
285
  handleQueryList();
209
286
  settingCallback && settingCallback('settingAddApplicationCallback', {
210
- id: res === null || res === void 0 ? void 0 : (_res$data6 = res.data) === null || _res$data6 === void 0 ? void 0 : _res$data6.appId
287
+ id: res === null || res === void 0 ? void 0 : (_res$data7 = res.data) === null || _res$data7 === void 0 ? void 0 : _res$data7.appId
211
288
  });
212
289
  _context2.next = 19;
213
290
  break;
@@ -248,7 +325,7 @@ var Application = function Application(_ref) {
248
325
  while (1) switch (_context5.prev = _context5.next) {
249
326
  case 0:
250
327
  Modal.confirm(_objectSpread(_objectSpread({}, modalConfig), {}, {
251
- title: '编辑应用',
328
+ title: '修改名称',
252
329
  icon: null,
253
330
  onCancel: function onCancel() {},
254
331
  onOk: function () {
@@ -319,8 +396,8 @@ var Application = function Application(_ref) {
319
396
  // 主体开关关闭时,设置的是默认主体
320
397
  var handleSettingClick = /*#__PURE__*/function () {
321
398
  var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(record) {
322
- var _res$data7, _res$data8, _res$data8$results;
323
- var res, _res$data9, mainPart;
399
+ var _res$data8, _res$data9, _res$data9$results;
400
+ var res, _res$data10, mainPart;
324
401
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
325
402
  while (1) switch (_context6.prev = _context6.next) {
326
403
  case 0:
@@ -334,8 +411,8 @@ var Application = function Application(_ref) {
334
411
  });
335
412
  case 2:
336
413
  res = _context6.sent;
337
- if ((res === null || res === void 0 ? void 0 : (_res$data7 = res.data) === null || _res$data7 === void 0 ? void 0 : _res$data7.results) && (res === null || res === void 0 ? void 0 : (_res$data8 = res.data) === null || _res$data8 === void 0 ? void 0 : (_res$data8$results = _res$data8.results) === null || _res$data8$results === void 0 ? void 0 : _res$data8$results.length) > 0) {
338
- mainPart = res === null || res === void 0 ? void 0 : (_res$data9 = res.data) === null || _res$data9 === void 0 ? void 0 : _res$data9.results[0];
414
+ if ((res === null || res === void 0 ? void 0 : (_res$data8 = res.data) === null || _res$data8 === void 0 ? void 0 : _res$data8.results) && (res === null || res === void 0 ? void 0 : (_res$data9 = res.data) === null || _res$data9 === void 0 ? void 0 : (_res$data9$results = _res$data9.results) === null || _res$data9$results === void 0 ? void 0 : _res$data9$results.length) > 0) {
415
+ mainPart = res === null || res === void 0 ? void 0 : (_res$data10 = res.data) === null || _res$data10 === void 0 ? void 0 : _res$data10.results[0];
339
416
  setProfile(mainPart);
340
417
  setShowSetting(true);
341
418
  }
@@ -484,6 +561,126 @@ var Application = function Application(_ref) {
484
561
  return _ref7.apply(this, arguments);
485
562
  };
486
563
  }();
564
+ // 应用状态开关
565
+ // 0:关闭 1:开启
566
+ var landleStatusClick = /*#__PURE__*/function () {
567
+ var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(props) {
568
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
569
+ while (1) switch (_context11.prev = _context11.next) {
570
+ case 0:
571
+ Modal.confirm(_objectSpread(_objectSpread({}, modalConfig), {}, {
572
+ title: props.status ? '关闭应用' : '开启应用',
573
+ content: props.status ? '关闭应用后,应用将不再接收数据' : '开启应用后,应用将开始接收数据',
574
+ icon: null,
575
+ onCancel: function onCancel() {},
576
+ onOk: function () {
577
+ var _onOk4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
578
+ var res;
579
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
580
+ while (1) switch (_context10.prev = _context10.next) {
581
+ case 0:
582
+ _context10.prev = 0;
583
+ _context10.next = 3;
584
+ return request(apis.setting.updateStatus, {
585
+ method: 'post',
586
+ data: {
587
+ companyId: companyId,
588
+ projectId: props === null || props === void 0 ? void 0 : props.id,
589
+ status: props.status ? 0 : 1
590
+ },
591
+ intercept: false
592
+ });
593
+ case 3:
594
+ res = _context10.sent;
595
+ if (['101000', '100000'].includes(res === null || res === void 0 ? void 0 : res.code)) {
596
+ _context10.next = 7;
597
+ break;
598
+ }
599
+ message.error(res === null || res === void 0 ? void 0 : res.msg);
600
+ return _context10.abrupt("return", Promise.reject());
601
+ case 7:
602
+ message.success(props.status ? '关闭应用成功' : '开启应用成功');
603
+ handleQueryList();
604
+ _context10.next = 15;
605
+ break;
606
+ case 11:
607
+ _context10.prev = 11;
608
+ _context10.t0 = _context10["catch"](0);
609
+ console.log('catch', _context10.t0);
610
+ return _context10.abrupt("return", Promise.reject(_context10.t0));
611
+ case 15:
612
+ case "end":
613
+ return _context10.stop();
614
+ }
615
+ }, _callee10, null, [[0, 11]]);
616
+ }));
617
+ function onOk() {
618
+ return _onOk4.apply(this, arguments);
619
+ }
620
+ return onOk;
621
+ }()
622
+ }));
623
+ case 1:
624
+ case "end":
625
+ return _context11.stop();
626
+ }
627
+ }, _callee11);
628
+ }));
629
+ return function landleStatusClick(_x4) {
630
+ return _ref8.apply(this, arguments);
631
+ };
632
+ }();
633
+ // 获取实时渲染数据
634
+ var getRealTimeData = /*#__PURE__*/function () {
635
+ var _ref9 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(list) {
636
+ var res, newList;
637
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
638
+ while (1) switch (_context12.prev = _context12.next) {
639
+ case 0:
640
+ _context12.prev = 0;
641
+ _context12.next = 3;
642
+ return request(apis.setting.queryRealTimeData, {
643
+ method: 'get',
644
+ data: {}
645
+ });
646
+ case 3:
647
+ res = _context12.sent;
648
+ if (['101000', '100000'].includes(res === null || res === void 0 ? void 0 : res.code)) {
649
+ _context12.next = 6;
650
+ break;
651
+ }
652
+ return _context12.abrupt("return", Promise.reject());
653
+ case 6:
654
+ if (res === null || res === void 0 ? void 0 : res.data) {
655
+ newList = list.map(function (item) {
656
+ var obj = item;
657
+ //对相关数据进行合并
658
+ res.data.forEach(function (resItem) {
659
+ if (item.id === resItem.appId) {
660
+ obj = Object.assign(item, resItem);
661
+ return;
662
+ }
663
+ });
664
+ return obj;
665
+ });
666
+ setList(newList);
667
+ }
668
+ _context12.next = 12;
669
+ break;
670
+ case 9:
671
+ _context12.prev = 9;
672
+ _context12.t0 = _context12["catch"](0);
673
+ return _context12.abrupt("return", Promise.reject(_context12.t0));
674
+ case 12:
675
+ case "end":
676
+ return _context12.stop();
677
+ }
678
+ }, _callee12, null, [[0, 9]]);
679
+ }));
680
+ return function getRealTimeData(_x5) {
681
+ return _ref9.apply(this, arguments);
682
+ };
683
+ }();
487
684
  return /*#__PURE__*/React.createElement("div", {
488
685
  className: "".concat(classPrefix)
489
686
  }, /*#__PURE__*/React.createElement("div", {
@@ -500,42 +697,17 @@ var Application = function Application(_ref) {
500
697
  type: "primary",
501
698
  size: "small",
502
699
  onClick: handleAddClick
503
- }, "\u521B\u5EFA\u5E94\u7528")), /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(Row, {
504
- gutter: [16, 16]
505
- }, list.length > 0 && (list === null || list === void 0 ? void 0 : list.map(function (item) {
506
- var _item$platform2;
507
- var content = /*#__PURE__*/React.createElement("div", {
508
- className: "".concat(classPrefix, "-content")
509
- }, /*#__PURE__*/React.createElement("div", {
510
- className: "".concat(classPrefix, "-content-item")
511
- }, /*#__PURE__*/React.createElement("div", null, "\u7248\u672C\uFF1A", item.appVersionName), /*#__PURE__*/React.createElement("div", {
512
- className: "".concat(classPrefix, "-content-item-platform")
513
- }, "\u63A5\u5165\u5E73\u53F0\uFF1A", (item === null || item === void 0 ? void 0 : (_item$platform2 = item.platform) === null || _item$platform2 === void 0 ? void 0 : _item$platform2.length) > 0 ? item === null || item === void 0 ? void 0 : item.platform.map(function (item) {
514
- return /*#__PURE__*/React.createElement(Tooltip, {
515
- title: getPlatText(item),
516
- placement: "top"
517
- }, /*#__PURE__*/React.createElement("span", {
518
- key: item,
519
- className: "icon-".concat(getPlatIcon(item))
520
- }));
521
- }) : '未接入数据')), isOpen && (/*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, {
522
- style: {
523
- padding: '0 10px'
524
- },
525
- disabled: !authority[1716284934],
526
- onClick: function onClick() {
527
- return openMainPart && openMainPart(item.id, item.name);
528
- }
529
- }, "\u4E3B\u4F53\u7BA1\u7406"))));
530
- return /*#__PURE__*/React.createElement(Col, {
531
- key: item.id,
532
- span: 8
533
- }, /*#__PURE__*/React.createElement(Card, _objectSpread(_objectSpread({}, item), {}, {
534
- title: item.name,
535
- btnNodes: btnNodes(),
536
- content: content
537
- })));
538
- })), loading && /*#__PURE__*/React.createElement(BizLoading, null)), /*#__PURE__*/React.createElement(Drawer, {
700
+ }, "\u521B\u5EFA\u5E94\u7528")), /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(Spin, {
701
+ spinning: loading
702
+ }, /*#__PURE__*/React.createElement(Table, {
703
+ dataSource: list,
704
+ columns: columns,
705
+ pagination: false,
706
+ scroll: {
707
+ x: 1000,
708
+ y: 500
709
+ }
710
+ })), /*#__PURE__*/React.createElement(Drawer, {
539
711
  className: "".concat(classPrefix, "-drawer"),
540
712
  open: showSetting,
541
713
  closable: true,