gongchunyi
2026-08-05 eb73bf315c9f7fe464145353534f8278e496a041
fix: 精度计算问题
已修改1个文件
9 ■■■■■ 文件已修改
src/views/productionPlan/productionPlan/index.vue 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/productionPlan/productionPlan/index.vue
@@ -739,13 +739,14 @@
    // 计算总制造数量 (默认qtyRequired的和)
    const totalAssignedQuantity = selectedRows.value.reduce((sum, row) => {
      return sum + Number(row.qtyRequired || 0) - Number(row.quantityIssued || 0);
    }, 0);
    sumAssignedQuantity.value = totalAssignedQuantity;
    console.log(totalAssignedQuantity);
    }, 0);  // 避免浮点数精度问题(如 37.800000000000004)
    const fixedTotal = Math.round(totalAssignedQuantity * 100) / 100;
    sumAssignedQuantity.value = fixedTotal;
    console.log(fixedTotal);
    // 设置表单数据
    mergeForm.productName = productName;
    mergeForm.model = firstRow.model || "";
    mergeForm.totalAssignedQuantity = totalAssignedQuantity;
    mergeForm.totalAssignedQuantity = fixedTotal;
    mergeForm.planCompleteTime = firstRow.requiredDate || "";
    mergeForm.productId = firstRow.productId || "";
    mergeForm.ids = selectedRows.value.map(row => row.id);