Repository navigation
fix(fields): 数值字段详情页显示大量末尾多余的 0 - #2132
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
NumberCellRenderer used `precision` (the total digit count `p` of a decimal(p, s) column) as the fraction-digit count and forced it via `minimumFractionDigits`, so a value like `1` from a decimal(10, 0) column rendered as "1.0000000000". Use `scale` (the decimal places `s`) instead: pad to it when declared (so an amount with scale 2 → "16.00", scale 3 → "3.140"), and when it is absent keep the minimum at 0 so trailing zeros are trimmed while preserving the value's natural precision. Also plumb `scale` through the detail/grid field-metadata enrichment and fix NumberField's input step. Closes #2131
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
详情页(以及网格)里,数值(number)字段显示出一大串末尾的 0,例如
版本号显示为1.0000000000、定额工时显示为16.00000000。期望是1/16。Closes #2131
根因
拿错了字段属性。服务端 spec(
framework/packages/spec/src/data/field.zod.ts)对decimal(p, s)列的定义是:precision= 总位数(p)scale= 小数位(s)但前端
NumberCellRenderer把precision(总位数)当成小数位,并用minimumFractionDigits强制补零:于是
decimal(10, 0)列里的整数1被补成了1.0000000000——0 的个数正好等于该字段的总位数。改动
NumberCellRenderer:小数位改用scale。scale有值 → 固定补零(金额scale=2→16.00,scale=3→3.140)scale无值 →minimumFractionDigits: 0,裁掉末尾 0,只用maximumFractionDigits保留自然精度precision(总位数)当小数位scale透传到渲染器:DetailSection/HeaderHighlight/RecordDetailDrawer/RelatedList/ObjectGrid的 field metadataNumberFieldMetadata增加scale字段(并标注precision/scale语义)NumberField编辑控件的step改用scaleNumberCellRenderer单测(8 例)验证
NumberCellRenderer.test.tsx:8 例全过packages/fields+plugin-detail:361 例全过plugin-grid+types:280 例全过