From 0a7f62f18d322dcb82ec3134075ea4e71f010825 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期四, 25 六月 2026 09:09:09 +0800
Subject: [PATCH] fix: 报价、审核、采购台账、供应商往来、销售台账、客户往来小数点保留6位小数
---
src/views/collaborativeApproval/approvalProcess/components/approvalDia.vue | 11 +
src/views/procurementManagement/procurementLedger/index.vue | 68 +++++++----
src/views/procurementManagement/procurementReport/index.vue | 7
src/utils/numberFormat.js | 47 +++++++
src/views/procurementManagement/procurementLedger/detail.vue | 8 -
src/views/salesManagement/receiptPaymentLedger/index.vue | 27 ++-
src/views/salesManagement/salesLedger/index.vue | 70 ++++++----
src/views/salesManagement/salesQuotation/index.vue | 15 +-
src/utils/summarizeTable.js | 21 ++-
src/views/procurementManagement/paymentLedger/index.vue | 43 +++---
10 files changed, 203 insertions(+), 114 deletions(-)
diff --git a/src/utils/numberFormat.js b/src/utils/numberFormat.js
new file mode 100644
index 0000000..50175f0
--- /dev/null
+++ b/src/utils/numberFormat.js
@@ -0,0 +1,47 @@
+/** 閲戦绫诲瓧娈甸粯璁ゆ渶澶у皬鏁颁綅鏁� */
+export const AMOUNT_DECIMAL_SCALE = 6
+
+/**
+ * 鏍煎紡鍖栨暟瀛楋細鏈�澶氫繚鐣� scale 浣嶅皬鏁帮紝骞跺幓闄ゆ湯灏惧浣欑殑 0
+ */
+export function formatDecimal(value, scale = AMOUNT_DECIMAL_SCALE, fallback = '0') {
+ if (value === null || value === undefined || value === '') {
+ return fallback
+ }
+ const num = Number(value)
+ if (Number.isNaN(num)) {
+ return fallback
+ }
+ return parseFloat(num.toFixed(scale)).toString()
+}
+
+/** 甯﹁揣甯佺鍙风殑閲戦灞曠ず */
+export function formatCurrency(value, scale = AMOUNT_DECIMAL_SCALE) {
+ return `楼${formatDecimal(value, scale)}`
+}
+
+/** el-table-column formatter */
+export function tableAmountFormatter(row, column, cellValue) {
+ return formatDecimal(cellValue)
+}
+
+/** 璁$畻鍚庝繚鐣欐寚瀹氫綅灏忔暟 */
+export function roundAmount(value, scale = AMOUNT_DECIMAL_SCALE) {
+ if (value === null || value === undefined || value === '') {
+ return 0
+ }
+ const num = Number(value)
+ if (Number.isNaN(num)) {
+ return 0
+ }
+ return parseFloat(num.toFixed(scale))
+}
+
+/** 鏋勫缓 summarizeTable 閲戦鍒楁牸寮忛厤缃� */
+export function buildAmountSummaryFormat(fields, extraFormat = {}) {
+ const format = { ...extraFormat }
+ fields.forEach(field => {
+ format[field] = { decimalPlaces: AMOUNT_DECIMAL_SCALE }
+ })
+ return format
+}
diff --git a/src/utils/summarizeTable.js b/src/utils/summarizeTable.js
index 1ad480d..3602523 100644
--- a/src/utils/summarizeTable.js
+++ b/src/utils/summarizeTable.js
@@ -1,3 +1,5 @@
+import { formatDecimal, AMOUNT_DECIMAL_SCALE } from './numberFormat'
+
/**
* 閫氱敤鐨勮〃鏍煎悎璁℃柟娉�
* @param {Object} param - 鍖呭惈琛ㄦ牸鍒楅厤缃拰鏁版嵁婧愮殑瀵硅薄
@@ -26,28 +28,35 @@
// 濡傛灉鎸囧畾浜嗕笉闇�瑕佷繚鐣欏皬鏁帮紝鍒欑洿鎺ヨ浆鎹负鏁存暟
sums[index] = Math.round(sum).toString();
} else {
- // 榛樿淇濈暀涓や綅灏忔暟
- sums[index] = parseFloat(sum).toFixed(
+ sums[index] = formatDecimal(
+ sum,
specialFormat[prop]?.decimalPlaces ?? 2
);
}
} else {
- sums[index] = "";
+ sums[index] = '';
}
} else {
- sums[index] = "";
+ sums[index] = '';
}
});
return sums;
};
+
// 涓嶅惈绋庢�讳环璁$畻
const calculateTaxExclusiveTotalPrice = (taxInclusiveTotalPrice, taxRate) => {
const taxRateDecimal = taxRate / 100;
- return (taxInclusiveTotalPrice / (1 + taxRateDecimal)).toFixed(2);
+ return formatDecimal(
+ Number(taxInclusiveTotalPrice) / (1 + taxRateDecimal),
+ AMOUNT_DECIMAL_SCALE
+ );
};
// 鍚◣鎬讳环璁$畻
const calculateTaxIncludeTotalPrice = (taxInclusiveUnitPrice, quantity) => {
- return (taxInclusiveUnitPrice * quantity).toFixed(2);
+ return formatDecimal(
+ Number(taxInclusiveUnitPrice) * Number(quantity),
+ AMOUNT_DECIMAL_SCALE
+ );
};
// 瀵煎嚭鍑芥暟渚涘叾浠栨枃浠朵娇鐢�
export {
diff --git a/src/views/collaborativeApproval/approvalProcess/components/approvalDia.vue b/src/views/collaborativeApproval/approvalProcess/components/approvalDia.vue
index 7c7524f..6a4b767 100644
--- a/src/views/collaborativeApproval/approvalProcess/components/approvalDia.vue
+++ b/src/views/collaborativeApproval/approvalProcess/components/approvalDia.vue
@@ -75,7 +75,7 @@
<el-descriptions-item label="鎶ヤ环鎬婚"
:span="2">
<span style="font-size: 18px; color: #e6a23c; font-weight: bold;">
- 楼{{ Number(currentQuotation.totalAmount ?? 0).toFixed(2) }}
+ {{ formatCurrency(currentQuotation.totalAmount) }}
</span>
</el-descriptions-item>
</el-descriptions>
@@ -92,7 +92,7 @@
label="鍗曚綅" />
<el-table-column prop="unitPrice"
label="鍗曚环">
- <template #default="scope">楼{{ Number(scope.row.unitPrice ?? 0).toFixed(2) }}</template>
+ <template #default="scope">{{ formatCurrency(scope.row.unitPrice) }}</template>
</el-table-column>
</el-table>
</div>
@@ -135,7 +135,7 @@
<el-descriptions-item label="鍚堝悓閲戦"
:span="2">
<span style="font-size: 18px; color: #e6a23c; font-weight: bold;">
- 楼{{ Number(currentPurchase.contractAmount ?? 0).toFixed(2) }}
+ {{ formatCurrency(currentPurchase.contractAmount) }}
</span>
</el-descriptions-item>
</el-descriptions>
@@ -154,11 +154,11 @@
label="鏁伴噺" />
<el-table-column prop="taxInclusiveUnitPrice"
label="鍚◣鍗曚环">
- <template #default="scope">楼{{ Number(scope.row.taxInclusiveUnitPrice ?? 0).toFixed(2) }}</template>
+ <template #default="scope">{{ formatCurrency(scope.row.taxInclusiveUnitPrice) }}</template>
</el-table-column>
<el-table-column prop="taxInclusiveTotalPrice"
label="鍚◣鎬讳环">
- <template #default="scope">楼{{ Number(scope.row.taxInclusiveTotalPrice ?? 0).toFixed(2) }}</template>
+ <template #default="scope">{{ formatCurrency(scope.row.taxInclusiveTotalPrice) }}</template>
</el-table-column>
</el-table>
</div>
@@ -332,6 +332,7 @@
import { getPurchaseByCode } from "@/api/procurementManagement/procurementLedger.js";
import { getDeliveryDetailByShippingNo } from "@/api/salesManagement/deliveryLedger.js";
import ImagePreview from "@/components/AttachmentPreview/image/index.vue";
+ import { formatCurrency } from "@/utils/numberFormat";
const emit = defineEmits(["close"]);
const { proxy } = getCurrentInstance();
diff --git a/src/views/procurementManagement/paymentLedger/index.vue b/src/views/procurementManagement/paymentLedger/index.vue
index ae2c30b..b913032 100644
--- a/src/views/procurementManagement/paymentLedger/index.vue
+++ b/src/views/procurementManagement/paymentLedger/index.vue
@@ -79,7 +79,7 @@
@pagination="sonPaginationSearch">
<template #payableAmountSlot="{ row }">
<el-text type="danger">
- {{ parseFloat(row.unshippedAmount).toFixed(2) }}
+ {{ formatDecimal(row.unshippedAmount) }}
</el-text>
</template>
</PIMTable>
@@ -90,13 +90,14 @@
</template>
<script setup>
- import { ref, toRefs } from "vue";
+ import { ref, toRefs, reactive, getCurrentInstance } from "vue";
import { Search } from "@element-plus/icons-vue";
import {
paymentLedgerList,
paymentRecordList,
} from "@/api/procurementManagement/paymentLedger.js";
import Pagination from "../../../components/PIMTable/Pagination.vue";
+ import { tableAmountFormatter, formatDecimal, buildAmountSummaryFormat } from "@/utils/numberFormat";
const tableData = ref([]);
const tableLoading = ref(false);
@@ -140,17 +141,13 @@
label: "鍚堝悓閲戦(鍏�)",
prop: "contractAmount",
width: 200,
- formatData: params => {
- return params ? parseFloat(params).toFixed(2) : 0;
- },
+ formatData: params => formatDecimal(params),
},
{
label: "宸插叆搴撻噾棰�(鍏�)",
prop: "shippedAmount",
width: 200,
- formatData: params => {
- return params ? parseFloat(params).toFixed(2) : 0;
- },
+ formatData: params => formatDecimal(params),
},
{
label: "鏈叆搴撻噾棰�(鍏�)",
@@ -171,10 +168,13 @@
return proxy.summarizeTable(
param,
["contractAmounts", "shippedAmount", "unshippedAmount"],
- {
- ticketsNum: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
- futureTickets: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
- }
+ buildAmountSummaryFormat(
+ ["contractAmounts", "shippedAmount", "unshippedAmount"],
+ {
+ ticketsNum: { noDecimal: true },
+ futureTickets: { noDecimal: true },
+ }
+ )
);
};
// 瀛愯〃鍚堣鏂规硶
@@ -182,10 +182,13 @@
let summarizeTable = proxy.summarizeTable(
param,
["contractAmount", "shippedAmount", "unshippedAmount"],
- {
- ticketsNum: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
- futureTickets: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
- }
+ buildAmountSummaryFormat(
+ ["contractAmount", "shippedAmount", "unshippedAmount"],
+ {
+ ticketsNum: { noDecimal: true },
+ futureTickets: { noDecimal: true },
+ }
+ )
);
return summarizeTable;
};
@@ -257,13 +260,7 @@
sonPage.size = pagination.limit;
getPaymenRecordtList(currentSupplierId.value);
};
- const formattedNumber = (row, column, cellValue) => {
- if (column.property !== "supplierName") {
- return parseFloat(cellValue).toFixed(2);
- } else {
- return cellValue;
- }
- };
+ const formattedNumber = tableAmountFormatter;
getList();
</script>
diff --git a/src/views/procurementManagement/procurementLedger/detail.vue b/src/views/procurementManagement/procurementLedger/detail.vue
index 37b7fdb..80aa42b 100644
--- a/src/views/procurementManagement/procurementLedger/detail.vue
+++ b/src/views/procurementManagement/procurementLedger/detail.vue
@@ -127,6 +127,7 @@
import FormDialog from "@/components/Dialog/FormDialog.vue"
import filePreview from '@/components/filePreview/index.vue'
import { getPurchaseById } from "@/api/procurementManagement/procurementLedger"
+import { tableAmountFormatter } from '@/utils/numberFormat'
const visible = ref(false)
// 鏄惁鏄剧ず閿�鍞悎鍚屽彿缁戝畾
@@ -157,12 +158,7 @@
fileList.value = []
}
-const formattedNumber = (row, column, cellValue) => {
- if (cellValue != null && !isNaN(cellValue)) {
- return Number(cellValue).toFixed(2)
- }
- return cellValue
-}
+const formattedNumber = tableAmountFormatter
const sumTaxInclusiveUnitPrice = computed(() => {
return productData.value.reduce((sum, item) => {
diff --git a/src/views/procurementManagement/procurementLedger/index.vue b/src/views/procurementManagement/procurementLedger/index.vue
index 2c9cec6..c0978ef 100644
--- a/src/views/procurementManagement/procurementLedger/index.vue
+++ b/src/views/procurementManagement/procurementLedger/index.vue
@@ -310,7 +310,7 @@
<el-row :gutter="30">
<el-col :span="12">
<el-form-item label="鍚◣鍗曚环(鍏�)锛�" prop="taxInclusiveUnitPrice">
- <el-input-number v-model="productForm.taxInclusiveUnitPrice" :precision="2" :step="0.1" :min="0" clearable
+ <el-input-number v-model="productForm.taxInclusiveUnitPrice" :precision="6" :step="0.000001" :min="0" clearable
style="width: 100%" @change="mathNum" />
</el-form-item>
</el-col>
@@ -324,13 +324,13 @@
<el-row :gutter="30">
<el-col :span="12">
<el-form-item label="鍚◣鎬讳环(鍏�)锛�" prop="taxInclusiveTotalPrice">
- <el-input-number v-model="productForm.taxInclusiveTotalPrice" :precision="2" :step="0.1" :min="0"
+ <el-input-number v-model="productForm.taxInclusiveTotalPrice" :precision="6" :step="0.000001" :min="0"
clearable style="width: 100%" @change="reverseMathNum('taxInclusiveTotalPrice')" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="涓嶅惈绋庢�讳环(鍏�)锛�" prop="taxExclusiveTotalPrice">
- <el-input-number v-model="productForm.taxExclusiveTotalPrice" :precision="2" :step="0.1" :min="0"
+ <el-input-number v-model="productForm.taxExclusiveTotalPrice" :precision="6" :step="0.000001" :min="0"
clearable style="width: 100%" @change="reverseMathNum('taxExclusiveTotalPrice')" />
</el-form-item>
</el-col>
@@ -445,6 +445,7 @@
import { modelList, productTreeList } from "@/api/basicData/product.js";
import dayjs from "dayjs";
import FileUpload from "@/components/AttachmentUpload/file/index.vue";
+import { tableAmountFormatter, formatDecimal, buildAmountSummaryFormat } from '@/utils/numberFormat';
const userStore = useUserStore();
@@ -771,9 +772,7 @@
handleQuery();
};
-const formattedNumber = (row, column, cellValue) => {
- return parseFloat(cellValue).toFixed(2);
-};
+const formattedNumber = tableAmountFormatter;
// 鏌ヨ鍒楄〃
/** 鎼滅储鎸夐挳鎿嶄綔 */
const handleQuery = () => {
@@ -891,10 +890,19 @@
"futureTickets",
"futureTicketsAmount",
],
- {
- ticketsNum: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
- futureTickets: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
- }
+ buildAmountSummaryFormat(
+ [
+ "taxInclusiveUnitPrice",
+ "taxInclusiveTotalPrice",
+ "taxExclusiveTotalPrice",
+ "ticketsAmount",
+ "futureTicketsAmount",
+ ],
+ {
+ ticketsNum: { noDecimal: true },
+ futureTickets: { noDecimal: true },
+ }
+ )
);
};
const paginationChange = obj => {
@@ -957,15 +965,27 @@
};
// 涓昏〃鍚堣鏂规硶
const summarizeMainTable = param => {
- return proxy.summarizeTable(param, ["contractAmount"]);
+ return proxy.summarizeTable(
+ param,
+ ["contractAmount"],
+ buildAmountSummaryFormat(["contractAmount"])
+ );
};
// 瀛愯〃鍚堣鏂规硶
const summarizeProTable = param => {
- return proxy.summarizeTable(param, [
- "taxInclusiveUnitPrice",
- "taxInclusiveTotalPrice",
- "taxExclusiveTotalPrice",
- ]);
+ return proxy.summarizeTable(
+ param,
+ [
+ "taxInclusiveUnitPrice",
+ "taxInclusiveTotalPrice",
+ "taxExclusiveTotalPrice",
+ ],
+ buildAmountSummaryFormat([
+ "taxInclusiveUnitPrice",
+ "taxInclusiveTotalPrice",
+ "taxExclusiveTotalPrice",
+ ])
+ );
};
// 鎵撳紑寮规
const openForm = async (type, row) => {
@@ -1474,10 +1494,10 @@
if (field === "taxInclusiveTotalPrice") {
// 宸茬煡鍚◣鎬讳环鍜屾暟閲忥紝鍙嶇畻鍚◣鍗曚环
if (productForm.value.quantity) {
- productForm.value.taxInclusiveUnitPrice = (
+ productForm.value.taxInclusiveUnitPrice = formatDecimal(
Number(productForm.value.taxInclusiveTotalPrice) /
Number(productForm.value.quantity)
- ).toFixed(2);
+ );
// 纭繚缁撴灉涓嶄负璐熸暟
if (Number(productForm.value.taxInclusiveUnitPrice) < 0) {
productForm.value.taxInclusiveUnitPrice = "0";
@@ -1495,30 +1515,30 @@
}
}
// 鍙嶇畻涓嶅惈绋庢�讳环
- productForm.value.taxExclusiveTotalPrice = (
+ productForm.value.taxExclusiveTotalPrice = formatDecimal(
Number(productForm.value.taxInclusiveTotalPrice) /
(1 + taxRate / 100)
- ).toFixed(2);
+ );
// 纭繚缁撴灉涓嶄负璐熸暟
if (Number(productForm.value.taxExclusiveTotalPrice) < 0) {
productForm.value.taxExclusiveTotalPrice = "0";
}
} else if (field === "taxExclusiveTotalPrice") {
// 鍙嶇畻鍚◣鎬讳环
- productForm.value.taxInclusiveTotalPrice = (
+ productForm.value.taxInclusiveTotalPrice = formatDecimal(
Number(productForm.value.taxExclusiveTotalPrice) *
(1 + taxRate / 100)
- ).toFixed(2);
+ );
// 纭繚缁撴灉涓嶄负璐熸暟
if (Number(productForm.value.taxInclusiveTotalPrice) < 0) {
productForm.value.taxInclusiveTotalPrice = "0";
}
// 宸茬煡鏁伴噺锛屽弽绠楀惈绋庡崟浠�
if (productForm.value.quantity) {
- productForm.value.taxInclusiveUnitPrice = (
+ productForm.value.taxInclusiveUnitPrice = formatDecimal(
Number(productForm.value.taxInclusiveTotalPrice) /
Number(productForm.value.quantity)
- ).toFixed(2);
+ );
// 纭繚缁撴灉涓嶄负璐熸暟
if (Number(productForm.value.taxInclusiveUnitPrice) < 0) {
productForm.value.taxInclusiveUnitPrice = "0";
diff --git a/src/views/procurementManagement/procurementReport/index.vue b/src/views/procurementManagement/procurementReport/index.vue
index 26e682d..e891868 100644
--- a/src/views/procurementManagement/procurementReport/index.vue
+++ b/src/views/procurementManagement/procurementReport/index.vue
@@ -83,6 +83,7 @@
import PIMTable from '@/components/PIMTable/PIMTable.vue'
import { procurementBusinessSummaryListPage } from '@/api/procurementManagement/procurementReport'
import { productTreeList } from '@/api/basicData/product'
+import { formatDecimal, formatCurrency } from '@/utils/numberFormat'
const { proxy } = getCurrentInstance()
@@ -135,14 +136,14 @@
prop: 'returnAmount',
width: 120,
formatData: (val) => {
- return val ? `楼${parseFloat(val).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}` : '楼0.00'
+ return val ? formatCurrency(val) : '楼0'
}
},
{
label: '閫�娆惧偍閲�',
prop: 'purchaseAmount',
formatData: (val) => {
- return val ? `楼${parseFloat(val).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}` : '楼0.00'
+ return val ? formatCurrency(val) : '楼0'
}
},
{
@@ -155,7 +156,7 @@
prop: 'averagePrice',
width: 120,
formatData: (val) => {
- return val ? `楼${parseFloat(val).toFixed(2)}` : '楼0.00'
+ return val ? formatCurrency(val) : '楼0'
}
},
{
diff --git a/src/views/salesManagement/receiptPaymentLedger/index.vue b/src/views/salesManagement/receiptPaymentLedger/index.vue
index 715cb9e..0bc5de3 100644
--- a/src/views/salesManagement/receiptPaymentLedger/index.vue
+++ b/src/views/salesManagement/receiptPaymentLedger/index.vue
@@ -126,6 +126,7 @@
customewTransactionsDetails,
} from "@/api/salesManagement/indicatorStats.js";
import Pagination from "../../../components/PIMTable/Pagination.vue";
+ import { tableAmountFormatter, buildAmountSummaryFormat } from "@/utils/numberFormat";
const { proxy } = getCurrentInstance();
const tableData = ref([]);
const receiptRecord = ref([]);
@@ -173,18 +174,19 @@
}
});
};
- const formattedNumber = (row, column, cellValue) => {
- return cellValue ? parseFloat(cellValue).toFixed(2) : "0.00";
- };
+ const formattedNumber = tableAmountFormatter;
// 涓昏〃鍚堣鏂规硶
const summarizeMainTable = param => {
return proxy.summarizeTable(
param,
["contractAmounts", "shippedAmount", "unshippedAmount"],
- {
- ticketsNum: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
- futureTickets: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
- }
+ buildAmountSummaryFormat(
+ ["contractAmounts", "shippedAmount", "unshippedAmount"],
+ {
+ ticketsNum: { noDecimal: true },
+ futureTickets: { noDecimal: true },
+ }
+ )
);
};
// 瀛愯〃鍚堣鏂规硶
@@ -192,10 +194,13 @@
var summarizeTable = proxy.summarizeTable(
param,
["contractAmount", "shippedAmount", "unshippedAmount"],
- {
- ticketsNum: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
- futureTickets: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
- }
+ buildAmountSummaryFormat(
+ ["contractAmount", "shippedAmount", "unshippedAmount"],
+ {
+ ticketsNum: { noDecimal: true },
+ futureTickets: { noDecimal: true },
+ }
+ )
);
return summarizeTable;
};
diff --git a/src/views/salesManagement/salesLedger/index.vue b/src/views/salesManagement/salesLedger/index.vue
index a82f141..6e1d64c 100644
--- a/src/views/salesManagement/salesLedger/index.vue
+++ b/src/views/salesManagement/salesLedger/index.vue
@@ -568,7 +568,7 @@
width="160"
align="right">
<template #default="scope">
- {{ Number(scope.row.totalAmount ?? 0).toFixed(2) }}
+ {{ formatDecimal(scope.row.totalAmount) }}
</template>
</el-table-column>
<el-table-column fixed="right"
@@ -666,11 +666,11 @@
<el-col :span="12">
<el-form-item label="鍚◣鍗曚环(鍏�)锛�"
prop="taxInclusiveUnitPrice">
- <el-input-number :step="0.01"
+ <el-input-number :step="0.000001"
:min="0"
v-model="productForm.taxInclusiveUnitPrice"
style="width: 100%"
- :precision="2"
+ :precision="6"
placeholder="璇疯緭鍏�"
clearable
@change="calculateFromUnitPrice" />
@@ -1057,6 +1057,11 @@
import useFormData from "@/hooks/useFormData.js";
import dayjs from "dayjs";
import FileUpload from "@/components/AttachmentUpload/file/index.vue";
+ import {
+ tableAmountFormatter,
+ formatDecimal,
+ buildAmountSummaryFormat,
+ } from "@/utils/numberFormat";
import ImageUpload from "@/components/AttachmentUpload/image/index.vue";
import { getCurrentDate } from "@/utils/index.js";
import { listCustomer } from "@/api/basicData/customer.js";
@@ -1401,12 +1406,7 @@
return productOptions.value;
});
};
- const formattedNumber = (row, column, cellValue) => {
- if (cellValue === undefined || cellValue === null || cellValue === "") {
- return "0.00";
- }
- return parseFloat(cellValue).toFixed(2);
- };
+ const formattedNumber = tableAmountFormatter;
const findLedgerRecordByRow = row => {
if (!row) return null;
if (
@@ -1569,11 +1569,15 @@
};
// 涓昏〃鍚堣鏂规硶
const summarizeMainTable = param => {
- return proxy.summarizeTable(param, [
- "contractAmount",
- "taxInclusiveTotalPrice",
- "taxExclusiveTotalPrice",
- ]);
+ return proxy.summarizeTable(
+ param,
+ ["contractAmount", "taxInclusiveTotalPrice", "taxExclusiveTotalPrice"],
+ buildAmountSummaryFormat([
+ "contractAmount",
+ "taxInclusiveTotalPrice",
+ "taxExclusiveTotalPrice",
+ ])
+ );
};
// 瀛愯〃鍚堣鏂规硶
const summarizeChildrenTable = (param, parentRow) => {
@@ -1595,11 +1599,19 @@
return "";
});
}
- return proxy.summarizeTable(param, [
- "taxInclusiveUnitPrice",
- "taxInclusiveTotalPrice",
- "taxExclusiveTotalPrice",
- ]);
+ return proxy.summarizeTable(
+ param,
+ [
+ "taxInclusiveUnitPrice",
+ "taxInclusiveTotalPrice",
+ "taxExclusiveTotalPrice",
+ ],
+ buildAmountSummaryFormat([
+ "taxInclusiveUnitPrice",
+ "taxInclusiveTotalPrice",
+ "taxExclusiveTotalPrice",
+ ])
+ );
};
// 鎵撳紑寮规
const openForm = async (type, row) => {
@@ -1727,7 +1739,7 @@
const quantity = Number(p.quantity ?? 0) || 0;
const unitPrice = Number(p.unitPrice ?? 0) || 0;
const taxRate = "13"; // 榛樿 13%锛屼究浜庣洿鎺ユ彁浜わ紙濡傞渶鍙湪浜у搧涓嚜琛屼慨鏀癸級
- const taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2);
+ const taxInclusiveTotalPrice = formatDecimal(unitPrice * quantity);
const taxExclusiveTotalPrice = proxy.calculateTaxExclusiveTotalPrice(
taxInclusiveTotalPrice,
taxRate
@@ -1739,7 +1751,7 @@
unit: p.unit || "",
quantity: quantity,
taxRate: taxRate,
- taxInclusiveUnitPrice: unitPrice.toFixed(2),
+ taxInclusiveUnitPrice: formatDecimal(unitPrice),
taxInclusiveTotalPrice: taxInclusiveTotalPrice,
taxExclusiveTotalPrice: taxExclusiveTotalPrice,
invoiceType: "澧炴櫘绁�",
@@ -2413,7 +2425,7 @@
const total = products.reduce((sum, product) => {
return sum + (parseFloat(product.taxInclusiveTotalPrice) || 0);
}, 0);
- return total.toFixed(2);
+ return formatDecimal(total);
};
// 鐢ㄤ簬鎵撳嵃鐨勮绠楀嚱鏁�
@@ -2430,7 +2442,7 @@
const total = products.reduce((sum, product) => {
return sum + (parseFloat(product.taxInclusiveTotalPrice) || 0);
}, 0);
- return total.toFixed(2);
+ return formatDecimal(total);
};
const mathNum = () => {
@@ -2471,7 +2483,7 @@
isCalculating.value = true;
// 璁$畻鍚◣鍗曚环 = 鍚◣鎬讳环 / 鏁伴噺
- productForm.value.taxInclusiveUnitPrice = (totalPrice / quantity).toFixed(2);
+ productForm.value.taxInclusiveUnitPrice = formatDecimal(totalPrice / quantity);
// 濡傛灉鏈夌◣鐜囷紝璁$畻涓嶅惈绋庢�讳环
if (productForm.value.taxRate) {
@@ -2508,12 +2520,12 @@
// 鍏堣绠楀惈绋庢�讳环 = 涓嶅惈绋庢�讳环 / (1 - 绋庣巼/100)
const taxRateDecimal = taxRate / 100;
const inclusiveTotalPrice = exclusiveTotalPrice / (1 - taxRateDecimal);
- productForm.value.taxInclusiveTotalPrice = inclusiveTotalPrice.toFixed(2);
+ productForm.value.taxInclusiveTotalPrice = formatDecimal(inclusiveTotalPrice);
// 璁$畻鍚◣鍗曚环 = 鍚◣鎬讳环 / 鏁伴噺
- productForm.value.taxInclusiveUnitPrice = (
+ productForm.value.taxInclusiveUnitPrice = formatDecimal(
inclusiveTotalPrice / quantity
- ).toFixed(2);
+ );
isCalculating.value = false;
};
@@ -2536,7 +2548,7 @@
isCalculating.value = true;
// 璁$畻鍚◣鎬讳环
- productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2);
+ productForm.value.taxInclusiveTotalPrice = formatDecimal(unitPrice * quantity);
// 濡傛灉鏈夌◣鐜囷紝璁$畻涓嶅惈绋庢�讳环
if (productForm.value.taxRate) {
@@ -2568,7 +2580,7 @@
isCalculating.value = true;
// 璁$畻鍚◣鎬讳环
- productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2);
+ productForm.value.taxInclusiveTotalPrice = formatDecimal(unitPrice * quantity);
// 濡傛灉鏈夌◣鐜囷紝璁$畻涓嶅惈绋庢�讳环
if (productForm.value.taxRate) {
diff --git a/src/views/salesManagement/salesQuotation/index.vue b/src/views/salesManagement/salesQuotation/index.vue
index fce764f..873f839 100644
--- a/src/views/salesManagement/salesQuotation/index.vue
+++ b/src/views/salesManagement/salesQuotation/index.vue
@@ -65,7 +65,7 @@
</el-table-column>
<el-table-column prop="totalAmount" label="鎶ヤ环閲戦" width="120">
<template #default="scope">
- 楼{{ scope.row.totalAmount.toFixed(2) }}
+ 楼{{ formatDecimal(scope.row.totalAmount) }}
</template>
</el-table-column>
<el-table-column label="鎿嶄綔" width="200" fixed="right" align="center">
@@ -215,7 +215,7 @@
<el-table-column prop="unitPrice" label="鍗曚环">
<template #default="scope">
<el-form-item :prop="`products.${scope.$index}.unitPrice`" class="product-table-form-item">
- <el-input-number v-model="scope.row.unitPrice" :min="0" :precision="2" style="width: 100%" />
+ <el-input-number v-model="scope.row.unitPrice" :min="0" :precision="6" :step="0.000001" style="width: 100%" />
</el-form-item>
</template>
</el-table-column>
@@ -267,7 +267,7 @@
<!-- <el-tag :type="getStatusType(currentQuotation.status)">{{ currentQuotation.status }}</el-tag>-->
<!-- </el-descriptions-item>-->
<el-descriptions-item label="鎶ヤ环鎬婚" :span="2">
- <span style="font-size: 18px; color: #e6a23c; font-weight: bold;">楼{{ currentQuotation.totalAmount?.toFixed(2) }}</span>
+ <span style="font-size: 18px; color: #e6a23c; font-weight: bold;">楼{{ formatDecimal(currentQuotation.totalAmount) }}</span>
</el-descriptions-item>
</el-descriptions>
@@ -279,7 +279,7 @@
<el-table-column prop="unit" label="鍗曚綅" />
<el-table-column prop="unitPrice" label="鍗曚环">
<template #default="scope">
- 楼{{ scope.row.unitPrice.toFixed(2) }}
+ 楼{{ formatDecimal(scope.row.unitPrice) }}
</template>
</el-table-column>
</el-table>
@@ -303,6 +303,7 @@
import {modelList, productTreeList} from "@/api/basicData/product.js";
import {listCustomer} from "@/api/basicData/customer.js";
import { userListNoPage } from "@/api/system/user.js";
+import { formatDecimal, roundAmount } from '@/utils/numberFormat';
// 鍝嶅簲寮忔暟鎹�
const loading = ref(false)
@@ -686,11 +687,11 @@
return
}
- // 璁$畻鎵�鏈変骇鍝佺殑鍗曚环鎬诲拰
- form.totalAmount = form.products.reduce((sum, product) => {
+ // 璁$畻鎵�鏈変骇鍝佺殑鍗曚环鎬诲拰锛屼繚鐣欏叚浣嶅皬鏁�
+ form.totalAmount = roundAmount(form.products.reduce((sum, product) => {
const price = Number(product.unitPrice) || 0
return sum + price
- }, 0)
+ }, 0))
form.customer = customerOption.value.find(item => item.id === form.customerId)?.customerName || ''
if (isEdit.value) {
--
Gitblit v1.9.3