优化了对money的渲染

This commit is contained in:
Xu Chang 2024-04-27 16:29:16 +08:00
parent 189f4fb36a
commit 9dcac9e0d1
5 changed files with 18 additions and 7 deletions

View File

@ -40,5 +40,6 @@
"bind": "绑定",
"true": "是",
"false": "否",
"other": "其他"
"other": "其他",
"money": "¥%{value}"
}

View File

@ -2,7 +2,7 @@ import { assert } from 'oak-domain/lib/utils/assert';
import { judgeRelation } from 'oak-domain/lib/store/relation';
import { get } from 'oak-domain/lib/utils/lodash';
import dayjs from 'dayjs';
import { ThousandCont } from 'oak-domain/lib/utils/money';
import { ThousandCont, ToYuan } from 'oak-domain/lib/utils/money';
const tableWidthMap = {
1: 120,
2: 200,
@ -152,7 +152,10 @@ export function getValue(data, path, entity, attr, attrType, t) {
});
}
if (attrType === 'money' && typeof value === 'number') {
value = ThousandCont(value);
value = t('common::money', {
value: ThousandCont(ToYuan(value)),
'#oakModule': 'oak-frontend-base'
});
}
return value;
}

View File

@ -162,7 +162,10 @@ function getValue(data, path, entity, attr, attrType, t) {
});
}
if (attrType === 'money' && typeof value === 'number') {
value = (0, money_1.ThousandCont)(value);
value = t('common::money', {
value: (0, money_1.ThousandCont)((0, money_1.ToYuan)(value)),
'#oakModule': 'oak-frontend-base'
});
}
return value;
}

View File

@ -40,5 +40,6 @@
"bind": "绑定",
"true": "是",
"false": "否",
"other": "其他"
"other": "其他",
"money": "¥%{value}"
}

View File

@ -27,7 +27,7 @@ import {
DataTypeParams,
} from 'oak-domain/lib/types/schema/DataTypes';
import dayjs from 'dayjs';
import { ThousandCont } from 'oak-domain/lib/utils/money';
import { ThousandCont, ToYuan } from 'oak-domain/lib/utils/money';
const tableWidthMap: Record<number, number> = {
1: 120,
@ -215,7 +215,10 @@ export function getValue<ED extends EntityDict & BaseEntityDict>(
});
}
if (attrType === 'money' && typeof value === 'number') {
value = ThousandCont(value);
value = t('common::money', {
value: ThousandCont(ToYuan(value)),
'#oakModule': 'oak-frontend-base'
});
}
return value;
}