zouyu
2025-11-14 be65feb64970908c7f0a287faa7a53612686dd43
销售台账、采购台账添加产品表单调整
已修改3个文件
116 ■■■■■ 文件已修改
src/utils/summarizeTable.js 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/procurementManagement/procurementLedger/index.vue 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/salesManagement/salesLedger/index.vue 77 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/summarizeTable.js
@@ -42,7 +42,8 @@
};
// 不含税总价计算
const calculateTaxExclusiveTotalPrice = (taxInclusiveTotalPrice, taxRate) => {
  const taxRateDecimal = taxRate / 100;
  const taxRateNumber = taxRate?Number(taxRate):0;
  const taxRateDecimal = taxRateNumber / 100;
  return (taxInclusiveTotalPrice / (1 + taxRateDecimal)).toFixed(2);
};
// 含税总价计算
src/views/procurementManagement/procurementLedger/index.vue
@@ -489,7 +489,7 @@
        </el-row>
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="含税单价(元):" prop="taxInclusiveUnitPrice">
            <el-form-item label="含税/不含税单价(元):" prop="taxInclusiveUnitPrice">
              <el-input-number
                v-model="productForm.taxInclusiveUnitPrice"
                :precision="2"
@@ -909,7 +909,7 @@
    taxInclusiveUnitPrice: [
      { required: true, message: "请输入", trigger: "blur" },
    ],
    taxRate: [{ required: true, message: "请选择", trigger: "change" }],
    // taxRate: [{ required: true, message: "请选择", trigger: "change" }],
        warnNum: [{ required: true, message: "请选择", trigger: "change" }],
    taxInclusiveTotalPrice: [
      { required: true, message: "请输入", trigger: "blur" },
@@ -917,7 +917,7 @@
    taxExclusiveTotalPrice: [
      { required: true, message: "请输入", trigger: "blur" },
    ],
    invoiceType: [{ required: true, message: "请选择", trigger: "change" }],
    // invoiceType: [{ required: true, message: "请选择", trigger: "change" }],
  },
});
const { productForm, productRules } = toRefs(productFormData);
@@ -1330,10 +1330,10 @@
  return `${year}-${month}-${day}`;
}
const mathNum = () => {
    if (!productForm.value.taxRate) {
        proxy.$modal.msgWarning("请先选择税率");
        return;
    }
    // if (!productForm.value.taxRate) {
    //     proxy.$modal.msgWarning("请先选择税率");
    //     return;
    // }
  if (!productForm.value.taxInclusiveUnitPrice) {
    return;
  }
@@ -1346,22 +1346,28 @@
      productForm.value.taxInclusiveUnitPrice,
      productForm.value.quantity
    );
  if (productForm.value.taxRate) {
    // 不含税总价计算
    productForm.value.taxExclusiveTotalPrice =
      proxy.calculateTaxExclusiveTotalPrice(
        productForm.value.taxInclusiveTotalPrice,
        productForm.value.taxRate
      );
  }
  // if (productForm.value.taxRate) {
  //   // 不含税总价计算
  //   productForm.value.taxExclusiveTotalPrice =
  //     proxy.calculateTaxExclusiveTotalPrice(
  //       productForm.value.taxInclusiveTotalPrice,
  //       productForm.value.taxRate
  //     );
  // }
};
const reverseMathNum = (field) => {
    if (!productForm.value.taxRate) {
        proxy.$modal.msgWarning("请先选择税率");
        return;
    }
  const taxRate = Number(productForm.value.taxRate);
  if (!taxRate) return;
    // if (!productForm.value.taxRate) {
    //     proxy.$modal.msgWarning("请先选择税率");
    //     return;
    // }
  const taxRate = productForm.value.taxRate?Number(productForm.value.taxRate):0;
  // if (!taxRate) return;
  if (field === 'taxInclusiveTotalPrice') {
    // 已知含税总价和数量,反算含税单价
    if (productForm.value.quantity) {
src/views/salesManagement/salesLedger/index.vue
@@ -250,7 +250,7 @@
        </el-row>
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="含税单价(元):" prop="taxInclusiveUnitPrice">
            <el-form-item label="含税/不含税单价(元):" prop="taxInclusiveUnitPrice">
              <el-input-number :step="0.01" :min="0" v-model="productForm.taxInclusiveUnitPrice" style="width: 100%"
                                                             :precision="2"
                                                             placeholder="请输入" clearable @change="calculateFromUnitPrice" />
@@ -563,14 +563,14 @@
    taxInclusiveUnitPrice: [
      { required: true, message: "请输入", trigger: "blur" },
    ],
    taxRate: [{ required: true, message: "请选择", trigger: "change" }],
    // taxRate: [{ required: true, message: "请选择", trigger: "change" }],
    taxInclusiveTotalPrice: [
      { required: true, message: "请输入", trigger: "blur" },
    ],
    taxExclusiveTotalPrice: [
      { required: true, message: "请输入", trigger: "blur" },
    ],
    invoiceType: [{ required: true, message: "请选择", trigger: "change" }],
    // invoiceType: [{ required: true, message: "请选择", trigger: "change" }],
  },
});
const { productForm, productRules } = toRefs(productFormData);
@@ -1380,30 +1380,38 @@
  productForm.value.taxInclusiveUnitPrice = (totalPrice / quantity).toFixed(2);
  
  // 如果有税率,计算不含税总价
  if (productForm.value.taxRate) {
  // if (productForm.value.taxRate) {
  //   productForm.value.taxExclusiveTotalPrice =
  //     proxy.calculateTaxExclusiveTotalPrice(
  //       totalPrice,
  //       productForm.value.taxRate
  //     );
  // }
    productForm.value.taxExclusiveTotalPrice =
      proxy.calculateTaxExclusiveTotalPrice(
        totalPrice,
        productForm.value.taxRate
      );
  }
  
  isCalculating.value = false;
};
// 根据不含税总价计算含税单价和数量
const calculateFromExclusiveTotalPrice = () => {
    if (!productForm.value.taxRate) {
        proxy.$modal.msgWarning("请先选择税率");
        return;
    }
    // if (!productForm.value.taxRate) {
    //     proxy.$modal.msgWarning("请先选择税率");
    //     return;
    // }
  if (isCalculating.value) return;
  
  const exclusiveTotalPrice = parseFloat(productForm.value.taxExclusiveTotalPrice);
  const quantity = parseFloat(productForm.value.quantity);
  const taxRate = parseFloat(productForm.value.taxRate);
  const taxRate = productForm.value.taxRate?parseFloat(productForm.value.taxRate):0;
  
  if (!exclusiveTotalPrice || !quantity || quantity <= 0 || !taxRate) {
  // if (!exclusiveTotalPrice || !quantity || quantity <= 0 || !taxRate) {
  //   return;
  // }
  if (!exclusiveTotalPrice || !quantity || quantity <= 0) {
    return;
  }
  
@@ -1422,10 +1430,10 @@
// 根据数量变化计算总价
const calculateFromQuantity = () => {
    if (!productForm.value.taxRate) {
        proxy.$modal.msgWarning("请先选择税率");
        return;
    }
    // if (!productForm.value.taxRate) {
    //     proxy.$modal.msgWarning("请先选择税率");
    //     return;
    // }
  if (isCalculating.value) return;
  
  const quantity = parseFloat(productForm.value.quantity);
@@ -1441,23 +1449,28 @@
  productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2);
  
  // 如果有税率,计算不含税总价
  if (productForm.value.taxRate) {
  // if (productForm.value.taxRate) {
  //   productForm.value.taxExclusiveTotalPrice =
  //     proxy.calculateTaxExclusiveTotalPrice(
  //       productForm.value.taxInclusiveTotalPrice,
  //       productForm.value.taxRate
  //     );
  // }
    productForm.value.taxExclusiveTotalPrice =
      proxy.calculateTaxExclusiveTotalPrice(
        productForm.value.taxInclusiveTotalPrice,
        productForm.value.taxRate
      );
  }
  
  isCalculating.value = false;
};
// 根据含税单价变化计算总价
const calculateFromUnitPrice = () => {
    if (!productForm.value.taxRate) {
        proxy.$modal.msgWarning("请先选择税率");
        return;
    }
    // if (!productForm.value.taxRate) {
    //     proxy.$modal.msgWarning("请先选择税率");
    //     return;
    // }
  if (isCalculating.value) return;
  
  const quantity = parseFloat(productForm.value.quantity);
@@ -1473,29 +1486,37 @@
  productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2);
  
  // 如果有税率,计算不含税总价
  if (productForm.value.taxRate) {
  // if (productForm.value.taxRate) {
  //   productForm.value.taxExclusiveTotalPrice =
  //     proxy.calculateTaxExclusiveTotalPrice(
  //       productForm.value.taxInclusiveTotalPrice,
  //       productForm.value.taxRate
  //     );
  // }
    productForm.value.taxExclusiveTotalPrice =
      proxy.calculateTaxExclusiveTotalPrice(
        productForm.value.taxInclusiveTotalPrice,
        productForm.value.taxRate
      );
  }
  
  isCalculating.value = false;
};
// 根据税率变化计算不含税总价
const calculateFromTaxRate = () => {
    if (!productForm.value.taxRate) {
        proxy.$modal.msgWarning("请先选择税率");
        return;
    }
    // if (!productForm.value.taxRate) {
    //     proxy.$modal.msgWarning("请先选择税率");
    //     return;
    // }
  if (isCalculating.value) return;
  
  const inclusiveTotalPrice = parseFloat(productForm.value.taxInclusiveTotalPrice);
  const taxRate = parseFloat(productForm.value.taxRate);
  
  if (!inclusiveTotalPrice || !taxRate) {
  // if (!inclusiveTotalPrice || !taxRate) {
  //   return;
  // }
  if (!inclusiveTotalPrice) {
    return;
  }