Skip to content

Commit ab42625

Browse files
committed
fix: 数字展示格式化
1 parent 18789a0 commit ab42625

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

km-console/packages/layout-clusters-fe/src/pages/Jobs/config.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,9 @@ export const getJobsListColumns = (arg?: any) => {
8989
title: '任务执行对象',
9090
dataIndex: 'target',
9191
key: 'target',
92+
width: 232,
9293
render(t: any, r: any) {
93-
return (
94-
<div style={{ width: '232px' }}>
95-
<TagsWithHide placement="bottom" list={t.split(',')} expandTagContent={(num: any) => `共有${num}个`} />
96-
</div>
97-
);
94+
return <TagsWithHide placement="bottom" list={t.split(',')} expandTagContent={(num: any) => `共有${num}个`} />;
9895
},
9996
},
10097
{

km-console/packages/layout-clusters-fe/src/pages/LoadRebalance/index.tsx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useState, useEffect, useRef } from 'react';
2-
import { Select, Form, Utils, AppContainer, Input, Button, ProTable, Badge, Tag, SearchInput, IconFont, Divider } from 'knowdesign';
2+
import { Select, Form, Utils, AppContainer, Input, Button, ProTable, Badge, Tag, SearchInput, Divider } from 'knowdesign';
3+
import { IconFont } from '@knowdesign/icons';
34
import BalanceDrawer from './BalanceDrawer';
45
import HistoryDrawer from './HistoryDrawer';
56
import DBreadcrumb from 'knowdesign/es/extend/d-breadcrumb';
@@ -133,7 +134,7 @@ const LoadBalance: React.FC = (props: any) => {
133134
key: 'disk_spec',
134135
width: '150px',
135136
render: (text: any, row: any) => {
136-
return text !== null ? `${text}GB` : '-';
137+
return text !== null ? `${text.toLocaleString()}GB` : '-';
137138
},
138139
},
139140
{
@@ -145,7 +146,10 @@ const LoadBalance: React.FC = (props: any) => {
145146
return text !== null ? (
146147
<span>
147148
<Badge status={row?.disk_status === 0 ? 'success' : 'error'} />
148-
{`${getSizeAndUnit(text, 'B').valueWithUnit} (${((row.disk_avg * 100) / Utils.transGBToB(row.disk_spec)).toFixed(2)}%)`}
149+
{`${getSizeAndUnit(text, 'B').valueWithUnit.toLocaleString()} (${(
150+
(row.disk_avg * 100) /
151+
Utils.transGBToB(row.disk_spec)
152+
).toFixed(2)}%)`}
149153
</span>
150154
) : (
151155
'-'
@@ -158,7 +162,7 @@ const LoadBalance: React.FC = (props: any) => {
158162
key: 'bytesIn_spec',
159163
width: '150px',
160164
render: (text: any, row: any) => {
161-
return text !== null ? `${text}MB/s` : '-';
165+
return text !== null ? `${text.toLocaleString()}MB/s` : '-';
162166
},
163167
},
164168
{
@@ -170,7 +174,10 @@ const LoadBalance: React.FC = (props: any) => {
170174
return text !== null ? (
171175
<span>
172176
<Badge status={row?.bytesIn_status === 0 ? 'success' : 'error'} />
173-
{`${getSizeAndUnit(text, 'B/s').valueWithUnit} (${((row.bytesIn_avg * 100) / (row.bytesIn_spec * 1024 * 1024)).toFixed(2)}%)`}
177+
{`${getSizeAndUnit(text, 'B/s').valueWithUnit.toLocaleString()} (${(
178+
(row.bytesIn_avg * 100) /
179+
(row.bytesIn_spec * 1024 * 1024)
180+
).toFixed(2)}%)`}
174181
</span>
175182
) : (
176183
'-'
@@ -183,7 +190,7 @@ const LoadBalance: React.FC = (props: any) => {
183190
key: 'bytesOut_spec',
184191
width: '150px',
185192
render: (text: any, row: any) => {
186-
return text !== null ? `${text}MB/s` : '-';
193+
return text !== null ? `${text.toLocaleString()}MB/s` : '-';
187194
},
188195
},
189196
{
@@ -196,7 +203,10 @@ const LoadBalance: React.FC = (props: any) => {
196203
return text !== null ? (
197204
<span>
198205
<Badge status={row?.bytesOut_status === 0 ? 'success' : 'error'} />
199-
{`${getSizeAndUnit(text, 'B/s').valueWithUnit} (${((row.bytesOut_avg * 100) / (row.bytesOut_spec * 1024 * 1024)).toFixed(2)}%)`}
206+
{`${getSizeAndUnit(text, 'B/s').valueWithUnit.toLocaleString()} (${(
207+
(row.bytesOut_avg * 100) /
208+
(row.bytesOut_spec * 1024 * 1024)
209+
).toFixed(2)}%)`}
200210
</span>
201211
) : (
202212
'-'

km-console/packages/layout-clusters-fe/src/pages/TopicList/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/* eslint-disable react/display-name */
22
import React, { useState, useEffect } from 'react';
33
import { useHistory, useParams } from 'react-router-dom';
4-
import { AppContainer, IconFont, Input, ProTable, Select, Switch, Tooltip, Utils, Dropdown, Menu, Button, Divider } from 'knowdesign';
4+
import { AppContainer, Input, ProTable, Select, Switch, Tooltip, Utils, Dropdown, Menu, Button, Divider } from 'knowdesign';
5+
import { IconFont } from '@knowdesign/icons';
56
import Create from './Create';
67
import './index.less';
78
import Api from '@src/api/index';
@@ -90,11 +91,11 @@ const AutoPage = (props: any) => {
9091
const orgVal = record?.latestMetrics?.metrics?.[metricName];
9192
if (orgVal !== undefined) {
9293
if (metricName === 'HealthScore') {
93-
return Math.round(orgVal);
94+
return Math.round(orgVal).toLocaleString();
9495
} else if (metricName === 'LogSize') {
95-
return Number(Utils.formatAssignSize(orgVal, 'MB'));
96+
return Number(Utils.formatAssignSize(orgVal, 'MB')).toLocaleString();
9697
} else {
97-
return Number(Utils.formatAssignSize(orgVal, 'KB'));
98+
return Number(Utils.formatAssignSize(orgVal, 'KB')).toLocaleString();
9899
// return Utils.formatAssignSize(orgVal, 'KB');
99100
}
100101
}

0 commit comments

Comments
 (0)