gaoluyang
2026-06-12 ac00bb7b8eae1bf6aabb7f1ae67c2e5aa5b8ae90
src/views/salesManagement/salesLedger/index.vue
@@ -160,6 +160,8 @@
                               prop="quantity" />
              <el-table-column label="每件数量"
                               prop="singleQuantity" />
              <el-table-column label="总数"
                               prop="totalQuantity" />
              <el-table-column label="待发货数量"
                               prop="noQuantity" />
              <el-table-column label="税率(%)"
@@ -452,6 +454,8 @@
                           prop="quantity" />
          <el-table-column label="每件数量"
                           prop="singleQuantity" />
          <el-table-column label="总数"
                           prop="totalQuantity" />
          <el-table-column label="税率(%)"
                           prop="taxRate" />
          <el-table-column label="含税单价(元)"
@@ -921,7 +925,7 @@
    <!-- 发货弹框 -->
    <el-dialog v-model="deliveryFormVisible"
               title="发货信息"
               width="40%"
               width="70%"
               @close="closeDeliveryDia">
      <el-form :model="deliveryForm"
               label-width="120px"
@@ -1738,6 +1742,7 @@
    productData.value = products.map(p => {
      const quantity = Number(p.quantity ?? 0) || 0;
      const unitPrice = Number(p.unitPrice ?? 0) || 0;
      const singleQuantity = 1;
      const taxRate = "13"; // 默认 13%,便于直接提交(如需可在产品中自行修改)
      const taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2);
      const taxExclusiveTotalPrice = proxy.calculateTaxExclusiveTotalPrice(
@@ -1750,6 +1755,8 @@
        specificationModel: p.specification || "",
        unit: p.unit || "",
        quantity: quantity,
        singleQuantity: singleQuantity,
        totalQuantity: String(quantity * singleQuantity),
        taxRate: taxRate,
        taxInclusiveUnitPrice: unitPrice.toFixed(2),
        taxInclusiveTotalPrice: taxInclusiveTotalPrice,
@@ -1817,6 +1824,12 @@
    if (type === "edit") {
      productForm.value = { ...row };
      productIndex.value = index;
      // 如果没有 totalQuantity,自动计算:总数 = 每件数量 * 数量
      if (!productForm.value.totalQuantity && productForm.value.quantity) {
        const singleQuantity = parseInt(productForm.value.singleQuantity) || 1;
        const quantity = parseFloat(productForm.value.quantity);
        productForm.value.totalQuantity = (quantity * singleQuantity).toFixed(0);
      }
      // 编辑时根据产品大类名称反查 tree 节点 id,并加载规格型号列表
      try {
        const options =
@@ -2799,6 +2812,22 @@
    const batchNoList = await getDeliveryBatchNoList(
      row.productModelId || row.modelId
    );
    // 自动分配发货数量:按照待发货数量,从上到下依次分配
    const noQuantity = Number(row?.noQuantity || 0);
    let remainingQuantity = noQuantity;
    batchNoList.forEach(item => {
      if (remainingQuantity <= 0) {
        item.deliveryQuantity = 0;
        return;
      }
      const batchStockQuantity = getDeliveryBatchQuantity(item);
      // 当前批次可分配的数量:取剩余待发货数量和库存数量的较小值
      const assignQuantity = Math.min(remainingQuantity, batchStockQuantity);
      item.deliveryQuantity = assignQuantity;
      remainingQuantity -= assignQuantity;
    });
    deliveryForm.value = {
      shippingCarNumber: "",
      expressCompany: "",