zouyu
2025-11-14 be65feb64970908c7f0a287faa7a53612686dd43
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;
  }