feat: 更新金额格式化功能,统一使用四舍五入到两位小数并去掉多余的零
| | |
| | | :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> |
| | |
| | | prop="contractAmount" |
| | | width="200" |
| | | show-overflow-tooltip |
| | | :formatter="formattedNumber" /> |
| | | :formatter="formattedAmount" /> |
| | | <!-- <el-table-column label="实际合同金额(元)"--> |
| | | <!-- prop="netContractAmount"--> |
| | | <!-- width="200"--> |
| | |
| | | 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" |
| | |
| | | import { modelList, productTreeList } from "@/api/basicData/product.js"; |
| | | import dayjs from "dayjs"; |
| | | import FileUpload from "@/components/AttachmentUpload/file/index.vue"; |
| | | import { trimZeros } from "@/utils/formatNumber.js"; |
| | | import { roundHalfUp, trimZeros } from "@/utils/formatNumber.js"; |
| | | |
| | | const userStore = useUserStore(); |
| | | |
| | |
| | | const formattedNumber = (row, column, cellValue) => { |
| | | 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); |
| | | }; |
| | | // 查询列表 |
| | | /** 搜索按钮操作 */ |
| | | const handleQuery = () => { |
| | |
| | | ], |
| | | { |
| | | taxInclusiveUnitPrice: { decimalPlaces: 6, trimZeros: true }, |
| | | taxInclusiveTotalPrice: { decimalPlaces: 6, trimZeros: true }, |
| | | taxExclusiveTotalPrice: { decimalPlaces: 6, trimZeros: true }, |
| | | ticketsAmount: { decimalPlaces: 6, trimZeros: true }, |
| | | futureTicketsAmount: { 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 }, // 不保留小数 |
| | | } |
| | |
| | | param, |
| | | ["contractAmount", "netContractAmount"], |
| | | { |
| | | contractAmount: { decimalPlaces: 6, trimZeros: true }, |
| | | netContractAmount: { decimalPlaces: 6, trimZeros: true }, |
| | | // 金额列:每行先按 2 位小数四舍五入再求和,保证合计与列内展示值一致 |
| | | contractAmount: { roundEach: 2, decimalPlaces: 2, trimZeros: true }, |
| | | netContractAmount: { roundEach: 2, decimalPlaces: 2, trimZeros: true }, |
| | | } |
| | | ); |
| | | }; |
| | |
| | | ], |
| | | { |
| | | taxInclusiveUnitPrice: { decimalPlaces: 6, trimZeros: true }, |
| | | taxInclusiveTotalPrice: { decimalPlaces: 6, trimZeros: true }, |
| | | taxExclusiveTotalPrice: { decimalPlaces: 6, trimZeros: true }, |
| | | // 金额列:每行先按 2 位小数四舍五入再求和,保证合计与列内展示值一致 |
| | | taxInclusiveTotalPrice: { roundEach: 2, decimalPlaces: 2, trimZeros: true }, |
| | | taxExclusiveTotalPrice: { roundEach: 2, decimalPlaces: 2, trimZeros: true }, |
| | | } |
| | | ); |
| | | }; |
| | |
| | | <el-table-column |
| | | label="含税总价(元)" |
| | | prop="taxInclusiveTotalPrice" |
| | | :formatter="formattedNumber" |
| | | :formatter="formattedAmount" |
| | | /> |
| | | <el-table-column |
| | | label="不含税总价(元)" |
| | | prop="taxExclusiveTotalPrice" |
| | | :formatter="formattedNumber" |
| | | :formatter="formattedAmount" |
| | | /> |
| | | <!--操作--> |
| | | <el-table-column Width="60px" label="操作" align="center"> |
| | |
| | | prop="contractAmount" |
| | | width="220" |
| | | show-overflow-tooltip |
| | | :formatter="formattedNumber" |
| | | :formatter="formattedAmount" |
| | | /> |
| | | <el-table-column |
| | | label="录入人" |
| | |
| | | <el-table-column |
| | | label="含税总价(元)" |
| | | prop="taxInclusiveTotalPrice" |
| | | :formatter="formattedNumber" |
| | | :formatter="formattedAmount" |
| | | /> |
| | | <el-table-column |
| | | label="不含税总价(元)" |
| | | prop="taxExclusiveTotalPrice" |
| | | :formatter="formattedNumber" |
| | | :formatter="formattedAmount" |
| | | /> |
| | | <el-table-column label="是否生产" prop="isProduction" width="150"> |
| | | <template #default="scope"> |
| | |
| | | align="right" |
| | | > |
| | | <template #default="scope"> |
| | | {{ trimZeros(scope.row.totalAmount, 6) }} |
| | | {{ formatAmount(scope.row.totalAmount) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column fixed="right" label="操作" width="120" align="center"> |
| | |
| | | <td>{{ trimZeros(product.taxInclusiveUnitPrice, 6) }}</td> |
| | | <td>{{ trimZeros(product.quantity, 6) }}</td> |
| | | <td> |
| | | {{ trimZeros(product.taxInclusiveTotalPrice, 6) }} |
| | | {{ formatAmount(product.taxInclusiveTotalPrice) }} |
| | | </td> |
| | | </tr> |
| | | <tr v-if="!item.products || item.products.length === 0"> |
| | |
| | | import FileUpload from "@/components/AttachmentUpload/file/index.vue"; |
| | | import ImageUpload from "@/components/AttachmentUpload/image/index.vue"; |
| | | import { getCurrentDate } from "@/utils/index.js"; |
| | | import { trimZeros } from "@/utils/formatNumber.js"; |
| | | import { roundHalfUp, trimZeros } from "@/utils/formatNumber.js"; |
| | | import { listCustomer } from "@/api/basicData/customer.js"; |
| | | |
| | | const FileList = defineAsyncComponent(() => |
| | |
| | | const formattedNumber = (row, column, cellValue) => { |
| | | 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); |
| | | }; |
| | | const findLedgerRecordByRow = (row) => { |
| | | if (!row) return null; |
| | | if ( |
| | |
| | | param, |
| | | ["contractAmount", "taxInclusiveTotalPrice", "taxExclusiveTotalPrice"], |
| | | { |
| | | contractAmount: { decimalPlaces: 6, trimZeros: true }, |
| | | taxInclusiveTotalPrice: { decimalPlaces: 6, trimZeros: true }, |
| | | taxExclusiveTotalPrice: { decimalPlaces: 6, trimZeros: true }, |
| | | // 金额列:每行先按 2 位小数四舍五入再求和,保证合计与列内展示值一致 |
| | | contractAmount: { roundEach: 2, decimalPlaces: 2, trimZeros: true }, |
| | | taxInclusiveTotalPrice: { roundEach: 2, decimalPlaces: 2, trimZeros: true }, |
| | | taxExclusiveTotalPrice: { roundEach: 2, decimalPlaces: 2, trimZeros: true }, |
| | | } |
| | | ); |
| | | }; |
| | |
| | | ], |
| | | { |
| | | taxInclusiveUnitPrice: { decimalPlaces: 6, trimZeros: true }, |
| | | taxInclusiveTotalPrice: { decimalPlaces: 6, trimZeros: true }, |
| | | taxExclusiveTotalPrice: { decimalPlaces: 6, trimZeros: true }, |
| | | // 金额列:每行先按 2 位小数四舍五入再求和,保证合计与列内展示值一致 |
| | | taxInclusiveTotalPrice: { roundEach: 2, decimalPlaces: 2, trimZeros: true }, |
| | | taxExclusiveTotalPrice: { roundEach: 2, decimalPlaces: 2, trimZeros: true }, |
| | | } |
| | | ); |
| | | }; |
| | |
| | | const total = products.reduce((sum, product) => { |
| | | return sum + (parseFloat(product.taxInclusiveTotalPrice) || 0); |
| | | }, 0); |
| | | return trimZeros(total, 6); |
| | | return formatAmount(total); |
| | | }; |
| | | |
| | | // 用于打印的计算函数 |
| | |
| | | const total = products.reduce((sum, product) => { |
| | | return sum + (parseFloat(product.taxInclusiveTotalPrice) || 0); |
| | | }, 0); |
| | | return trimZeros(total, 6); |
| | | return formatAmount(total); |
| | | }; |
| | | |
| | | const mathNum = () => { |