aldehyde 0.2.284 → 0.2.285

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 (104) hide show
  1. package/lib/controls/entry-control.d.ts.map +1 -1
  2. package/lib/controls/entry-control.js +4 -0
  3. package/lib/controls/entry-control.js.map +1 -1
  4. package/lib/controls/select/index.d.ts.map +1 -1
  5. package/lib/controls/select/index.js +1 -0
  6. package/lib/controls/select/index.js.map +1 -1
  7. package/lib/controls/view-control.d.ts.map +1 -1
  8. package/lib/controls/view-control.js +1 -0
  9. package/lib/controls/view-control.js.map +1 -1
  10. package/lib/detail/view/act-dtmpl-view.d.ts.map +1 -1
  11. package/lib/detail/view/act-dtmpl-view.js +3 -2
  12. package/lib/detail/view/act-dtmpl-view.js.map +1 -1
  13. package/lib/lowcode-components/bar-chart/index.d.ts +10 -6
  14. package/lib/lowcode-components/bar-chart/index.d.ts.map +1 -1
  15. package/lib/lowcode-components/bar-chart/index.js +91 -11
  16. package/lib/lowcode-components/bar-chart/index.js.map +1 -1
  17. package/lib/lowcode-components/base-map/index.d.ts +10 -6
  18. package/lib/lowcode-components/base-map/index.d.ts.map +1 -1
  19. package/lib/lowcode-components/base-map/index.js +86 -7
  20. package/lib/lowcode-components/base-map/index.js.map +1 -1
  21. package/lib/lowcode-components/base-table/index.d.ts +53 -0
  22. package/lib/lowcode-components/base-table/index.d.ts.map +1 -0
  23. package/lib/lowcode-components/base-table/index.js +158 -0
  24. package/lib/lowcode-components/base-table/index.js.map +1 -0
  25. package/lib/lowcode-components/base-table/index.less +59 -0
  26. package/lib/lowcode-components/capsule-bar-chart/index.d.ts +43 -0
  27. package/lib/lowcode-components/capsule-bar-chart/index.d.ts.map +1 -0
  28. package/lib/lowcode-components/capsule-bar-chart/index.js +179 -0
  29. package/lib/lowcode-components/capsule-bar-chart/index.js.map +1 -0
  30. package/lib/lowcode-components/circular-progress-chart/index.d.ts +26 -0
  31. package/lib/lowcode-components/circular-progress-chart/index.d.ts.map +1 -0
  32. package/lib/lowcode-components/circular-progress-chart/index.js +179 -0
  33. package/lib/lowcode-components/circular-progress-chart/index.js.map +1 -0
  34. package/lib/lowcode-components/column-chart/index.d.ts +11 -6
  35. package/lib/lowcode-components/column-chart/index.d.ts.map +1 -1
  36. package/lib/lowcode-components/column-chart/index.js +115 -16
  37. package/lib/lowcode-components/column-chart/index.js.map +1 -1
  38. package/lib/lowcode-components/data-number/index.d.ts +10 -0
  39. package/lib/lowcode-components/data-number/index.d.ts.map +1 -1
  40. package/lib/lowcode-components/data-number/index.js +80 -6
  41. package/lib/lowcode-components/data-number/index.js.map +1 -1
  42. package/lib/lowcode-components/effectScatter-map/index.d.ts +10 -6
  43. package/lib/lowcode-components/effectScatter-map/index.d.ts.map +1 -1
  44. package/lib/lowcode-components/effectScatter-map/index.js +87 -9
  45. package/lib/lowcode-components/effectScatter-map/index.js.map +1 -1
  46. package/lib/lowcode-components/gauge-chart/index.d.ts +10 -6
  47. package/lib/lowcode-components/gauge-chart/index.d.ts.map +1 -1
  48. package/lib/lowcode-components/gauge-chart/index.js +65 -8
  49. package/lib/lowcode-components/gauge-chart/index.js.map +1 -1
  50. package/lib/lowcode-components/index.d.ts +8 -0
  51. package/lib/lowcode-components/index.d.ts.map +1 -1
  52. package/lib/lowcode-components/index.js +6 -1
  53. package/lib/lowcode-components/index.js.map +1 -1
  54. package/lib/lowcode-components/line-chart/index.d.ts +10 -6
  55. package/lib/lowcode-components/line-chart/index.d.ts.map +1 -1
  56. package/lib/lowcode-components/line-chart/index.js +91 -11
  57. package/lib/lowcode-components/line-chart/index.js.map +1 -1
  58. package/lib/lowcode-components/liquid-chart/index.d.ts +10 -6
  59. package/lib/lowcode-components/liquid-chart/index.d.ts.map +1 -1
  60. package/lib/lowcode-components/liquid-chart/index.js +64 -7
  61. package/lib/lowcode-components/liquid-chart/index.js.map +1 -1
  62. package/lib/lowcode-components/lowcode-view/component/assets.d.ts.map +1 -1
  63. package/lib/lowcode-components/lowcode-view/component/assets.js +46 -0
  64. package/lib/lowcode-components/lowcode-view/component/assets.js.map +1 -1
  65. package/lib/lowcode-components/lowcode-view/component/component-container.d.ts.map +1 -1
  66. package/lib/lowcode-components/lowcode-view/component/component-container.js +30 -29
  67. package/lib/lowcode-components/lowcode-view/component/component-container.js.map +1 -1
  68. package/lib/lowcode-components/pie-chart/index.d.ts +11 -6
  69. package/lib/lowcode-components/pie-chart/index.d.ts.map +1 -1
  70. package/lib/lowcode-components/pie-chart/index.js +102 -15
  71. package/lib/lowcode-components/pie-chart/index.js.map +1 -1
  72. package/lib/lowcode-components/text-scroller/index.d.ts +23 -0
  73. package/lib/lowcode-components/text-scroller/index.d.ts.map +1 -0
  74. package/lib/lowcode-components/text-scroller/index.js +96 -0
  75. package/lib/lowcode-components/text-scroller/index.js.map +1 -0
  76. package/lib/lowcode-components/text-scroller/index.less +29 -0
  77. package/lib/tmpl/control-type-supportor.d.ts.map +1 -1
  78. package/lib/tmpl/control-type-supportor.js +1 -0
  79. package/lib/tmpl/control-type-supportor.js.map +1 -1
  80. package/package.json +1 -1
  81. package/src/aldehyde/controls/entry-control.tsx +12 -0
  82. package/src/aldehyde/controls/select/index.tsx +1 -0
  83. package/src/aldehyde/controls/view-control.tsx +1 -0
  84. package/src/aldehyde/detail/view/act-dtmpl-view.tsx +22 -23
  85. package/src/aldehyde/lowcode-components/bar-chart/index.tsx +100 -19
  86. package/src/aldehyde/lowcode-components/base-map/index.tsx +94 -15
  87. package/src/aldehyde/lowcode-components/base-table/index.less +59 -0
  88. package/src/aldehyde/lowcode-components/base-table/index.tsx +233 -0
  89. package/src/aldehyde/lowcode-components/capsule-bar-chart/index.tsx +219 -0
  90. package/src/aldehyde/lowcode-components/circular-progress-chart/index.tsx +201 -0
  91. package/src/aldehyde/lowcode-components/column-chart/index.tsx +128 -24
  92. package/src/aldehyde/lowcode-components/data-number/index.tsx +89 -7
  93. package/src/aldehyde/lowcode-components/data.d.ts +6 -0
  94. package/src/aldehyde/lowcode-components/effectScatter-map/index.tsx +93 -19
  95. package/src/aldehyde/lowcode-components/gauge-chart/index.tsx +73 -16
  96. package/src/aldehyde/lowcode-components/index.ts +10 -1
  97. package/src/aldehyde/lowcode-components/line-chart/index.tsx +105 -22
  98. package/src/aldehyde/lowcode-components/liquid-chart/index.tsx +70 -15
  99. package/src/aldehyde/lowcode-components/lowcode-view/component/assets.ts +46 -0
  100. package/src/aldehyde/lowcode-components/lowcode-view/component/component-container.tsx +29 -28
  101. package/src/aldehyde/lowcode-components/pie-chart/index.tsx +111 -25
  102. package/src/aldehyde/lowcode-components/text-scroller/index.less +29 -0
  103. package/src/aldehyde/lowcode-components/text-scroller/index.tsx +122 -0
  104. package/src/aldehyde/tmpl/control-type-supportor.tsx +1 -0
@@ -1,6 +1,8 @@
1
1
  import * as echarts from 'echarts';
2
2
  import React, { useEffect, useRef, useState, ForwardedRef, forwardRef, useImperativeHandle } from 'react';
3
3
  import _ from 'lodash';
4
+ import HydrocarbonService from "../../tmpl/hcservice-v3";
5
+ import { DataConfigProps } from "../data";
4
6
 
5
7
  const defOption = {
6
8
  tooltip: {
@@ -13,13 +15,13 @@ const defOption = {
13
15
  progress: { show: true },
14
16
  radius: "75%",
15
17
  data: [
16
- { value: 50, }
18
+ { value: 50 }
17
19
  ]
18
20
  }
19
21
  ],
20
22
  };
21
23
 
22
- export interface ChartComponentStyle {
24
+ export interface ComponentStyle {
23
25
  tooltip?: { show: boolean };
24
26
  radius?: number;
25
27
  startAngle?: number;
@@ -35,27 +37,42 @@ export interface ChartComponentStyle {
35
37
  center?: { x: number, y: number };
36
38
  }
37
39
 
38
- export interface ChartComponentProps {
39
- style?: ChartComponentStyle;
40
- base: { width: number, height: number }
40
+ export interface ComponentProps {
41
+ style?: ComponentStyle;
42
+ base: { width: number, height: number },
43
+ data?: DataConfigProps;
44
+ isDesignMode?: boolean; // 是否编辑模式
41
45
  }
42
46
 
43
- export interface ChartComponentRef {
44
- updateConfig: (newConfig: ChartComponentProps) => void;
47
+ export interface ComponentRef {
48
+ updateConfig: (newConfig: ComponentProps) => void;
49
+ destroy: () => void;
45
50
  }
46
51
 
47
- const Index = forwardRef((props: ChartComponentProps, ref: ForwardedRef<ChartComponentRef>) => {
48
- const [config, setConfig] = useState<ChartComponentStyle>(props.style || {});
49
- const [size, setSize] = useState<{ width: number, height: number }>()
52
+ const Index = forwardRef((props: ComponentProps, ref: ForwardedRef<ComponentRef>) => {
53
+ const { style, data: propsData, isDesignMode } = props;
54
+ const [config, setConfig] = useState<ComponentStyle>(style || {});
55
+ const [size, setSize] = useState<{ width: number, height: number }>();
56
+ const [dataConfig, setDataConfig] = useState<DataConfigProps>({ ...propsData }); // 数据源配置
57
+ const [data, setData] = useState<number>(0);
50
58
  const chartRef = useRef<HTMLDivElement>(null);
51
59
  const chart = useRef<any>(null);
60
+ const pollingIntervalRef = useRef<number | NodeJS.Timeout>(null);
61
+
62
+ const handleDestroy = () => {
63
+ pollingIntervalRef.current && clearInterval(pollingIntervalRef.current);
64
+ window.removeEventListener('resize', handleResize);
65
+ chart.current.dispose();
66
+ };
52
67
 
53
68
  useImperativeHandle(ref, () => ({
54
69
  updateConfig: (newConfig) => {
55
- const { base, style } = newConfig;
56
- setConfig({ ...(style || {}) });
70
+ const { base, style: newStyle, data: newDataConfig } = newConfig;
71
+ setConfig({ ...(newStyle || {}) });
57
72
  setSize({ width: base.width, height: base.height });
73
+ setDataConfig(newDataConfig);
58
74
  },
75
+ destroy: handleDestroy,
59
76
  }));
60
77
 
61
78
  // 窗口大小变化时重新调整图表大小
@@ -67,16 +84,55 @@ const Index = forwardRef((props: ChartComponentProps, ref: ForwardedRef<ChartCom
67
84
  chart.current = echarts.init(chartRef.current);
68
85
  window.addEventListener('resize', handleResize);
69
86
  return () => {
70
- window.removeEventListener('resize', handleResize);
71
- chart.current.dispose();
87
+ handleDestroy();
72
88
  }
73
89
  }, []);
74
90
 
91
+
92
+ // 请求数据
93
+ const getData = async () => {
94
+ const { entities: { config, value } } = await HydrocarbonService.requestMstrucLtmplQueryTop(null, dataConfig?.sourceId, null) || {};
95
+ const temData = value?.[0]?.value?.[0]?.v1;
96
+ setData(temData);
97
+ return config;
98
+ };
99
+
100
+ // 初始化请求数据
101
+ const getInitData = async () => {
102
+ pollingIntervalRef.current && clearInterval(pollingIntervalRef.current);
103
+ const config = await getData();
104
+ if (config?.requestType === "polling") {
105
+ pollingIntervalRef.current = setInterval(() => { getData() }, config?.pollingInterval || 60000);
106
+ }
107
+ };
108
+
109
+ // 静态数据处理
110
+ useEffect(() => {
111
+ if (dataConfig?.sourceType === 'staticData') {
112
+ const { value } = dataConfig.staticData || {};
113
+ setData(value);
114
+ }
115
+ }, [dataConfig?.sourceType, dataConfig?.staticData]);
116
+
117
+ /**
118
+ * 数据源数据请求
119
+ * 1、编辑态不请求数据
120
+ */
121
+ useEffect(() => {
122
+ if (!isDesignMode && dataConfig?.sourceType === 'sourceId' && dataConfig?.sourceId) {
123
+ getInitData();
124
+ } else if (dataConfig?.sourceType === 'sourceId') {
125
+ setData(0);
126
+ }
127
+ }, [dataConfig?.sourceType, dataConfig?.sourceId]);
128
+
75
129
  const renderChart = () => {
76
130
  const { tooltip, radius, startAngle, endAngle, min, max, axisLine, splitLine, axisTick, axisLabel, detail, progress, center } = config;
77
131
  const temAxisLine = { ...axisLine, lineStyle: { ...axisLine?.lineStyle, color: axisLine?.lineStyle?.color?.map(r => ([r.percentage, r.color])) } };
78
132
  const option = _.cloneDeep(defOption);
79
133
  option.tooltip = { trigger: "item", ...tooltip };
134
+ // 编辑态数据源类型显示默认数据50
135
+ const temData = isDesignMode && dataConfig?.sourceType === 'sourceId' ? 50 : (data || 0);
80
136
  option.series = option.series.map((r) => ({
81
137
  ...r,
82
138
  pointer: {
@@ -95,7 +151,8 @@ const Index = forwardRef((props: ChartComponentProps, ref: ForwardedRef<ChartCom
95
151
  splitLine,
96
152
  axisTick,
97
153
  axisLabel,
98
- detail
154
+ detail,
155
+ data: [{ value: temData }]
99
156
  }));
100
157
  chart.current.setOption(option, true);
101
158
  }
@@ -103,7 +160,7 @@ const Index = forwardRef((props: ChartComponentProps, ref: ForwardedRef<ChartCom
103
160
  if (config) {
104
161
  renderChart();
105
162
  }
106
- }, [config]);
163
+ }, [config, data]);
107
164
 
108
165
  useEffect(() => {
109
166
  if (size) {
@@ -36,6 +36,10 @@ import Decoration8 from "./decoration/decoration8";
36
36
  import Decoration9 from "./decoration/decoration9";
37
37
  import Decoration10 from "./decoration/decoration10";
38
38
  import Decoration11 from "./decoration/decoration11";
39
+ import BaseTable from "./base-table";
40
+ import TextScroller from "./text-scroller";
41
+ import CapsuleBarChart from "./capsule-bar-chart";
42
+ import CircularProgressChart from "./circular-progress-chart";
39
43
 
40
44
 
41
45
  type CompoundedComponent = {
@@ -77,6 +81,10 @@ type CompoundedComponent = {
77
81
  Decoration9?: typeof Decoration9;
78
82
  Decoration10?: typeof Decoration10;
79
83
  Decoration11?: typeof Decoration11;
84
+ BaseTable?: typeof BaseTable;
85
+ TextScroller?: typeof TextScroller;
86
+ CapsuleBarChart?: typeof CapsuleBarChart;
87
+ CircularProgressChart?: typeof CircularProgressChart
80
88
  };
81
89
 
82
90
  const LowcodeComponents: CompoundedComponent = {
@@ -86,7 +94,8 @@ const LowcodeComponents: CompoundedComponent = {
86
94
  Border1, Border2, Border3, Border4, Border5, Border6,
87
95
  Border7, Border8, Border9, Border10, Border11, Border12, Border13,
88
96
  Decoration1, Decoration2, Decoration3, Decoration4, Decoration5,
89
- Decoration6, Decoration7, Decoration8, Decoration9, Decoration10, Decoration11
97
+ Decoration6, Decoration7, Decoration8, Decoration9, Decoration10, Decoration11,
98
+ BaseTable, TextScroller, CapsuleBarChart, CircularProgressChart
90
99
  };
91
100
 
92
101
  export default LowcodeComponents;
@@ -1,15 +1,23 @@
1
1
  import * as echarts from 'echarts';
2
2
  import React, { useEffect, useRef, useState, ForwardedRef, forwardRef, useImperativeHandle } from 'react';
3
- import lodash from 'lodash';
3
+ import _ from 'lodash';
4
+ import HydrocarbonService from "../../tmpl/hcservice-v3";
5
+ import { DataConfigProps } from "../data";
6
+
4
7
 
5
8
  const defOption = {
9
+ title: {
10
+ text: '暂无数据',
11
+ left: 'center',
12
+ top: 'middle',
13
+ show: false, // 无数据时显示
14
+ },
6
15
  tooltip: { trigger: "axis" },
7
16
  grid: { top: 30, let: 30, right: 20, bottom: 30 },
8
17
  xAxis: {
9
18
  type: 'category',
10
19
  boundaryGap: true,
11
20
  axisTick: { show: true },
12
- data: ['1990', '1991', '1992', '1993', '1994', '1995', '1996'],
13
21
  },
14
22
  yAxis: {
15
23
  type: 'value'
@@ -17,7 +25,7 @@ const defOption = {
17
25
  legend: { show: false },
18
26
  series: [
19
27
  {
20
- data: [525, 459, 357, 414, 234, 250, 156],
28
+ data: [["1990", 525], ["1991", 459], ["1992", 357], ["1993", 414], ["1994", 234], ["1995", 250], ["1996", 156]],
21
29
  type: 'line',
22
30
  }
23
31
  ]
@@ -32,9 +40,28 @@ const legends = {
32
40
  rightTop: { right: 5 },
33
41
  leftBottom: { left: 5, bottom: 0 },
34
42
  rightBottom: { right: 5, bottom: 0 },
35
- }
43
+ };
44
+
45
+ // 处理数据格式
46
+ const handleData = (data: { config: { [key: string]: string }, value: { [key: string]: any }[] }[]) => {
47
+ if (!data?.length) {
48
+ return [];
49
+ }
50
+ const temData = data.map((r) => {
51
+ const { config, value } = r;
52
+ const vNames = Object.keys(config).filter((r) => r.startsWith("v")).sort((a, b) => parseInt(a.substring(1)) - parseInt(b.substring(1)));
53
+ return {
54
+ name: config.d1,
55
+ data: vNames.map((r) => ({
56
+ name: config[r],
57
+ data: value.map((v) => [v["d1"], v[r]]),
58
+ }))
59
+ };
60
+ });
61
+ return temData[0]?.data || [];
62
+ };
36
63
 
37
- export interface ChartComponentStyle {
64
+ export interface ComponentStyle {
38
65
  tooltip?: { show: boolean };
39
66
  color?: string[];
40
67
  grid?: { top: number, let: number, right: number, bottom: number };
@@ -50,27 +77,42 @@ export interface ChartComponentStyle {
50
77
  areaStyle?: { opacity: number } // 面积图样式
51
78
  }
52
79
 
53
- export interface ChartComponentProps {
54
- style?: ChartComponentStyle;
55
- base: { width: number, height: number }
80
+ export interface ComponentProps {
81
+ style?: ComponentStyle;
82
+ base: { width: number, height: number },
83
+ data?: DataConfigProps;
84
+ isDesignMode?: boolean; // 是否编辑模式
56
85
  }
57
86
 
58
- export interface BaseTextComponentRef {
59
- updateConfig: (newConfig: ChartComponentProps) => void;
87
+ export interface ComponentRef {
88
+ updateConfig: (newConfig: ComponentProps) => void;
89
+ destroy: () => void;
60
90
  }
61
91
 
62
- const Index = forwardRef((props: ChartComponentProps, ref: ForwardedRef<BaseTextComponentRef>) => {
63
- const [config, setConfig] = useState<ChartComponentStyle>(props.style || {});
64
- const [size, setSize] = useState<{ width: number, height: number }>()
92
+ const Index = forwardRef((props: ComponentProps, ref: ForwardedRef<ComponentRef>) => {
93
+ const { style, data: propsData, isDesignMode } = props;
94
+ const [config, setConfig] = useState<ComponentStyle>(style || {});
95
+ const [size, setSize] = useState<{ width: number, height: number }>();
96
+ const [dataConfig, setDataConfig] = useState<DataConfigProps>({ ...propsData }); // 数据源配置
97
+ const [data, setData] = useState<{ name: string, data: any }[]>([]);
65
98
  const chartRef = useRef<HTMLDivElement>(null);
66
99
  const chart = useRef<any>(null);
100
+ const pollingIntervalRef = useRef<number | NodeJS.Timeout>(null);
101
+
102
+ const handleDestroy = () => {
103
+ pollingIntervalRef.current && clearInterval(pollingIntervalRef.current);
104
+ window.removeEventListener('resize', handleResize);
105
+ chart.current.dispose();
106
+ };
67
107
 
68
108
  useImperativeHandle(ref, () => ({
69
109
  updateConfig: (newConfig) => {
70
- const { base, style } = newConfig;
71
- setConfig({ ...(style || {}) });
110
+ const { base, style: newStyle, data: newDataConfig } = newConfig;
111
+ setConfig({ ...(newStyle || {}) });
72
112
  setSize({ width: base.width, height: base.height });
113
+ setDataConfig(newDataConfig);
73
114
  },
115
+ destroy: handleDestroy,
74
116
  }));
75
117
 
76
118
  // 窗口大小变化时重新调整图表大小
@@ -82,32 +124,73 @@ const Index = forwardRef((props: ChartComponentProps, ref: ForwardedRef<BaseText
82
124
  chart.current = echarts.init(chartRef.current);
83
125
  window.addEventListener('resize', handleResize);
84
126
  return () => {
85
- window.removeEventListener('resize', handleResize);
86
- chart.current.dispose();
127
+ handleDestroy();
87
128
  }
88
129
  }, []);
89
130
 
131
+ // 请求数据
132
+ const getData = async () => {
133
+ const { entities: { config, value } } = await HydrocarbonService.requestMstrucLtmplQueryTop(null, dataConfig?.sourceId, null) || {};
134
+ const temData = handleData(value);
135
+ setData(temData);
136
+ return config;
137
+ };
138
+
139
+ // 初始化请求数据
140
+ const getInitData = async () => {
141
+ pollingIntervalRef.current && clearInterval(pollingIntervalRef.current);
142
+ const config = await getData();
143
+ if (config?.requestType === "polling") {
144
+ pollingIntervalRef.current = setInterval(() => { getData() }, config?.pollingInterval || 60000);
145
+ }
146
+ };
147
+
148
+ // 静态数据处理
149
+ useEffect(() => {
150
+ if (dataConfig?.sourceType === 'staticData') {
151
+ setData(handleData(dataConfig.staticData));
152
+ }
153
+ }, [dataConfig?.sourceType, dataConfig?.staticData]);
154
+
155
+ /**
156
+ * 数据源数据请求
157
+ * 1、编辑态不请求数据
158
+ */
159
+ useEffect(() => {
160
+ if (!isDesignMode && dataConfig?.sourceType === 'sourceId' && dataConfig?.sourceId) {
161
+ getInitData();
162
+ } else if (dataConfig?.sourceType === 'sourceId') {
163
+ setData([]);
164
+ }
165
+ }, [dataConfig?.sourceType, dataConfig?.sourceId]);
166
+
90
167
  const renderChart = () => {
91
168
  const { grid, legend, tooltip, color, xAxis, yAxis, smooth, lineStyle, step, isArea, areaStyle, symbol: { itemStyle, ...symbol } } = config;
92
- const option = lodash.cloneDeep(defOption);
169
+ const option = _.cloneDeep(defOption);
170
+ // 编辑态无数据显示默认数据
171
+ const temData = isDesignMode && !data?.length ? option.series : data;
93
172
  option.grid = grid;
94
173
  option.legend = { ...legend, ...legends[legend?.position] };
95
174
  option.tooltip = { trigger: "axis", ...tooltip };
96
175
  option.xAxis = { ...option.xAxis, ...xAxis, axisTick: { show: xAxis?.axisLine?.show } };
97
176
  option.yAxis = { ...option.yAxis, ...yAxis };
98
- option.series = option.series.map((r, index) => ({
99
- ...r, ...symbol, step, smooth,
177
+ option.title.show = !temData?.length;
178
+ option.series = temData.map((r, index) => ({
179
+ type: "line",
180
+ ...r,
181
+ ...symbol, step, smooth,
100
182
  itemStyle: symbol.showSymbol ? { color: itemStyle.color[index] || color[index] } : undefined,
101
183
  lineStyle: { ...lineStyle, color: color[index] },
102
184
  areaStyle: isArea ? { ...areaStyle, color: color[index] } : undefined
103
185
  }));
104
186
  chart.current.setOption(option, true);
105
- }
187
+ };
188
+
106
189
  useEffect(() => {
107
190
  if (config) {
108
191
  renderChart();
109
192
  }
110
- }, [config]);
193
+ }, [config, data]);
111
194
 
112
195
  useEffect(() => {
113
196
  if (size) {
@@ -2,6 +2,8 @@ import * as echarts from 'echarts';
2
2
  import 'echarts-liquidfill';
3
3
  import React, { useEffect, useRef, useState, ForwardedRef, forwardRef, useImperativeHandle } from 'react';
4
4
  import _ from 'lodash';
5
+ import HydrocarbonService from "../../tmpl/hcservice-v3";
6
+ import { DataConfigProps } from "../data";
5
7
 
6
8
  const defColor = {
7
9
  type: 'linear',
@@ -39,7 +41,7 @@ const defOption = {
39
41
  ],
40
42
  };
41
43
 
42
- export interface ChartComponentStyle {
44
+ export interface ComponentStyle {
43
45
  tooltip?: { show: boolean };
44
46
  radius?: number;
45
47
  center?: { x: number, y: number };
@@ -51,27 +53,42 @@ export interface ChartComponentStyle {
51
53
  label?: { position: { x: number, y: number }, textStyle: { fontSize: number, color: string, }, [key: string]: any }
52
54
  }
53
55
 
54
- export interface ChartComponentProps {
55
- style?: ChartComponentStyle;
56
- base: { width: number, height: number }
56
+ export interface ComponentProps {
57
+ style?: ComponentStyle;
58
+ base: { width: number, height: number },
59
+ data?: DataConfigProps;
60
+ isDesignMode?: boolean; // 是否编辑模式
57
61
  }
58
62
 
59
- export interface ChartComponentRef {
60
- updateConfig: (newConfig: ChartComponentProps) => void;
63
+ export interface ComponentRef {
64
+ updateConfig: (newConfig: ComponentProps) => void;
65
+ destroy: () => void;
61
66
  }
62
67
 
63
- const Index = forwardRef((props: ChartComponentProps, ref: ForwardedRef<ChartComponentRef>) => {
64
- const [config, setConfig] = useState<ChartComponentStyle>(props.style || {});
65
- const [size, setSize] = useState<{ width: number, height: number }>()
68
+ const Index = forwardRef((props: ComponentProps, ref: ForwardedRef<ComponentRef>) => {
69
+ const { style, data: propsData, isDesignMode } = props;
70
+ const [config, setConfig] = useState<ComponentStyle>(style || {});
71
+ const [size, setSize] = useState<{ width: number, height: number }>();
72
+ const [dataConfig, setDataConfig] = useState<DataConfigProps>({ ...propsData }); // 数据源配置
73
+ const [data, setData] = useState<number>(0);
66
74
  const chartRef = useRef<HTMLDivElement>(null);
67
75
  const chart = useRef<any>(null);
76
+ const pollingIntervalRef = useRef<number | NodeJS.Timeout>(null);
77
+
78
+ const handleDestroy = () => {
79
+ pollingIntervalRef.current && clearInterval(pollingIntervalRef.current);
80
+ window.removeEventListener('resize', handleResize);
81
+ chart.current.dispose();
82
+ };
68
83
 
69
84
  useImperativeHandle(ref, () => ({
70
85
  updateConfig: (newConfig) => {
71
- const { base, style } = newConfig;
72
- setConfig({ ...(style || {}) });
86
+ const { base, style: newStyle, data: newDataConfig } = newConfig;
87
+ setConfig({ ...(newStyle || {}) });
73
88
  setSize({ width: base.width, height: base.height });
89
+ setDataConfig(newDataConfig);
74
90
  },
91
+ destroy: handleDestroy,
75
92
  }));
76
93
 
77
94
  // 窗口大小变化时重新调整图表大小
@@ -83,15 +100,53 @@ const Index = forwardRef((props: ChartComponentProps, ref: ForwardedRef<ChartCom
83
100
  chart.current = echarts.init(chartRef.current);
84
101
  window.addEventListener('resize', handleResize);
85
102
  return () => {
86
- window.removeEventListener('resize', handleResize);
87
- chart.current.dispose();
103
+ handleDestroy();
88
104
  }
89
105
  }, []);
90
106
 
107
+ // 请求数据
108
+ const getData = async () => {
109
+ const { entities: { config, value } } = await HydrocarbonService.requestMstrucLtmplQueryTop(null, dataConfig?.sourceId, null) || {};
110
+ const temData = value?.[0]?.value?.[0]?.v1;
111
+ setData(temData);
112
+ return config;
113
+ };
114
+
115
+ // 初始化请求数据
116
+ const getInitData = async () => {
117
+ pollingIntervalRef.current && clearInterval(pollingIntervalRef.current);
118
+ const config = await getData();
119
+ if (config?.requestType === "polling") {
120
+ pollingIntervalRef.current = setInterval(() => { getData() }, config?.pollingInterval || 60000);
121
+ }
122
+ };
123
+
124
+ // 静态数据处理
125
+ useEffect(() => {
126
+ if (dataConfig?.sourceType === 'staticData') {
127
+ const { value } = dataConfig.staticData || {};
128
+ setData(value);
129
+ }
130
+ }, [dataConfig?.sourceType, dataConfig?.staticData]);
131
+
132
+ /**
133
+ * 数据源数据请求
134
+ * 1、编辑态不请求数据
135
+ */
136
+ useEffect(() => {
137
+ if (!isDesignMode && dataConfig?.sourceType === 'sourceId' && dataConfig?.sourceId) {
138
+ getInitData();
139
+ } else if (dataConfig?.sourceType === 'sourceId') {
140
+ setData(0);
141
+ }
142
+ }, [dataConfig?.sourceType, dataConfig?.sourceId]);
143
+
91
144
  const renderChart = () => {
92
145
  const { tooltip, radius, center, shape, amplitude, dataNum, color, backgroundStyle, label } = config;
93
146
  const option = _.cloneDeep(defOption);
94
147
  option.tooltip = { trigger: "item", ...tooltip };
148
+ // 编辑态数据源类型显示默认数据0.5
149
+ const temData = isDesignMode && dataConfig?.sourceType === 'sourceId' ? 0.5 : (data || 0);
95
150
  option.series = option.series.map((r) => ({
96
151
  ...r,
97
152
  radius: `${radius}%`,
@@ -106,7 +161,7 @@ const Index = forwardRef((props: ChartComponentProps, ref: ForwardedRef<ChartCom
106
161
  }],
107
162
  backgroundStyle,
108
163
  label: { ...label, position: [`${label?.position?.x}%`, `${label?.position?.y}%`] },
109
- data: Array(dataNum).fill(0.5),
164
+ data: Array(dataNum).fill(temData),
110
165
  }));
111
166
  chart.current.setOption(option, true);
112
167
  }
@@ -114,7 +169,7 @@ const Index = forwardRef((props: ChartComponentProps, ref: ForwardedRef<ChartCom
114
169
  if (config) {
115
170
  renderChart();
116
171
  }
117
- }, [config]);
172
+ }, [config, data]);
118
173
 
119
174
  useEffect(() => {
120
175
  if (size) {
@@ -38,6 +38,10 @@ import Decoration8 from "../../decoration/decoration8";
38
38
  import Decoration9 from "../../decoration/decoration9";
39
39
  import Decoration10 from "../../decoration/decoration10";
40
40
  import Decoration11 from "../../decoration/decoration11";
41
+ import BaseTable from "../../base-table";
42
+ import TextScroller from "../../text-scroller";
43
+ import CapsuleBarChart from "../../capsule-bar-chart";
44
+ import CircularProgressChart from "../../circular-progress-chart";
41
45
 
42
46
  interface ComponentItemConfig {
43
47
  baseInfo: BaseInfoType, // 基础信息
@@ -109,6 +113,13 @@ export const compsConfig: { [key: string]: ComponentItemConfig } = {
109
113
  compKey: "ColumnChart",
110
114
  },
111
115
  },
116
+ StackColumnChart: {
117
+ componentNode: ColumnChart,
118
+ baseInfo: {
119
+ compName: "堆叠柱状图",
120
+ compKey: "StackColumnChart",
121
+ },
122
+ },
112
123
  BarChart: {
113
124
  componentNode: BarChart,
114
125
  baseInfo: {
@@ -123,6 +134,13 @@ export const compsConfig: { [key: string]: ComponentItemConfig } = {
123
134
  compKey: "PieChart"
124
135
  }
125
136
  },
137
+ RoseChart: {
138
+ componentNode: PieChart,
139
+ baseInfo: {
140
+ compName: "玫瑰图",
141
+ compKey: "RoseChart"
142
+ }
143
+ },
126
144
  GaugeChart: {
127
145
  componentNode: GaugeChart,
128
146
  baseInfo: {
@@ -325,5 +343,33 @@ export const compsConfig: { [key: string]: ComponentItemConfig } = {
325
343
  compName: "装饰11",
326
344
  compKey: "Decoration11"
327
345
  }
346
+ },
347
+ BaseTable: {
348
+ componentNode: BaseTable,
349
+ baseInfo: {
350
+ compName: "基础表格",
351
+ compKey: "BaseTable"
352
+ }
353
+ },
354
+ TextScroller: {
355
+ componentNode: TextScroller,
356
+ baseInfo: {
357
+ compName: "文本跑马灯",
358
+ compKey: "TextScroller"
359
+ }
360
+ },
361
+ CapsuleBarChart: {
362
+ componentNode: CapsuleBarChart,
363
+ baseInfo: {
364
+ compName: "胶囊图",
365
+ compKey: "CapsuleBarChart"
366
+ }
367
+ },
368
+ CircularProgressChart: {
369
+ componentNode: CircularProgressChart,
370
+ baseInfo: {
371
+ compName: "环形进度图",
372
+ compKey: "CircularProgressChart"
373
+ }
328
374
  }
329
375
  };
@@ -20,40 +20,41 @@ export interface ComponentContainerProps {
20
20
  const ComponentContainer = memo((props: ComponentContainerProps) => {
21
21
  const { layer, layerManager } = props;
22
22
  const ref = useRef(null);
23
- const [compController, setCompController] = useState<{ [key: string]: AbstractDesignerController }>({})
23
+ const [compController, setCompController] = useState<{ [key: string]: AbstractDesignerController }>({});
24
24
 
25
25
  useEffect(() => {
26
26
  //通过ref创建组件,并将组件实例存入Map中。后续通过Map匹配到具体实例,调用实例的对象方法进行组件的更新操作
27
27
  const { elemConfigs } = layerManager;
28
28
  const componentDefine = abstractDesignerLoader.definitionMap[layer.type];
29
- if (componentDefine) {
30
- const Controller = componentDefine.getController() as any;
31
- if (Controller) {
32
- let config;
33
- if (layer.id! in compController!) {
34
- //重新编组后,被编组组件会重新渲染,需从之前的实例中获取原有数据
35
- config = compController![layer.id!].getConfig();
36
- } else if (layer.id! in elemConfigs!) {
37
- config = elemConfigs![layer.id!];
38
- }
39
- /**
40
- * 此处注意,执行顺序尤为重要!!!
41
- * 第一步:动态代理绑定在前,
42
- * 第二步:赋值controller在后,
43
- * 第三步:最后才是执行create方法。
44
- */
45
- //todo 此处逻辑应该使用设计模式优化,而非写死
46
- registerProxy(layer.id!, Controller);
47
- setCompController(val => ({ ...val, [layer.id]: Controller }))
48
- Controller.create(ref.current!, config).then(() => {
49
- //在组件完全渲染完毕后进行数据的加载和事件的注册
50
- Controller.loadComponentData();
51
- //设置组件滤镜效果(todo 考虑是否应该在此处设置?)
52
- Controller.updateFilter(Controller.getConfig()?.filter);
53
- //渲染后删除elemConfigs中的映射关系(需要观察是否会造成其他问题)
54
- delete elemConfigs![layer.id!];
55
- });
29
+ const Controller = componentDefine?.getController() as any;
30
+ if (Controller) {
31
+ let config;
32
+ if (layer.id! in compController!) {
33
+ //重新编组后,被编组组件会重新渲染,需从之前的实例中获取原有数据
34
+ config = compController![layer.id!].getConfig();
35
+ } else if (layer.id! in elemConfigs!) {
36
+ config = elemConfigs![layer.id!];
56
37
  }
38
+ /**
39
+ * 此处注意,执行顺序尤为重要!!!
40
+ * 第一步:动态代理绑定在前,
41
+ * 第二步:赋值controller在后,
42
+ * 第三步:最后才是执行create方法。
43
+ */
44
+ //todo 此处逻辑应该使用设计模式优化,而非写死
45
+ registerProxy(layer.id!, Controller);
46
+ setCompController(val => ({ ...val, [layer.id]: Controller }))
47
+ Controller.create(ref.current!, config).then(() => {
48
+ //在组件完全渲染完毕后进行数据的加载和事件的注册
49
+ Controller.loadComponentData();
50
+ //设置组件滤镜效果(todo 考虑是否应该在此处设置?)
51
+ Controller.updateFilter(Controller.getConfig()?.filter);
52
+ //渲染后删除elemConfigs中的映射关系(需要观察是否会造成其他问题)
53
+ delete elemConfigs![layer.id!];
54
+ });
55
+ }
56
+ return () => {
57
+ Controller.destroy();
57
58
  }
58
59
  }, []);
59
60