|
@@ -822,9 +822,9 @@ const handleInsertSelected = () => {
|
|
|
}
|
|
|
|
|
|
const handleUnitChange = (row, newUnit, col = null) => {
|
|
|
- // console.log('handleUnitChange row:', row, 'newUnit:', newUnit, 'col:', col);
|
|
|
+ console.log('handleUnitChange row:', row, 'newUnit:', newUnit, 'col:', col);
|
|
|
const target = col ? row[col.code] : row;
|
|
|
- // console.log('target:', target);
|
|
|
+ console.log('target:', target);
|
|
|
if (!target || !target.value || isNaN(parseFloat(target.value))) {
|
|
|
// console.log('Invalid value check failed:', { target, value: target?.value, isNaN: isNaN(parseFloat(target?.value)) });
|
|
|
ElMessage.warning('请输入有效数值');
|
|
@@ -836,8 +836,8 @@ const handleUnitChange = (row, newUnit, col = null) => {
|
|
|
ElMessage.error(`单位选项未定义 for ${col?.name || 'unknown'}`);
|
|
|
return;
|
|
|
}
|
|
|
- // 使用 row[col.code].unit 作为当前单位,而不是 col.prevUnitDef
|
|
|
- const currentUnit = unitOptions.find(opt => opt.value === target.unit) || unitOptions.find(opt => opt.value === col.unitDef);
|
|
|
+ // 使用 row[col.code].unit 作为当前单位,而不是 col.prevUnitDef
|
|
|
+ const currentUnit = unitOptions.find(opt => opt.value === target.unit) || unitOptions.find(opt => opt.value === col ? col.unitDef : target.unitDef);
|
|
|
// console.log('currentUnit:', currentUnit, 'row unit:', target.unit);
|
|
|
if (!currentUnit) {
|
|
|
console.error('未找到当前单位信息', target.unit);
|
|
@@ -853,7 +853,7 @@ const handleUnitChange = (row, newUnit, col = null) => {
|
|
|
}
|
|
|
const currentValue = parseFloat(target.value);
|
|
|
const newValue = ((currentValue - currentUnit.utOffset) / currentUnit.factor) * targetUnit.factor + targetUnit.utOffset;
|
|
|
- target.value = newValue.toFixed(6);
|
|
|
+ target.value = newValue.toFixed(8);
|
|
|
target.unit = newUnit;
|
|
|
// console.log('Updated value:', target.value, 'unit:', target.unit);
|
|
|
if (col) {
|