优化混炼示方中换算系数和配方参数的数值展示与输入解析,调整相关字段的小数精度,增强用户交互体验。
This commit is contained in:
@@ -57,7 +57,7 @@ export const mainSchema: FormSchema[] = [
|
||||
{ label: '制作日期', field: 'makeDate', component: 'DatePicker', colProps: { span: 8 }, componentProps: { valueFormat: 'YYYY-MM-DD' } },
|
||||
{ label: '发行编号', field: 'issueNumber', component: 'Input', required: true, colProps: { span: 8 } },
|
||||
//update-end---author:cursor ---date:20260522 for:【XSLMES-20260522-A33】混炼示方基本信息字段优化-----------
|
||||
{ label: '换算系数', field: 'convertFactor', component: 'InputNumber', colProps: { span: 8 }, componentProps: { precision: 6, style: { width: '100%' } } },
|
||||
{ label: '换算系数', field: 'convertFactor', component: 'InputNumber', colProps: { span: 8 }, componentProps: { precision: 2, style: { width: '100%' } } },
|
||||
{ label: '填充体积', field: 'fillVolume', component: 'InputNumber', colProps: { span: 8 }, componentProps: { precision: 6, style: { width: '100%' } } },
|
||||
{ label: '回收炭黑(秒)', field: 'recycleCarbonSec', component: 'InputNumber', colProps: { span: 8 }, componentProps: { precision: 0, style: { width: '100%' } } },
|
||||
{ label: '母胶比重', field: 'motherRubberSg', component: 'InputNumber', colProps: { span: 8 }, componentProps: { precision: 6, style: { width: '100%' } } },
|
||||
@@ -279,6 +279,79 @@ function toMixingMaterialNumber(value: unknown): number | null {
|
||||
/** 混炼示方重量小数位(与后端 BigDecimal 精度一致) */
|
||||
const MIXING_MATERIAL_WEIGHT_SCALE = 6;
|
||||
|
||||
//update-begin---author:cursor ---date:20260526 for:【XSLMES-20260526-A60】换算系数/配方参数数值展示优化-----------
|
||||
/** 换算系数展示小数位 */
|
||||
export const MIXING_CONVERT_FACTOR_SCALE = 2;
|
||||
|
||||
/** 配方参数设定允许的小数精度 */
|
||||
export const MIXING_RECIPE_PARAM_DECIMAL_SCALE = 6;
|
||||
|
||||
/** 配方参数设定:允许小数的字段 */
|
||||
export const MIXING_RECIPE_PARAM_DECIMAL_FIELDS = [
|
||||
'sideWallWaterTemp',
|
||||
'overtempDischargeTemp',
|
||||
'doorWaterTemp',
|
||||
'rotorWaterTemp',
|
||||
'maxFeedTemp',
|
||||
] as const;
|
||||
|
||||
/** 换算系数展示:固定保留两位小数 */
|
||||
export function formatMixingConvertFactorDisplay(value: unknown): string {
|
||||
if (value === null || value === undefined || value === '') {
|
||||
return '';
|
||||
}
|
||||
const num = Number(value);
|
||||
if (Number.isNaN(num)) {
|
||||
return String(value);
|
||||
}
|
||||
return num.toFixed(MIXING_CONVERT_FACTOR_SCALE);
|
||||
}
|
||||
|
||||
/** 换算系数输入解析 */
|
||||
export function parseMixingConvertFactorValue(value: unknown): number | null {
|
||||
if (value === '' || value == null) {
|
||||
return null;
|
||||
}
|
||||
const num = Number(String(value).replace(/,/g, '').trim());
|
||||
if (Number.isNaN(num)) {
|
||||
return null;
|
||||
}
|
||||
return Number(num.toFixed(MIXING_CONVERT_FACTOR_SCALE));
|
||||
}
|
||||
|
||||
/** 配方参数展示:允许小数,无小数部分时仅展示整数 */
|
||||
export function formatMixingRecipeParamDisplay(value: unknown, maxPrecision = MIXING_RECIPE_PARAM_DECIMAL_SCALE): string {
|
||||
if (value === null || value === undefined || value === '') {
|
||||
return '';
|
||||
}
|
||||
const num = Number(value);
|
||||
if (Number.isNaN(num)) {
|
||||
return String(value);
|
||||
}
|
||||
const rounded = Number(num.toFixed(maxPrecision));
|
||||
if (Number.isInteger(rounded)) {
|
||||
return String(rounded);
|
||||
}
|
||||
return String(rounded);
|
||||
}
|
||||
|
||||
/** 配方参数输入解析 */
|
||||
export function parseMixingRecipeParamValue(value: unknown): number | null {
|
||||
if (value === '' || value == null) {
|
||||
return null;
|
||||
}
|
||||
const text = String(value).replace(/,/g, '').trim();
|
||||
if (!text) {
|
||||
return null;
|
||||
}
|
||||
const num = Number(text);
|
||||
if (Number.isNaN(num)) {
|
||||
return null;
|
||||
}
|
||||
return Number(num.toFixed(MIXING_RECIPE_PARAM_DECIMAL_SCALE));
|
||||
}
|
||||
//update-end---author:cursor ---date:20260526 for:【XSLMES-20260526-A60】换算系数/配方参数数值展示优化-----------
|
||||
|
||||
/** 重量四舍五入,消除浮点累加误差 */
|
||||
function roundMixingMaterialNumber(value: number): number {
|
||||
return Number(value.toFixed(MIXING_MATERIAL_WEIGHT_SCALE));
|
||||
|
||||
Reference in New Issue
Block a user