Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6fa43f1

Browse files
added precision for float number columns
1 parent05eacdc commit6fa43f1

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

‎client/packages/lowcoder/src/comps/comps/tableComp/column/columnTypeComps/ColumnNumberComp.tsx‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import{defaultasInputNumber}from"antd/es/input-number";
2-
import{NumberControl,StringControl}from"comps/controls/codeControl";
2+
import{NumberControl,RangeControl,StringControl}from"comps/controls/codeControl";
33
import{BoolControl}from"comps/controls/boolControl";
44
import{trans}from"i18n";
55
import{ColumnTypeCompBuilder,ColumnTypeViewFn}from"../columnTypeCompBuilder";
@@ -25,13 +25,16 @@ const InputNumberWrapper = styled.div`
2525
constchildrenMap={
2626
text:NumberControl,
2727
step:withDefault(NumberControl,1),
28+
precision:RangeControl.closed(0,20,0),
2829
float:BoolControl,
2930
prefix:StringControl,
3031
suffix:StringControl,
3132
};
3233

3334
letfloat=false;
3435
letstep=1;
36+
letprecision=0;
37+
3538
constgetBaseValue:ColumnTypeViewFn<typeofchildrenMap,number,number>=(
3639
props
3740
)=>{
@@ -44,8 +47,13 @@ export const ColumnNumberComp = (function () {
4447
(props,dispatch)=>{
4548
float=props.float;
4649
step=props.step;
47-
constvalue=!float ?Math.floor(props.changeValue??getBaseValue(props,dispatch)) :props.changeValue??getBaseValue(props,dispatch);
48-
returnprops.prefix+value+props.suffix;
50+
precision=props.precision;
51+
constvalue=props.changeValue??getBaseValue(props,dispatch);
52+
letformattedValue:string|number=!float ?Math.floor(value) :value;
53+
if(float){
54+
formattedValue=formattedValue.toPrecision(precision+1);
55+
}
56+
returnprops.prefix+formattedValue+props.suffix;
4957
},
5058
(nodeValue)=>nodeValue.text.value,
5159
getBaseValue,
@@ -62,6 +70,7 @@ export const ColumnNumberComp = (function () {
6270
value=value??0;
6371
props.onChange(!float ?Math.floor(value) :value);
6472
}}
73+
precision={float ?precision :0}
6574
onBlur={props.onChangeEnd}
6675
onPressEnter={props.onChangeEnd}
6776
/>
@@ -86,6 +95,11 @@ export const ColumnNumberComp = (function () {
8695
}
8796
}
8897
})}
98+
{float&&(
99+
children.precision.propertyView({
100+
label:trans("table.precision"),
101+
})
102+
)}
89103
{children.prefix.propertyView({
90104
label:trans("table.prefix"),
91105
})}

‎client/packages/lowcoder/src/i18n/locales/de.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,7 @@ export const de = {
11371137
"columnType":"Säule Typ",
11381138
"numberStep":"Schritt",
11391139
"numberStepTooltip":"Die Zahl, auf die der aktuelle Wert erhöht oder verringert wird. Es kann eine ganze Zahl oder eine Dezimalzahl sein",
1140+
"precision":"Präzision",
11401141
"float":"Schwimmer",
11411142
"prefix":"Präfix",
11421143
"suffix":"Nachsilbe",

‎client/packages/lowcoder/src/i18n/locales/en.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,6 +1241,7 @@ export const en = {
12411241
"columnType":"Column Type",
12421242
"numberStep":"Step",
12431243
"numberStepTooltip":"The number to which the current value is increased or decreased. It can be an integer or decimal",
1244+
"precision":"Precision",
12441245
"float":"Float",
12451246
"prefix":"Prefix",
12461247
"suffix":"Suffix",

‎client/packages/lowcoder/src/i18n/locales/zh.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,7 @@ table: {
12121212
columnType:"列类型",
12131213
numberStep:"步",
12141214
numberStepTooltip:"当前值增加或减少的数量。它可以是整数或小数",
1215+
precision:"精度",
12151216
float:"分数",
12161217
prefix:"字首",
12171218
suffix:"后缀",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp