Ver Fonte

格式化金额显示

cyy há 3 anos atrás
pai
commit
bcece4e484

+ 39 - 1
src/views/crm/component/individualPerformance.vue

@@ -76,7 +76,45 @@ import echarts from 'echarts'
                         show: false
                     }
                 },
-                series: [{ name: '销量',type: 'bar',barWidth:'10%',label: {show: true,position: 'top'}  }]
+                series: [{ 
+                    name: '销售金额(元)',
+                    type: 'bar',
+                    barWidth:'10%',
+                    label: {
+                        show: true,
+                        position: 'top',
+                        formatter:function (param) {
+                            /*
+                            parameter:
+                            num:格式化目标数字
+                            decimal:保留几位小数,默认2位
+                            split:千分位分隔符,默认为,
+                            */
+                           let num = param.data.jiage
+                            let decimal = 2
+                            let split = ','
+                            if (isFinite(num)) { // num是数字
+                                if (num === 0) { // 为0
+                                    return 0
+                                } else { // 非0
+                                    var res = ''
+                                    var dotIndex = String(num).indexOf('.')
+                                    if (dotIndex === -1) { // 整数
+                                    res = String(num).replace(/(\d)(?=(?:\d{3})+$)/g, `$1${split}`) + '.' + '0'.repeat(decimal)
+                                    } else { 
+                                    const numStr = String((Math.round(num * Math.pow(10, decimal)) / Math.pow(10, decimal)).toFixed(decimal)) // 四舍五入,然后固定保留2位小数
+                                    const decimals = numStr.slice(dotIndex, dotIndex + decimal + 1) // 截取小数位
+                                    res = String(numStr.slice(0, dotIndex)).replace(/(\d)(?=(?:\d{3})+$)/g, `$1${split}`) + decimals
+                                    }
+                                    return res
+                                }
+                            } else {
+                                return '--'
+                            }
+                        }
+                    },
+                    
+                }]
             };
             option && inpms.setOption(option);
         }

+ 27 - 5
src/views/crm/component/personPerformance.vue

@@ -108,7 +108,7 @@ import dialogView from '../messageBox/personAllDetails'
                     {
                         data: this.data[1],
                         type: 'bar',
-                        name: '销',
+                        name: '销售金额(元)',
                         // showBackground: true,
                         backgroundStyle: {
                             color: 'rgba(180, 180, 180, 0.2)'
@@ -116,11 +116,33 @@ import dialogView from '../messageBox/personAllDetails'
                         label: {
                             show: true,
                             position: 'top',
-                            formatter: function(params) {
-                                if (params.value > 0) {
-                                    return params.value;
+                            formatter:function (param) {
+                                /*
+                                parameter:
+                                num:格式化目标数字
+                                decimal:保留几位小数,默认2位
+                                split:千分位分隔符,默认为,
+                                */
+                                let num = param.value
+                                let decimal = 2
+                                let split = ','
+                                if (isFinite(num)) { // num是数字
+                                    if (num === 0) { // 为0
+                                        return ''
+                                    } else { // 非0
+                                        var res = ''
+                                        var dotIndex = String(num).indexOf('.')
+                                        if (dotIndex === -1) { // 整数
+                                        res = String(num).replace(/(\d)(?=(?:\d{3})+$)/g, `$1${split}`) + '.' + '0'.repeat(decimal)
+                                        } else { 
+                                        const numStr = String((Math.round(num * Math.pow(10, decimal)) / Math.pow(10, decimal)).toFixed(decimal)) // 四舍五入,然后固定保留2位小数
+                                        const decimals = numStr.slice(dotIndex, dotIndex + decimal + 1) // 截取小数位
+                                        res = String(numStr.slice(0, dotIndex)).replace(/(\d)(?=(?:\d{3})+$)/g, `$1${split}`) + decimals
+                                        }
+                                        return res
+                                    }
                                 } else {
-                                    return '';
+                                    return '--'
                                 }
                             }
                         } 

+ 27 - 5
src/views/crm/component/personPerformanceMonth.vue

@@ -110,7 +110,7 @@ import dialogView from '../messageBox/personMonthDetails'
                     {
                         data: this.data[1],
                         type: 'bar',
-                        name: '销',
+                        name: '销售金额(元)',
                         // showBackground: true,
                         backgroundStyle: {
                             color: 'rgba(180, 180, 180, 0.2)'
@@ -118,11 +118,33 @@ import dialogView from '../messageBox/personMonthDetails'
                         label: {
                             show: true,
                             position: 'top',
-                            formatter: function(params) {
-                                if (params.value > 0) {
-                                    return params.value;
+                            formatter:function (param) {
+                                /*
+                                parameter:
+                                num:格式化目标数字
+                                decimal:保留几位小数,默认2位
+                                split:千分位分隔符,默认为,
+                                */
+                                let num = param.value
+                                let decimal = 2
+                                let split = ','
+                                if (isFinite(num)) { // num是数字
+                                    if (num === 0) { // 为0
+                                        return ''
+                                    } else { // 非0
+                                        var res = ''
+                                        var dotIndex = String(num).indexOf('.')
+                                        if (dotIndex === -1) { // 整数
+                                        res = String(num).replace(/(\d)(?=(?:\d{3})+$)/g, `$1${split}`) + '.' + '0'.repeat(decimal)
+                                        } else { 
+                                        const numStr = String((Math.round(num * Math.pow(10, decimal)) / Math.pow(10, decimal)).toFixed(decimal)) // 四舍五入,然后固定保留2位小数
+                                        const decimals = numStr.slice(dotIndex, dotIndex + decimal + 1) // 截取小数位
+                                        res = String(numStr.slice(0, dotIndex)).replace(/(\d)(?=(?:\d{3})+$)/g, `$1${split}`) + decimals
+                                        }
+                                        return res
+                                    }
                                 } else {
-                                    return '';
+                                    return '--'
                                 }
                             }
                         } 

+ 38 - 1
src/views/crm/component/teamPerformance.vue

@@ -105,7 +105,44 @@ export default {
                         show: false
                     }
                 },
-                series: [{ name: '销量',type: 'bar',barWidth:'10%',label: {show: true,position: 'top'} }]
+                series: [{ 
+                    name: '销售金额(元)',
+                    type: 'bar',
+                    barWidth:'10%',
+                    label: {
+                        show: true,
+                        position: 'top',
+                        formatter:function (param) {
+                            /*
+                            parameter:
+                            num:格式化目标数字
+                            decimal:保留几位小数,默认2位
+                            split:千分位分隔符,默认为,
+                            */
+                           let num = param.data.jiage
+                            let decimal = 2
+                            let split = ','
+                            if (isFinite(num)) { // num是数字
+                                if (num === 0) { // 为0
+                                    return 0
+                                } else { // 非0
+                                    var res = ''
+                                    var dotIndex = String(num).indexOf('.')
+                                    if (dotIndex === -1) { // 整数
+                                    res = String(num).replace(/(\d)(?=(?:\d{3})+$)/g, `$1${split}`) + '.' + '0'.repeat(decimal)
+                                    } else { 
+                                    const numStr = String((Math.round(num * Math.pow(10, decimal)) / Math.pow(10, decimal)).toFixed(decimal)) // 四舍五入,然后固定保留2位小数
+                                    const decimals = numStr.slice(dotIndex, dotIndex + decimal + 1) // 截取小数位
+                                    res = String(numStr.slice(0, dotIndex)).replace(/(\d)(?=(?:\d{3})+$)/g, `$1${split}`) + decimals
+                                    }
+                                    return res
+                                }
+                            } else {
+                                return '--'
+                            }
+                        }
+                    } 
+                }]
             };
             tmecs.on('click', function (params) {
                 // console.log(params.data.bian_zhi_ren_)

+ 39 - 1
src/views/crm/component/teamPerformanceMonth.vue

@@ -106,7 +106,45 @@ import dialogView from '../messageBox/teamMonthDetails'
                         show: false
                     }
                 },
-                series: [{ name: '销量',type: 'bar',barWidth:'10%',label: {show: true,position: 'top'} }]
+                series: [{ 
+                    name: '销售金额(元)',
+                    type: 'bar',
+                    barWidth:'10%',
+                    label: {
+                        show: true,
+                        position: 'top',
+                        formatter:function (param) {
+                            /*
+                            parameter:
+                            num:格式化目标数字
+                            decimal:保留几位小数,默认2位
+                            split:千分位分隔符,默认为,
+                            */
+                           let num = param.data.jiage
+                           console.log(num,'4t435er')
+                            let decimal = 2
+                            let split = ','
+                            if (isFinite(num)) { // num是数字
+                                if (num === 0) { // 为0
+                                    return 0
+                                } else { // 非0
+                                    var res = ''
+                                    var dotIndex = String(num).indexOf('.')
+                                    if (dotIndex === -1) { // 整数
+                                    res = String(num).replace(/(\d)(?=(?:\d{3})+$)/g, `$1${split}`) + '.' + '0'.repeat(decimal)
+                                    } else { 
+                                    const numStr = String((Math.round(num * Math.pow(10, decimal)) / Math.pow(10, decimal)).toFixed(decimal)) // 四舍五入,然后固定保留2位小数
+                                    const decimals = numStr.slice(dotIndex, dotIndex + decimal + 1) // 截取小数位
+                                    res = String(numStr.slice(0, dotIndex)).replace(/(\d)(?=(?:\d{3})+$)/g, `$1${split}`) + decimals
+                                    }
+                                    return res
+                                }
+                            } else {
+                                return '--'
+                            }
+                        }
+                    }
+                }]
             };
             ors.on('click', function (params) {
                 // console.log(params.data.bian_zhi_ren_)

+ 30 - 2
src/views/crm/messageBox/personAllDetails.vue

@@ -91,8 +91,10 @@
 
         let sql = "select e.*,ibps_party_employee.NAME_ from (select d.*,t_mjwtsqb.zong_jia_ as jiage from (select * from t_bjd LEFT JOIN (select a.id_ as leibieid,a.lai_yuan_qu_dao_ as laiyuan,b.id_ as qudaoid, b.lei_bie_ from ((select id_, lai_yuan_qu_dao_ from t_qzkhb GROUP BY id_) UNION (select id_, lai_yuan_qu_dao_ from t_yxkh GROUP BY id_) UNION (select ke_hu_ming_cheng_, lai_yuan_qu_dao_ as khnum from t_khxx GROUP BY ke_hu_ming_cheng_)) as a LEFT JOIN (select t_qdgl.id_,t_qdlbb.lei_bie_ from t_qdgl LEFT JOIN t_qdlbb on t_qdgl.qu_dao_lei_bie_ = t_qdlbb.id_) as b on a.lai_yuan_qu_dao_ = b.id_) as c on t_bjd.ke_hu_ming_cheng_ = c.leibieid where c.lei_bie_ is not NULL and t_bjd.sheng_xiao_shi_ji like '"+ this.date.split('-')[0]+"-"+newmonth +"%' and t_bjd.bian_zhi_ren_ = '"+tempid+"') as d left join t_mjwtsqb on t_mjwtsqb.he_tong_bian_hao_ = d.id_ WHERE t_mjwtsqb.shi_fou_guo_shen_ = '1' ) as e LEFT JOIN ibps_party_employee on e.bian_zhi_ren_ = ibps_party_employee.id_ ORDER BY e.he_tong_bian_hao_ desc"
         curdPost('sql',sql).then(res=>{
-
-          this.tableData = res.variables.data
+            for (let i = 0; i < res.variables.data.length; i++) {
+                res.variables.data[i].jiage = this.moneyFormat(res.variables.data[i].jiage)
+            }
+            this.tableData = res.variables.data
         })
     },
     watch:{
@@ -132,6 +134,32 @@
         },
         handleCurrentChange(val) {
             this.currpage = val
+        },
+        moneyFormat (num, decimal = 2, split = ',') {
+        /*
+          parameter:
+          num:格式化目标数字
+          decimal:保留几位小数,默认2位
+          split:千分位分隔符,默认为,
+        */
+            if (isFinite(num)) { // num是数字
+            if (num === 0) { // 为0
+                return num.toFixed(decimal)
+            } else { // 非0
+                var res = ''
+                var dotIndex = String(num).indexOf('.')
+                if (dotIndex === -1) { // 整数
+                res = String(num).replace(/(\d)(?=(?:\d{3})+$)/g, `$1${split}`) + '.' + '0'.repeat(decimal)
+                } else { 
+                const numStr = String((Math.round(num * Math.pow(10, decimal)) / Math.pow(10, decimal)).toFixed(decimal)) // 四舍五入,然后固定保留2位小数
+                const decimals = numStr.slice(dotIndex, dotIndex + decimal + 1) // 截取小数位
+                res = String(numStr.slice(0, dotIndex)).replace(/(\d)(?=(?:\d{3})+$)/g, `$1${split}`) + decimals
+                }
+                return res
+            }
+            } else {
+            return '--'
+            }
         }
     }
   }

+ 30 - 1
src/views/crm/messageBox/personMonthDetails.vue

@@ -92,7 +92,10 @@
         let sql = "select e.*,ibps_party_employee.NAME_ from (select d.*,t_mjwtsqb.zong_jia_ as jiage from (select * from t_bjd LEFT JOIN (select a.id_ as leibieid,a.lai_yuan_qu_dao_ as laiyuan,b.id_ as qudaoid, b.lei_bie_ from ((select id_, lai_yuan_qu_dao_ from t_qzkhb GROUP BY id_) UNION (select id_, lai_yuan_qu_dao_ from t_yxkh GROUP BY id_) UNION (select ke_hu_ming_cheng_, lai_yuan_qu_dao_ as khnum from t_khxx GROUP BY ke_hu_ming_cheng_)) as a LEFT JOIN (select t_qdgl.id_,t_qdlbb.lei_bie_ from t_qdgl LEFT JOIN t_qdlbb on t_qdgl.qu_dao_lei_bie_ = t_qdlbb.id_) as b on a.lai_yuan_qu_dao_ = b.id_) as c on t_bjd.ke_hu_ming_cheng_ = c.leibieid where c.lei_bie_ is not NULL and t_bjd.sheng_xiao_shi_ji like '"+ this.date+"-"+newmonth +"%' and t_bjd.bian_zhi_ren_ = '"+tempid+"') as d left join t_mjwtsqb on t_mjwtsqb.he_tong_bian_hao_ = d.id_ WHERE t_mjwtsqb.shi_fou_guo_shen_ = '1' ) as e LEFT JOIN ibps_party_employee on e.bian_zhi_ren_ = ibps_party_employee.id_ ORDER BY e.he_tong_bian_hao_ desc"
         curdPost('sql',sql).then(res=>{
 
-          this.tableData = res.variables.data
+            for (let i = 0; i < res.variables.data.length; i++) {
+                res.variables.data[i].jiage = this.moneyFormat(res.variables.data[i].jiage)
+            }
+            this.tableData = res.variables.data
         })
     },
     watch:{
@@ -132,6 +135,32 @@
         },
         handleCurrentChange(val) {
             this.currpage = val
+        },
+        moneyFormat (num, decimal = 2, split = ',') {
+        /*
+          parameter:
+          num:格式化目标数字
+          decimal:保留几位小数,默认2位
+          split:千分位分隔符,默认为,
+        */
+            if (isFinite(num)) { // num是数字
+            if (num === 0) { // 为0
+                return num.toFixed(decimal)
+            } else { // 非0
+                var res = ''
+                var dotIndex = String(num).indexOf('.')
+                if (dotIndex === -1) { // 整数
+                res = String(num).replace(/(\d)(?=(?:\d{3})+$)/g, `$1${split}`) + '.' + '0'.repeat(decimal)
+                } else { 
+                const numStr = String((Math.round(num * Math.pow(10, decimal)) / Math.pow(10, decimal)).toFixed(decimal)) // 四舍五入,然后固定保留2位小数
+                const decimals = numStr.slice(dotIndex, dotIndex + decimal + 1) // 截取小数位
+                res = String(numStr.slice(0, dotIndex)).replace(/(\d)(?=(?:\d{3})+$)/g, `$1${split}`) + decimals
+                }
+                return res
+            }
+            } else {
+            return '--'
+            }
         }
     }
   }

+ 30 - 2
src/views/crm/messageBox/teamAllDetails.vue

@@ -88,8 +88,10 @@
     beforeMount: function () {
         let sql = "select e.*,ibps_party_employee.NAME_ from (select d.*,t_mjwtsqb.zong_jia_ as jiage from (select * from t_bjd LEFT JOIN (select a.id_ as leibieid,a.lai_yuan_qu_dao_ as laiyuan,b.id_ as qudaoid, b.lei_bie_ from ((select id_, lai_yuan_qu_dao_ from t_qzkhb GROUP BY id_) UNION (select id_, lai_yuan_qu_dao_ from t_yxkh GROUP BY id_) UNION (select ke_hu_ming_cheng_, lai_yuan_qu_dao_ as khnum from t_khxx GROUP BY ke_hu_ming_cheng_)) as a LEFT JOIN (select t_qdgl.id_,t_qdlbb.lei_bie_ from t_qdgl LEFT JOIN t_qdlbb on t_qdgl.qu_dao_lei_bie_ = t_qdlbb.id_) as b on a.lai_yuan_qu_dao_ = b.id_) as c on t_bjd.ke_hu_ming_cheng_ = c.leibieid where c.lei_bie_ is not NULL and t_bjd.sheng_xiao_shi_ji like '"+ this.date.split('-')[0] +"%' and t_bjd.bian_zhi_ren_ = '"+this.data[0]+"') as d left join t_mjwtsqb on t_mjwtsqb.he_tong_bian_hao_ = d.id_ WHERE t_mjwtsqb.shi_fou_guo_shen_ = '1' ) as e LEFT JOIN ibps_party_employee on e.bian_zhi_ren_ = ibps_party_employee.id_ ORDER BY e.he_tong_bian_hao_ desc"
         curdPost('sql',sql).then(res=>{
-
-          this.tableData = res.variables.data
+            for (let i = 0; i < res.variables.data.length; i++) {
+                res.variables.data[i].jiage = this.moneyFormat(res.variables.data[i].jiage)
+            }
+            this.tableData = res.variables.data
         })
     },
     watch:{
@@ -129,6 +131,32 @@
         },
         handleCurrentChange(val) {
             this.currpage = val
+        },
+        moneyFormat (num, decimal = 2, split = ',') {
+        /*
+          parameter:
+          num:格式化目标数字
+          decimal:保留几位小数,默认2位
+          split:千分位分隔符,默认为,
+        */
+            if (isFinite(num)) { // num是数字
+            if (num === 0) { // 为0
+                return num.toFixed(decimal)
+            } else { // 非0
+                var res = ''
+                var dotIndex = String(num).indexOf('.')
+                if (dotIndex === -1) { // 整数
+                res = String(num).replace(/(\d)(?=(?:\d{3})+$)/g, `$1${split}`) + '.' + '0'.repeat(decimal)
+                } else { 
+                const numStr = String((Math.round(num * Math.pow(10, decimal)) / Math.pow(10, decimal)).toFixed(decimal)) // 四舍五入,然后固定保留2位小数
+                const decimals = numStr.slice(dotIndex, dotIndex + decimal + 1) // 截取小数位
+                res = String(numStr.slice(0, dotIndex)).replace(/(\d)(?=(?:\d{3})+$)/g, `$1${split}`) + decimals
+                }
+                return res
+            }
+            } else {
+            return '--'
+            }
         }
     }
   }

+ 30 - 2
src/views/crm/messageBox/teamMonthDetails.vue

@@ -88,8 +88,10 @@
     beforeMount: function () {
         let sql = "select e.*,ibps_party_employee.NAME_ from (select d.*,t_mjwtsqb.zong_jia_ as jiage from (select * from t_bjd LEFT JOIN (select a.id_ as leibieid,a.lai_yuan_qu_dao_ as laiyuan,b.id_ as qudaoid, b.lei_bie_ from ((select id_, lai_yuan_qu_dao_ from t_qzkhb GROUP BY id_) UNION (select id_, lai_yuan_qu_dao_ from t_yxkh GROUP BY id_) UNION (select ke_hu_ming_cheng_, lai_yuan_qu_dao_ as khnum from t_khxx GROUP BY ke_hu_ming_cheng_)) as a LEFT JOIN (select t_qdgl.id_,t_qdlbb.lei_bie_ from t_qdgl LEFT JOIN t_qdlbb on t_qdgl.qu_dao_lei_bie_ = t_qdlbb.id_) as b on a.lai_yuan_qu_dao_ = b.id_) as c on t_bjd.ke_hu_ming_cheng_ = c.leibieid where c.lei_bie_ is not NULL and t_bjd.sheng_xiao_shi_ji like '"+ this.date.split('-')[0] +"%' and t_bjd.bian_zhi_ren_ = '"+this.data[0]+"') as d left join t_mjwtsqb on t_mjwtsqb.he_tong_bian_hao_ = d.id_ WHERE t_mjwtsqb.shi_fou_guo_shen_ = '1' ) as e LEFT JOIN ibps_party_employee on e.bian_zhi_ren_ = ibps_party_employee.id_ ORDER BY e.he_tong_bian_hao_ desc"
         curdPost('sql',sql).then(res=>{
-
-          this.tableData = res.variables.data
+            for (let i = 0; i < res.variables.data.length; i++) {
+                res.variables.data[i].jiage = this.moneyFormat(res.variables.data[i].jiage)
+            }
+            this.tableData = res.variables.data
         })
     },
     watch:{
@@ -129,6 +131,32 @@
         },
         handleCurrentChange(val) {
             this.currpage = val
+        },
+        moneyFormat (num, decimal = 2, split = ',') {
+        /*
+          parameter:
+          num:格式化目标数字
+          decimal:保留几位小数,默认2位
+          split:千分位分隔符,默认为,
+        */
+            if (isFinite(num)) { // num是数字
+            if (num === 0) { // 为0
+                return num.toFixed(decimal)
+            } else { // 非0
+                var res = ''
+                var dotIndex = String(num).indexOf('.')
+                if (dotIndex === -1) { // 整数
+                res = String(num).replace(/(\d)(?=(?:\d{3})+$)/g, `$1${split}`) + '.' + '0'.repeat(decimal)
+                } else { 
+                const numStr = String((Math.round(num * Math.pow(10, decimal)) / Math.pow(10, decimal)).toFixed(decimal)) // 四舍五入,然后固定保留2位小数
+                const decimals = numStr.slice(dotIndex, dotIndex + decimal + 1) // 截取小数位
+                res = String(numStr.slice(0, dotIndex)).replace(/(\d)(?=(?:\d{3})+$)/g, `$1${split}`) + decimals
+                }
+                return res
+            }
+            } else {
+            return '--'
+            }
         }
     }
   }

+ 53 - 2
src/views/crm/tongji.vue

@@ -126,7 +126,7 @@
         pmArr:[],
         peArr:[],
         tableData:{
-          header: ['公司名称', '付款方式', '价格(元)'],
+          header: ['公司名称', '付款方式', '销售金额(元)'],
           data: [
             ['行1列1', '行1列2', '行1列3'],
             ['行2列1', '行2列2', '行2列3'],
@@ -160,7 +160,32 @@
       //初始化
       this.Date()
     },
+    created() {
+      if (screenfull.isEnabled && !screenfull.isFullscreen) {
+        this.allView()
+      }
+
+      // this.refreshAll(this.allDate)
+
+      if (this.timer){
+        clearInterval(this.timer)
+      }
+
+      this.timer = setInterval(() => {
+        this.refreshAll(this.allDate)
+      },600000)
+    },
+    beforeDestroy() {
+      if (screenfull.isFullscreen) {
+        screenfull.toggle()
+      }
+      clearInterval(this.timer)
+    },
     methods: {
+      allView() {
+        // 默认显示全屏
+        screenfull.request()
+      },
       Date() {
         const nowDate = new Date();
         const date = {
@@ -239,7 +264,7 @@
         curdPost('sql',sql).then(res=>{
           let arr = res.variables.data
           for (var i = 0; i < arr.length; i++) {
-            let changeArr = [arr[i].zhuan_huan_ke_hu_,arr[i].fu_kuan_fang_shi_,arr[i].jiage]
+            let changeArr = [arr[i].zhuan_huan_ke_hu_,arr[i].fu_kuan_fang_shi_,this.moneyFormat(arr[i].jiage)]
             this.tableData.data.push(changeArr)
           }
           // }
@@ -323,6 +348,32 @@
             break;
           }
         }
+      },
+      moneyFormat (num, decimal = 2, split = ',') {
+        /*
+          parameter:
+          num:格式化目标数字
+          decimal:保留几位小数,默认2位
+          split:千分位分隔符,默认为,
+        */
+        if (isFinite(num)) { // num是数字
+          if (num === 0) { // 为0
+            return num.toFixed(decimal)
+          } else { // 非0
+            var res = ''
+            var dotIndex = String(num).indexOf('.')
+            if (dotIndex === -1) { // 整数
+              res = String(num).replace(/(\d)(?=(?:\d{3})+$)/g, `$1${split}`) + '.' + '0'.repeat(decimal)
+            } else { 
+              const numStr = String((Math.round(num * Math.pow(10, decimal)) / Math.pow(10, decimal)).toFixed(decimal)) // 四舍五入,然后固定保留2位小数
+              const decimals = numStr.slice(dotIndex, dotIndex + decimal + 1) // 截取小数位
+              res = String(numStr.slice(0, dotIndex)).replace(/(\d)(?=(?:\d{3})+$)/g, `$1${split}`) + decimals
+            }
+            return res
+          }
+        } else {
+          return '--'
+        }
       }
     }
   }

+ 6 - 5
src/views/statistics/index.vue

@@ -362,8 +362,9 @@
         let nowDate = new Date();
         return nowDate.getFullYear() - year;
       },
-      allView(){
-        screenfull.request() //默认显示全屏
+      allView() {
+        // 默认显示全屏
+        screenfull.request()
       },
       goBack(){
         this.$router.back(-1)
@@ -371,16 +372,16 @@
     },
     created() {
       //时间
-      this.currentTime()
+      // this.currentTime()
       if(screenfull.isEnabled && !screenfull.isFullscreen){
-      this.allView()
+        this.allView()
         
       }
     },
     beforeDestroy() {
       if(screenfull.isFullscreen){
         screenfull.toggle()
-        }
+      }
     }
   }
 </script>