Quellcode durchsuchen

feat: 数据看板 - 运营数据 - 权限控制逻辑

zhengxy vor 2 Jahren
Ursprung
Commit
c65b3d80a6
1 geänderte Dateien mit 101 neuen und 29 gelöschten Zeilen
  1. 101 29
      project/src/components/dataBoard/operateDayRetrieve.vue

+ 101 - 29
project/src/components/dataBoard/operateDayRetrieve.vue

@@ -1,36 +1,47 @@
1 1
 <template>
2
-  <div v-loading="loading">
3
-    <div class="screenBox flex">
4
-      <div class="flex">
2
+  <div class="operateDayRetrieve-wrap" v-loading="loading">
3
+    <!-- S 无权限 -->
4
+    <el-empty class="empty-wrap" v-if="isShowEmpty" description="暂无数据权限" />
5
+    <!-- E 无权限 -->
6
+
7
+    <template v-else>
8
+      <div class="screenBox flex">
5 9
         <!-- S 选择订单类型 - 组件 -->
6
-        <switch-mp-adq v-model="order_type" @change="init(1)" />
10
+        <switchMpAdq
11
+          v-model="order_type"
12
+          :isShowAdqBtn="isShowAdqBtn"
13
+          :isShowMpBtn="isShowMpBtn"
14
+          @change="init(1)"
15
+        />
7 16
         <!-- E 选择订单类型 - 组件 -->
8
-        <date-picker title="选择日期" @changeTime="changeTime"></date-picker>
17
+        <el-button v-if="isCanExport" type="primary" size="mini" @click="init(1,'export')">导出Excel</el-button>
18
+      </div>
19
+      <div class="screenBox filter-wrap">
20
+        <date-picker style="margin-left: -20px;" :labelWidth="true" title="选择日期" @changeTime="changeTime"></date-picker>
9 21
         <self-channel v-show="isMP" title="公众号" type='thePublic' @channelDefine="(val)=>{account_id = val;init(1)}"></self-channel>
10 22
         <self-channel v-show="isMP" title="剧集" type='dramaList' @channelDefine="(val)=>{playlet_id = val;init(1)}"></self-channel>
11 23
       </div>
12
-      <el-button type="primary" size="mini" @click="init(1,'export')">导出Excel</el-button>
13
-    </div>
14 24
 
15
-    <ux-grid style="margin-top:10px" ref="plxTable" :border="false" @row-click="()=>{return}" :header-cell-style="()=>{return { backgroundColor: '#FFFFFF !important', border: 'none!important' }}" :height="height" show-footer-overflow="tooltip" show-overflow="tooltip" size="mini">
16
-      <ux-table-column v-for="item in desCol" :key="item.prop" :resizable="true" :field="item.prop" :title="item.label" :min-width="item.min_width?item.min_width:120" :fixed="item.prop == 'date'?'left':''" align="center">
17
-        <template #header>
18
-          <div class="flex-align-jus-center">{{item.label}}
19
-            <el-tooltip v-if="item.notes" :content="item.notes" placement="top">
20
-              <div><i class="el-icon-question"></i></div>
21
-            </el-tooltip>
22
-          </div>
23
-        </template>
24
-        <template v-slot="{ row }">
25
-          <span v-if="item.self_type == 'extra'">{{row.retrieveInfo[item.prop]||row.retrieveInfo[item.prop]==0?$formatNum(row.retrieveInfo[item.prop]):'-' }}</span>
26
-          <span v-else>{{row[item.prop]||row[item.prop]==0?$formatNum(row[item.prop]):'-' }}</span>
27
-        </template>
28
-      </ux-table-column>
29
-    </ux-grid>
30
-    <div class="pagination" v-show="total>0">
31
-      <el-pagination background :current-page="page" @current-change="handleCurrentChange" layout="prev, pager, next" :page-count='Number(pages)'>
32
-      </el-pagination>
33
-    </div>
25
+      <ux-grid style="margin-top:10px" ref="plxTable" :border="false" @row-click="()=>{return}" :header-cell-style="()=>{return { backgroundColor: '#FFFFFF !important', border: 'none!important' }}" :height="height" show-footer-overflow="tooltip" show-overflow="tooltip" size="mini">
26
+        <ux-table-column v-for="item in desCol" :key="item.prop" :resizable="true" :field="item.prop" :title="item.label" :min-width="item.min_width?item.min_width:120" :fixed="item.prop == 'date'?'left':''" align="center">
27
+          <template #header>
28
+            <div class="flex-align-jus-center">{{item.label}}
29
+              <el-tooltip v-if="item.notes" :content="item.notes" placement="top">
30
+                <div><i class="el-icon-question"></i></div>
31
+              </el-tooltip>
32
+            </div>
33
+          </template>
34
+          <template v-slot="{ row }">
35
+            <span v-if="item.self_type == 'extra'">{{row.retrieveInfo[item.prop]||row.retrieveInfo[item.prop]==0?$formatNum(row.retrieveInfo[item.prop]):'-' }}</span>
36
+            <span v-else>{{row[item.prop]||row[item.prop]==0?$formatNum(row[item.prop]):'-' }}</span>
37
+          </template>
38
+        </ux-table-column>
39
+      </ux-grid>
40
+      <div class="pagination" v-show="total>0">
41
+        <el-pagination background :current-page="page" @current-change="handleCurrentChange" layout="prev, pager, next" :page-count='Number(pages)'>
42
+        </el-pagination>
43
+      </div>
44
+    </template>
34 45
   </div>
35 46
 </template>
36 47
 <script>
@@ -63,7 +74,8 @@ export default {
63 74
         { prop: "new_cost", label: "下单成本", notes: '下单成本=当日总消耗/当日新增用户首单人数' },
64 75
       ],
65 76
       desColFlag: false,
66
-      height: ''
77
+      height: '',
78
+      isShowEmpty: false, // 是否展示空页面 => 无任何权限时展示
67 79
     }
68 80
   },
69 81
   computed: {
@@ -75,12 +87,46 @@ export default {
75 87
     isADQ() {
76 88
       return this.order_type === orderTypeOptions.ADQ
77 89
     },
90
+    // 是否有“ADQ”权限
91
+    isShowAdqBtn() {
92
+      return !!this.$store.state.dataBoardAuth.adq_auth
93
+    },
94
+    // 是否有“MP”权限
95
+    isShowMpBtn() {
96
+      return !!this.$store.state.dataBoardAuth.mp_auth
97
+    },
98
+    // 是否有“总表”权限
99
+    isShowSumBtn() {
100
+      return this.isShowAdqBtn && this.isShowMpBtn
101
+    },
102
+    // 是否有“导出”权限
103
+    isCanExport() {
104
+      return !!this.$store.state.dataBoardAuth.can_export
105
+    },
78 106
   },
79 107
   created () {
80
-    this.height = document.documentElement.clientHeight - 200 > 400 ? document.documentElement.clientHeight - 200 : 400
81
-    this.init(1)
108
+    const isPermissioned = this.getDefaultOrderType() // 根据用户权限 获取order_type默认值
109
+    if (isPermissioned) { // 有权限 => 获取对应报表数据
110
+      this.height = document.documentElement.clientHeight - 200 > 400 ? document.documentElement.clientHeight - 200 : 400
111
+      this.init(1)
112
+    } else { // 无权限 => 展示空页面
113
+      this.isShowEmpty = true
114
+    }
82 115
   },
83 116
   methods: {
117
+    // 根据用户权限 获取 order_type 默认值
118
+    getDefaultOrderType() {
119
+      if (this.isShowAdqBtn) { // 有ADQ权限 => 默认值ADQ
120
+        this.order_type = orderTypeOptions.ADQ
121
+        return orderTypeOptions.ADQ
122
+      } else if (this.isShowMpBtn) { // 有MP权限 => 默认值MP
123
+        this.order_type = orderTypeOptions.MP
124
+        return orderTypeOptions.MP
125
+      } else { // 无以上权限 => 返回false
126
+        this.$message.warning('暂无数据权限')
127
+        return false
128
+      }
129
+    },
84 130
     changeTime (time) {//筛选时间变化
85 131
       if (!time || time && time.length == 0) {
86 132
         this.time = []
@@ -187,6 +233,32 @@ export default {
187 233
 }
188 234
 </script>
189 235
 <style lang="scss" scoped>
236
+.operateDayRetrieve-wrap {
237
+  position: relative;
238
+  min-width: 1125px;
239
+  min-height: calc(100vh - 70px);
240
+  .empty-wrap {
241
+    position: absolute;
242
+    top: 50%;
243
+    left: 50%;
244
+    transform: translate(-50%, -50%);
245
+  }
246
+  .filter-wrap {
247
+    display: flex;
248
+    align-items: center;
249
+    flex-wrap: wrap;
250
+    padding-bottom: 10px;
251
+    & > div {
252
+      margin: 0 10px 10px 0;
253
+    }
254
+    & > button {
255
+      margin: -10px 0 0 10px;
256
+    }
257
+    .el-button+.el-button {
258
+      margin-left: 10px;
259
+    }
260
+  }
261
+}
190 262
 .screenBox {
191 263
   background: #fff;
192 264
   padding: 5px 20px;