gaoluyang
14 小时以前 3ab45f295fb26c7794b4829976f3fb20c68a012e
src/views/procurementManagement/procurementLedger/index.vue
@@ -106,6 +106,12 @@
          prop="supplierName"
          show-overflow-tooltip
        />
            <el-table-column
               label="签订日期"
               prop="executionDate"
               width="100"
               show-overflow-tooltip
            />
        <el-table-column
          label="付款方式"
          width="100"
@@ -174,6 +180,7 @@
    </div>
    <el-dialog
      v-model="dialogFormVisible"
         draggable
      :title="operationType === 'add' ? '新增采购台账页面' : '编辑采购台账页面'"
      width="70%"
      @close="closeDia"
@@ -202,7 +209,6 @@
                placeholder="请选择"
                        filterable
                clearable
                @change="salesLedgerChange"
              >
                <el-option
                  v-for="item in salesContractList"
@@ -405,6 +411,7 @@
    </el-dialog>
    <el-dialog
      v-model="productFormVisible"
         draggable
      :title="productOperationType === 'add' ? '新增产品' : '编辑产品'"
      width="40%"
      @close="closeProductDia"
@@ -470,7 +477,9 @@
                        @change="mathNum"
                     >
                        <el-option label="1" value="1" />
                        <el-option label="3" value="3" />
                        <el-option label="6" value="6" />
                        <el-option label="9" value="9" />
                        <el-option label="13" value="13" />
                     </el-select>
                  </el-form-item>
@@ -481,7 +490,7 @@
            <el-form-item label="含税单价(元):" prop="taxInclusiveUnitPrice">
              <el-input-number
                v-model="productForm.taxInclusiveUnitPrice"
                :precision="2"
                :precision="3"
                :step="0.1"
                clearable
                style="width: 100%"
@@ -494,7 +503,7 @@
                     <el-input-number
                        :step="0.1"
                        clearable
                        :precision="2"
                        :precision="3"
                        style="width: 100%"
                        v-model="productForm.quantity"
                        placeholder="请输入"
@@ -508,7 +517,7 @@
            <el-form-item label="含税总价(元):" prop="taxInclusiveTotalPrice">
              <el-input-number
                v-model="productForm.taxInclusiveTotalPrice"
                :precision="2"
                :precision="3"
                :step="0.1"
                clearable
                style="width: 100%"
@@ -545,7 +554,7 @@
                  <el-form-item label="库存预警数量:" prop="warnNum">
                     <el-input-number
                        v-model="productForm.warnNum"
                        :precision="2"
                        :precision="3"
                        :step="0.1"
                        clearable
                        style="width: 100%"
@@ -629,7 +638,7 @@
            <el-form-item label="合同金额(元):" prop="contractAmount">
              <el-input-number
                v-model="scanAddForm.contractAmount"
                :precision="2"
                :precision="3"
                :step="0.1"
                clearable
                style="width: 100%"
@@ -813,6 +822,7 @@
import useUserStore from "@/store/modules/user";
import { modelList, productTreeList } from "@/api/basicData/product.js";
import dayjs from "dayjs";
import { getCurrentDate, truncate } from "@/utils/index.js";
const userStore = useUserStore();
@@ -920,7 +930,7 @@
};
const formattedNumber = (row, column, cellValue) => {
  return parseFloat(cellValue).toFixed(2);
  return truncate(parseFloat(cellValue), 3);
};
// 查询列表
/** 搜索按钮操作 */
@@ -1030,6 +1040,11 @@
  });
  form.value.recorderId = userStore.id;
  form.value.entryDate = getCurrentDate();
  if (type === "add") {
    // 新增时设置默认值
    form.value.paymentMethod = "电汇"; // 付款方式默认为电汇
    form.value.executionDate = getCurrentDate(); // 签订日期默认为当天
  }
  if (type === "edit") {
    currentId.value = row.id;
    getPurchaseById({ id: row.id, type: 2 }).then((res) => {
@@ -1101,6 +1116,12 @@
      }
      form.value.tempFileIds = tempFileIds;
      form.value.type = 2;
      // 如果salesLedgerId为空,则不传递salesContractNo
      if (!form.value.salesLedgerId) {
        form.value.salesContractNo = ''
      }
      addOrEditPurchase(form.value).then((res) => {
        proxy.$modal.msgSuccess("提交成功");
        closeDia();
@@ -1122,12 +1143,17 @@
  proxy.resetForm("productFormRef");
  if (type === "edit") {
    productForm.value = { ...row };
  } else {
    // 新增产品时设置默认值
    productForm.value.taxRate = "13"; // 税率默认为13%
    productForm.value.invoiceType = "增专票"; // 发票类型默认为增专票
    productForm.value.warnNum = 500; // 预警量默认为500
  }
  productFormVisible.value = true;
  getProductOptions();
};
const getProductOptions = () => {
  productTreeList().then((res) => {
  productTreeList({productName: '采购'}).then((res) => {
    productOptions.value = convertIdToValue(res);
  });
};
@@ -1301,14 +1327,6 @@
      proxy.$modal.msg("已取消");
    });
};
// 获取当前日期并格式化为 YYYY-MM-DD
function getCurrentDate() {
  const today = new Date();
  const year = today.getFullYear();
  const month = String(today.getMonth() + 1).padStart(2, "0"); // 月份从0开始
  const day = String(today.getDate()).padStart(2, "0");
  return `${year}-${month}-${day}`;
}
const mathNum = () => {
   if (!productForm.value.taxRate) {
      proxy.$modal.msgWarning("请先选择税率");
@@ -1322,16 +1340,18 @@
  }
  // 含税总价计算
  productForm.value.taxInclusiveTotalPrice =
    proxy.calculateTaxIncludeTotalPrice(
      productForm.value.taxInclusiveUnitPrice,
      productForm.value.quantity
    truncate(
      Number(productForm.value.taxInclusiveUnitPrice) * Number(productForm.value.quantity),
      3
    );
  if (productForm.value.taxRate) {
    // 不含税总价计算
    const taxRate = Number(productForm.value.taxRate);
    const taxRateDecimal = taxRate / 100;
    productForm.value.taxExclusiveTotalPrice =
      proxy.calculateTaxExclusiveTotalPrice(
        productForm.value.taxInclusiveTotalPrice,
        productForm.value.taxRate
      truncate(
        Number(productForm.value.taxInclusiveTotalPrice) / (1 + taxRateDecimal),
        3
      );
  }
};
@@ -1346,29 +1366,29 @@
    // 已知含税总价和数量,反算含税单价
    if (productForm.value.quantity) {
      productForm.value.taxInclusiveUnitPrice = 
        (Number(productForm.value.taxInclusiveTotalPrice) / Number(productForm.value.quantity)).toFixed(2);
        truncate(Number(productForm.value.taxInclusiveTotalPrice) / Number(productForm.value.quantity), 3);
    }
    // 已知含税总价和含税单价,反算数量
    else if (productForm.value.taxInclusiveUnitPrice) {
      productForm.value.quantity = 
        (Number(productForm.value.taxInclusiveTotalPrice) / Number(productForm.value.taxInclusiveUnitPrice)).toFixed(2);
        truncate(Number(productForm.value.taxInclusiveTotalPrice) / Number(productForm.value.taxInclusiveUnitPrice), 3);
    }
    // 反算不含税总价
    productForm.value.taxExclusiveTotalPrice = 
      (Number(productForm.value.taxInclusiveTotalPrice) / (1 + taxRate / 100)).toFixed(2);
      truncate(Number(productForm.value.taxInclusiveTotalPrice) / (1 + taxRate / 100), 3);
  } else if (field === 'taxExclusiveTotalPrice') {
    // 反算含税总价
    productForm.value.taxInclusiveTotalPrice = 
      (Number(productForm.value.taxExclusiveTotalPrice) * (1 + taxRate / 100)).toFixed(2);
      truncate(Number(productForm.value.taxExclusiveTotalPrice) * (1 + taxRate / 100), 3);
    // 已知数量,反算含税单价
    if (productForm.value.quantity) {
      productForm.value.taxInclusiveUnitPrice = 
        (Number(productForm.value.taxInclusiveTotalPrice) / Number(productForm.value.quantity)).toFixed(2);
        truncate(Number(productForm.value.taxInclusiveTotalPrice) / Number(productForm.value.quantity), 3);
    }
    // 已知含税单价,反算数量
    else if (productForm.value.taxInclusiveUnitPrice) {
      productForm.value.quantity = 
        (Number(productForm.value.taxInclusiveTotalPrice) / Number(productForm.value.taxInclusiveUnitPrice)).toFixed(2);
        truncate(Number(productForm.value.taxInclusiveTotalPrice) / Number(productForm.value.taxInclusiveUnitPrice), 3);
    }
  }
};
@@ -1582,4 +1602,4 @@
});
</script>
<style scoped lang="scss"></style>
<style scoped lang="scss"></style>