gongchunyi
6 天以前 6f1acfd2086a1f8c2cb80afd3db4e534e44d545e
src/views/productionPlan/productionPlan/index.vue
@@ -13,6 +13,14 @@
                    style="width: 160px;"
                    @keyup.enter="handleQuery" />
        </el-form-item>
        <el-form-item label="销售合同号:"
                      prop="salesContractNo">
          <el-input v-model="searchForm.salesContractNo"
                    placeholder="请输入"
                    clearable
                    style="width: 160px;"
                    @keyup.enter="handleQuery" />
        </el-form-item>
        <el-form-item label="需求日期范围:"
                      prop="dateRange">
          <el-date-picker v-model="searchForm.dateRange"
@@ -135,6 +143,7 @@
      <template #footer>
        <span class="dialog-footer">
          <el-button type="primary"
                     :loading="mergeSubmitLoading"
                     @click="handleMergeSubmit">确定下发</el-button>
          <el-button @click="isShowNewModal = false">取消</el-button>
        </span>
@@ -295,6 +304,13 @@
        return params == "销售" ? "销售" : "内部";
      },
    },
    {
      label: "销售合同号",
      prop: "salesContractNo",
      width: "200px",
      dataType: "slot",
      slot: "salesContractNo",
    },
    {
      label: "产品名称",
@@ -320,7 +336,6 @@
      label: "所需数量",
      prop: "qtyRequired",
      width: "150px",
      align: "right",
      dataType: "slot",
      slot: "qtyRequired",
      className: "volume-cell",
@@ -369,13 +384,7 @@
      className: "date-cell",
      formatData: cell => (cell ? dayjs(cell).format("YYYY-MM-DD") : ""),
    },
    {
      label: "销售合同号",
      prop: "salesContractNo",
      width: "200px",
      dataType: "slot",
      slot: "salesContractNo",
    },
    {
      label: "客户名称",
      prop: "customerName",
@@ -458,6 +467,7 @@
  // 合并下发弹窗控制
  const isShowNewModal = ref(false);
  const mergeSubmitLoading = ref(false);
  // 合并下发表单数据
  const mergeForm = reactive({
    productName: "",
@@ -520,8 +530,7 @@
    });
  };
  const onBlur = value => {
    // 限制四位小数
    mergeForm.totalAssignedQuantity = Number(value.toFixed(4));
    mergeForm.totalAssignedQuantity = Number(Number(value).toFixed(10));
  };
  const fetchProductOptions = () => {
@@ -589,6 +598,7 @@
  const data = reactive({
    searchForm: {
      mpsNo: "",
      salesContractNo: "",
      productName: "",
      model: "",
      status: "",
@@ -617,6 +627,7 @@
    }
    Object.assign(searchForm.value, {
      mpsNo: "",
      salesContractNo: "",
      productName: "",
      model: "",
      status: "",
@@ -644,9 +655,9 @@
        };
      }
      summary[category].totalAssignedQuantity += Number(
        (Number(row.qtyRequired || 0) - Number(row.quantityIssued || 0)).toFixed(
          4
        )
        (
          Number(row.qtyRequired || 0) - Number(row.quantityIssued || 0)
        ).toFixed(10)
      );
    });
@@ -727,13 +738,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 = Number(totalAssignedQuantity.toFixed(10));
    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);
@@ -768,6 +780,7 @@
    const payload = {
      ...mergeForm,
    };
    mergeSubmitLoading.value = true;
    productionPlanCombine(payload)
      .then(res => {
        if (res.code === 200) {
@@ -783,6 +796,9 @@
      .catch(err => {
        console.error("合并下发异常:", err);
        ElMessage.error("系统异常,合并下发失败");
      })
      .finally(() => {
        mergeSubmitLoading.value = false;
      });
    // 可以选择刷新列表或其他操作
  };