aldehyde 0.2.283 → 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.
- package/lib/controls/entity-select/entity-select.d.ts +2 -2
- package/lib/controls/entity-select/entity-select.d.ts.map +1 -1
- package/lib/controls/entity-select/entity-select.js +14 -12
- package/lib/controls/entity-select/entity-select.js.map +1 -1
- package/lib/controls/entry-control.d.ts.map +1 -1
- package/lib/controls/entry-control.js +4 -0
- package/lib/controls/entry-control.js.map +1 -1
- package/lib/controls/select/index.d.ts.map +1 -1
- package/lib/controls/select/index.js +1 -0
- package/lib/controls/select/index.js.map +1 -1
- package/lib/controls/view-control.d.ts.map +1 -1
- package/lib/controls/view-control.js +1 -0
- package/lib/controls/view-control.js.map +1 -1
- package/lib/detail/view/act-dtmpl-view.d.ts.map +1 -1
- package/lib/detail/view/act-dtmpl-view.js +3 -2
- package/lib/detail/view/act-dtmpl-view.js.map +1 -1
- package/lib/detail/view/dtmpl-view.js +1 -1
- package/lib/detail/view/dtmpl-view.js.map +1 -1
- package/lib/form/form-Item-group.d.ts.map +1 -1
- package/lib/form/form-Item-group.js +0 -1
- package/lib/form/form-Item-group.js.map +1 -1
- package/lib/lowcode-components/bar-chart/index.d.ts +10 -6
- package/lib/lowcode-components/bar-chart/index.d.ts.map +1 -1
- package/lib/lowcode-components/bar-chart/index.js +91 -11
- package/lib/lowcode-components/bar-chart/index.js.map +1 -1
- package/lib/lowcode-components/base-map/index.d.ts +10 -6
- package/lib/lowcode-components/base-map/index.d.ts.map +1 -1
- package/lib/lowcode-components/base-map/index.js +86 -7
- package/lib/lowcode-components/base-map/index.js.map +1 -1
- package/lib/lowcode-components/base-table/index.d.ts +53 -0
- package/lib/lowcode-components/base-table/index.d.ts.map +1 -0
- package/lib/lowcode-components/base-table/index.js +158 -0
- package/lib/lowcode-components/base-table/index.js.map +1 -0
- package/lib/lowcode-components/base-table/index.less +59 -0
- package/lib/lowcode-components/capsule-bar-chart/index.d.ts +43 -0
- package/lib/lowcode-components/capsule-bar-chart/index.d.ts.map +1 -0
- package/lib/lowcode-components/capsule-bar-chart/index.js +179 -0
- package/lib/lowcode-components/capsule-bar-chart/index.js.map +1 -0
- package/lib/lowcode-components/circular-progress-chart/index.d.ts +26 -0
- package/lib/lowcode-components/circular-progress-chart/index.d.ts.map +1 -0
- package/lib/lowcode-components/circular-progress-chart/index.js +179 -0
- package/lib/lowcode-components/circular-progress-chart/index.js.map +1 -0
- package/lib/lowcode-components/column-chart/index.d.ts +11 -6
- package/lib/lowcode-components/column-chart/index.d.ts.map +1 -1
- package/lib/lowcode-components/column-chart/index.js +115 -16
- package/lib/lowcode-components/column-chart/index.js.map +1 -1
- package/lib/lowcode-components/data-number/index.d.ts +10 -0
- package/lib/lowcode-components/data-number/index.d.ts.map +1 -1
- package/lib/lowcode-components/data-number/index.js +80 -6
- package/lib/lowcode-components/data-number/index.js.map +1 -1
- package/lib/lowcode-components/decoration/decoration1/index.d.ts +19 -0
- package/lib/lowcode-components/decoration/decoration1/index.d.ts.map +1 -0
- package/lib/lowcode-components/decoration/decoration1/index.js +58 -0
- package/lib/lowcode-components/decoration/decoration1/index.js.map +1 -0
- package/lib/lowcode-components/decoration/decoration1/index.less +8 -0
- package/lib/lowcode-components/decoration/decoration10/index.d.ts +20 -0
- package/lib/lowcode-components/decoration/decoration10/index.d.ts.map +1 -0
- package/lib/lowcode-components/decoration/decoration10/index.js +29 -0
- package/lib/lowcode-components/decoration/decoration10/index.js.map +1 -0
- package/lib/lowcode-components/decoration/decoration10/index.less +6 -0
- package/lib/lowcode-components/decoration/decoration11/index.d.ts +20 -0
- package/lib/lowcode-components/decoration/decoration11/index.d.ts.map +1 -0
- package/lib/lowcode-components/decoration/decoration11/index.js +81 -0
- package/lib/lowcode-components/decoration/decoration11/index.js.map +1 -0
- package/lib/lowcode-components/decoration/decoration11/index.less +6 -0
- package/lib/lowcode-components/decoration/decoration2/index.d.ts +19 -0
- package/lib/lowcode-components/decoration/decoration2/index.d.ts.map +1 -0
- package/lib/lowcode-components/decoration/decoration2/index.js +23 -0
- package/lib/lowcode-components/decoration/decoration2/index.js.map +1 -0
- package/lib/lowcode-components/decoration/decoration2/index.less +7 -0
- package/lib/lowcode-components/decoration/decoration3/index.d.ts +19 -0
- package/lib/lowcode-components/decoration/decoration3/index.d.ts.map +1 -0
- package/lib/lowcode-components/decoration/decoration3/index.js +39 -0
- package/lib/lowcode-components/decoration/decoration3/index.js.map +1 -0
- package/lib/lowcode-components/decoration/decoration3/index.less +8 -0
- package/lib/lowcode-components/decoration/decoration4/index.d.ts +19 -0
- package/lib/lowcode-components/decoration/decoration4/index.d.ts.map +1 -0
- package/lib/lowcode-components/decoration/decoration4/index.js +20 -0
- package/lib/lowcode-components/decoration/decoration4/index.js.map +1 -0
- package/lib/lowcode-components/decoration/decoration4/index.less +30 -0
- package/lib/lowcode-components/decoration/decoration5/index.d.ts +19 -0
- package/lib/lowcode-components/decoration/decoration5/index.d.ts.map +1 -0
- package/lib/lowcode-components/decoration/decoration5/index.js +56 -0
- package/lib/lowcode-components/decoration/decoration5/index.js.map +1 -0
- package/lib/lowcode-components/decoration/decoration5/index.less +4 -0
- package/lib/lowcode-components/decoration/decoration6/index.d.ts +19 -0
- package/lib/lowcode-components/decoration/decoration6/index.d.ts.map +1 -0
- package/lib/lowcode-components/decoration/decoration6/index.js +55 -0
- package/lib/lowcode-components/decoration/decoration6/index.js.map +1 -0
- package/lib/lowcode-components/decoration/decoration6/index.less +8 -0
- package/lib/lowcode-components/decoration/decoration7/index.d.ts +20 -0
- package/lib/lowcode-components/decoration/decoration7/index.d.ts.map +1 -0
- package/lib/lowcode-components/decoration/decoration7/index.js +28 -0
- package/lib/lowcode-components/decoration/decoration7/index.js.map +1 -0
- package/lib/lowcode-components/decoration/decoration7/index.less +5 -0
- package/lib/lowcode-components/decoration/decoration8/index.d.ts +20 -0
- package/lib/lowcode-components/decoration/decoration8/index.d.ts.map +1 -0
- package/lib/lowcode-components/decoration/decoration8/index.js +31 -0
- package/lib/lowcode-components/decoration/decoration8/index.js.map +1 -0
- package/lib/lowcode-components/decoration/decoration8/index.less +15 -0
- package/lib/lowcode-components/decoration/decoration9/index.d.ts +20 -0
- package/lib/lowcode-components/decoration/decoration9/index.d.ts.map +1 -0
- package/lib/lowcode-components/decoration/decoration9/index.js +52 -0
- package/lib/lowcode-components/decoration/decoration9/index.js.map +1 -0
- package/lib/lowcode-components/decoration/decoration9/index.less +5 -0
- package/lib/lowcode-components/effectScatter-map/index.d.ts +10 -6
- package/lib/lowcode-components/effectScatter-map/index.d.ts.map +1 -1
- package/lib/lowcode-components/effectScatter-map/index.js +87 -9
- package/lib/lowcode-components/effectScatter-map/index.js.map +1 -1
- package/lib/lowcode-components/gauge-chart/index.d.ts +10 -6
- package/lib/lowcode-components/gauge-chart/index.d.ts.map +1 -1
- package/lib/lowcode-components/gauge-chart/index.js +65 -8
- package/lib/lowcode-components/gauge-chart/index.js.map +1 -1
- package/lib/lowcode-components/index.d.ts +30 -0
- package/lib/lowcode-components/index.d.ts.map +1 -1
- package/lib/lowcode-components/index.js +25 -28
- package/lib/lowcode-components/index.js.map +1 -1
- package/lib/lowcode-components/line-chart/index.d.ts +10 -6
- package/lib/lowcode-components/line-chart/index.d.ts.map +1 -1
- package/lib/lowcode-components/line-chart/index.js +91 -11
- package/lib/lowcode-components/line-chart/index.js.map +1 -1
- package/lib/lowcode-components/liquid-chart/index.d.ts +10 -6
- package/lib/lowcode-components/liquid-chart/index.d.ts.map +1 -1
- package/lib/lowcode-components/liquid-chart/index.js +64 -7
- package/lib/lowcode-components/liquid-chart/index.js.map +1 -1
- package/lib/lowcode-components/lowcode-view/component/assets.d.ts.map +1 -1
- package/lib/lowcode-components/lowcode-view/component/assets.js +134 -0
- package/lib/lowcode-components/lowcode-view/component/assets.js.map +1 -1
- package/lib/lowcode-components/lowcode-view/component/component-container.d.ts.map +1 -1
- package/lib/lowcode-components/lowcode-view/component/component-container.js +30 -29
- package/lib/lowcode-components/lowcode-view/component/component-container.js.map +1 -1
- package/lib/lowcode-components/pie-chart/index.d.ts +11 -6
- package/lib/lowcode-components/pie-chart/index.d.ts.map +1 -1
- package/lib/lowcode-components/pie-chart/index.js +102 -15
- package/lib/lowcode-components/pie-chart/index.js.map +1 -1
- package/lib/lowcode-components/text-scroller/index.d.ts +23 -0
- package/lib/lowcode-components/text-scroller/index.d.ts.map +1 -0
- package/lib/lowcode-components/text-scroller/index.js +96 -0
- package/lib/lowcode-components/text-scroller/index.js.map +1 -0
- package/lib/lowcode-components/text-scroller/index.less +29 -0
- package/lib/table/act-table.d.ts.map +1 -1
- package/lib/table/act-table.js.map +1 -1
- package/lib/table/query-table.js +5 -5
- package/lib/table/query-table.js.map +1 -1
- package/lib/table/relation-table.d.ts.map +1 -1
- package/lib/table/relation-table.js +0 -2
- package/lib/table/relation-table.js.map +1 -1
- package/lib/tmpl/control-type-supportor.d.ts.map +1 -1
- package/lib/tmpl/control-type-supportor.js +1 -0
- package/lib/tmpl/control-type-supportor.js.map +1 -1
- package/package.json +1 -1
- package/src/aldehyde/controls/entity-select/entity-select.tsx +15 -15
- package/src/aldehyde/controls/entry-control.tsx +12 -0
- package/src/aldehyde/controls/select/index.tsx +1 -0
- package/src/aldehyde/controls/view-control.tsx +1 -0
- package/src/aldehyde/detail/view/act-dtmpl-view.tsx +22 -23
- package/src/aldehyde/detail/view/dtmpl-view.tsx +1 -1
- package/src/aldehyde/form/form-Item-group.tsx +0 -1
- package/src/aldehyde/lowcode-components/bar-chart/index.tsx +100 -19
- package/src/aldehyde/lowcode-components/base-map/index.tsx +94 -15
- package/src/aldehyde/lowcode-components/base-table/index.less +59 -0
- package/src/aldehyde/lowcode-components/base-table/index.tsx +233 -0
- package/src/aldehyde/lowcode-components/capsule-bar-chart/index.tsx +219 -0
- package/src/aldehyde/lowcode-components/circular-progress-chart/index.tsx +201 -0
- package/src/aldehyde/lowcode-components/column-chart/index.tsx +128 -24
- package/src/aldehyde/lowcode-components/data-number/index.tsx +89 -7
- package/src/aldehyde/lowcode-components/data.d.ts +6 -0
- package/src/aldehyde/lowcode-components/decoration/decoration1/index.less +8 -0
- package/src/aldehyde/lowcode-components/decoration/decoration1/index.tsx +153 -0
- package/src/aldehyde/lowcode-components/decoration/decoration10/index.less +6 -0
- package/src/aldehyde/lowcode-components/decoration/decoration10/index.tsx +89 -0
- package/src/aldehyde/lowcode-components/decoration/decoration11/index.less +6 -0
- package/src/aldehyde/lowcode-components/decoration/decoration11/index.tsx +133 -0
- package/src/aldehyde/lowcode-components/decoration/decoration2/index.less +7 -0
- package/src/aldehyde/lowcode-components/decoration/decoration2/index.tsx +61 -0
- package/src/aldehyde/lowcode-components/decoration/decoration3/index.less +8 -0
- package/src/aldehyde/lowcode-components/decoration/decoration3/index.tsx +87 -0
- package/src/aldehyde/lowcode-components/decoration/decoration4/index.less +30 -0
- package/src/aldehyde/lowcode-components/decoration/decoration4/index.tsx +53 -0
- package/src/aldehyde/lowcode-components/decoration/decoration5/index.less +4 -0
- package/src/aldehyde/lowcode-components/decoration/decoration5/index.tsx +116 -0
- package/src/aldehyde/lowcode-components/decoration/decoration6/index.less +8 -0
- package/src/aldehyde/lowcode-components/decoration/decoration6/index.tsx +121 -0
- package/src/aldehyde/lowcode-components/decoration/decoration7/index.less +5 -0
- package/src/aldehyde/lowcode-components/decoration/decoration7/index.tsx +70 -0
- package/src/aldehyde/lowcode-components/decoration/decoration8/index.less +15 -0
- package/src/aldehyde/lowcode-components/decoration/decoration8/index.tsx +122 -0
- package/src/aldehyde/lowcode-components/decoration/decoration9/index.less +5 -0
- package/src/aldehyde/lowcode-components/decoration/decoration9/index.tsx +196 -0
- package/src/aldehyde/lowcode-components/effectScatter-map/index.tsx +93 -19
- package/src/aldehyde/lowcode-components/gauge-chart/index.tsx +73 -16
- package/src/aldehyde/lowcode-components/index.ts +40 -29
- package/src/aldehyde/lowcode-components/line-chart/index.tsx +105 -22
- package/src/aldehyde/lowcode-components/liquid-chart/index.tsx +70 -15
- package/src/aldehyde/lowcode-components/lowcode-view/component/assets.ts +134 -0
- package/src/aldehyde/lowcode-components/lowcode-view/component/component-container.tsx +29 -28
- package/src/aldehyde/lowcode-components/pie-chart/index.tsx +111 -25
- package/src/aldehyde/lowcode-components/text-scroller/index.less +29 -0
- package/src/aldehyde/lowcode-components/text-scroller/index.tsx +122 -0
- package/src/aldehyde/table/act-table.tsx +0 -1
- package/src/aldehyde/table/query-table.tsx +5 -5
- package/src/aldehyde/table/relation-table.tsx +0 -2
- package/src/aldehyde/tmpl/control-type-supportor.tsx +1 -0
|
@@ -1,14 +1,48 @@
|
|
|
1
1
|
import * as echarts from 'echarts';
|
|
2
2
|
import React, { useEffect, useRef, useState, ForwardedRef, forwardRef, useImperativeHandle } from 'react';
|
|
3
|
-
import
|
|
3
|
+
import _ from 'lodash';
|
|
4
|
+
import HydrocarbonService from "../../tmpl/hcservice-v3";
|
|
5
|
+
import { DataConfigProps } from "../data";
|
|
6
|
+
|
|
7
|
+
const defColumnValue = [
|
|
8
|
+
{
|
|
9
|
+
data: [["1990", 52], ["1991", 45], ["1992", 35], ["1993", 41], ["1994", 23], ["1995", 25], ["1996", 15]],
|
|
10
|
+
type: 'bar',
|
|
11
|
+
}
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
const defStackValue = [
|
|
15
|
+
{
|
|
16
|
+
data: [["1990", 3], ["1991", 4], ["1992", 3.5], ["1993", 5], ["1994", 4.9], ["1995", 6], ["1996", 7]],
|
|
17
|
+
type: 'bar',
|
|
18
|
+
name: "Val1",
|
|
19
|
+
stack: "stack"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
data: [["1990", 3], ["1991", 4], ["1992", 3.5], ["1993", 5], ["1994", 4.9], ["1995", 6], ["1996", 7]],
|
|
23
|
+
type: 'bar',
|
|
24
|
+
name: "Val2",
|
|
25
|
+
stack: "stack"
|
|
26
|
+
}
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
const defDatas = {
|
|
30
|
+
ColumnChart: defColumnValue,
|
|
31
|
+
StackColumnChart: defStackValue,
|
|
32
|
+
};
|
|
4
33
|
|
|
5
34
|
const defOption = {
|
|
35
|
+
title: {
|
|
36
|
+
text: '暂无数据',
|
|
37
|
+
left: 'center',
|
|
38
|
+
top: 'middle',
|
|
39
|
+
show: false, // 无数据时显示
|
|
40
|
+
},
|
|
6
41
|
tooltip: { trigger: "axis" },
|
|
7
42
|
grid: { top: 30, let: 30, right: 20, bottom: 30 },
|
|
8
43
|
xAxis: {
|
|
9
44
|
type: 'category',
|
|
10
45
|
boundaryGap: true,
|
|
11
|
-
data: ['1990', '1991', '1992', '1993', '1994', '1995', '1996'],
|
|
12
46
|
axisTick: { show: true },
|
|
13
47
|
},
|
|
14
48
|
yAxis: {
|
|
@@ -16,12 +50,7 @@ const defOption = {
|
|
|
16
50
|
},
|
|
17
51
|
legend: { show: false },
|
|
18
52
|
barMaxWidth: 30,
|
|
19
|
-
series:
|
|
20
|
-
{
|
|
21
|
-
data: [525, 459, 357, 414, 234, 250, 156],
|
|
22
|
-
type: 'bar',
|
|
23
|
-
}
|
|
24
|
-
]
|
|
53
|
+
series: defColumnValue
|
|
25
54
|
};
|
|
26
55
|
|
|
27
56
|
const legends = {
|
|
@@ -35,7 +64,26 @@ const legends = {
|
|
|
35
64
|
rightBottom: { right: 5, bottom: 0 },
|
|
36
65
|
};
|
|
37
66
|
|
|
38
|
-
|
|
67
|
+
// 处理数据格式
|
|
68
|
+
const handleData = (data: { config: { [key: string]: string }, value: { [key: string]: any }[] }[]) => {
|
|
69
|
+
if (!data?.length) {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
const temData = data.map((r) => {
|
|
73
|
+
const { config, value } = r;
|
|
74
|
+
const vNames = Object.keys(config).filter((r) => r.startsWith("v")).sort((a, b) => parseInt(a.substring(1)) - parseInt(b.substring(1)));
|
|
75
|
+
return {
|
|
76
|
+
name: config.d1,
|
|
77
|
+
data: vNames.map((r) => ({
|
|
78
|
+
name: config[r],
|
|
79
|
+
data: value.map((v) => [v["d1"], v[r]]),
|
|
80
|
+
}))
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
return temData[0]?.data || [];
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export interface ComponentStyle {
|
|
39
87
|
tooltip?: { show: boolean };
|
|
40
88
|
color?: string[];
|
|
41
89
|
grid?: { top: number, let: number, right: number, bottom: number };
|
|
@@ -45,27 +93,42 @@ export interface ChartComponentStyle {
|
|
|
45
93
|
barMaxWidth?: number;
|
|
46
94
|
}
|
|
47
95
|
|
|
48
|
-
export interface
|
|
49
|
-
style?:
|
|
50
|
-
base: { width: number, height: number }
|
|
96
|
+
export interface ComponentProps {
|
|
97
|
+
style?: ComponentStyle;
|
|
98
|
+
base: { width: number, height: number, type: string },
|
|
99
|
+
data?: DataConfigProps;
|
|
100
|
+
isDesignMode?: boolean; // 是否编辑模式
|
|
51
101
|
}
|
|
52
102
|
|
|
53
|
-
export interface
|
|
54
|
-
updateConfig: (newConfig:
|
|
103
|
+
export interface ComponentRef {
|
|
104
|
+
updateConfig: (newConfig: ComponentProps) => void;
|
|
105
|
+
destroy: () => void;
|
|
55
106
|
}
|
|
56
107
|
|
|
57
|
-
const Index = forwardRef((props:
|
|
58
|
-
const
|
|
59
|
-
const [
|
|
108
|
+
const Index = forwardRef((props: ComponentProps, ref: ForwardedRef<ComponentRef>) => {
|
|
109
|
+
const { style, base: { type: componentType }, data: propsData, isDesignMode } = props;
|
|
110
|
+
const [config, setConfig] = useState<ComponentStyle>(style || {});
|
|
111
|
+
const [size, setSize] = useState<{ width: number, height: number }>();
|
|
112
|
+
const [dataConfig, setDataConfig] = useState<DataConfigProps>({ ...propsData }); // 数据源配置
|
|
113
|
+
const [data, setData] = useState<{ name: string, data: any }[]>([]);
|
|
60
114
|
const chartRef = useRef<HTMLDivElement>(null);
|
|
61
115
|
const chart = useRef<any>(null);
|
|
116
|
+
const pollingIntervalRef = useRef<number | NodeJS.Timeout>(null);
|
|
117
|
+
|
|
118
|
+
const handleDestroy = () => {
|
|
119
|
+
pollingIntervalRef.current && clearInterval(pollingIntervalRef.current);
|
|
120
|
+
window.removeEventListener('resize', handleResize);
|
|
121
|
+
chart.current.dispose();
|
|
122
|
+
};
|
|
62
123
|
|
|
63
124
|
useImperativeHandle(ref, () => ({
|
|
64
125
|
updateConfig: (newConfig) => {
|
|
65
|
-
const { base, style } = newConfig;
|
|
66
|
-
setConfig({ ...(
|
|
126
|
+
const { base, style: newStyle, data: newDataConfig } = newConfig;
|
|
127
|
+
setConfig({ ...(newStyle || {}) });
|
|
67
128
|
setSize({ width: base.width, height: base.height });
|
|
129
|
+
setDataConfig(newDataConfig);
|
|
68
130
|
},
|
|
131
|
+
destroy: handleDestroy,
|
|
69
132
|
}));
|
|
70
133
|
|
|
71
134
|
// 窗口大小变化时重新调整图表大小
|
|
@@ -77,23 +140,64 @@ const Index = forwardRef((props: ChartComponentProps, ref: ForwardedRef<BaseText
|
|
|
77
140
|
chart.current = echarts.init(chartRef.current);
|
|
78
141
|
window.addEventListener('resize', handleResize);
|
|
79
142
|
return () => {
|
|
80
|
-
|
|
81
|
-
chart.current.dispose();
|
|
143
|
+
handleDestroy();
|
|
82
144
|
}
|
|
83
145
|
}, []);
|
|
84
146
|
|
|
147
|
+
|
|
148
|
+
// 请求数据
|
|
149
|
+
const getData = async () => {
|
|
150
|
+
const { entities: { config, value } } = await HydrocarbonService.requestMstrucLtmplQueryTop(null, dataConfig?.sourceId, null) || {};
|
|
151
|
+
const temData = handleData(value);
|
|
152
|
+
setData(temData);
|
|
153
|
+
return config;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// 初始化请求数据
|
|
157
|
+
const getInitData = async () => {
|
|
158
|
+
pollingIntervalRef.current && clearInterval(pollingIntervalRef.current);
|
|
159
|
+
const config = await getData();
|
|
160
|
+
if (config?.requestType === "polling") {
|
|
161
|
+
pollingIntervalRef.current = setInterval(() => { getData() }, config?.pollingInterval || 60000);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// 静态数据处理
|
|
166
|
+
useEffect(() => {
|
|
167
|
+
if (dataConfig?.sourceType === 'staticData') {
|
|
168
|
+
setData(handleData(dataConfig.staticData));
|
|
169
|
+
}
|
|
170
|
+
}, [dataConfig?.sourceType, dataConfig?.staticData]);
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* 数据源数据请求
|
|
174
|
+
* 1、编辑态不请求数据
|
|
175
|
+
*/
|
|
176
|
+
useEffect(() => {
|
|
177
|
+
if (!isDesignMode && dataConfig?.sourceType === 'sourceId' && dataConfig?.sourceId) {
|
|
178
|
+
getInitData();
|
|
179
|
+
} else if (dataConfig?.sourceType === 'sourceId') {
|
|
180
|
+
setData([]);
|
|
181
|
+
}
|
|
182
|
+
}, [dataConfig?.sourceType, dataConfig?.sourceId]);
|
|
183
|
+
|
|
85
184
|
const renderChart = () => {
|
|
86
185
|
const { grid, barMaxWidth, legend, tooltip, color, xAxis, yAxis, } = config
|
|
87
|
-
const option =
|
|
186
|
+
const option = _.cloneDeep(defOption);
|
|
187
|
+
// 编辑态无数据显示默认数据
|
|
188
|
+
const temData = isDesignMode && !data?.length ? defDatas[componentType] || [] : data;
|
|
88
189
|
option.barMaxWidth = barMaxWidth;
|
|
89
190
|
option.grid = grid;
|
|
90
191
|
option.legend = { ...legend, ...legends[legend?.position] };
|
|
91
192
|
option.tooltip = { trigger: "axis", ...tooltip };
|
|
92
193
|
option.xAxis = { ...option.xAxis, ...xAxis, axisTick: { show: xAxis?.axisLine?.show } };
|
|
93
194
|
option.yAxis = { ...option.yAxis, ...yAxis };
|
|
94
|
-
option.
|
|
195
|
+
option.title.show = !temData?.length;
|
|
196
|
+
option.series = temData.map((r, index) => ({
|
|
197
|
+
type: "bar",
|
|
95
198
|
...r,
|
|
96
199
|
itemStyle: { color: color[index] },
|
|
200
|
+
stack: componentType === 'StackColumnChart' ? 'stack' : undefined,
|
|
97
201
|
}));
|
|
98
202
|
chart.current.setOption(option, true);
|
|
99
203
|
}
|
|
@@ -101,7 +205,7 @@ const Index = forwardRef((props: ChartComponentProps, ref: ForwardedRef<BaseText
|
|
|
101
205
|
if (config) {
|
|
102
206
|
renderChart();
|
|
103
207
|
}
|
|
104
|
-
}, [config]);
|
|
208
|
+
}, [config, data]);
|
|
105
209
|
|
|
106
210
|
useEffect(() => {
|
|
107
211
|
if (size) {
|
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
|
|
2
|
-
import React, { ForwardedRef, forwardRef, useImperativeHandle, useState } from 'react';
|
|
2
|
+
import React, { ForwardedRef, forwardRef, useEffect, useImperativeHandle, useMemo, useState, useRef } from 'react';
|
|
3
|
+
import HydrocarbonService from "../../tmpl/hcservice-v3";
|
|
4
|
+
import { DataConfigProps } from "../data";
|
|
3
5
|
import './index.less';
|
|
4
6
|
|
|
7
|
+
const rules = {
|
|
8
|
+
eq: '==',
|
|
9
|
+
ne: '!=',
|
|
10
|
+
gt: '>',
|
|
11
|
+
gte: '>=',
|
|
12
|
+
lt: '<',
|
|
13
|
+
lte: '<=',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
interface EnumeProps {
|
|
17
|
+
rule: string,
|
|
18
|
+
num: number,
|
|
19
|
+
value: string
|
|
20
|
+
}
|
|
21
|
+
|
|
5
22
|
export interface ComponentStyle {
|
|
6
23
|
color?: string;
|
|
7
24
|
fontSize?: number;
|
|
@@ -14,28 +31,93 @@ export interface ComponentStyle {
|
|
|
14
31
|
letterSpacing?: number;
|
|
15
32
|
lineHeight?: number;
|
|
16
33
|
defaultValue?: number;
|
|
34
|
+
enume?: EnumeProps[];
|
|
17
35
|
}
|
|
18
36
|
|
|
19
37
|
export interface ComponentProps {
|
|
20
38
|
style?: ComponentStyle;
|
|
39
|
+
data?: DataConfigProps;
|
|
40
|
+
isDesignMode?: boolean; // 是否编辑模式
|
|
21
41
|
}
|
|
22
42
|
|
|
23
43
|
export interface ComponentRef {
|
|
24
44
|
updateConfig: (newConfig: ComponentProps) => void;
|
|
45
|
+
destroy: () => void;
|
|
25
46
|
}
|
|
26
47
|
|
|
27
48
|
const Index = forwardRef((props: ComponentProps, ref: ForwardedRef<ComponentRef>) => {
|
|
28
|
-
const
|
|
29
|
-
const [
|
|
49
|
+
const { style, data: propsData, isDesignMode } = props;
|
|
50
|
+
const [config, setConfig] = useState<ComponentStyle>(style || {});
|
|
51
|
+
const [enume, setEnume] = useState<EnumeProps[]>(style?.enume || []);
|
|
52
|
+
const [dataConfig, setDataConfig] = useState<DataConfigProps>({ ...propsData }); // 数据源配置
|
|
53
|
+
const [data, setData] = useState<number>(style?.defaultValue);
|
|
54
|
+
const pollingIntervalRef = useRef<number | NodeJS.Timeout>(null);
|
|
55
|
+
|
|
56
|
+
const handleDestroy = () => {
|
|
57
|
+
pollingIntervalRef.current && clearInterval(pollingIntervalRef.current);
|
|
58
|
+
};
|
|
59
|
+
|
|
30
60
|
|
|
31
|
-
useImperativeHandle(ref, () => ({
|
|
32
|
-
updateConfig: (newConfig) => {
|
|
33
|
-
const { style: { defaultValue, ...style } } = newConfig;
|
|
61
|
+
useImperativeHandle(ref, () => ({ // 暴露到外部func
|
|
62
|
+
updateConfig: (newConfig) => { // 组件更新配置
|
|
63
|
+
const { style: { defaultValue, enume: newEnume, ...style }, data: newDataConfig } = newConfig;
|
|
34
64
|
setConfig({ ...(style || {}) });
|
|
35
65
|
setData(defaultValue || 0);
|
|
66
|
+
setEnume([...(newEnume || [])]);
|
|
67
|
+
setDataConfig(newDataConfig);
|
|
36
68
|
},
|
|
69
|
+
destroy: handleDestroy
|
|
37
70
|
}));
|
|
38
71
|
|
|
72
|
+
// 请求数据
|
|
73
|
+
const getData = async () => {
|
|
74
|
+
const { entities: { config, value } } = await HydrocarbonService.requestMstrucLtmplQueryTop(null, dataConfig?.sourceId, null) || {};
|
|
75
|
+
const temData = value?.[0]?.value?.[0]?.v1;
|
|
76
|
+
setData(temData);
|
|
77
|
+
return config;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// 初始化请求数据
|
|
81
|
+
const getInitData = async () => {
|
|
82
|
+
pollingIntervalRef.current && clearInterval(pollingIntervalRef.current);
|
|
83
|
+
const config = await getData();
|
|
84
|
+
if (config?.requestType === "polling") {
|
|
85
|
+
pollingIntervalRef.current = setInterval(() => { getData() }, config?.pollingInterval || 60000);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
return () => {
|
|
91
|
+
handleDestroy();
|
|
92
|
+
}
|
|
93
|
+
}, []);
|
|
94
|
+
|
|
95
|
+
// 静态数据处理
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
if (dataConfig?.sourceType === 'staticData') {
|
|
98
|
+
const { value } = dataConfig.staticData || {};
|
|
99
|
+
setData(value);
|
|
100
|
+
}
|
|
101
|
+
}, [dataConfig?.sourceType, dataConfig?.staticData]);
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 数据源数据请求
|
|
105
|
+
* 1、编辑态不请求数据
|
|
106
|
+
*/
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
if (!isDesignMode && dataConfig?.sourceType === 'sourceId' && dataConfig?.sourceId) {
|
|
109
|
+
getInitData();
|
|
110
|
+
}
|
|
111
|
+
}, [dataConfig?.sourceType, dataConfig?.sourceId]);
|
|
112
|
+
|
|
113
|
+
const value = useMemo(() => {
|
|
114
|
+
if (enume?.length > 0) { // 枚举
|
|
115
|
+
const temEnume = enume.filter(item => item.rule && (item.num || item.num === 0));
|
|
116
|
+
return temEnume.find((item) => eval(`${data} ${rules[item.rule]} ${item.num}`))?.value || data;
|
|
117
|
+
} else {
|
|
118
|
+
return data;
|
|
119
|
+
}
|
|
120
|
+
}, [data, enume]);
|
|
39
121
|
|
|
40
122
|
return (
|
|
41
123
|
<div
|
|
@@ -46,7 +128,7 @@ const Index = forwardRef((props: ComponentProps, ref: ForwardedRef<ComponentRef>
|
|
|
46
128
|
WebkitTextStrokeColor: config?.strokeColor,
|
|
47
129
|
}}
|
|
48
130
|
>
|
|
49
|
-
{
|
|
131
|
+
{value}
|
|
50
132
|
</div>
|
|
51
133
|
);
|
|
52
134
|
});
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import React, { ForwardedRef, forwardRef, useImperativeHandle, useState, useMemo } from "react";
|
|
2
|
+
import "./index.less";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
const pointSideLength = 2.5;
|
|
6
|
+
const halfPointSideLength = pointSideLength / 2;
|
|
7
|
+
const svgWH = [200, 50];
|
|
8
|
+
const rowNum = 4;
|
|
9
|
+
const rowPoints = 20;
|
|
10
|
+
|
|
11
|
+
const getPoints = () => {
|
|
12
|
+
const [w, h] = svgWH;
|
|
13
|
+
const horizontalGap = w / (rowPoints + 1);
|
|
14
|
+
const verticalGap = h / (rowNum + 1);
|
|
15
|
+
const points = new Array(rowNum)
|
|
16
|
+
.fill(0)
|
|
17
|
+
.map((_, i) =>
|
|
18
|
+
new Array(rowPoints)
|
|
19
|
+
.fill(0)
|
|
20
|
+
.map((_, j) => [horizontalGap * (j + 1), verticalGap * (i + 1)])
|
|
21
|
+
);
|
|
22
|
+
return points.reduce((all, item) => [...all, ...item], []);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface ComponentStyle {
|
|
26
|
+
mainColor?: string;
|
|
27
|
+
subColor?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface ComponentProps {
|
|
31
|
+
style?: ComponentStyle;
|
|
32
|
+
base?: { width?: number, height?: number }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface ComponentRef {
|
|
36
|
+
updateConfig: (config: ComponentProps) => void;
|
|
37
|
+
}
|
|
38
|
+
const Index = forwardRef((props: ComponentProps, ref: ForwardedRef<ComponentRef>) => {
|
|
39
|
+
const [style, setStyle] = useState<ComponentStyle>({ ...props.style });
|
|
40
|
+
const [width, setWidth] = useState<number>(300);
|
|
41
|
+
const [height, setHeight] = useState<number>(100);
|
|
42
|
+
const { mainColor = "#83BFF6", subColor = "#00CED1" } = style || {};
|
|
43
|
+
|
|
44
|
+
useImperativeHandle(ref, () => ({
|
|
45
|
+
updateConfig: (newConfig) => {
|
|
46
|
+
setStyle({ ...newConfig.style });
|
|
47
|
+
setWidth(newConfig.base.width);
|
|
48
|
+
setHeight(newConfig.base.height);
|
|
49
|
+
},
|
|
50
|
+
}));
|
|
51
|
+
|
|
52
|
+
const calcSVGData = () => {
|
|
53
|
+
const points = getPoints();
|
|
54
|
+
return {
|
|
55
|
+
points: points.reduce((prev, point, i) => Math.random() > 0.6
|
|
56
|
+
? [
|
|
57
|
+
...prev,
|
|
58
|
+
<rect
|
|
59
|
+
key={i}
|
|
60
|
+
fill={mainColor}
|
|
61
|
+
x={point[0] - halfPointSideLength}
|
|
62
|
+
y={point[1] - halfPointSideLength}
|
|
63
|
+
width={pointSideLength}
|
|
64
|
+
height={pointSideLength}
|
|
65
|
+
>
|
|
66
|
+
{Math.random() > 0.6 && (
|
|
67
|
+
<animate
|
|
68
|
+
attributeName='fill'
|
|
69
|
+
values={`${mainColor};transparent`}
|
|
70
|
+
dur='1s'
|
|
71
|
+
begin={Math.random() * 2}
|
|
72
|
+
repeatCount='indefinite'
|
|
73
|
+
/>
|
|
74
|
+
)}
|
|
75
|
+
</rect>
|
|
76
|
+
] as any
|
|
77
|
+
: prev, []),
|
|
78
|
+
rects: [points[rowPoints * 2 - 1], points[rowPoints * 2 - 3]],
|
|
79
|
+
svgScale: [width / svgWH[0], height / svgWH[1]]
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const { svgScale, points, rects } = useMemo(calcSVGData, [width, height, mainColor]);
|
|
84
|
+
|
|
85
|
+
return <div className="decoration-1" >
|
|
86
|
+
<svg
|
|
87
|
+
className="decoration-1-container"
|
|
88
|
+
width={`${svgWH[0]}px`}
|
|
89
|
+
height={`${svgWH[1]}px`}
|
|
90
|
+
style={{ transform: `scale(${svgScale[0]},${svgScale[1]})` }}
|
|
91
|
+
>
|
|
92
|
+
{points}
|
|
93
|
+
{!!rects[0] && (
|
|
94
|
+
<rect
|
|
95
|
+
fill={subColor}
|
|
96
|
+
x={rects[0][0] - pointSideLength}
|
|
97
|
+
y={rects[0][1] - pointSideLength}
|
|
98
|
+
width={pointSideLength * 2}
|
|
99
|
+
height={pointSideLength * 2}
|
|
100
|
+
>
|
|
101
|
+
<animate
|
|
102
|
+
attributeName='width'
|
|
103
|
+
values={`0;${pointSideLength * 2}`}
|
|
104
|
+
dur='2s'
|
|
105
|
+
repeatCount='indefinite'
|
|
106
|
+
/>
|
|
107
|
+
<animate
|
|
108
|
+
attributeName='height'
|
|
109
|
+
values={`0;${pointSideLength * 2}`}
|
|
110
|
+
dur='2s'
|
|
111
|
+
repeatCount='indefinite'
|
|
112
|
+
/>
|
|
113
|
+
<animate
|
|
114
|
+
attributeName='x'
|
|
115
|
+
values={`${rects[0][0]};${rects[0][0] - pointSideLength}`}
|
|
116
|
+
dur='2s'
|
|
117
|
+
repeatCount='indefinite'
|
|
118
|
+
/>
|
|
119
|
+
<animate
|
|
120
|
+
attributeName='y'
|
|
121
|
+
values={`${rects[0][1]};${rects[0][1] - pointSideLength}`}
|
|
122
|
+
dur='2s'
|
|
123
|
+
repeatCount='indefinite'
|
|
124
|
+
/>
|
|
125
|
+
</rect>
|
|
126
|
+
)}
|
|
127
|
+
{!!rects[1] && (
|
|
128
|
+
<rect
|
|
129
|
+
fill={subColor}
|
|
130
|
+
x={rects[1][0] - 40}
|
|
131
|
+
y={rects[1][1] - pointSideLength}
|
|
132
|
+
width='40'
|
|
133
|
+
height={pointSideLength * 2}
|
|
134
|
+
>
|
|
135
|
+
<animate
|
|
136
|
+
attributeName='width'
|
|
137
|
+
values='0;40;0'
|
|
138
|
+
dur='2s'
|
|
139
|
+
repeatCount='indefinite'
|
|
140
|
+
/>
|
|
141
|
+
<animate
|
|
142
|
+
attributeName='x'
|
|
143
|
+
values={`${rects[1][0]};${rects[1][0] - 40};${rects[1][0]}`}
|
|
144
|
+
dur='2s'
|
|
145
|
+
repeatCount='indefinite'
|
|
146
|
+
/>
|
|
147
|
+
</rect>
|
|
148
|
+
)}
|
|
149
|
+
</svg>
|
|
150
|
+
</div>;
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
export default Index;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React, { ForwardedRef, forwardRef, useImperativeHandle, useState } from "react";
|
|
2
|
+
import "./index.less";
|
|
3
|
+
|
|
4
|
+
interface ComponentStyle {
|
|
5
|
+
mainColor?: string;
|
|
6
|
+
subColor?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ComponentProps {
|
|
10
|
+
style?: ComponentStyle;
|
|
11
|
+
base?: { width?: number, height?: number, id: string }
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ComponentRef {
|
|
15
|
+
updateConfig: (config: ComponentProps) => void;
|
|
16
|
+
}
|
|
17
|
+
const Index = forwardRef((props: ComponentProps, ref: ForwardedRef<ComponentRef>) => {
|
|
18
|
+
const [style, setStyle] = useState<ComponentStyle>({ ...props.style });
|
|
19
|
+
const [width, setWidth] = useState<number>(300)
|
|
20
|
+
const [height, setHeight] = useState<number>(100);
|
|
21
|
+
const { mainColor = "#83BFF6", subColor = "#00CED1" } = style || {};
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
useImperativeHandle(ref, () => ({
|
|
25
|
+
updateConfig: (newConfig) => {
|
|
26
|
+
setStyle({ ...newConfig.style });
|
|
27
|
+
setWidth(newConfig.base.width);
|
|
28
|
+
setHeight(newConfig.base.height);
|
|
29
|
+
},
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
return <div className="decoration-9" >
|
|
33
|
+
<svg width={width} height={height}>
|
|
34
|
+
<polygon
|
|
35
|
+
fill={subColor}
|
|
36
|
+
fillOpacity={0.1}
|
|
37
|
+
stroke={subColor}
|
|
38
|
+
points={`20 10, 25 4, 55 4 60 10`}
|
|
39
|
+
/>
|
|
40
|
+
|
|
41
|
+
<polygon
|
|
42
|
+
fill={subColor}
|
|
43
|
+
fillOpacity={0.1}
|
|
44
|
+
stroke={subColor}
|
|
45
|
+
points={`20 ${height - 10}, 25 ${height - 4}, 55 ${height - 4} 60 ${height - 10}`}
|
|
46
|
+
/>
|
|
47
|
+
|
|
48
|
+
<polygon
|
|
49
|
+
fill={subColor}
|
|
50
|
+
fillOpacity={0.1}
|
|
51
|
+
stroke={subColor}
|
|
52
|
+
points={`${width - 20} 10, ${width - 25} 4, ${width - 55} 4 ${width - 60} 10`}
|
|
53
|
+
/>
|
|
54
|
+
|
|
55
|
+
<polygon
|
|
56
|
+
fill={subColor}
|
|
57
|
+
fillOpacity={0.1}
|
|
58
|
+
stroke={subColor}
|
|
59
|
+
points={`${width - 20} ${height - 10}, ${width - 25} ${height - 4}, ${width - 55} ${height - 4} ${width - 60} ${height - 10}`}
|
|
60
|
+
/>
|
|
61
|
+
|
|
62
|
+
<polygon
|
|
63
|
+
fill={mainColor}
|
|
64
|
+
fillOpacity={0.2}
|
|
65
|
+
stroke={mainColor}
|
|
66
|
+
points={`
|
|
67
|
+
20 10, 5 ${height / 2} 20 ${height - 10}
|
|
68
|
+
${width - 20} ${height - 10} ${width - 5} ${height / 2} ${width - 20} 10
|
|
69
|
+
`}
|
|
70
|
+
/>
|
|
71
|
+
|
|
72
|
+
<polyline
|
|
73
|
+
fill='transparent'
|
|
74
|
+
stroke={mainColor}
|
|
75
|
+
strokeOpacity={0.7}
|
|
76
|
+
points={`25 18, 15 ${height / 2} 25 ${height - 18}`}
|
|
77
|
+
/>
|
|
78
|
+
|
|
79
|
+
<polyline
|
|
80
|
+
fill='transparent'
|
|
81
|
+
stroke={mainColor}
|
|
82
|
+
strokeOpacity={0.7}
|
|
83
|
+
points={`${width - 25} 18, ${width - 15} ${height / 2} ${width - 25} ${height - 18}`}
|
|
84
|
+
/>
|
|
85
|
+
</svg>
|
|
86
|
+
</div>;
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
export default Index;
|