Browse Source

feat: 数据看板 - 账号数据趋势 - 权限控制逻辑

zhengxy 2 years ago
parent
commit
9f0d416026

+ 81 - 0
project/src/components/assembly/screen/copy0104_switchMpAdq.vue

@@ -0,0 +1,81 @@
1
+<template>
2
+  <div class="switch-wrap">
3
+    <div
4
+      class="switch-item"
5
+      :class="{ 'active': value === orderTypeOptions.ADQ}"
6
+      @click="onClickSwitch(orderTypeOptions.ADQ)"
7
+    >ADQ</div>
8
+    <div
9
+      class="switch-item"
10
+      :class="{ 'active': value === orderTypeOptions.MP}"
11
+      @click="onClickSwitch(orderTypeOptions.MP)"
12
+    >MP</div>
13
+    <div
14
+      v-if="isSum"
15
+      class="switch-item"
16
+      :class="{ 'active': value === orderTypeOptions.SUM}"
17
+      @click="onClickSwitch(orderTypeOptions.SUM)"
18
+    >总表</div>
19
+  </div>
20
+</template>
21
+
22
+<script>
23
+import { orderTypeOptions } from '@/assets/js/staticTypes'
24
+export default {
25
+  props: {
26
+    value: {
27
+      type: String | Number,
28
+      default: () => ''
29
+    },
30
+    isSum: { // 是否显示"总表"(目前"账号数据趋势"、"短剧数据趋势"中存在)
31
+      type: Boolean,
32
+      default: () => false
33
+    },
34
+  },
35
+  data () {
36
+    return {
37
+      orderTypeOptions: Object.freeze(orderTypeOptions),
38
+    }
39
+  },
40
+  methods: {
41
+    onClickSwitch(orderType) {
42
+      this.$emit('input', orderType)
43
+      this.$emit('change', orderType)
44
+    },
45
+  }
46
+}
47
+</script>
48
+
49
+<style lang="scss" scoped>
50
+.switch-wrap {
51
+  display: flex;
52
+  font-size: 14px;
53
+  font-weight: 600;
54
+  color: #32B38A;
55
+  .switch-item {
56
+    display: flex;
57
+    align-items: center;
58
+    justify-content: center;
59
+    width: 70px;
60
+    height: 28px;
61
+    border-top: 1px solid #E7E8EC;
62
+    border-bottom: 1px solid #E7E8EC;
63
+    cursor: pointer;
64
+    &:first-child {
65
+      border-left: 1px solid #E7E8EC;
66
+      border-top-left-radius: 4px;
67
+      border-bottom-left-radius: 4px;
68
+    }
69
+    &:last-child {
70
+      border-right: 1px solid #E7E8EC;
71
+      border-top-right-radius: 4px;
72
+      border-bottom-right-radius: 4px;
73
+    }
74
+    &.active {
75
+      border-color: #32B38A;
76
+      background-color: #32B38A;
77
+      color: #fff;
78
+    }
79
+  }
80
+}
81
+</style>

+ 12 - 2
project/src/components/assembly/screen/switchMpAdq.vue

@@ -1,17 +1,19 @@
1 1
 <template>
2 2
   <div class="switch-wrap">
3 3
     <div
4
+      v-if="isShowAdqBtn"
4 5
       class="switch-item"
5 6
       :class="{ 'active': value === orderTypeOptions.ADQ}"
6 7
       @click="onClickSwitch(orderTypeOptions.ADQ)"
7 8
     >ADQ</div>
8 9
     <div
10
+      v-if="isShowMpBtn"
9 11
       class="switch-item"
10 12
       :class="{ 'active': value === orderTypeOptions.MP}"
11 13
       @click="onClickSwitch(orderTypeOptions.MP)"
12 14
     >MP</div>
13 15
     <div
14
-      v-if="isSum"
16
+      v-if="isShowSumBtn"
15 17
       class="switch-item"
16 18
       :class="{ 'active': value === orderTypeOptions.SUM}"
17 19
       @click="onClickSwitch(orderTypeOptions.SUM)"
@@ -27,7 +29,15 @@ export default {
27 29
       type: String | Number,
28 30
       default: () => ''
29 31
     },
30
-    isSum: { // 是否显示"总表"(目前"账号数据趋势"、"短剧数据趋势"中存在)
32
+    isShowAdqBtn: { // 是否显示"ADQ"(默认显示)
33
+      type: Boolean,
34
+      default: () => true
35
+    },
36
+    isShowMpBtn: { // 是否显示"MP"(默认显示)
37
+      type: Boolean,
38
+      default: () => true
39
+    },
40
+    isShowSumBtn: { // 是否显示"总表"(默认不显示、目前"账号数据趋势"、"短剧数据趋势"中存在)
31 41
       type: Boolean,
32 42
       default: () => false
33 43
     },

+ 103 - 50
project/src/components/dataBoard/accountTrends.vue

@@ -1,51 +1,60 @@
1 1
 <template>
2 2
   <div class="accountTrends-wrap" v-loading="pageLoading">
3
-    <div class="screenBox flex">
4
-      <switchMpAdq v-model="filter.order_type" :isSum="true" @change="onChangeOrderType" />
5
-      <el-button type="primary" size="mini" @click="onClickExport">导出Excel</el-button>
6
-    </div>
7
-    <!-- S 筛选区 -->
8
-    <div class="screenBox filter-wrap">
9
-      <!-- 日期 -->
10
-      <datePicker style="margin-right: 30px;" :reset="reset" title="自定义" :quickFlag="true" :afferent_time="default_time" :clearFlag="false" @changeTime="onChangeTime" />
11
-      <!-- MP账号(公众号) -->
12
-      <selfChannelMultiple style="margin-right: 30px;margin-left: -30px;" v-show="isMP" :reset="reset" title="账号" type="thePublic" labelWidth @channelDefine="onChangeAccountId" />
13
-      <!-- ADQ账号(ADQ) -->
14
-      <selfChannelMultiple style="margin-right: 30px;margin-left: -30px;" v-show="isADQ" :reset="reset" title="账号" type="adqAccount" labelWidth @channelDefine="onChangeAccountIdAdq" />
15
-      <!-- "总表"账号(总表) -->
16
-      <selfChannelMultiple style="margin-right: 30px;margin-left: -30px;" v-show="isSUM" :reset="reset" title="账号" type="allAccount" labelWidth @channelDefine="onChangeAccountIdSum" />
17
-      <!-- 收益截止日期 -->
18
-      <div style="margin-right: 30px;" class="common-screen-item">
19
-        <label class="common-screen-label">收益截止日期</label>
20
-        <el-date-picker v-model="filter.closing_date" value-format="yyyy-MM-dd" type="date" placeholder="选择日期" size="small" style="width:150px" @change="onChangeClosingDate" />
3
+    <!-- S 无权限 -->
4
+    <el-empty class="empty-wrap" v-if="isShowEmpty" description="暂无数据权限" />
5
+    <!-- E 无权限 -->
6
+
7
+    <template v-else>
8
+      <div class="screenBox flex">
9
+        <switchMpAdq
10
+          v-model="filter.order_type"
11
+          :isShowAdqBtn="isShowAdqBtn"
12
+          :isShowMpBtn="isShowMpBtn"
13
+          :isShowSumBtn="isShowSumBtn"
14
+          @change="onChangeOrderType"
15
+        />
16
+        <el-button v-if="isCanExport" type="primary" size="mini" @click="onClickExport">导出Excel</el-button>
21 17
       </div>
22
-      <div class="flex">
23
-        <!-- 推广类型 -->
24
-        <selfChannel style="margin-right: 30px;margin-left: -30px;" :reset="reset" title="推广类型" type="promotionType" labelWidth @channelDefine="onChangePromotionType" />
25
-        <!-- 回本率(范围) -->
26
-        <!-- <inputRange style="margin-right: 10px;" v-model="filter.costCover" label="回本率" /> -->
27
-        <el-button size="mini" type="primary" plain @click="onClickSearch">确定</el-button>
28
-        <el-button size="mini" plain @click="onClickReset">重置</el-button>
18
+      <!-- S 筛选区 -->
19
+      <div class="screenBox filter-wrap">
20
+        <!-- 日期 -->
21
+        <datePicker style="margin-right: 30px;" :reset="reset" title="自定义" :quickFlag="true" :afferent_time="default_time" :clearFlag="false" @changeTime="onChangeTime" />
22
+        <!-- MP账号(公众号) -->
23
+        <selfChannelMultiple style="margin-right: 30px;margin-left: -30px;" v-show="isMP" :reset="reset" title="账号" type="thePublic" labelWidth @channelDefine="onChangeAccountId" />
24
+        <!-- ADQ账号(ADQ) -->
25
+        <selfChannelMultiple style="margin-right: 30px;margin-left: -30px;" v-show="isADQ" :reset="reset" title="账号" type="adqAccount" labelWidth @channelDefine="onChangeAccountIdAdq" />
26
+        <!-- "总表"账号(总表) -->
27
+        <selfChannelMultiple style="margin-right: 30px;margin-left: -30px;" v-show="isSUM" :reset="reset" title="账号" type="allAccount" labelWidth @channelDefine="onChangeAccountIdSum" />
28
+        <!-- 收益截止日期 -->
29
+        <div style="margin-right: 30px;" class="common-screen-item">
30
+          <label class="common-screen-label">收益截止日期</label>
31
+          <el-date-picker v-model="filter.closing_date" value-format="yyyy-MM-dd" type="date" placeholder="选择日期" size="small" style="width:150px" @change="onChangeClosingDate" />
32
+        </div>
33
+        <div class="flex">
34
+          <!-- 推广类型 -->
35
+          <selfChannel style="margin-right: 30px;margin-left: -30px;" :reset="reset" title="推广类型" type="promotionType" labelWidth @channelDefine="onChangePromotionType" />
36
+          <!-- 回本率(范围) -->
37
+          <!-- <inputRange style="margin-right: 10px;" v-model="filter.costCover" label="回本率" /> -->
38
+          <el-button size="mini" type="primary" plain @click="onClickSearch">确定</el-button>
39
+          <el-button size="mini" plain @click="onClickReset">重置</el-button>
40
+        </div>
29 41
       </div>
30
-    </div>
31
-    <!-- E 筛选区 -->
32
-    <!-- S 数据更新时间 -->
33
-    <div class="update-time"><i class="el-icon-warning-outline" />数据更新时间:{{ updateTime || '-' }}</div>
34
-    <!-- E 数据更新时间 -->
35
-    <!-- S 折线图 -->
36
-    <div class="trendBox mt-10" v-loading="chartLoading">
37
-      <div class="legendBox">
38
-        <div class="legendItem" v-for="(item, index) in legendList" :key="index" @click="onClickLegend(item, index)">{{ item.name }}
39
-          <div :class="['checkbox', item.selectFlag ? 'checkbox_active': '']" :style="item.selectFlag ? `background: ${item.color};border-color: ${item.color};`: '' "><i class="el-icon-check" /></div>
42
+      <!-- E 筛选区 -->
43
+      <!-- S 数据更新时间 -->
44
+      <div class="update-time"><i class="el-icon-warning-outline" />数据更新时间:{{ updateTime || '-' }}</div>
45
+      <!-- E 数据更新时间 -->
46
+      <!-- S 折线图 -->
47
+      <div class="trendBox mt-10" v-loading="chartLoading">
48
+        <div class="legendBox">
49
+          <div class="legendItem" v-for="(item, index) in legendList" :key="index" @click="onClickLegend(item, index)">{{ item.name }}
50
+            <div :class="['checkbox', item.selectFlag ? 'checkbox_active': '']" :style="item.selectFlag ? `background: ${item.color};border-color: ${item.color};`: '' "><i class="el-icon-check" /></div>
51
+          </div>
40 52
         </div>
53
+        <div id="trend" style="width: 100%; height: 250px;" />
54
+        <div v-if="!chartDataList || !chartDataList.length" style="text-align: center; color: #333; font-size: 14px; position: relative; top: -100px;">暂无数据</div>
41 55
       </div>
42
-      <div id="trend" style="width: 100%; height: 250px;" />
43
-      <div v-if="!chartDataList || !chartDataList.length" style="text-align: center; color: #333; font-size: 14px; position: relative; top: -100px;">暂无数据</div>
44
-    </div>
45
-    <!-- E 折线图 -->
46
-
47
-    <!-- S 表 -->
48
-
56
+      <!-- E 折线图 -->
57
+      <!-- S 表 -->
49 58
       <!-- S 汇总表 summaryTable -->
50 59
       <div v-loading="summaryLoading">
51 60
         <ux-grid class="summaryTable" ref="summaryTable" :border="false" @row-click="() => { return }" :header-cell-style="getHeaderCellStyle" show-footer-overflow="tooltip" show-overflow="tooltip" size="mini">
@@ -178,7 +187,8 @@
178 187
         </div>
179 188
       </div>
180 189
       <!-- E 明细表 detailsTable -->
181
-    <!-- E 表 -->
190
+      <!-- E 表 -->
191
+    </template>
182 192
   </div>
183 193
 </template>
184 194
 <script>
@@ -234,7 +244,7 @@ export default {
234 244
         total: 0,
235 245
       },
236 246
       filter: {
237
-        order_type: orderTypeOptions.ADQ,
247
+        order_type: '',
238 248
         time: DEFAULT_TIME, // 自定义日期
239 249
         account_id: [], // 账号"MP"
240 250
         account_id_adq: [], // 账号"ADQ"
@@ -246,6 +256,7 @@ export default {
246 256
         sort_type: 'desc', // 升序/降序
247 257
       },
248 258
       updateTime: '', // 数据更新时间
259
+      isShowEmpty: false, // 是否展示空页面 => 无任何权限时展示
249 260
     }
250 261
   },
251 262
   computed: {
@@ -270,19 +281,53 @@ export default {
270 281
         return true
271 282
       }
272 283
     },
284
+    // 是否有“ADQ”权限
285
+    isShowAdqBtn() {
286
+      return !!this.$store.state.dataBoardAuth.adq_auth
287
+    },
288
+    // 是否有“MP”权限
289
+    isShowMpBtn() {
290
+      return !!this.$store.state.dataBoardAuth.mp_auth
291
+    },
292
+    // 是否有“总表”权限
293
+    isShowSumBtn() {
294
+      return this.isShowAdqBtn && this.isShowMpBtn
295
+    },
296
+    // 是否有“导出”权限
297
+    isCanExport() {
298
+      return !!this.$store.state.dataBoardAuth.can_export
299
+    },
273 300
   },
274 301
   created () {
275 302
     console.log('created => ')
276
-    this.initTableHeight()
277
-    this.handleGetChart()
278
-    this.handleGetSummaryList()
279
-    this.handleGetList()
280
-    this.handleGetUpdateTime()
303
+    const isPermissioned = this.getDefaultOrderType() // 根据用户权限 获取order_type默认值
304
+    if (isPermissioned) { // 有权限 => 获取对应报表数据
305
+      this.initTableHeight()
306
+      this.handleGetChart()
307
+      this.handleGetSummaryList()
308
+      this.handleGetList()
309
+      this.handleGetUpdateTime()
310
+    } else { // 无权限 => 展示空页面
311
+      this.isShowEmpty = true
312
+    }
281 313
   },
282 314
   beforeDestroy () {
283 315
     this.myChart && this.myChart.clear()
284 316
   },
285 317
   methods: {
318
+    // 根据用户权限 获取 order_type 默认值
319
+    getDefaultOrderType() {
320
+      if (this.isShowAdqBtn) { // 有ADQ权限 => 默认值ADQ
321
+        this.filter.order_type = orderTypeOptions.ADQ
322
+        return orderTypeOptions.ADQ
323
+      } else if (this.isShowMpBtn) { // 有MP权限 => 默认值MP
324
+        this.filter.order_type = orderTypeOptions.MP
325
+        return orderTypeOptions.MP
326
+      } else { // 无以上权限 => 返回false
327
+        this.$message.warning('暂无数据权限')
328
+        return false
329
+      }
330
+    },
286 331
     initTableHeight() {
287 332
       this.height = document.documentElement.clientHeight - 200 > 400 ? document.documentElement.clientHeight - 200 : 400
288 333
     },
@@ -772,7 +817,7 @@ export default {
772 817
     // 监听点击"重置"按钮
773 818
     onClickReset() {
774 819
       this.reset = !this.reset
775
-      this.filter.order_type = orderTypeOptions.ADQ
820
+      this.filter.order_type = this.getDefaultOrderType()
776 821
       this.filter.time = this.default_time
777 822
       this.filter.account_id = []
778 823
       this.filter.account_id_adq = []
@@ -930,7 +975,15 @@ export default {
930 975
 </style>
931 976
 <style lang="scss" scoped>
932 977
 .accountTrends-wrap {
978
+  position: relative;
933 979
   min-width: 1125px;
980
+  min-height: calc(100vh - 70px);
981
+  .empty-wrap {
982
+    position: absolute;
983
+    top: 50%;
984
+    left: 50%;
985
+    transform: translate(-50%, -50%);
986
+  }
934 987
   .update-time {
935 988
     margin-top: 10px;
936 989
     padding-left: 20px;

File diff suppressed because it is too large
+ 1022 - 0
project/src/components/dataBoard/copy0104_accountTrends.vue


File diff suppressed because it is too large
+ 904 - 0
project/src/components/dataBoard/copy0104_shortDramaTrends.vue


+ 1 - 1
project/src/components/dataBoard/shortDramaTrends.vue

@@ -1,7 +1,7 @@
1 1
 <template>
2 2
   <div class="shortDramaTrends-wrap" v-loading="pageLoading">
3 3
     <div class="screenBox flex">
4
-      <switchMpAdq v-model="filter.order_type" :isSum="true" @change="onChangeOrderType" />
4
+      <switchMpAdq v-model="filter.order_type" :isShowSumBtn="true" @change="onChangeOrderType" />
5 5
       <el-button type="primary" size="mini" @click="onClickExport">导出Excel</el-button>
6 6
     </div>
7 7
     <!-- S 筛选区 -->