[FE-Widget] Fix error of the score board #177

This commit is contained in:
SA K
2022-10-27 18:49:05 +09:00
parent a3c6cb2502
commit 797a94e2b4
3 changed files with 18 additions and 6 deletions

View File

@@ -34,7 +34,11 @@ const NumericBoard = props => {
const result = getAggregationData(option.content.aggregation, dataSet, field);
setScore(option.content.prefix + result + option.content.suffix);
if (option.content.numForm) {
setScore(option.content.prefix + result.toLocaleString('ko-KR') + option.content.suffix);
} else {
setScore(option.content.prefix + result + option.content.suffix);
}
return { ...defaultComponentOption, ...option };
};

View File

@@ -112,9 +112,9 @@ export const getAggregationData = (type, data, field) => {
switch (type) {
case WIDGET_AGGREGATION.SUM:
data.forEach(item => {
// console.log('item ', item[field]);
console.log('item ', item[field]);
if (item[field]) {
result += item[field];
result += Number(item[field]);
}
});
break;
@@ -122,7 +122,7 @@ export const getAggregationData = (type, data, field) => {
data.forEach(item => {
// console.log('item ', item[field]);
if (item[field]) {
result += item[field];
result += Number(item[field]);
}
});
result = Math.floor(result / data.length);

View File

@@ -1,8 +1,8 @@
import React from 'react';
import { ListItem, ListItemText } from '@mui/material';
import { ListItem, ListItemText, Divider } from '@mui/material';
import SelectForm from '@/components/form/SelectForm';
import ColorPickerForm from '@/components/form/ColorPickerForm';
import { AGGREGATION_LIST, COLUMN_TYPE } from '@/constant';
import { AGGREGATION_LIST, COLUMN_TYPE, LABEL_LIST } from '@/constant';
import TextFieldForm from '@/components/form/TextFieldForm';
const fontSizeList = [10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 40, 50, 60, 70, 80, 85, 90, 95, 100];
@@ -66,6 +66,7 @@ const NumericBoardSetting = props => {
onChange={handleContentChange}
disabledDefaultValue
/>
<Divider />
<SelectForm
name="fontSize"
label="사이즈 및 색상"
@@ -74,6 +75,13 @@ const NumericBoardSetting = props => {
onChange={handleContentChange}
endButton={<ColorPickerForm color={option.content.color} name="color" onChange={handleContentChange} />}
/>
<SelectForm
name="numForm"
label="숫자 서식"
optionList={LABEL_LIST}
value={option.content.numForm}
onChange={handleContentChange}
/>
<TextFieldForm label="Prefix" name="prefix" value={option.content.prefix} onChange={handleContentChange} />
<TextFieldForm label="Suffix" name="suffix" value={option.content.suffix} onChange={handleContentChange} />
</ListItem>