yuan
7 天以前 d2192e6e8b6a8d0f2fb68dd554c065a436e22c71
src/views/procurementManagement/procurementLedger/index.vue
@@ -68,6 +68,7 @@
      <div style="display: flex;justify-content: flex-end;margin-bottom: 20px;">
        <el-button type="success"
                   plain
                   v-if="false"
                   @click="handleBatchGenerate">批量生成数据</el-button>
        <el-button type="primary"
                   @click="openForm('add')">新增台账</el-button>
@@ -124,7 +125,7 @@
              <el-table-column label="可用数量"
                               prop="availableQuality" />
              <el-table-column label="退货数量"
                               prop="returnQuality" />
                               prop="returnQuantity" />
              <el-table-column label="税率(%)"
                               prop="taxRate" />
              <el-table-column label="含税单价(元)"
@@ -132,10 +133,10 @@
                               :formatter="formattedNumber" />
              <el-table-column label="含税总价(元)"
                               prop="taxInclusiveTotalPrice"
                               :formatter="formattedNumber" />
                               :formatter="formattedAmount" />
              <el-table-column label="不含税总价(元)"
                               prop="taxExclusiveTotalPrice"
                               :formatter="formattedNumber" />
                               :formatter="formattedAmount" />
            </el-table>
          </template>
        </el-table-column>
@@ -193,7 +194,12 @@
                         prop="contractAmount"
                         width="200"
                         show-overflow-tooltip
                         :formatter="formattedNumber" />
                         :formatter="formattedAmount" />
<!--        <el-table-column label="实际合同金额(元)"-->
<!--                         prop="netContractAmount"-->
<!--                         width="200"-->
<!--                         show-overflow-tooltip-->
<!--                         :formatter="formattedNumber" />-->
        <el-table-column label="录入人"
                         prop="recorderName"
                         width="120"
@@ -426,11 +432,11 @@
                           width="150" />
          <el-table-column label="含税总价(元)"
                           prop="taxInclusiveTotalPrice"
                           :formatter="formattedNumber"
                           :formatter="formattedAmount"
                           width="150" />
          <el-table-column label="不含税总价(元)"
                           prop="taxExclusiveTotalPrice"
                           :formatter="formattedNumber"
                           :formatter="formattedAmount"
                           width="150" />
          <el-table-column label="是否质检"
                           prop="isChecked"
@@ -593,7 +599,7 @@
            <el-form-item label="含税单价(元):"
                          prop="taxInclusiveUnitPrice">
              <el-input-number v-model="productForm.taxInclusiveUnitPrice"
                               :precision="2"
                               :precision="6"
                               :step="0.1"
                               :min="0"
                               clearable
@@ -606,7 +612,7 @@
                          prop="quantity">
              <el-input-number :step="0.1"
                               clearable
                               :precision="2"
                               :precision="6"
                               :min="0"
                               style="width: 100%"
                               v-model="productForm.quantity"
@@ -620,7 +626,7 @@
            <el-form-item label="含税总价(元):"
                          prop="taxInclusiveTotalPrice">
              <el-input-number v-model="productForm.taxInclusiveTotalPrice"
                               :precision="2"
                               :precision="6"
                               :step="0.1"
                               :min="0"
                               clearable
@@ -632,7 +638,7 @@
            <el-form-item label="不含税总价(元):"
                          prop="taxExclusiveTotalPrice">
              <el-input-number v-model="productForm.taxExclusiveTotalPrice"
                               :precision="2"
                               :precision="6"
                               :step="0.1"
                               :min="0"
                               clearable
@@ -659,7 +665,7 @@
            <el-form-item label="库存预警数量:"
                          prop="warnNum">
              <el-input-number v-model="productForm.warnNum"
                               :precision="2"
                               :precision="6"
                               :step="0.1"
                               :min="0"
                               clearable
@@ -755,6 +761,7 @@
  import { modelList, productTreeList } from "@/api/basicData/product.js";
  import dayjs from "dayjs";
  import FileUpload from "@/components/AttachmentUpload/file/index.vue";
  import { roundHalfUp, trimZeros } from "@/utils/formatNumber.js";
  const userStore = useUserStore();
@@ -938,7 +945,16 @@
    },
  });
  const { form, rules } = toRefs(data);
  const { form: searchForm } = useFormData(data.searchForm);
  const { form: searchForm } = useFormData({
    ...data.searchForm,
    // 设置录入日期范围为当天
    entryDate: [
      dayjs().startOf("day").format("YYYY-MM-DD"),
      dayjs().endOf("day").format("YYYY-MM-DD"),
    ],
    entryDateStart: dayjs().startOf("day").format("YYYY-MM-DD"),
    entryDateEnd: dayjs().endOf("day").format("YYYY-MM-DD"),
  });
  // 产品表单弹框数据
  const productFormVisible = ref(false);
@@ -1070,7 +1086,15 @@
  };
  const formattedNumber = (row, column, cellValue) => {
    return parseFloat(cellValue).toFixed(2);
    return trimZeros(cellValue, 6);
  };
  // 金额显示格式化:按十进制四舍五入到 2 位小数(与数据库 ROUND 一致),再去掉末尾多余的 0
  const formatAmount = value => {
    return trimZeros(roundHalfUp(value, 2), 2);
  };
  // 金额列的表格格式化函数(单价列仍用 formattedNumber 保留 6 位小数)
  const formattedAmount = (row, column, cellValue) => {
    return formatAmount(cellValue);
  };
  // 查询列表
  /** 搜索按钮操作 */
@@ -1190,6 +1214,12 @@
        "futureTicketsAmount",
      ],
      {
        taxInclusiveUnitPrice: { decimalPlaces: 6, trimZeros: true },
        // 金额列:每行先按 2 位小数四舍五入再求和,保证合计与列内展示值一致
        taxInclusiveTotalPrice: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
        taxExclusiveTotalPrice: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
        ticketsAmount: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
        futureTicketsAmount: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
        ticketsNum: { noDecimal: true }, // 不保留小数
        futureTickets: { noDecimal: true }, // 不保留小数
      }
@@ -1255,15 +1285,32 @@
  };
  // 主表合计方法
  const summarizeMainTable = param => {
    return proxy.summarizeTable(param, ["contractAmount"]);
    return proxy.summarizeTable(
      param,
      ["contractAmount", "netContractAmount"],
      {
        // 金额列:每行先按 2 位小数四舍五入再求和,保证合计与列内展示值一致
        contractAmount: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
        netContractAmount: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
      }
    );
  };
  // 子表合计方法
  const summarizeProTable = param => {
    return proxy.summarizeTable(param, [
      "taxInclusiveUnitPrice",
      "taxInclusiveTotalPrice",
      "taxExclusiveTotalPrice",
    ]);
    return proxy.summarizeTable(
      param,
      [
        "taxInclusiveUnitPrice",
        "taxInclusiveTotalPrice",
        "taxExclusiveTotalPrice",
      ],
      {
        taxInclusiveUnitPrice: { decimalPlaces: 6, trimZeros: true },
        // 金额列:每行先按 2 位小数四舍五入再求和,保证合计与列内展示值一致
        taxInclusiveTotalPrice: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
        taxExclusiveTotalPrice: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
      }
    );
  };
  // 打开弹框
  const openForm = async (type, row) => {
@@ -1771,14 +1818,16 @@
    productForm.value.taxInclusiveTotalPrice =
      proxy.calculateTaxIncludeTotalPrice(
        productForm.value.taxInclusiveUnitPrice,
        productForm.value.quantity
        productForm.value.quantity,
        6
      );
    if (productForm.value.taxRate) {
      // 不含税总价计算
      productForm.value.taxExclusiveTotalPrice =
        proxy.calculateTaxExclusiveTotalPrice(
          productForm.value.taxInclusiveTotalPrice,
          productForm.value.taxRate
          productForm.value.taxRate,
          6
        );
    }
  };
@@ -1809,7 +1858,7 @@
        productForm.value.taxInclusiveUnitPrice = (
          Number(productForm.value.taxInclusiveTotalPrice) /
          Number(productForm.value.quantity)
        ).toFixed(2);
        ).toFixed(6);
        // 确保结果不为负数
        if (Number(productForm.value.taxInclusiveUnitPrice) < 0) {
          productForm.value.taxInclusiveUnitPrice = "0";
@@ -1820,7 +1869,7 @@
        productForm.value.quantity = (
          Number(productForm.value.taxInclusiveTotalPrice) /
          Number(productForm.value.taxInclusiveUnitPrice)
        ).toFixed(2);
        ).toFixed(6);
        // 确保结果不为负数
        if (Number(productForm.value.quantity) < 0) {
          productForm.value.quantity = "0";
@@ -1830,7 +1879,7 @@
      productForm.value.taxExclusiveTotalPrice = (
        Number(productForm.value.taxInclusiveTotalPrice) /
        (1 + taxRate / 100)
      ).toFixed(2);
      ).toFixed(6);
      // 确保结果不为负数
      if (Number(productForm.value.taxExclusiveTotalPrice) < 0) {
        productForm.value.taxExclusiveTotalPrice = "0";
@@ -1840,7 +1889,7 @@
      productForm.value.taxInclusiveTotalPrice = (
        Number(productForm.value.taxExclusiveTotalPrice) *
        (1 + taxRate / 100)
      ).toFixed(2);
      ).toFixed(6);
      // 确保结果不为负数
      if (Number(productForm.value.taxInclusiveTotalPrice) < 0) {
        productForm.value.taxInclusiveTotalPrice = "0";
@@ -1850,7 +1899,7 @@
        productForm.value.taxInclusiveUnitPrice = (
          Number(productForm.value.taxInclusiveTotalPrice) /
          Number(productForm.value.quantity)
        ).toFixed(2);
        ).toFixed(6);
        // 确保结果不为负数
        if (Number(productForm.value.taxInclusiveUnitPrice) < 0) {
          productForm.value.taxInclusiveUnitPrice = "0";
@@ -1861,7 +1910,7 @@
        productForm.value.quantity = (
          Number(productForm.value.taxInclusiveTotalPrice) /
          Number(productForm.value.taxInclusiveUnitPrice)
        ).toFixed(2);
        ).toFixed(6);
        // 确保结果不为负数
        if (Number(productForm.value.quantity) < 0) {
          productForm.value.quantity = "0";