@cloudbase/weda-ui 0.2.16 → 1.0.24
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 +23 -11
- package/src/configs/components/calendar.json +4 -1
- 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 +61 -13
- package/src/configs/components/container.json +7 -2
- package/src/configs/components/dataView.json +21 -6
- package/src/configs/components/form/checkbox.json +97 -5
- package/src/configs/components/form/radio.json +96 -4
- package/src/configs/components/form/select.json +245 -11
- package/src/configs/components/graphicCard.json +84 -73
- package/src/configs/components/image.json +7 -2
- package/src/configs/components/link.json +19 -3
- package/src/configs/components/listView.json +65 -18
- package/src/configs/components/lottery.json +151 -0
- package/src/configs/components/modal.json +37 -5
- package/src/configs/components/navLayout.json +87 -75
- 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 +4 -1
- 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 +20 -0
- package/src/index.js +2 -0
- package/src/mp/components/button/index.wxml +1 -2
- 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 +33 -6
- 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/form/index.wxml +1 -2
- package/src/mp/components/form/input/index.js +1 -1
- package/src/mp/components/form/location/index.js +43 -2
- package/src/mp/components/form/radio/index.js +38 -0
- package/src/mp/components/form/select/index.js +348 -40
- package/src/mp/components/form/select/index.wxml +21 -6
- package/src/mp/components/form/select/region/index.js +101 -0
- package/src/mp/components/form/textarea/index.wxml +6 -5
- package/src/mp/components/form/uploader/index.js +76 -44
- package/src/mp/components/form/uploader/index.wxml +15 -3
- package/src/mp/components/form/uploaderFile/index.js +61 -29
- package/src/mp/components/graphicCard/index.js +26 -28
- package/src/mp/components/listView/index.js +52 -64
- package/src/mp/components/listView/index.wxml +2 -2
- package/src/mp/components/listView/index.wxss +5 -0
- package/src/mp/components/lottery/index.js +270 -0
- package/src/mp/components/lottery/index.json +4 -0
- package/src/mp/components/lottery/index.wxml +43 -0
- package/src/mp/components/lottery/index.wxss +317 -0
- package/src/mp/components/navLayout/index.js +3 -3
- 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/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 +10 -1
- package/src/mp/style/weda-ui.wxss +2 -0
- package/src/mp/utils/constant.js +15 -0
- package/src/mp/utils/destr.js +48 -0
- package/src/mp/utils/lodash.js +2 -0
- package/src/mp/utils/platform.js +25 -0
- package/src/mp/utils/tcb.js +44 -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/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.tsx +29 -8
- package/src/web/components/form/checkbox/index.tsx +61 -23
- package/src/web/components/form/formcell/index.tsx +10 -5
- package/src/web/components/form/location/components/LocationH5/location.h5.jsx +3 -3
- package/src/web/components/form/location/components/LocationPC/location.PC.jsx +2 -2
- package/src/web/components/form/radio/index.tsx +90 -53
- package/src/web/components/form/select/h5.tsx +371 -72
- package/src/web/components/form/select/index.css +10 -0
- package/src/web/components/form/select/index.tsx +392 -145
- 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/tips/index.css +4 -0
- package/src/web/components/form/tips/index.tsx +4 -3
- package/src/web/components/form/uploader/uploader.h5.tsx +28 -19
- package/src/web/components/form/uploader/uploader.pc.tsx +17 -20
- package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +48 -44
- package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +28 -26
- package/src/web/components/graphicCard/index.css +1 -5
- package/src/web/components/graphicCard/index.tsx +4 -3
- package/src/web/components/image/image.tsx +1 -1
- package/src/web/components/image/index.tsx +1 -1
- package/src/web/components/index.js +13 -2
- package/src/web/components/link/index.tsx +6 -3
- package/src/web/components/listView/index.css +4 -0
- package/src/web/components/listView/index.tsx +10 -18
- package/src/web/components/lottery/index.css +327 -0
- package/src/web/components/lottery/index.tsx +567 -0
- package/src/web/components/lottery/lotteryUtil.ts +130 -0
- package/src/web/components/modal/index.tsx +3 -1
- 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 +2 -0
- package/src/web/components/tabs/tabs.h5.tsx +43 -33
- package/src/web/components/tabs/tabs.pc.tsx +23 -10
- package/src/web/components/text/index.tsx +6 -14
- package/src/web/components/userInfo/index.css +0 -0
- package/src/web/components/userInfo/index.tsx +30 -0
- package/src/web/utils/{constant.js → constant.ts} +17 -2
- package/src/web/utils/lodash.ts +2 -0
- package/src/web/utils/platform.js +10 -1
- package/src/web/utils/tcb.js +20 -6
- 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
|
+
}
|
|
@@ -127,20 +127,41 @@ export function customToFixed(num, digit = 0) {
|
|
|
127
127
|
return integer;
|
|
128
128
|
}
|
|
129
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
|
+
|
|
130
158
|
/**
|
|
131
159
|
* 格式化:添加千分符,四舍五入
|
|
132
160
|
* @param val
|
|
133
161
|
* @param digits
|
|
134
162
|
*/
|
|
135
163
|
const formatNumber = (val, digits = 0) => {
|
|
136
|
-
return isNaN(val)
|
|
137
|
-
? val
|
|
138
|
-
: Intl
|
|
139
|
-
? Intl.NumberFormat('en-US', {
|
|
140
|
-
maximumFractionDigits: 10,
|
|
141
|
-
minimumFractionDigits: digits,
|
|
142
|
-
}).format(+customToFixed(val, digits))
|
|
143
|
-
: val;
|
|
164
|
+
return isNaN(val) ? val : addDelimiter(customToFixed(val, digits), digits);
|
|
144
165
|
};
|
|
145
166
|
|
|
146
167
|
export default function StatisticsCard({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { Checkbox as TeaCheckbox, ConfigProvider } from 'tea-component';
|
|
3
3
|
|
|
4
4
|
import classNames from '../../../utils/classnames';
|
|
@@ -8,6 +8,8 @@ import fromEntries from 'object.fromentries';
|
|
|
8
8
|
import { usePlatform } from '../../../utils/platform';
|
|
9
9
|
import { renderDecorator } from '../renderDecorator';
|
|
10
10
|
import { CommonFormPropsType } from '../types';
|
|
11
|
+
import { callWedaApi } from '../../../utils/tcb';
|
|
12
|
+
import destr from 'destr';
|
|
11
13
|
|
|
12
14
|
export default function Checkbox({
|
|
13
15
|
// 系统属性
|
|
@@ -19,6 +21,8 @@ export default function Checkbox({
|
|
|
19
21
|
name = 'formCheckbox',
|
|
20
22
|
label = '标题',
|
|
21
23
|
labelVisible = true,
|
|
24
|
+
format = '',
|
|
25
|
+
enumName = '',
|
|
22
26
|
range = [],
|
|
23
27
|
layout = 'horizontal',
|
|
24
28
|
disabled = false,
|
|
@@ -40,21 +44,53 @@ export default function Checkbox({
|
|
|
40
44
|
'weui-cell_disabled': isH5 && disabled,
|
|
41
45
|
});
|
|
42
46
|
|
|
47
|
+
const [option, setOption] = useState(range);
|
|
43
48
|
const [checkedItems, setCheckedItems] = React.useState(
|
|
44
|
-
platform === 'h5' ? fromEntries(
|
|
45
|
-
|
|
49
|
+
platform === 'h5' ? fromEntries(option.map(({ value, checked }) => [value, !!checked]))
|
|
50
|
+
: option.filter(({ checked }) => checked).map(({ value }) => value)
|
|
46
51
|
);
|
|
47
52
|
// 两次range不同时, 需要刷新checkedItems
|
|
48
53
|
const prevRangeRef = React.useRef<object[]>();
|
|
49
54
|
React.useEffect(() => {
|
|
50
|
-
if (!isObjectEqual(prevRangeRef.current,
|
|
51
|
-
prevRangeRef.current =
|
|
55
|
+
if (!isObjectEqual(prevRangeRef.current, option)) {
|
|
56
|
+
prevRangeRef.current = option;
|
|
52
57
|
setCheckedItems(
|
|
53
|
-
fromEntries(
|
|
58
|
+
fromEntries(option.map(({ value, checked }) => [value, !!checked]))
|
|
54
59
|
);
|
|
55
60
|
}
|
|
56
61
|
});
|
|
57
62
|
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
// 如果绑定字段类型为枚举,且传入自定义选项集的名称则默认使用自定义选项集的内容作为选项
|
|
65
|
+
if (format === 'x-enum' && enumName) {
|
|
66
|
+
fetchData({ OptNameList: [enumName], PageIndex: 1, PageSize: 10 });
|
|
67
|
+
}
|
|
68
|
+
}, []);
|
|
69
|
+
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (format !== 'x-enum') {
|
|
72
|
+
setOption(range)
|
|
73
|
+
}
|
|
74
|
+
}, [range]);
|
|
75
|
+
|
|
76
|
+
const fetchData = async (param:
|
|
77
|
+
{ OptNameList?: object, PageIndex?: number, PageSize?: number }
|
|
78
|
+
) => {
|
|
79
|
+
let data = await callWedaApi({
|
|
80
|
+
action: 'DescribeGeneralOptionsDetailList',
|
|
81
|
+
data: param,
|
|
82
|
+
});
|
|
83
|
+
const config = destr(data?.Items?.[0]?.Config) ?? [];
|
|
84
|
+
const enumOption = config.map(item => {
|
|
85
|
+
return {
|
|
86
|
+
label: item.value,
|
|
87
|
+
value: item.key,
|
|
88
|
+
checked: false
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
setOption(enumOption);
|
|
92
|
+
};
|
|
93
|
+
|
|
58
94
|
/**
|
|
59
95
|
* 在ios h5端, label和input的绑定不生效
|
|
60
96
|
* 导致 onChange 事件触发有问题, 所以改为监听 onClick 事件
|
|
@@ -82,8 +118,8 @@ export default function Checkbox({
|
|
|
82
118
|
// 现在低码组件往源码组件传入的id不唯一, 暂时使用hashcode替代
|
|
83
119
|
const hashcode = React.useMemo(() => getLocalCounter(), []);
|
|
84
120
|
let checkboxElement;
|
|
85
|
-
if(platform === 'h5') {
|
|
86
|
-
checkboxElement =
|
|
121
|
+
if (platform === 'h5') {
|
|
122
|
+
checkboxElement = option.map(({ label, value }, index) => {
|
|
87
123
|
const _id = `checkbox-${hashcode}-${index}`;
|
|
88
124
|
const _name = `checkbox-${hashcode}-${name}`;
|
|
89
125
|
return (
|
|
@@ -120,17 +156,17 @@ export default function Checkbox({
|
|
|
120
156
|
.map(([value]) => value)
|
|
121
157
|
}
|
|
122
158
|
onChange={value => {
|
|
123
|
-
const newMap =
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
159
|
+
const newMap = option
|
|
160
|
+
.map((opt) => opt.value)
|
|
161
|
+
.reduce((acc, cur) => {
|
|
162
|
+
const idx = value.indexOf(cur);
|
|
163
|
+
if (idx < 0) {
|
|
164
|
+
acc[cur] = false;
|
|
165
|
+
} else {
|
|
166
|
+
acc[cur] = true;
|
|
167
|
+
}
|
|
168
|
+
return acc;
|
|
169
|
+
}, {});
|
|
134
170
|
setCheckedItems(newMap);
|
|
135
171
|
events.change(
|
|
136
172
|
{
|
|
@@ -141,7 +177,7 @@ export default function Checkbox({
|
|
|
141
177
|
);
|
|
142
178
|
}}
|
|
143
179
|
>
|
|
144
|
-
{
|
|
180
|
+
{option.map(({ value, label }, index) => {
|
|
145
181
|
const _id = `checkbox-${hashcode}-${index}`;
|
|
146
182
|
return (
|
|
147
183
|
<TeaCheckbox key={_id} name={value} id={_id}>
|
|
@@ -149,7 +185,7 @@ export default function Checkbox({
|
|
|
149
185
|
</TeaCheckbox>
|
|
150
186
|
);
|
|
151
187
|
})}
|
|
152
|
-
|
|
188
|
+
</TeaCheckbox.Group>
|
|
153
189
|
</ConfigProvider>
|
|
154
190
|
);
|
|
155
191
|
}
|
|
@@ -167,5 +203,7 @@ export default function Checkbox({
|
|
|
167
203
|
}
|
|
168
204
|
|
|
169
205
|
export interface PropsType extends CommonFormPropsType {
|
|
170
|
-
range?: {label: string, value: any;
|
|
171
|
-
|
|
206
|
+
range?: { label: string, value: any;[key: string]: any }[];
|
|
207
|
+
format?: string;
|
|
208
|
+
enumName?: string;
|
|
209
|
+
}
|
|
@@ -14,13 +14,13 @@ export default function FormCell({
|
|
|
14
14
|
children,
|
|
15
15
|
multiCell,
|
|
16
16
|
requiredFlag,
|
|
17
|
-
size
|
|
17
|
+
size,
|
|
18
18
|
}: PropsType) {
|
|
19
19
|
const platform = usePlatform();
|
|
20
20
|
const isFlex = layout !== 'vertical';
|
|
21
21
|
|
|
22
|
-
if(platform === 'pc') {
|
|
23
|
-
return (
|
|
22
|
+
if (platform === 'pc') {
|
|
23
|
+
return (
|
|
24
24
|
<ConfigProvider classPrefix="wedatea2td">
|
|
25
25
|
<TeaForm.Item
|
|
26
26
|
style={style}
|
|
@@ -31,9 +31,14 @@ export default function FormCell({
|
|
|
31
31
|
'weda-formcells__pc': !!label,
|
|
32
32
|
'weda-formcells__full-width': size === 'full',
|
|
33
33
|
[layout]: layout,
|
|
34
|
-
[className]: [className]
|
|
34
|
+
[className]: [className],
|
|
35
35
|
})}
|
|
36
|
-
label={
|
|
36
|
+
label={
|
|
37
|
+
<>
|
|
38
|
+
{requiredFlag && <span className="weda-formcells__flag">*</span>}
|
|
39
|
+
{label}
|
|
40
|
+
</>
|
|
41
|
+
}
|
|
37
42
|
>
|
|
38
43
|
{children}
|
|
39
44
|
</TeaForm.Item>
|
|
@@ -77,7 +77,7 @@ export default function LocationH5(props) {
|
|
|
77
77
|
value: {
|
|
78
78
|
address: poiname,
|
|
79
79
|
geopoint: {
|
|
80
|
-
coordinates: [
|
|
80
|
+
coordinates: [lng, lat],
|
|
81
81
|
type: 'Point',
|
|
82
82
|
},
|
|
83
83
|
},
|
|
@@ -176,7 +176,7 @@ export default function LocationH5(props) {
|
|
|
176
176
|
value: {
|
|
177
177
|
address: city + addr,
|
|
178
178
|
geopoint: {
|
|
179
|
-
coordinates: [
|
|
179
|
+
coordinates: [lng, lat],
|
|
180
180
|
type: 'Point',
|
|
181
181
|
},
|
|
182
182
|
},
|
|
@@ -283,7 +283,7 @@ export default function LocationH5(props) {
|
|
|
283
283
|
value: {
|
|
284
284
|
address: poiname,
|
|
285
285
|
geopoint: {
|
|
286
|
-
coordinates: [latlng.
|
|
286
|
+
coordinates: [latlng.lng, latlng.lat],
|
|
287
287
|
type: 'Point',
|
|
288
288
|
},
|
|
289
289
|
},
|
|
@@ -58,7 +58,7 @@ export default function LocationPC(props) {
|
|
|
58
58
|
let res = {
|
|
59
59
|
address: poiname,
|
|
60
60
|
geopoint: {
|
|
61
|
-
coordinates: [
|
|
61
|
+
coordinates: [longitude, latitude],
|
|
62
62
|
type: 'Point',
|
|
63
63
|
},
|
|
64
64
|
};
|
|
@@ -124,7 +124,7 @@ export default function LocationPC(props) {
|
|
|
124
124
|
value: {
|
|
125
125
|
address: poiname,
|
|
126
126
|
geopoint: {
|
|
127
|
-
coordinates: [latlng.
|
|
127
|
+
coordinates: [latlng.lng, latlng.lat],
|
|
128
128
|
type: 'Point',
|
|
129
129
|
},
|
|
130
130
|
},
|