@cloudbase/weda-ui 0.2.17 → 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 +3 -0
- package/package.json +6 -3
- package/src/configs/components/calendar.json +4 -1
- package/src/configs/components/chart/bar.json +19 -6
- package/src/configs/components/chart/line.json +19 -6
- package/src/configs/components/chart/pie.json +14 -4
- 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 +63 -17
- 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 +11 -0
- package/src/mp/components/chart/bar/index.js +6 -2
- package/src/mp/components/chart/common/core/eChartBar.js +9 -8
- package/src/mp/components/chart/common/core/eChartBase.js +20 -16
- package/src/mp/components/chart/common/core/eChartLine.js +6 -5
- package/src/mp/components/chart/line/index.js +10 -6
- package/src/mp/components/chart/pie/index.js +6 -2
- package/src/mp/components/chart/statisticsCard/index.js +33 -6
- package/src/mp/components/dataView/index.json +1 -1
- 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/index.js +43 -2
- package/src/mp/components/form/radio/index.js +34 -1
- package/src/mp/components/form/select/index.js +360 -40
- package/src/mp/components/form/select/index.wxml +17 -2
- package/src/mp/components/form/select/region/index.js +98 -0
- package/src/mp/components/form/uploader/index.js +39 -27
- package/src/mp/components/form/uploaderFile/index.js +10 -6
- package/src/mp/components/listView/index.js +33 -27
- package/src/mp/components/listView/index.wxml +1 -1
- package/src/mp/components/listView/index.wxss +5 -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/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/{internals/listView → wxOpenApi/phone}/index.json +0 -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 +7 -2
- package/src/mp/style/weda-ui.wxss +2 -0
- package/src/mp/utils/destr.js +48 -0
- package/src/mp/utils/platform.js +10 -0
- package/src/mp/utils/tcb.js +44 -0
- 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 +40 -39
- package/src/web/components/chart/common/core/eChartBar.js +7 -6
- package/src/web/components/chart/common/core/eChartBase.ts +20 -16
- package/src/web/components/chart/common/core/eChartLine.js +8 -6
- package/src/web/components/chart/line/index.tsx +40 -39
- package/src/web/components/chart/statisticsCard/index.tsx +29 -8
- package/src/web/components/form/checkbox/index.tsx +55 -23
- package/src/web/components/form/radio/index.tsx +84 -53
- package/src/web/components/form/select/h5.tsx +388 -72
- 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 +89 -0
- package/src/web/components/form/select/year.tsx +170 -0
- package/src/web/components/form/uploader/uploader.h5.tsx +9 -2
- package/src/web/components/form/uploader/uploader.pc.tsx +4 -4
- package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +13 -7
- package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +13 -5
- package/src/web/components/image/image.tsx +1 -1
- package/src/web/components/image/index.tsx +1 -1
- package/src/web/components/index.js +7 -0
- 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 +6 -1
- 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/platform.js +9 -0
- package/src/web/utils/tcb.js +26 -0
- package/src/web/weda-ui.css +2 -0
- package/src/mp/components/internals/listView/arrow-right-line.svg +0 -3
- package/src/mp/components/internals/listView/index.js +0 -286
- package/src/mp/components/internals/listView/index.wxml +0 -40
- package/src/mp/components/internals/listView/index.wxss +0 -150
- package/src/mp/components/internals/listView/more-line.svg +0 -3
- 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
package/src/mp/index.json
CHANGED
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"RichTextView": "components/richText/index",
|
|
30
30
|
"Tabs": "components/tabs/index",
|
|
31
31
|
"ListView": "components/listView/index",
|
|
32
|
+
"NavigationBar": "components/navigationBar/index",
|
|
32
33
|
"DataView": "components/dataView/index",
|
|
33
34
|
"Calendar": "components/calendar/index",
|
|
34
35
|
"NavLayout": "components/navLayout/index",
|
|
@@ -36,10 +37,14 @@
|
|
|
36
37
|
"Bar": "components/chart/bar/index",
|
|
37
38
|
"Pie": "components/chart/pie/index",
|
|
38
39
|
"StatisticsCard": "components/chart/statisticsCard/index",
|
|
39
|
-
"GraphicCard": "components/graphicCard/index"
|
|
40
|
+
"GraphicCard": "components/graphicCard/index",
|
|
41
|
+
"UserInfo": "components/wxOpenApi/userInfo/index",
|
|
42
|
+
"Phone": "components/wxOpenApi/phone/index",
|
|
43
|
+
"PhoneCode": "components/wxOpenApi/phoneCode/index",
|
|
44
|
+
"Share": "components/wxOpenApi/share/index"
|
|
40
45
|
},
|
|
41
46
|
"actions": {
|
|
42
47
|
"showToast": "actions/showToast/index",
|
|
43
48
|
"showModal": "actions/showModal/index"
|
|
44
49
|
}
|
|
45
|
-
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// https://github.com/unjs/destr/blob/2f6612533dd798d2ff5786274f2244558f86d09c/src/index.ts
|
|
2
|
+
// https://github.com/fastify/secure-json-parse
|
|
3
|
+
// https://github.com/hapijs/bourne
|
|
4
|
+
const suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
|
|
5
|
+
const suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
|
|
6
|
+
const JsonSigRx = /^["{[]|^-?[0-9][0-9.]{0,14}$/;
|
|
7
|
+
function jsonParseTransform(key, value) {
|
|
8
|
+
if (key === '__proto__' || key === 'constructor') {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
export default function destr(val) {
|
|
14
|
+
if (typeof val !== 'string') {
|
|
15
|
+
return val;
|
|
16
|
+
}
|
|
17
|
+
const _lval = val.toLowerCase();
|
|
18
|
+
if (_lval === 'true') {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
if (_lval === 'false') {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
if (_lval === 'null') {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
if (_lval === 'nan') {
|
|
28
|
+
return NaN;
|
|
29
|
+
}
|
|
30
|
+
if (_lval === 'infinity') {
|
|
31
|
+
return Infinity;
|
|
32
|
+
}
|
|
33
|
+
if (_lval === 'undefined') {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
if (!JsonSigRx.test(val)) {
|
|
37
|
+
return val;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
if (suspectProtoRx.test(val) || suspectConstructorRx.test(val)) {
|
|
41
|
+
return JSON.parse(val, jsonParseTransform);
|
|
42
|
+
}
|
|
43
|
+
return JSON.parse(val);
|
|
44
|
+
}
|
|
45
|
+
catch (_e) {
|
|
46
|
+
return val;
|
|
47
|
+
}
|
|
48
|
+
}
|
package/src/mp/utils/platform.js
CHANGED
|
@@ -18,6 +18,16 @@ export const transSize = (size) => {
|
|
|
18
18
|
const g = getBig(m);
|
|
19
19
|
return `${g}G`;
|
|
20
20
|
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 判断是否是url
|
|
24
|
+
*/
|
|
25
|
+
const reg =
|
|
26
|
+
// eslint-disable-next-line no-useless-escape
|
|
27
|
+
/(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;
|
|
28
|
+
|
|
29
|
+
export const isUrl = (path) => reg.test(path);
|
|
30
|
+
|
|
21
31
|
/**
|
|
22
32
|
* 生成随机数
|
|
23
33
|
*/
|
package/src/mp/utils/tcb.js
CHANGED
|
@@ -13,6 +13,32 @@ export async function getTempFileURL(data) {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* 云API:获取用户自定义导航内容
|
|
18
|
+
* param
|
|
19
|
+
* WeAppId: string,
|
|
20
|
+
* EnvId: string,
|
|
21
|
+
* PublishType?: string,
|
|
22
|
+
*/
|
|
23
|
+
export async function getAppCustomNav() {
|
|
24
|
+
try {
|
|
25
|
+
const PublishType = getApp().app.cloud?.IS_WEDA_IDE ? 'preview' : '';
|
|
26
|
+
const WeAppId = getApp().app?.id;
|
|
27
|
+
const res = await callWedaApi({
|
|
28
|
+
action: 'DescribeAppCustomNav',
|
|
29
|
+
serviceType: 'lowcode',
|
|
30
|
+
data: {
|
|
31
|
+
WeAppId,
|
|
32
|
+
PublishType,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
return res;
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error('错误', error);
|
|
38
|
+
return {};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
16
42
|
/**
|
|
17
43
|
* 调用微搭后端API服务
|
|
18
44
|
*/
|
|
@@ -30,3 +56,21 @@ export async function callDataSource(param) {
|
|
|
30
56
|
return await getApp().app.cloud.callDataSource(param);
|
|
31
57
|
}
|
|
32
58
|
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 云函数获取数据
|
|
62
|
+
*/
|
|
63
|
+
export async function callDataSourceApi(param) {
|
|
64
|
+
const { params, dataSourceName, methodName } = param;
|
|
65
|
+
try {
|
|
66
|
+
const res = await getApp()?.app?.cloud?.callDataSource?.({
|
|
67
|
+
params,
|
|
68
|
+
dataSourceName,
|
|
69
|
+
methodName,
|
|
70
|
+
});
|
|
71
|
+
return res;
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.error('错误', error);
|
|
74
|
+
return {};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -6,6 +6,14 @@
|
|
|
6
6
|
background-color: var(--weui-BRAND);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
.weda-button.weui-btn.weui-btn_primary.weui-btn_wechat:not(.weui-btn_disabled):active {
|
|
10
|
+
background-color: var(--weui-TAG-TEXT-GREEN);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.weda-button.weui-btn_primary.weui-btn_wechat {
|
|
14
|
+
background-color: var(--weui-WECHAT);
|
|
15
|
+
}
|
|
16
|
+
|
|
9
17
|
.weda-button.weda-button-mini {
|
|
10
18
|
font-size: smaller;
|
|
11
19
|
}
|
|
@@ -17,4 +25,3 @@
|
|
|
17
25
|
text-align: center;
|
|
18
26
|
width: 100%;
|
|
19
27
|
}
|
|
20
|
-
|
|
@@ -29,9 +29,10 @@ const Button = ({
|
|
|
29
29
|
'weda-button-mini': size === 'mini',
|
|
30
30
|
'weui-btn': isH5,
|
|
31
31
|
'weui-btn_mini': isH5 && size === 'mini',
|
|
32
|
-
'weui-btn_primary': isH5 && type === 'primary',
|
|
32
|
+
'weui-btn_primary': isH5 && (type === 'primary' || type === 'wechat'),
|
|
33
33
|
'weui-btn_default': isH5 && type === 'default',
|
|
34
34
|
'weui-btn_warn': isH5 && type === 'warn',
|
|
35
|
+
'weui-btn_wechat': isH5 && type === 'wechat',
|
|
35
36
|
'weui-btn_disabled': isH5 && disabled,
|
|
36
37
|
[className]: className,
|
|
37
38
|
});
|
|
@@ -90,7 +91,7 @@ export interface PropsType extends CommonPropsType {
|
|
|
90
91
|
/**
|
|
91
92
|
* 样式类型
|
|
92
93
|
*/
|
|
93
|
-
type?:
|
|
94
|
+
type?: 'primary' | 'warn' | 'wechat' | 'default';
|
|
94
95
|
/**
|
|
95
96
|
* 大小
|
|
96
97
|
*/
|
|
@@ -40,45 +40,46 @@ interface PropsType extends CommonPropsType {
|
|
|
40
40
|
decimalDigits?: number;
|
|
41
41
|
suffix?: string;
|
|
42
42
|
}
|
|
43
|
-
export default function Bar({
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
43
|
+
export default function Bar(opts: PropsType) {
|
|
44
|
+
const {
|
|
45
|
+
directionType,
|
|
46
|
+
isPile,
|
|
47
|
+
id,
|
|
48
|
+
style,
|
|
49
|
+
className,
|
|
50
|
+
isTitle,
|
|
51
|
+
title,
|
|
52
|
+
titleLocation,
|
|
53
|
+
dataSource,
|
|
54
|
+
setColor,
|
|
55
|
+
filterData,
|
|
56
|
+
xField,
|
|
57
|
+
xStatistics,
|
|
58
|
+
groupKey,
|
|
59
|
+
groupKeyTimeSpan,
|
|
60
|
+
xIsCountEmpty,
|
|
61
|
+
yField,
|
|
62
|
+
isLegend,
|
|
63
|
+
legend,
|
|
64
|
+
legend2,
|
|
65
|
+
isXaxisName,
|
|
66
|
+
xAxisName,
|
|
67
|
+
isXaxisAxisLabelShow,
|
|
68
|
+
isXaxisAxisTickShow,
|
|
69
|
+
isXaxisAxisLabelRotate,
|
|
70
|
+
isYAxisSplitlineLinestyleWidth,
|
|
71
|
+
yAxisSplitlineLinestyleType,
|
|
72
|
+
yAxisMax,
|
|
73
|
+
yAxisMin,
|
|
74
|
+
isYAxisName,
|
|
75
|
+
yAxisName,
|
|
76
|
+
isSeriesShowSymbol,
|
|
77
|
+
isYAxisShow,
|
|
78
|
+
isUnit,
|
|
79
|
+
unit,
|
|
80
|
+
decimalDigits,
|
|
81
|
+
suffix,
|
|
82
|
+
} = opts;
|
|
82
83
|
const domRef = useRef<HTMLDivElement>();
|
|
83
84
|
useWedaChart(domRef, EchartBar, {
|
|
84
85
|
directionType,
|
|
@@ -39,10 +39,11 @@ class EchartBar extends EchartBase {
|
|
|
39
39
|
params,
|
|
40
40
|
);
|
|
41
41
|
// 获取 x 轴数据
|
|
42
|
-
const
|
|
42
|
+
const sortedXAxisData = this.sortXAxisData(arrSourData, xField.format);
|
|
43
|
+
const arrXaxisData = this.setXaxis(sortedXAxisData, xField.format);
|
|
43
44
|
const arrXisCountEmptyIndex = []; // 记录空值的key
|
|
44
|
-
if (
|
|
45
|
-
const numLine =
|
|
45
|
+
if (Object.keys(groupKey ?? {}).length === 0) {
|
|
46
|
+
const numLine = sortedXAxisData[0].YLabels.length;
|
|
46
47
|
if (numLine > 0) {
|
|
47
48
|
for (let j = 0; j < numLine; j++) {
|
|
48
49
|
this.config.series[j] = {
|
|
@@ -56,9 +57,9 @@ class EchartBar extends EchartBase {
|
|
|
56
57
|
},
|
|
57
58
|
data: [],
|
|
58
59
|
};
|
|
59
|
-
|
|
60
|
+
sortedXAxisData.forEach((itemSource,index) => {
|
|
60
61
|
this.config.series[j].name = itemSource.YLabels[j].Cn_Name;
|
|
61
|
-
if ((
|
|
62
|
+
if ((itemSource.YLabels[j].Value === undefined || itemSource.YLabels[j].Value === null) && !xIsCountEmpty) {
|
|
62
63
|
arrXisCountEmptyIndex.push(index);
|
|
63
64
|
} else {
|
|
64
65
|
const value = itemSource.YLabels[j].Value ? itemSource.YLabels[j].Value : 0;
|
|
@@ -73,7 +74,7 @@ class EchartBar extends EchartBase {
|
|
|
73
74
|
// 如果是分组,则这里需要特殊处理
|
|
74
75
|
// 按groupKey分组存放数据值
|
|
75
76
|
const objGroupKey = {}; // {'分组字段':[{value:'统计的值', dimensionality:'维度名', name:'统计的数值字段名'}]}
|
|
76
|
-
|
|
77
|
+
sortedXAxisData.forEach((itemSourData) => {
|
|
77
78
|
itemSourData.YLabels.forEach((yLabel) => {
|
|
78
79
|
if (!objGroupKey[yLabel.Group_Name]) {
|
|
79
80
|
objGroupKey[yLabel.Group_Name] = [];
|
|
@@ -188,8 +188,25 @@ class EchartBase extends AbstractEchartBaseModal {
|
|
|
188
188
|
* @param { Array<object> } arrData 后台返回的数据
|
|
189
189
|
* @param { string } formatType 类型 datetime:日期时间;date:日期,time:时间,其它
|
|
190
190
|
*/
|
|
191
|
-
protected setXaxis(
|
|
191
|
+
protected setXaxis(sortedXAxisData, formatType) {
|
|
192
192
|
const xAxisData = [];
|
|
193
|
+
if (sortedXAxisData.length > 0) {
|
|
194
|
+
sortedXAxisData.forEach((itemSource) => {
|
|
195
|
+
let value = itemSource.XLabel.Value;
|
|
196
|
+
if (formatType === 'datetime') {
|
|
197
|
+
value = this.formatTime(itemSource.XLabel.Value, 'dt');
|
|
198
|
+
} else if (formatType === 'date') {
|
|
199
|
+
value = this.formatTime(itemSource.XLabel.Value, 'd');
|
|
200
|
+
} else if (formatType === 'time') {
|
|
201
|
+
value = this.formatTime(itemSource.XLabel.Value, 't');
|
|
202
|
+
}
|
|
203
|
+
xAxisData.push(value);
|
|
204
|
+
});
|
|
205
|
+
this.config.xAxis.data = xAxisData;
|
|
206
|
+
}
|
|
207
|
+
return xAxisData;
|
|
208
|
+
}
|
|
209
|
+
protected sortXAxisData(arrData, formatType = ''): Array<any> {
|
|
193
210
|
let xFields = [...arrData];
|
|
194
211
|
if(['datetime', 'date', 'time'].includes(formatType)) {
|
|
195
212
|
xFields.sort((a, b) => {
|
|
@@ -205,21 +222,8 @@ class EchartBase extends AbstractEchartBaseModal {
|
|
|
205
222
|
}
|
|
206
223
|
});
|
|
207
224
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
let value = itemSource.XLabel.Value;
|
|
211
|
-
if (formatType === 'datetime') {
|
|
212
|
-
value = this.formatTime(itemSource.XLabel.Value, 'dt');
|
|
213
|
-
} else if (formatType === 'date') {
|
|
214
|
-
value = this.formatTime(itemSource.XLabel.Value, 'd');
|
|
215
|
-
} else if (formatType === 'time') {
|
|
216
|
-
value = this.formatTime(itemSource.XLabel.Value, 't');
|
|
217
|
-
}
|
|
218
|
-
xAxisData.push(value);
|
|
219
|
-
});
|
|
220
|
-
this.config.xAxis.data = xAxisData;
|
|
221
|
-
}
|
|
222
|
-
return xAxisData;
|
|
225
|
+
|
|
226
|
+
return xFields;
|
|
223
227
|
}
|
|
224
228
|
|
|
225
229
|
/**
|
|
@@ -38,10 +38,12 @@ class EchartLine extends EchartBase {
|
|
|
38
38
|
params,
|
|
39
39
|
);
|
|
40
40
|
// 获取 x 轴数据
|
|
41
|
-
|
|
41
|
+
|
|
42
|
+
const sortedXAxisData = this.sortXAxisData(arrSourData, xField.format);
|
|
43
|
+
const arrXaxisData = this.setXaxis(sortedXAxisData, xField.format);
|
|
42
44
|
const arrXisCountEmptyIndex = []; // 记录空值的key
|
|
43
|
-
if (
|
|
44
|
-
const numLine =
|
|
45
|
+
if (Object.keys(groupKey ?? {}).length === 0) {
|
|
46
|
+
const numLine = sortedXAxisData[0].YLabels.length;
|
|
45
47
|
if (numLine > 0) {
|
|
46
48
|
for (let j = 0; j < numLine; j++) {
|
|
47
49
|
this.config.series[j] = {
|
|
@@ -55,9 +57,9 @@ class EchartLine extends EchartBase {
|
|
|
55
57
|
},
|
|
56
58
|
data: [],
|
|
57
59
|
};
|
|
58
|
-
|
|
60
|
+
sortedXAxisData.forEach((itemSource,index) => {
|
|
59
61
|
this.config.series[j].name = itemSource.YLabels[j].Cn_Name;
|
|
60
|
-
if ((
|
|
62
|
+
if ((itemSource.YLabels[j].Value === undefined || itemSource.YLabels[j].Value === null) && !xIsCountEmpty) {
|
|
61
63
|
arrXisCountEmptyIndex.push(index);
|
|
62
64
|
} else {
|
|
63
65
|
const value = itemSource.YLabels[j].Value ? itemSource.YLabels[j].Value : 0;
|
|
@@ -72,7 +74,7 @@ class EchartLine extends EchartBase {
|
|
|
72
74
|
// 如果是分组,则这里需要特殊处理
|
|
73
75
|
// 按groupKey分组存放数据值
|
|
74
76
|
const objGroupKey = {}; // {'分组字段':[{value:'统计的值', dimensionality:'维度名', name:'统计的数值字段名'}]}
|
|
75
|
-
|
|
77
|
+
sortedXAxisData.forEach((itemSourData) => {
|
|
76
78
|
itemSourData.YLabels.forEach((yLabel) => {
|
|
77
79
|
if (!objGroupKey[yLabel.Group_Name]) {
|
|
78
80
|
objGroupKey[yLabel.Group_Name] = [];
|
|
@@ -38,45 +38,46 @@ interface PropsType extends CommonPropsType {
|
|
|
38
38
|
decimalDigits?: number;
|
|
39
39
|
suffix?: string;
|
|
40
40
|
}
|
|
41
|
-
export default function Line({
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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;
|
|
80
81
|
const domRef = useRef<HTMLDivElement>();
|
|
81
82
|
useWedaChart(domRef, EChartLine, {
|
|
82
83
|
chartType,
|
|
@@ -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({
|