gaoluyang
6 天以前 287fd4cd8b556e99997168341577b2deaa8a8e8e
宝东
1.销售管理新增产品时添加一个总数字段
已修改1个文件
66 ■■■■ 文件已修改
src/views/salesManagement/salesLedger/index.vue 66 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/salesManagement/salesLedger/index.vue
@@ -700,6 +700,15 @@
                               style="width: 100%" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="总数:"
                          prop="totalQuantity">
              <el-input v-model="productForm.totalQuantity"
                        placeholder="自动计算"
                        disabled
                        style="width: 100%" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="30">
          <el-col :span="12">
@@ -1137,6 +1146,7 @@
      unit: "",
      quantity: "",
      singleQuantity: 1,
      totalQuantity: "",
      taxInclusiveUnitPrice: "",
      taxRate: "",
      taxInclusiveTotalPrice: "",
@@ -2469,7 +2479,6 @@
    const totalPrice = parseFloat(productForm.value.taxInclusiveTotalPrice);
    const quantity = parseFloat(productForm.value.quantity);
    const singleQuantity = parseInt(productForm.value.singleQuantity) || 1;
    if (!totalPrice || !quantity || quantity <= 0) {
      return;
@@ -2477,8 +2486,8 @@
    isCalculating.value = true;
    // 计算含税单价 = 含税总价 / (数量 * 每件数量)
    productForm.value.taxInclusiveUnitPrice = (totalPrice / (quantity * singleQuantity)).toFixed(2);
    // 计算含税单价 = 含税总价 / 数量
    productForm.value.taxInclusiveUnitPrice = (totalPrice / quantity).toFixed(2);
    // 如果有税率,计算不含税总价
    if (productForm.value.taxRate) {
@@ -2488,6 +2497,10 @@
          productForm.value.taxRate
        );
    }
    // 计算总数 = 每件数量 * 数量
    const singleQuantity = parseInt(productForm.value.singleQuantity) || 1;
    productForm.value.totalQuantity = (quantity * singleQuantity).toFixed(0);
    isCalculating.value = false;
  };
@@ -2505,7 +2518,6 @@
    );
    const quantity = parseFloat(productForm.value.quantity);
    const taxRate = parseFloat(productForm.value.taxRate);
    const singleQuantity = parseInt(productForm.value.singleQuantity) || 1;
    if (!exclusiveTotalPrice || !quantity || quantity <= 0 || !taxRate) {
      return;
@@ -2518,10 +2530,14 @@
    const inclusiveTotalPrice = exclusiveTotalPrice / (1 - taxRateDecimal);
    productForm.value.taxInclusiveTotalPrice = inclusiveTotalPrice.toFixed(2);
    // 计算含税单价 = 含税总价 / (数量 * 每件数量)
    // 计算含税单价 = 含税总价 / 数量
    productForm.value.taxInclusiveUnitPrice = (
      inclusiveTotalPrice / (quantity * singleQuantity)
      inclusiveTotalPrice / quantity
    ).toFixed(2);
    // 计算总数 = 每件数量 * 数量
    const singleQuantity = parseInt(productForm.value.singleQuantity) || 1;
    productForm.value.totalQuantity = (quantity * singleQuantity).toFixed(0);
    isCalculating.value = false;
  };
@@ -2536,7 +2552,6 @@
    const quantity = parseFloat(productForm.value.quantity);
    const unitPrice = parseFloat(productForm.value.taxInclusiveUnitPrice);
    const singleQuantity = parseInt(productForm.value.singleQuantity) || 1;
    if (!quantity || quantity <= 0 || !unitPrice) {
      return;
@@ -2544,8 +2559,8 @@
    isCalculating.value = true;
    // 计算含税总价 = 单价 * 数量 * 每件数量
    productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity * singleQuantity).toFixed(2);
    // 计算含税总价 = 单价 * 数量
    productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2);
    // 如果有税率,计算不含税总价
    if (productForm.value.taxRate) {
@@ -2555,6 +2570,10 @@
          productForm.value.taxRate
        );
    }
    // 计算总数 = 每件数量 * 数量
    const singleQuantity = parseInt(productForm.value.singleQuantity) || 1;
    productForm.value.totalQuantity = (quantity * singleQuantity).toFixed(0);
    isCalculating.value = false;
  };
@@ -2569,7 +2588,6 @@
    const quantity = parseFloat(productForm.value.quantity);
    const unitPrice = parseFloat(productForm.value.taxInclusiveUnitPrice);
    const singleQuantity = parseInt(productForm.value.singleQuantity) || 1;
    if (!quantity || quantity <= 0 || !unitPrice) {
      return;
@@ -2577,8 +2595,8 @@
    isCalculating.value = true;
    // 计算含税总价 = 单价 * 数量 * 每件数量
    productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity * singleQuantity).toFixed(2);
    // 计算含税总价 = 单价 * 数量
    productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2);
    // 如果有税率,计算不含税总价
    if (productForm.value.taxRate) {
@@ -2592,35 +2610,21 @@
    isCalculating.value = false;
  };
  // 根据每件数量变化计算总价
  // 根据每件数量变化计算总数
  const calculateFromSingleQuantity = () => {
    if (!productForm.value.taxRate) {
      proxy.$modal.msgWarning("请先选择税率");
      return;
    }
    if (isCalculating.value) return;
    const quantity = parseFloat(productForm.value.quantity);
    const unitPrice = parseFloat(productForm.value.taxInclusiveUnitPrice);
    const singleQuantity = parseInt(productForm.value.singleQuantity) || 1;
    if (!quantity || quantity <= 0 || !unitPrice) {
    if (!quantity || quantity <= 0) {
      return;
    }
    isCalculating.value = true;
    // 计算含税总价 = 单价 * 数量 * 每件数量
    productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity * singleQuantity).toFixed(2);
    // 如果有税率,计算不含税总价
    if (productForm.value.taxRate) {
      productForm.value.taxExclusiveTotalPrice =
        proxy.calculateTaxExclusiveTotalPrice(
          productForm.value.taxInclusiveTotalPrice,
          productForm.value.taxRate
        );
    }
    // 计算总数 = 每件数量 * 数量
    const singleQuantity = parseInt(productForm.value.singleQuantity) || 1;
    productForm.value.totalQuantity = (quantity * singleQuantity).toFixed(0);
    isCalculating.value = false;
  };