@cloudbase/weda-ui 0.2.15 → 1.0.21
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/README.md +41 -169
- package/package.json +28 -15
- package/src/configs/components/calendar.json +78 -0
- package/src/configs/components/carousel.json +273 -0
- package/src/configs/components/chart/bar.json +724 -0
- package/src/configs/components/chart/line.json +679 -0
- package/src/configs/components/chart/pie.json +497 -0
- package/src/configs/components/chart/statisticsCard.json +379 -0
- package/src/configs/components/container.json +7 -2
- package/src/configs/components/dataView.json +154 -0
- package/src/configs/components/form/checkbox.json +97 -5
- package/src/configs/components/form/location.json +152 -0
- package/src/configs/components/form/radio.json +96 -4
- package/src/configs/components/form/select.json +245 -11
- package/src/configs/components/form/uploaderFile.json +2 -1
- package/src/configs/components/graphicCard.json +410 -0
- package/src/configs/components/image.json +7 -2
- package/src/configs/components/link.json +20 -4
- package/src/configs/components/listView.json +277 -0
- package/src/configs/components/modal.json +37 -5
- package/src/configs/components/navLayout.json +362 -0
- package/src/configs/components/navigationBar.json +59 -0
- package/src/configs/components/richtextview.json +4 -1
- package/src/configs/components/scrollVeiw.json +74 -22
- package/src/configs/components/swiper.json +6 -3
- package/src/configs/components/tabs.json +51 -8
- package/src/configs/components/text.json +33 -25
- package/src/configs/components/wxOpenApi/phone.json +141 -0
- package/src/configs/components/wxOpenApi/phoneCode.json +121 -0
- package/src/configs/components/wxOpenApi/share.json +167 -0
- package/src/configs/components/wxOpenApi/userInfo.json +174 -0
- package/src/configs/index.js +34 -0
- package/src/mp/components/button/index.js +12 -13
- package/src/mp/components/button/index.wxml +1 -1
- package/src/mp/components/calendar/arrowright--line.svg +11 -0
- package/src/mp/components/calendar/index.js +238 -0
- package/src/mp/components/calendar/index.json +4 -0
- package/src/mp/components/calendar/index.wxml +37 -0
- package/src/mp/components/calendar/index.wxss +178 -0
- package/src/mp/components/carousel/index.js +88 -0
- package/src/mp/components/carousel/index.json +7 -0
- package/src/mp/components/carousel/index.wxml +6 -0
- package/src/mp/components/chart/bar/index.js +258 -0
- package/src/mp/components/chart/bar/index.json +6 -0
- package/src/mp/components/chart/bar/index.wxml +3 -0
- package/src/mp/components/chart/bar/index.wxss +9 -0
- package/src/mp/components/chart/common/config/bar.js +50 -0
- package/src/mp/components/chart/common/config/global.js +16 -0
- package/src/mp/components/chart/common/config/line.js +48 -0
- package/src/mp/components/chart/common/config/pie.js +36 -0
- package/src/mp/components/chart/common/core/eChartBar.js +263 -0
- package/src/mp/components/chart/common/core/eChartBase.js +375 -0
- package/src/mp/components/chart/common/core/eChartLine.js +229 -0
- package/src/mp/components/chart/common/core/eChartPie.js +166 -0
- package/src/mp/components/chart/common/lib/echarts.min.js +18 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.js +277 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.json +4 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.wxml +4 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.wxss +4 -0
- package/src/mp/components/chart/ec-canvas/wx-canvas.js +107 -0
- package/src/mp/components/chart/line/index.js +247 -0
- package/src/mp/components/chart/line/index.json +6 -0
- package/src/mp/components/chart/line/index.wxml +3 -0
- package/src/mp/components/chart/line/index.wxss +9 -0
- package/src/mp/components/chart/pie/index.js +182 -0
- package/src/mp/components/chart/pie/index.json +6 -0
- package/src/mp/components/chart/pie/index.wxml +4 -0
- package/src/mp/components/chart/pie/index.wxss +9 -0
- package/src/mp/components/chart/statisticsCard/index.js +253 -0
- package/src/mp/components/chart/statisticsCard/index.json +4 -0
- package/src/mp/components/chart/statisticsCard/index.wxml +9 -0
- package/src/mp/components/chart/statisticsCard/index.wxss +45 -0
- package/src/mp/components/dataView/index.js +34 -0
- package/src/mp/components/dataView/index.json +7 -0
- package/src/mp/components/dataView/index.wxml +15 -0
- package/src/mp/components/dataView/index.wxss +0 -0
- package/src/mp/components/form/checkbox/index.js +41 -2
- package/src/mp/components/form/checkbox/index.wxml +1 -1
- package/src/mp/components/form/input/index.js +1 -1
- package/src/mp/components/form/location/components/mapChoose/index.js +201 -0
- package/src/mp/components/form/location/components/mapChoose/index.json +4 -0
- package/src/mp/components/form/location/components/mapChoose/index.wxml +42 -0
- package/src/mp/components/form/location/components/mapChoose/index.wxss +188 -0
- package/src/mp/components/form/location/index.js +382 -0
- package/src/mp/components/form/location/index.json +6 -0
- package/src/mp/components/form/location/index.wxml +25 -0
- package/src/mp/components/form/location/index.wxss +91 -0
- package/src/mp/components/form/radio/index.js +38 -0
- package/src/mp/components/form/select/index.js +360 -40
- package/src/mp/components/form/select/index.wxml +21 -6
- package/src/mp/components/form/select/region/index.js +98 -0
- package/src/mp/components/form/textarea/index.wxml +6 -5
- package/src/mp/components/form/uploader/index.js +84 -48
- package/src/mp/components/form/uploader/index.wxml +15 -3
- package/src/mp/components/form/uploaderFile/index.js +106 -27
- package/src/mp/components/graphicCard/chevron-right.svg +3 -0
- package/src/mp/components/graphicCard/index.js +203 -0
- package/src/mp/components/graphicCard/index.json +4 -0
- package/src/mp/components/graphicCard/index.wxml +29 -0
- package/src/mp/components/graphicCard/index.wxss +157 -0
- package/src/mp/components/image/index.js +0 -1
- package/src/mp/components/listView/arrow-right-line.svg +3 -0
- package/src/mp/components/listView/index.js +285 -0
- package/src/mp/components/listView/index.json +4 -0
- package/src/mp/components/listView/index.wxml +40 -0
- package/src/mp/components/listView/index.wxss +155 -0
- package/src/mp/components/listView/more-line.svg +3 -0
- package/src/mp/components/navLayout/index.js +123 -0
- package/src/mp/components/navLayout/index.json +7 -0
- package/src/mp/components/navLayout/index.wxml +25 -0
- package/src/mp/components/navLayout/index.wxss +1193 -0
- package/src/mp/components/navigationBar/index.js +193 -0
- package/src/mp/components/navigationBar/index.json +6 -0
- package/src/mp/components/navigationBar/index.wxml +88 -0
- package/src/mp/components/navigationBar/index.wxss +1257 -0
- package/src/mp/components/swiper/index.wxml +2 -0
- package/src/mp/components/tabs/index.js +7 -2
- package/src/mp/components/tabs/index.wxml +2 -1
- package/src/mp/components/text/index.js +0 -25
- package/src/mp/components/text/index.wxml +3 -3
- package/src/mp/components/wxOpenApi/phone/index.js +117 -0
- package/src/mp/components/wxOpenApi/phone/index.json +4 -0
- package/src/mp/components/wxOpenApi/phone/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/phone/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.js +89 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.json +4 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/share/index.js +117 -0
- package/src/mp/components/wxOpenApi/share/index.json +4 -0
- package/src/mp/components/wxOpenApi/share/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/share/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/userInfo/index.js +88 -0
- package/src/mp/components/wxOpenApi/userInfo/index.json +4 -0
- package/src/mp/components/wxOpenApi/userInfo/index.wxml +14 -0
- package/src/mp/components/wxOpenApi/userInfo/index.wxss +22 -0
- package/src/mp/index.json +18 -2
- package/src/mp/style/weda-ui.wxss +2 -0
- package/src/mp/utils/debounce.js +133 -0
- package/src/mp/utils/destr.js +48 -0
- package/src/mp/utils/dr_square_point.js +25 -0
- package/src/mp/utils/platform.js +25 -0
- package/src/mp/utils/qqmap-wx-jssdk1.2/qqmap-wx-jssdk.js +1336 -0
- package/src/mp/utils/spark-md5.js +776 -0
- package/src/mp/utils/tcb.js +62 -0
- package/src/setupTests.js +2 -1
- package/src/web/components/button/index.css +8 -1
- package/src/web/components/button/index.tsx +3 -2
- package/src/web/components/calendar/index.css +382 -0
- package/src/web/components/calendar/index.jsx +312 -0
- package/src/web/components/calendar/util.js +90 -0
- package/src/web/components/carousel/index.css +119 -0
- package/src/web/components/carousel/index.tsx +417 -0
- package/src/web/components/chart/bar/index.tsx +140 -0
- package/src/web/components/chart/common/config/bar.js +49 -0
- package/src/web/components/chart/common/config/global.js +16 -0
- package/src/web/components/chart/common/config/line.js +50 -0
- package/src/web/components/chart/common/config/pie.js +37 -0
- package/src/web/components/chart/common/core/eChartBar.js +265 -0
- package/src/web/components/chart/common/core/eChartBase.ts +383 -0
- package/src/web/components/chart/common/core/eChartLine.js +231 -0
- package/src/web/components/chart/common/core/eChartPie.js +170 -0
- package/src/web/components/chart/common/core/type.ts +34 -0
- package/src/web/components/chart/common/echart.css +106 -0
- package/src/web/components/chart/common/echarts.ts +33 -0
- package/src/web/components/chart/common/useChart.tsx +69 -0
- package/src/web/components/chart/line/index.tsx +136 -0
- package/src/web/components/chart/pie/index.tsx +99 -0
- package/src/web/components/chart/statisticsCard/index.css +62 -0
- package/src/web/components/chart/statisticsCard/index.tsx +307 -0
- package/src/web/components/chart/statisticsCard/interface.ts +14 -0
- package/src/web/components/dataView/index.tsx +20 -0
- package/src/web/components/dataView/interface.ts +6 -0
- package/src/web/components/form/checkbox/index.tsx +55 -23
- package/src/web/components/form/location/common/mapChoose.css +178 -0
- package/src/web/components/form/location/common/mapChoose.jsx +343 -0
- package/src/web/components/form/location/common/mapView.jsx +190 -0
- package/src/web/components/form/location/common/propsConfig.js +54 -0
- package/src/web/components/form/location/common/selectModal.css +44 -0
- package/src/web/components/form/location/common/selectModal.jsx +82 -0
- package/src/web/components/form/location/common/useLocationInfo.js +100 -0
- package/src/web/components/form/location/components/LocationH5/index.css +243 -0
- package/src/web/components/form/location/components/LocationH5/location.h5.jsx +403 -0
- package/src/web/components/form/location/components/LocationPC/Header.jsx +109 -0
- package/src/web/components/form/location/components/LocationPC/index.css +44 -0
- package/src/web/components/form/location/components/LocationPC/location.PC.jsx +323 -0
- package/src/web/components/form/location/constants.js +4 -0
- package/src/web/components/form/location/index.css +0 -0
- package/src/web/components/form/location/index.jsx +25 -0
- package/src/web/components/form/radio/index.tsx +84 -53
- package/src/web/components/form/select/h5.tsx +389 -71
- package/src/web/components/form/select/index.css +10 -0
- package/src/web/components/form/select/index.tsx +404 -144
- package/src/web/components/form/select/region/index.ts +122 -31
- package/src/web/components/form/select/time.jsx +90 -0
- package/src/web/components/form/select/year.tsx +170 -0
- package/src/web/components/form/uploader/uploader.h5.tsx +19 -4
- package/src/web/components/form/uploader/uploader.pc.tsx +8 -7
- package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +132 -113
- package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +16 -11
- package/src/web/components/graphicCard/index.css +159 -0
- package/src/web/components/graphicCard/index.tsx +310 -0
- package/src/web/components/image/image.tsx +1 -2
- package/src/web/components/image/index.tsx +1 -1
- package/src/web/components/index.js +24 -2
- package/src/web/components/link/index.tsx +6 -3
- package/src/web/components/listView/arrow-right-line.svg +3 -0
- package/src/web/components/listView/index.css +143 -0
- package/src/web/components/listView/index.tsx +359 -0
- package/src/web/components/listView/interface.ts +98 -0
- package/src/web/components/modal/index.tsx +3 -1
- package/src/web/components/navLayout/index.css +332 -0
- package/src/web/components/navLayout/index.tsx +247 -0
- package/src/web/components/navigationBar/chevron-right--double.svg +3 -0
- package/src/web/components/navigationBar/common.tsx +198 -0
- package/src/web/components/navigationBar/h5Menu.tsx +179 -0
- package/src/web/components/navigationBar/horizontalMenu.tsx +200 -0
- package/src/web/components/navigationBar/index.css +762 -0
- package/src/web/components/navigationBar/index.tsx +231 -0
- package/src/web/components/navigationBar/type.d.ts +111 -0
- package/src/web/components/navigationBar/verticalMenu.tsx +81 -0
- package/src/web/components/phone/index.css +0 -0
- package/src/web/components/phone/index.tsx +22 -0
- package/src/web/components/phoneCode/index.css +0 -0
- package/src/web/components/phoneCode/index.tsx +22 -0
- package/src/web/components/richTextView/index.tsx +3 -5
- package/src/web/components/share/index.css +0 -0
- package/src/web/components/share/index.tsx +38 -0
- package/src/web/components/tabs/index.tsx +4 -2
- package/src/web/components/tabs/tabs.h5.tsx +50 -37
- package/src/web/components/tabs/tabs.pc.tsx +23 -10
- package/src/web/components/text/index.tsx +6 -14
- package/src/web/components/uploaderFileView/index.css +9 -9
- package/src/web/components/uploaderFileView/index.jsx +32 -23
- package/src/web/components/userInfo/index.css +0 -0
- package/src/web/components/userInfo/index.tsx +30 -0
- package/src/web/types.d.ts +15 -14
- package/src/web/utils/debounce.js +98 -0
- package/src/web/utils/platform.js +40 -0
- package/src/web/utils/tcb.js +49 -0
- package/src/web/utils/tmap.js +4 -0
- package/src/web/weda-ui.css +2 -0
- package/CHANGELOG.md +0 -240
- package/src/.DS_Store +0 -0
- package/src/configs/.DS_Store +0 -0
- package/src/mp/.gitignore +0 -10
- package/src/web/.DS_Store +0 -0
- package/src/web/components/form/select/region/cities.ts +0 -2410
- package/src/web/components/form/select/region/provinces.ts +0 -240
- package/src/web/components/form/select/region/regions.ts +0 -20645
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import { CommonPropsType } from '../../../types';
|
|
3
|
+
import { DataSource, Xfield, Yfield } from '../common/core/type';
|
|
4
|
+
import EChartLine from '../common/core/eChartLine';
|
|
5
|
+
import classNames from '../../../utils/classnames';
|
|
6
|
+
import { useWedaChart } from '../common/useChart';
|
|
7
|
+
interface PropsType extends CommonPropsType {
|
|
8
|
+
chartType?: string;
|
|
9
|
+
isTitle?: boolean;
|
|
10
|
+
title?: string;
|
|
11
|
+
titleLocation?: string;
|
|
12
|
+
dataSource?: DataSource;
|
|
13
|
+
filterData?: string;
|
|
14
|
+
xField?: Xfield;
|
|
15
|
+
groupKey?: Xfield;
|
|
16
|
+
groupKeyTimeSpan?: string;
|
|
17
|
+
xStatistics?: string;
|
|
18
|
+
xIsCountEmpty?: boolean;
|
|
19
|
+
yField?: Yfield;
|
|
20
|
+
isLegend?: boolean;
|
|
21
|
+
legend?: string;
|
|
22
|
+
legend2?: string;
|
|
23
|
+
isXaxisName?: boolean;
|
|
24
|
+
xAxisName?: string;
|
|
25
|
+
isXaxisAxisLabelShow?: boolean;
|
|
26
|
+
isXaxisAxisTickShow?: boolean;
|
|
27
|
+
isXaxisAxisLabelRotate?: boolean;
|
|
28
|
+
isYAxisSplitlineLinestyleWidth?: boolean;
|
|
29
|
+
yAxisSplitlineLinestyleType?: string;
|
|
30
|
+
yAxisMax?: number;
|
|
31
|
+
yAxisMin?: number;
|
|
32
|
+
isYAxisName?: boolean;
|
|
33
|
+
yAxisName?: string;
|
|
34
|
+
isSeriesShowSymbol?: boolean;
|
|
35
|
+
isYAxisShow?: boolean;
|
|
36
|
+
isUnit?: boolean;
|
|
37
|
+
unit?: string;
|
|
38
|
+
decimalDigits?: number;
|
|
39
|
+
suffix?: string;
|
|
40
|
+
}
|
|
41
|
+
export default function Line(opts: PropsType) {
|
|
42
|
+
const {
|
|
43
|
+
id,
|
|
44
|
+
style,
|
|
45
|
+
events,
|
|
46
|
+
className,
|
|
47
|
+
children,
|
|
48
|
+
chartType,
|
|
49
|
+
isTitle,
|
|
50
|
+
title,
|
|
51
|
+
titleLocation,
|
|
52
|
+
dataSource,
|
|
53
|
+
filterData,
|
|
54
|
+
xField,
|
|
55
|
+
xStatistics,
|
|
56
|
+
xIsCountEmpty,
|
|
57
|
+
yField,
|
|
58
|
+
groupKey,
|
|
59
|
+
groupKeyTimeSpan,
|
|
60
|
+
isLegend,
|
|
61
|
+
legend,
|
|
62
|
+
legend2,
|
|
63
|
+
isXaxisName,
|
|
64
|
+
xAxisName,
|
|
65
|
+
isXaxisAxisLabelShow,
|
|
66
|
+
isXaxisAxisTickShow,
|
|
67
|
+
isXaxisAxisLabelRotate,
|
|
68
|
+
isYAxisSplitlineLinestyleWidth,
|
|
69
|
+
yAxisSplitlineLinestyleType,
|
|
70
|
+
yAxisMax,
|
|
71
|
+
yAxisMin,
|
|
72
|
+
isYAxisName,
|
|
73
|
+
yAxisName,
|
|
74
|
+
isSeriesShowSymbol,
|
|
75
|
+
isYAxisShow,
|
|
76
|
+
isUnit,
|
|
77
|
+
unit,
|
|
78
|
+
decimalDigits,
|
|
79
|
+
suffix,
|
|
80
|
+
} = opts;
|
|
81
|
+
const domRef = useRef<HTMLDivElement>();
|
|
82
|
+
useWedaChart(domRef, EChartLine, {
|
|
83
|
+
chartType,
|
|
84
|
+
isTitle,
|
|
85
|
+
title,
|
|
86
|
+
titleLocation,
|
|
87
|
+
dataSource,
|
|
88
|
+
filterData,
|
|
89
|
+
xField,
|
|
90
|
+
xStatistics,
|
|
91
|
+
xIsCountEmpty,
|
|
92
|
+
yField,
|
|
93
|
+
groupKey,
|
|
94
|
+
groupKeyTimeSpan,
|
|
95
|
+
isLegend,
|
|
96
|
+
legend,
|
|
97
|
+
legend2,
|
|
98
|
+
isXaxisName,
|
|
99
|
+
xAxisName,
|
|
100
|
+
isXaxisAxisLabelShow,
|
|
101
|
+
isXaxisAxisTickShow,
|
|
102
|
+
isXaxisAxisLabelRotate,
|
|
103
|
+
isYAxisSplitlineLinestyleWidth,
|
|
104
|
+
yAxisSplitlineLinestyleType,
|
|
105
|
+
yAxisMax,
|
|
106
|
+
yAxisMin,
|
|
107
|
+
isYAxisName,
|
|
108
|
+
yAxisName,
|
|
109
|
+
isSeriesShowSymbol,
|
|
110
|
+
isYAxisShow,
|
|
111
|
+
isUnit,
|
|
112
|
+
unit,
|
|
113
|
+
decimalDigits,
|
|
114
|
+
suffix,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const inlineStyle = {
|
|
118
|
+
height: '380px',
|
|
119
|
+
width: '100%',
|
|
120
|
+
backgroundColor: '#ffffff',
|
|
121
|
+
...style,
|
|
122
|
+
};
|
|
123
|
+
return (
|
|
124
|
+
<div
|
|
125
|
+
id={id}
|
|
126
|
+
ref={domRef}
|
|
127
|
+
data-testid="line"
|
|
128
|
+
style={inlineStyle}
|
|
129
|
+
className={classNames({
|
|
130
|
+
'echart-wrapper-canvas': true,
|
|
131
|
+
'echart-dark-body': true,
|
|
132
|
+
[className]: className,
|
|
133
|
+
})}
|
|
134
|
+
/>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import { CommonPropsType } from '../../../types';
|
|
3
|
+
import { DataSource, Xfield, Yfield } from '../common/core/type';
|
|
4
|
+
import EchartPie from '../common/core/eChartPie';
|
|
5
|
+
import { useWedaChart } from '../common/useChart';
|
|
6
|
+
import classNames from '../../../utils/classnames';
|
|
7
|
+
|
|
8
|
+
interface PropsType extends CommonPropsType {
|
|
9
|
+
chartType?: string;
|
|
10
|
+
isTitle?: boolean;
|
|
11
|
+
title?: string;
|
|
12
|
+
titleLocation?: string;
|
|
13
|
+
dataSource?: DataSource;
|
|
14
|
+
filterData?: string;
|
|
15
|
+
setColor?: Array<string>;
|
|
16
|
+
xField?: Xfield;
|
|
17
|
+
xStatistics?: string;
|
|
18
|
+
xIsCountEmpty?: boolean;
|
|
19
|
+
yField?: Yfield;
|
|
20
|
+
isLegend?: boolean;
|
|
21
|
+
legend?: string;
|
|
22
|
+
legend2?: string;
|
|
23
|
+
isSeriesShowSymbol?: boolean;
|
|
24
|
+
isPercent?: boolean;
|
|
25
|
+
isUnit?: boolean;
|
|
26
|
+
unit?: string;
|
|
27
|
+
decimalDigits?: number;
|
|
28
|
+
suffix?: string;
|
|
29
|
+
}
|
|
30
|
+
export default function Line({
|
|
31
|
+
id,
|
|
32
|
+
style,
|
|
33
|
+
events,
|
|
34
|
+
className,
|
|
35
|
+
children,
|
|
36
|
+
chartType,
|
|
37
|
+
isTitle,
|
|
38
|
+
title,
|
|
39
|
+
titleLocation,
|
|
40
|
+
dataSource,
|
|
41
|
+
filterData,
|
|
42
|
+
setColor,
|
|
43
|
+
xField,
|
|
44
|
+
xStatistics,
|
|
45
|
+
xIsCountEmpty,
|
|
46
|
+
yField,
|
|
47
|
+
isLegend,
|
|
48
|
+
legend,
|
|
49
|
+
legend2,
|
|
50
|
+
isSeriesShowSymbol,
|
|
51
|
+
isPercent,
|
|
52
|
+
isUnit,
|
|
53
|
+
unit,
|
|
54
|
+
decimalDigits,
|
|
55
|
+
suffix,
|
|
56
|
+
}: PropsType) {
|
|
57
|
+
const domRef = useRef<HTMLDivElement>();
|
|
58
|
+
useWedaChart(domRef, EchartPie, {
|
|
59
|
+
chartType,
|
|
60
|
+
isTitle,
|
|
61
|
+
title,
|
|
62
|
+
titleLocation,
|
|
63
|
+
dataSource,
|
|
64
|
+
filterData,
|
|
65
|
+
setColor,
|
|
66
|
+
xField,
|
|
67
|
+
xStatistics,
|
|
68
|
+
xIsCountEmpty,
|
|
69
|
+
yField,
|
|
70
|
+
isLegend,
|
|
71
|
+
legend,
|
|
72
|
+
legend2,
|
|
73
|
+
isSeriesShowSymbol,
|
|
74
|
+
isPercent,
|
|
75
|
+
isUnit,
|
|
76
|
+
unit,
|
|
77
|
+
decimalDigits,
|
|
78
|
+
suffix,
|
|
79
|
+
});
|
|
80
|
+
const inlineStyle = {
|
|
81
|
+
height: '380px',
|
|
82
|
+
width: '100%',
|
|
83
|
+
backgroundColor: '#ffffff',
|
|
84
|
+
...style,
|
|
85
|
+
};
|
|
86
|
+
return (
|
|
87
|
+
<div
|
|
88
|
+
id={id}
|
|
89
|
+
data-testid="pie"
|
|
90
|
+
ref={domRef}
|
|
91
|
+
style={inlineStyle}
|
|
92
|
+
className={classNames({
|
|
93
|
+
'echart-wrapper-canvas': true,
|
|
94
|
+
'echart-dark-body': true,
|
|
95
|
+
[className]: className,
|
|
96
|
+
})}
|
|
97
|
+
/>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/* pc style */
|
|
2
|
+
.weda-statistics-card {
|
|
3
|
+
background: #ffffff;
|
|
4
|
+
border: 1px solid #f1f2f5;
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.1);
|
|
7
|
+
border-radius: 6px;
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
}
|
|
10
|
+
.weda-statistics-card.weda-statistics-card-pc {
|
|
11
|
+
width: 276px;
|
|
12
|
+
min-height: 128px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.weda-statistics-card .weda-statistics-card__wrapper {
|
|
16
|
+
width: 100%;
|
|
17
|
+
padding: 28px 24px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.weda-statistics-card .weda-statistics-card__title {
|
|
21
|
+
font-size: 14px;
|
|
22
|
+
line-height: 22px;
|
|
23
|
+
color: rgba(0, 0, 0, 0.6);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.weda-statistics-card .weda-statistics-card__detail {
|
|
27
|
+
margin-top: 8px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.weda-statistics-card .weda-statistics-card__count {
|
|
31
|
+
font-size: 32px;
|
|
32
|
+
line-height: 44px;
|
|
33
|
+
color: rgba(0, 0, 0, 0.9);
|
|
34
|
+
word-break: break-all;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.weda-statistics-card .weda-statistics-card__unit {
|
|
38
|
+
font-size: 14px;
|
|
39
|
+
line-height: 22px;
|
|
40
|
+
color: rgba(0, 0, 0, 0.4);
|
|
41
|
+
margin-left: 4px;
|
|
42
|
+
vertical-align: middle;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* h5 style */
|
|
46
|
+
.weda-statistics-card.weda-statistics-card-mobile {
|
|
47
|
+
max-width: 100%;
|
|
48
|
+
min-height: 140px;
|
|
49
|
+
}
|
|
50
|
+
.weda-statistics-card-mobile .weda-statistics-card__wrapper {
|
|
51
|
+
width: 100%;
|
|
52
|
+
padding: 40px 24px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.weda-statistics-card-mobile .weda-statistics-card__detail {
|
|
56
|
+
margin-top: 4px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.weda-statistics-card-mobile .weda-statistics-card__count {
|
|
60
|
+
font-size: 28px;
|
|
61
|
+
line-height: 34px;
|
|
62
|
+
}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
2
|
+
import { CommonPropsType } from '../../../types';
|
|
3
|
+
import './index.css';
|
|
4
|
+
import classNames from '../../../utils/classnames';
|
|
5
|
+
import { ConfigProvider } from 'tea-component';
|
|
6
|
+
import { usePlatform } from '../../../utils/platform';
|
|
7
|
+
import { IDataSource, IField } from './interface';
|
|
8
|
+
import { useDeepCompareEffect, useIsMounted } from '@react-hookz/web';
|
|
9
|
+
import { callDataSource, callWedaApi } from '../../../utils/tcb';
|
|
10
|
+
|
|
11
|
+
interface PropsType extends CommonPropsType {
|
|
12
|
+
/**
|
|
13
|
+
* 数据源
|
|
14
|
+
*/
|
|
15
|
+
dataSource?: IDataSource;
|
|
16
|
+
/**
|
|
17
|
+
* 数据筛选
|
|
18
|
+
*/
|
|
19
|
+
filterData?: any;
|
|
20
|
+
/**
|
|
21
|
+
* 字段
|
|
22
|
+
*/
|
|
23
|
+
field?: IField;
|
|
24
|
+
/**
|
|
25
|
+
* 统计方式
|
|
26
|
+
*/
|
|
27
|
+
operationType?: string;
|
|
28
|
+
/**
|
|
29
|
+
* 字段展示名称
|
|
30
|
+
*/
|
|
31
|
+
label?: string;
|
|
32
|
+
/**
|
|
33
|
+
* 是否统计空值
|
|
34
|
+
*/
|
|
35
|
+
isCountEmpty?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* 是否显示单位
|
|
38
|
+
*/
|
|
39
|
+
isShowUnit?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* 单位
|
|
42
|
+
*/
|
|
43
|
+
unit?: number;
|
|
44
|
+
/**
|
|
45
|
+
* 小数位数
|
|
46
|
+
*/
|
|
47
|
+
decimalDigits?: number;
|
|
48
|
+
/**
|
|
49
|
+
* 后缀
|
|
50
|
+
*/
|
|
51
|
+
suffix?: number;
|
|
52
|
+
/**
|
|
53
|
+
* app.cloud 对象依赖,默认会从 window.app 取值
|
|
54
|
+
*/
|
|
55
|
+
appCloud?: { callDataSource?: any; callWedaApi?: any };
|
|
56
|
+
/**
|
|
57
|
+
* 其他属性
|
|
58
|
+
*/
|
|
59
|
+
[key: string]: any;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const CLASS_PREFIX = 'weda-statistics-card';
|
|
63
|
+
// 默认显示值
|
|
64
|
+
const defaultVal = 1000;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 修复科学计数法问题
|
|
68
|
+
* @param num 小数
|
|
69
|
+
* @returns {string}
|
|
70
|
+
*/
|
|
71
|
+
export function scientificToNumber(num) {
|
|
72
|
+
const str = num;
|
|
73
|
+
const reg = /^([-]?\d+\.?\d*)(e)([-|+]?\d+)$/;
|
|
74
|
+
let zero = '';
|
|
75
|
+
if (!reg.test(str)) {
|
|
76
|
+
return num;
|
|
77
|
+
}
|
|
78
|
+
const arr = reg.exec(str);
|
|
79
|
+
const len = Math.abs(+arr[3]) - 1;
|
|
80
|
+
for (let i = 0; i < len; i += 1) {
|
|
81
|
+
zero += '0';
|
|
82
|
+
}
|
|
83
|
+
if (arr[1].indexOf('-') === 0) {
|
|
84
|
+
return `-0.${zero}${arr[1].replace('-', '').replace('.', '')}`;
|
|
85
|
+
}
|
|
86
|
+
return `0.${zero}${arr[1].replace('.', '')}`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* 补齐小数位数0
|
|
91
|
+
* @param source 源字符串
|
|
92
|
+
* @param targetLength 目标长度
|
|
93
|
+
* @returns {string}
|
|
94
|
+
*/
|
|
95
|
+
export function padEnd(source, targetLength) {
|
|
96
|
+
targetLength = Math.floor(targetLength); //floor if number or convert non-number to 0;
|
|
97
|
+
if (source.length > targetLength) {
|
|
98
|
+
return source;
|
|
99
|
+
} else {
|
|
100
|
+
targetLength = targetLength - source.length;
|
|
101
|
+
return source + '0'.repeat(targetLength);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 修复toFixed四舍五入不准确问题
|
|
107
|
+
* @param num
|
|
108
|
+
* @param digit 小数位数
|
|
109
|
+
* @returns {string}
|
|
110
|
+
*/
|
|
111
|
+
export function customToFixed(num, digit = 0) {
|
|
112
|
+
const pow = Math.pow(10, digit);
|
|
113
|
+
let value = `${num}`;
|
|
114
|
+
// 如果是小数,四舍五入进行转化处理确保精度正确
|
|
115
|
+
if (!Number.isInteger(num)) {
|
|
116
|
+
if (num > 0) {
|
|
117
|
+
value = (Math.round((num + Number.EPSILON) * pow) / pow).toString();
|
|
118
|
+
} else if (num < 0) {
|
|
119
|
+
value = (Math.round((num - Number.EPSILON) * pow) / pow).toString();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
value = scientificToNumber(value);
|
|
123
|
+
const [integer, decimal = ''] = value.split('.');
|
|
124
|
+
if (digit > 0) {
|
|
125
|
+
return `${integer}.${padEnd(decimal, digit)}`;
|
|
126
|
+
}
|
|
127
|
+
return integer;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* 添加千位分隔符
|
|
132
|
+
* @param fixedString
|
|
133
|
+
* @param digit
|
|
134
|
+
*/
|
|
135
|
+
export function addDelimiter(fixedString, digit) {
|
|
136
|
+
let len = fixedString.length;
|
|
137
|
+
let result = '';
|
|
138
|
+
const decimalPoint = digit > 0 ? digit + 1 : 0;
|
|
139
|
+
for (let i = len - 1; i >= 0; i--) {
|
|
140
|
+
let stepFromTail = len - 1 - i;
|
|
141
|
+
let char = fixedString.charAt(i);
|
|
142
|
+
|
|
143
|
+
if (stepFromTail <= decimalPoint) {
|
|
144
|
+
// 小数部分不处理
|
|
145
|
+
result = char + result;
|
|
146
|
+
} else {
|
|
147
|
+
if ((stepFromTail - decimalPoint) % 3 === 0) {
|
|
148
|
+
if (char !== '-') {
|
|
149
|
+
result = ',' + result;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
result = char + result;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return result;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* 格式化:添加千分符,四舍五入
|
|
160
|
+
* @param val
|
|
161
|
+
* @param digits
|
|
162
|
+
*/
|
|
163
|
+
const formatNumber = (val, digits = 0) => {
|
|
164
|
+
return isNaN(val) ? val : addDelimiter(customToFixed(val, digits), digits);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export default function StatisticsCard({
|
|
168
|
+
dataSource,
|
|
169
|
+
filterData,
|
|
170
|
+
field,
|
|
171
|
+
operationType,
|
|
172
|
+
label,
|
|
173
|
+
isCountEmpty,
|
|
174
|
+
isShowUnit,
|
|
175
|
+
unit,
|
|
176
|
+
decimalDigits,
|
|
177
|
+
suffix,
|
|
178
|
+
className,
|
|
179
|
+
style,
|
|
180
|
+
events,
|
|
181
|
+
id,
|
|
182
|
+
role,
|
|
183
|
+
appCloud = { callDataSource, callWedaApi },
|
|
184
|
+
}: PropsType) {
|
|
185
|
+
const [val, setVal] = useState(defaultVal);
|
|
186
|
+
const isMounted = useIsMounted();
|
|
187
|
+
|
|
188
|
+
async function getSourceData(
|
|
189
|
+
dataSource,
|
|
190
|
+
filterData,
|
|
191
|
+
field,
|
|
192
|
+
operationType,
|
|
193
|
+
isCountEmpty
|
|
194
|
+
) {
|
|
195
|
+
const where = filterData?.map
|
|
196
|
+
? filterData.map((val) => {
|
|
197
|
+
let arrLogicData = val.logicData;
|
|
198
|
+
if (val.logicData && val.logicData.length > 0) {
|
|
199
|
+
arrLogicData = val.logicData.map((mval) => {
|
|
200
|
+
return {
|
|
201
|
+
Key: mval.key,
|
|
202
|
+
Rel: mval.rel,
|
|
203
|
+
Value: mval.value,
|
|
204
|
+
Logic: mval.logic,
|
|
205
|
+
};
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
return {
|
|
209
|
+
GroupLogic: val.groupLogic,
|
|
210
|
+
LogicData: arrLogicData,
|
|
211
|
+
};
|
|
212
|
+
})
|
|
213
|
+
: [];
|
|
214
|
+
const params = {
|
|
215
|
+
dataSourceName: dataSource?.name,
|
|
216
|
+
where,
|
|
217
|
+
value: [
|
|
218
|
+
{
|
|
219
|
+
Key: field?.name,
|
|
220
|
+
OperationType: operationType,
|
|
221
|
+
IsCountEmpty: isCountEmpty,
|
|
222
|
+
},
|
|
223
|
+
],
|
|
224
|
+
};
|
|
225
|
+
try {
|
|
226
|
+
if (dataSource?.type === 'database') {
|
|
227
|
+
return await appCloud?.callWedaApi({
|
|
228
|
+
action: 'DescribeChartCardData',
|
|
229
|
+
data: params,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
return await appCloud?.callDataSource({
|
|
233
|
+
dataSourceName: dataSource?.name,
|
|
234
|
+
methodName: dataSource?.methodName,
|
|
235
|
+
});
|
|
236
|
+
} catch {
|
|
237
|
+
return [];
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const initCard = async () => {
|
|
242
|
+
// 内部数据源需要字段和统计方式,外部数据源不需要
|
|
243
|
+
if (
|
|
244
|
+
(dataSource?.type === 'database' && field && operationType) ||
|
|
245
|
+
(dataSource && dataSource?.type !== 'database')
|
|
246
|
+
) {
|
|
247
|
+
let data = await getSourceData(
|
|
248
|
+
dataSource,
|
|
249
|
+
filterData,
|
|
250
|
+
field,
|
|
251
|
+
operationType,
|
|
252
|
+
isCountEmpty
|
|
253
|
+
);
|
|
254
|
+
// 自定义连接器 返回处理
|
|
255
|
+
if (dataSource?.type !== 'database' && data?.result) {
|
|
256
|
+
data = data?.result;
|
|
257
|
+
}
|
|
258
|
+
if (data?.length) {
|
|
259
|
+
const val = isNaN(data[0]?.Value) ? 0 : data[0]?.Value;
|
|
260
|
+
isMounted && setVal(val);
|
|
261
|
+
} else {
|
|
262
|
+
// 返回数据为空 使用 0
|
|
263
|
+
isMounted && setVal(0);
|
|
264
|
+
}
|
|
265
|
+
} else {
|
|
266
|
+
// 没有配置数据使用默认数据
|
|
267
|
+
isMounted && setVal(defaultVal);
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
useDeepCompareEffect(() => {
|
|
272
|
+
initCard();
|
|
273
|
+
}, [dataSource, filterData, field, operationType, isCountEmpty]);
|
|
274
|
+
|
|
275
|
+
const platform = usePlatform();
|
|
276
|
+
const cls = classNames({
|
|
277
|
+
'weda-ui': true,
|
|
278
|
+
[CLASS_PREFIX]: true,
|
|
279
|
+
[className]: className,
|
|
280
|
+
[`${CLASS_PREFIX}-mobile`]: platform === 'h5',
|
|
281
|
+
[`${CLASS_PREFIX}-pc`]: platform !== 'h5',
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
return (
|
|
285
|
+
<ConfigProvider classPrefix="wedatea2td">
|
|
286
|
+
<div
|
|
287
|
+
id={id}
|
|
288
|
+
role={role}
|
|
289
|
+
className={cls}
|
|
290
|
+
style={style}
|
|
291
|
+
onClick={(e) => events.tap({}, { originEvent: e })}
|
|
292
|
+
>
|
|
293
|
+
<div className={`${CLASS_PREFIX}__wrapper`}>
|
|
294
|
+
<div className={`${CLASS_PREFIX}__title`}>{label}</div>
|
|
295
|
+
<div className={`${CLASS_PREFIX}__detail`}>
|
|
296
|
+
<div className={`${CLASS_PREFIX}__count`}>
|
|
297
|
+
{isShowUnit ? formatNumber(val / unit, decimalDigits) : val}
|
|
298
|
+
{isShowUnit && (
|
|
299
|
+
<label className={`${CLASS_PREFIX}__unit`}>{suffix}</label>
|
|
300
|
+
)}
|
|
301
|
+
</div>
|
|
302
|
+
</div>
|
|
303
|
+
</div>
|
|
304
|
+
</div>
|
|
305
|
+
</ConfigProvider>
|
|
306
|
+
);
|
|
307
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface IDataSource {
|
|
2
|
+
name: string; // 数据源名
|
|
3
|
+
type: string; // 数据源类型
|
|
4
|
+
subType: string; // 数据源子类型
|
|
5
|
+
provider?: string; // 内置连接器类型
|
|
6
|
+
methodName: string; // 数据源方法名
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface IField {
|
|
10
|
+
format: string;
|
|
11
|
+
type: string;
|
|
12
|
+
title: string;
|
|
13
|
+
name: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IDataView } from './interface';
|
|
3
|
+
import ListView from '../listView';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 数据容器-列表视图
|
|
7
|
+
*/
|
|
8
|
+
export default function DataView(props: IDataView) {
|
|
9
|
+
return (
|
|
10
|
+
<ListView
|
|
11
|
+
{...props}
|
|
12
|
+
orderBy={undefined}
|
|
13
|
+
orderType={undefined}
|
|
14
|
+
template="none"
|
|
15
|
+
pageSize={1}
|
|
16
|
+
pagination="none"
|
|
17
|
+
beforeDataChange={(values) => values?.[0]}
|
|
18
|
+
/>
|
|
19
|
+
);
|
|
20
|
+
}
|