yumeng 1 неделя назад
Родитель
Сommit
3401cea593

+ 41 - 15
src/views/modules/stockWatch/modules/new-keepManage/group-keepManage.vue

@@ -66,9 +66,10 @@
                     <a-spin :spinning="spinningGroup">
                         <div style="width: 100%; height: 315px">
                             <ul class="group-keep-ul">
-                                <li>
-                                    今日消耗: <span style="font-weight: bold">{{ todayCost | formatNum }}</span>
-                                </li>
+                                <li>
+                                    {{ groupCostLabel }}:
+                                    <span style="font-weight: bold">{{ groupCostValue | formatNum }}</span>
+                                </li>
                                 <li v-if="!!compare">
                                     <span style="margin-left: 20%" v-if="compare.indexOf('-') == 0">
                                         <img
@@ -89,12 +90,12 @@
                                         <span style="color: red">{{ compare }}</span>
                                     </span>
 
-                                    <a-tooltip placement="top">
-                                        <template slot="title">
-                                            <span>今天截止此时的消耗跟昨天截止同个时段的消耗变化</span>
-                                        </template>
-                                        <a-icon style="margin-left: 10px" type="question-circle" />
-                                    </a-tooltip>
+                                    <a-tooltip placement="top">
+                                        <template slot="title">
+                                            <span>{{ groupCompareTooltip }}</span>
+                                        </template>
+                                        <a-icon style="margin-left: 10px" type="question-circle" />
+                                    </a-tooltip>
                                 </li>
                                 <li><span style="margin-left: 31px">消耗:</span> {{ sectionCost | formatNum }}</li>
                                 <li>人均带户: {{ userAverageAccount | formatNum }}</li>
@@ -698,7 +699,7 @@ export default {
                 .replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,')
         },
     },
-    mounted() {
+    mounted() {
 
         if(this.userInfo().id == '4afe739502ae4258a18c36a000d7ff20'||this.userInfo().roleName == '头条运营经理'){
             this.mediaId= '1'
@@ -715,11 +716,36 @@ export default {
         this.getItemList()
         this.clientWidth = document.documentElement.clientWidth - 224
     },
-    activated() {
-        this.$nextTick(() => {
-            this.clientWidth = document.documentElement.clientWidth - 224
-        })
-    },
+    activated() {
+        this.$nextTick(() => {
+            this.clientWidth = document.documentElement.clientWidth - 224
+        })
+    },
+    computed: {
+        groupCostLabel() {
+            if (!Array.isArray(this.dateEchart) || this.dateEchart.length !== 2) {
+                return '区间消耗'
+            }
+            const start = this.dateEchart[0] && this.dateEchart[0].format ? this.dateEchart[0].format('YYYY-MM-DD') : ''
+            const end = this.dateEchart[1] && this.dateEchart[1].format ? this.dateEchart[1].format('YYYY-MM-DD') : ''
+            const today = moment().format('YYYY-MM-DD')
+            return start === today && end === today ? '今日消耗' : '区间消耗'
+        },
+        groupCompareTooltip() {
+            if (!Array.isArray(this.dateEchart) || this.dateEchart.length !== 2) {
+                return '所选区间消耗与上一区间消耗变化'
+            }
+            const start = this.dateEchart[0] && this.dateEchart[0].format ? this.dateEchart[0].format('YYYY-MM-DD') : ''
+            const end = this.dateEchart[1] && this.dateEchart[1].format ? this.dateEchart[1].format('YYYY-MM-DD') : ''
+            const today = moment().format('YYYY-MM-DD')
+            return start === today && end === today
+                ? '今天截止此时的消耗跟昨天截止同个时段的消耗变化'
+                : '所选区间消耗与上一区间消耗变化'
+        },
+        groupCostValue() {
+            return this.groupCostLabel === '今日消耗' ? this.todayCost : this.sectionCost
+        },
+    },
     methods: {
         ...mapGetters(['userInfo']),
         isTencentMedia(mediaId) {

+ 18 - 2
src/views/modules/stockWatch/modules/new-keepManage/personal-keepManage.vue

@@ -47,7 +47,7 @@
                     <div style="width: 100%;height: 315px;margin-left: 10px;">
                         <ul class="group-keep-ul">
                             <li>
-                                今日消耗: <span style="font-weight: bold;">{{ todayCost | formatNum }}</span>
+                                {{ currentSpendLabel }}: <span style="font-weight: bold;">{{ todayCost | formatNum }}</span>
                             </li>
                             <li v-if="!!todayCompare">
                                 <span style="margin-left:20%;" v-if="todayCompare.indexOf('-') == 0">
@@ -63,7 +63,7 @@
                                 </span>
                                 <a-tooltip placement="top">
                                     <template slot="title">
-                                        <span>截止此时今日消耗与昨日同时刻消耗的对比</span>
+                                        <span>{{ currentSpendCompareTip }}</span>
                                     </template>
                                     <a-icon style="margin-left: 10px;" type="question-circle"/>
                                 </a-tooltip>
@@ -183,6 +183,22 @@ require('echarts/lib/component/legend');
 import {mapGetters} from 'vuex'
 
 export default {
+    computed: {
+        currentSpendLabel() {
+            if (!this.dateEchart || this.dateEchart.length < 2) {
+                return '区间消耗'
+            }
+            const start = this.dateEchart[0] && this.dateEchart[0].format ? this.dateEchart[0].format('YYYY-MM-DD') : ''
+            const end = this.dateEchart[1] && this.dateEchart[1].format ? this.dateEchart[1].format('YYYY-MM-DD') : ''
+            const today = moment().format('YYYY-MM-DD')
+            return start === today && end === today ? '今日消耗' : '区间消耗'
+        },
+        currentSpendCompareTip() {
+            return this.currentSpendLabel === '今日消耗'
+                ? '截止此时今日消耗与昨日同时刻消耗的对比'
+                : '所选区间消耗与上一区间消耗变化'
+        }
+    },
     data() {
         return {
             updateAccountEchart: '2021-12-22 8:00:00',