| | |
| | | /** 金额类字段默认最大小数位数 */ |
| | | export const AMOUNT_DECIMAL_SCALE = 6 |
| | | |
| | | /** 金额(元)默认展示小数位数 */ |
| | | export const MONEY_DECIMAL_SCALE = 2 |
| | | |
| | | /** |
| | | * 格式化数字:最多保留 scale 位小数,并去除末尾多余的 0 |
| | | */ |
| | |
| | | return formatDecimal(cellValue) |
| | | } |
| | | |
| | | /** el-table-column formatter:金额(元)列,最多保留 2 位小数 */ |
| | | export function moneyAmountFormatter(row, column, cellValue) { |
| | | return formatDecimal(cellValue, MONEY_DECIMAL_SCALE) |
| | | } |
| | | |
| | | /** 计算后保留指定位小数 */ |
| | | export function roundAmount(value, scale = AMOUNT_DECIMAL_SCALE) { |
| | | if (value === null || value === undefined || value === '') { |
| | |
| | | } |
| | | |
| | | /** 构建 summarizeTable 金额列格式配置 */ |
| | | export function buildAmountSummaryFormat(fields, extraFormat = {}) { |
| | | export function buildAmountSummaryFormat( |
| | | fields, |
| | | extraFormat = {}, |
| | | scale = AMOUNT_DECIMAL_SCALE |
| | | ) { |
| | | const format = { ...extraFormat } |
| | | fields.forEach(field => { |
| | | format[field] = { decimalPlaces: AMOUNT_DECIMAL_SCALE } |
| | | format[field] = { decimalPlaces: scale } |
| | | }) |
| | | return format |
| | | } |
| | |
| | | customewTransactionsDetails, |
| | | } from "@/api/salesManagement/indicatorStats.js"; |
| | | import Pagination from "../../../components/PIMTable/Pagination.vue"; |
| | | import { tableAmountFormatter, buildAmountSummaryFormat } from "@/utils/numberFormat"; |
| | | import { moneyAmountFormatter, buildAmountSummaryFormat, MONEY_DECIMAL_SCALE } from "@/utils/numberFormat"; |
| | | const { proxy } = getCurrentInstance(); |
| | | const tableData = ref([]); |
| | | const receiptRecord = ref([]); |
| | |
| | | } |
| | | }); |
| | | }; |
| | | const formattedNumber = tableAmountFormatter; |
| | | const formattedNumber = moneyAmountFormatter; |
| | | // 主表合计方法 |
| | | const summarizeMainTable = param => { |
| | | return proxy.summarizeTable( |
| | |
| | | { |
| | | ticketsNum: { noDecimal: true }, |
| | | futureTickets: { noDecimal: true }, |
| | | } |
| | | }, |
| | | MONEY_DECIMAL_SCALE |
| | | ) |
| | | ); |
| | | }; |
| | |
| | | { |
| | | ticketsNum: { noDecimal: true }, |
| | | futureTickets: { noDecimal: true }, |
| | | } |
| | | }, |
| | | MONEY_DECIMAL_SCALE |
| | | ) |
| | | ); |
| | | return summarizeTable; |