diff --git a/src/assets/images/data-view-table-header-bg-large.png b/src/assets/images/data-view-table-header-bg-large.png deleted file mode 100644 index c42ab21..0000000 Binary files a/src/assets/images/data-view-table-header-bg-large.png and /dev/null differ diff --git a/src/assets/images/data-view-table-header-bg-middle.png b/src/assets/images/data-view-table-header-bg-middle.png deleted file mode 100644 index a7268f6..0000000 Binary files a/src/assets/images/data-view-table-header-bg-middle.png and /dev/null differ diff --git a/src/assets/images/data-view-table-header-bg.png b/src/assets/images/data-view-table-header-bg.png new file mode 100644 index 0000000..acbc17c Binary files /dev/null and b/src/assets/images/data-view-table-header-bg.png differ diff --git a/src/assets/images/data-view-table-header-parta.png b/src/assets/images/data-view-table-header-parta.png deleted file mode 100644 index 0a7d552..0000000 Binary files a/src/assets/images/data-view-table-header-parta.png and /dev/null differ diff --git a/src/assets/images/data-view-table-header-partb.png b/src/assets/images/data-view-table-header-partb.png deleted file mode 100644 index e795e73..0000000 Binary files a/src/assets/images/data-view-table-header-partb.png and /dev/null differ diff --git a/src/utils/ruoyi.js b/src/utils/ruoyi.js index 1ca2f91..927952d 100644 --- a/src/utils/ruoyi.js +++ b/src/utils/ruoyi.js @@ -365,30 +365,38 @@ export function toFixedWithOutRounded(num, s) { * @return {string | number} */ export const amountFormat = (o) => { - if (o.amount === undefined || o.amount === null) { - return o.amount; - } - let amount = o.amount; - // 如果 amount 是字符串, 则转换为数字 - if (typeof amount === 'string') { - amount = parseFloat(amount); + // 默认参数值 + const { + amount, + precision = 100, + thousand = true, + decimal = true, + decimalLength = 2, + decimalSeparator = '.', + thousandSeparator = ',' + } = o; + + // 将金额转换为数字类型 + const numAmount = typeof amount === 'string' ? parseFloat(amount) : amount; + if (isNaN(numAmount)) { + return ''; } - let precision = o.precision || 100; - let thousand = o.thousand === undefined ? true : o.thousand; - let decimal = o.decimal === undefined ? true : o.decimal; - let decimalLength = o.decimalLength || 2; - let decimalSeparator = o.decimalSeparator || '.'; - let thousandSeparator = o.thousandSeparator || ','; - amount = amount / precision; - amount = toFixedWithOutRounded(amount, decimalLength); + + // 根据精度对金额进行四舍五入 + const roundedAmount = numAmount / precision; + + // 格式化小数部分 + let formattedAmount = decimal ? roundedAmount.toFixed(decimalLength) : Math.floor(roundedAmount).toString(); + + // 添加千分位分隔符 if (thousand) { - amount = amount.replace(/(\d)(?=(\d{3})+\.)/g, '$1' + thousandSeparator); + const parts = formattedAmount.split('.'); + parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, thousandSeparator); + formattedAmount = parts.join(decimalSeparator); } - if (decimal) { - amount = amount.replace('.', decimalSeparator); - } - return amount; -} + + return formattedAmount; +}; /** * 格式化金额, 自动进万, 百万 diff --git a/src/views/data-view/components/data-view-layout.vue b/src/views/data-view/components/data-view-layout.vue index 679601a..b083d2e 100644 --- a/src/views/data-view/components/data-view-layout.vue +++ b/src/views/data-view/components/data-view-layout.vue @@ -161,15 +161,15 @@ export default { height: 100%; .left-table { - width: 23.5%; + width: 32.5%; } .middle { - width: 50%; + width: 32.5%; } .right-table { - width: 23.5%; + width: 32.5%; } } diff --git a/src/views/data-view/components/data-view-table.vue b/src/views/data-view/components/data-view-table.vue index db1882b..dfa92d0 100644 --- a/src/views/data-view/components/data-view-table.vue +++ b/src/views/data-view/components/data-view-table.vue @@ -4,6 +4,7 @@
- + - {{ item[column.key] }} + + {{ item[column.key] }} + @@ -50,10 +53,8 @@ -