Browse Source

feat: 企微数据 - 数据循环统计 - 前端页面

zhengxy 2 years ago
parent
commit
50768b5256

+ 6 - 0
project/src/components/assembly/screen/channel.vue

@@ -158,6 +158,12 @@ export default {
158 158
         { key: 2, val: '小程序' },
159 159
       ]
160 160
       this.placeholderVal = '推广类型'
161
+    } else if (this.type == 'incomeSource') { // 收入来源
162
+      this.options = [
163
+        { key: 1, val: '投放推广' },
164
+        { key: 2, val: '运营推广' },
165
+      ]
166
+      this.placeholderVal = '收入来源'
161 167
     } else {
162 168
       this.init()
163 169
     }

+ 33 - 3
project/src/components/dataBoard/regRangeReport.vue

@@ -1,13 +1,19 @@
1 1
 <template>
2 2
   <div v-loading="loading">
3 3
     <div class="screenBox flex">
4
+      <switchMpAdq v-model="order_type" @change="init(1)" />
5
+      <el-button type="primary" size="mini" @click="init(1, 'export')">导出Excel</el-button>
6
+    </div>
7
+    <div class="screenBox flex">
4 8
       <div class="flex">
5 9
         <date-picker :reset="reset" title="自定义" :quickFlag='true' :afferent_time="default_time" :clearFlag='false'
6 10
           @changeTime="changeTime"></date-picker>
11
+        <!-- 推广类型 -->
12
+        <selfChannel :reset="reset" title="推广类型" type="promotionType" @channelDefine="(val)=>{promotion_type=val;init(1)}" />
13
+        <!-- 收入来源 -->
14
+        <selfChannel :reset="reset" title="收入来源" type="incomeSource" @channelDefine="(val)=>{income_source=val;init(1)}" />
7 15
       </div>
8
-      <el-button type="primary" size="mini" @click="init(1, 'export')">导出Excel</el-button>
9 16
     </div>
10
-
11 17
     <!-- S 新增区间筛选项 -->
12 18
     <div class="screenBox filter-wrap">
13 19
       <input-range v-model="firstDayRoi" label="首日ROI" />
@@ -50,8 +56,12 @@
50 56
 <script>
51 57
 import datePicker from '@/components/assembly/screen/datePicker.vue'
52 58
 import inputRange from '@/components/dataBoard/inputRange.vue'
59
+import switchMpAdq from '@/components/assembly/screen/switchMpAdq.vue'
60
+import selfChannel from '@/components/assembly/screen/channel.vue'
61
+import { orderTypeOptions } from '@/assets/js/staticTypes'
62
+
53 63
 export default {
54
-  components: { datePicker, inputRange },
64
+  components: { datePicker, inputRange, switchMpAdq, selfChannel },
55 65
   data () {
56 66
     return {
57 67
       loading: false,
@@ -72,8 +82,21 @@ export default {
72 82
       perFollowCost: ['', ''], // 企微成本(范围)
73 83
       totalRoi: ['', ''], // 回本率(范围)
74 84
       reset: false,
85
+      order_type: orderTypeOptions.MP, // MP/ADQ
86
+      promotion_type: '', // 推广类型
87
+      income_source: '', // 收入来源
75 88
     }
76 89
   },
90
+  computed: {
91
+    // 当前列表是否为"MP运营数据"
92
+    isMP() {
93
+      return this.order_type === orderTypeOptions.MP
94
+    },
95
+    // 当前列表是否为"ADQ运营数据"
96
+    isADQ() {
97
+      return this.order_type === orderTypeOptions.ADQ
98
+    },
99
+  },
77 100
   created () {
78 101
     this.height = document.documentElement.clientHeight - 200 > 400 ? document.documentElement.clientHeight - 200 : 400
79 102
     this.time = this.default_time
@@ -82,6 +105,9 @@ export default {
82 105
   methods: {
83 106
     handleReset() {
84 107
       this.reset = !this.reset
108
+      this.order_type = orderTypeOptions.MP
109
+      this.promotion_type = ''
110
+      this.income_source = ''
85 111
       this.time = this.default_time
86 112
       this.firstDayRoi = ['', ''] // 首日ROI(范围)
87 113
       this.firstOrderCost = ['', ''] // 下单成本(范围)
@@ -113,6 +139,10 @@ export default {
113 139
       this.loading = true
114 140
       this.$axios.get(`${this.URL.BASEURL}${this.URL.statistics_reg_range_report_new}`, {
115 141
         params: {
142
+          order_type: this.order_type, // mock 新增参数
143
+          promotion_type: this.promotion_type, // mock 新增参数
144
+          income_source: this.income_source, // mock 新增参数
145
+
116 146
           begin_date: this.time[0],
117 147
           end_date: this.time[1],
118 148
           first_day_roi_min: this.firstDayRoi[0],

+ 208 - 0
project/src/components/dataBoard/regRangeReport_backup.vue

@@ -0,0 +1,208 @@
1
+<template>
2
+  <div v-loading="loading">
3
+    <div class="screenBox flex">
4
+      <div class="flex">
5
+        <date-picker :reset="reset" title="自定义" :quickFlag='true' :afferent_time="default_time" :clearFlag='false'
6
+          @changeTime="changeTime"></date-picker>
7
+      </div>
8
+      <el-button type="primary" size="mini" @click="init(1, 'export')">导出Excel</el-button>
9
+    </div>
10
+
11
+    <!-- S 新增区间筛选项 -->
12
+    <div class="screenBox filter-wrap">
13
+      <input-range v-model="firstDayRoi" label="首日ROI" />
14
+      <input-range v-model="firstOrderCost " label="下单成本" />
15
+      <input-range v-model="firstOrderCostUnique" label="下单成本(去重)" />
16
+      <input-range v-model="perFollowCost" label="企微成本" />
17
+      <input-range v-model="totalRoi" label="回本率" />
18
+      <div>
19
+        <el-button size="mini" type="primary" plain @click="init(1)">确定</el-button>
20
+        <el-button size="mini" plain @click="handleReset">重置</el-button>
21
+      </div>
22
+    </div>
23
+    <!-- S 新增区间筛选项 -->
24
+
25
+    <ux-grid style="margin-top:10px" ref="plxTable" :border="false" @row-click="() => { return }"
26
+      :header-cell-style="() => { return { backgroundColor: '#FFFFFF !important', border: 'none!important' } }"
27
+      :height="height" show-footer-overflow="tooltip" show-overflow="tooltip" size="mini">
28
+      <ux-table-column v-for="item in desCol" :key="item.column" :resizable="true" :field="item.column"
29
+        :title="item.name" :min-width="item.min_width ? item.min_width : 140"
30
+        :fixed="item.column == 'date' ? 'left' : ''" align="center">
31
+        <template #header>
32
+          <div class="flex-align-jus-center">{{ item.name }}
33
+            <el-tooltip v-if="item.notes" :content="item.notes" placement="top">
34
+              <div><i class="el-icon-question"></i></div>
35
+            </el-tooltip>
36
+          </div>
37
+        </template>
38
+        <template v-slot="{ row }">
39
+          <span>{{ row[item.column] ? $formatNum(row[item.column]) : '-' }}</span>
40
+        </template>
41
+      </ux-table-column>
42
+    </ux-grid>
43
+    <div class="pagination" v-show="total > 0">
44
+      <el-pagination background :current-page="page" @current-change="handleCurrentChange" layout="prev, pager, next"
45
+        :page-count='Number(pages)'>
46
+      </el-pagination>
47
+    </div>
48
+  </div>
49
+</template>
50
+<script>
51
+import datePicker from '@/components/assembly/screen/datePicker.vue'
52
+import inputRange from '@/components/dataBoard/inputRange.vue'
53
+export default {
54
+  components: { datePicker, inputRange },
55
+  data () {
56
+    return {
57
+      loading: false,
58
+      page: 1,
59
+      pages: 0,
60
+      total: 0,
61
+      page_size: 20,
62
+      sort_field: 'charge_total',
63
+      dataInfo: {},
64
+      default_time: [this.$getDay(-30, false), this.$getDay(0, false)],
65
+      time: [],
66
+      desCol: [],
67
+      height: '',
68
+
69
+      firstDayRoi: ['', ''], // 首日ROI(范围)
70
+      firstOrderCost: ['', ''], // 下单成本(范围)
71
+      firstOrderCostUnique: ['', ''], // 下单成本(去重)(范围)
72
+      perFollowCost: ['', ''], // 企微成本(范围)
73
+      totalRoi: ['', ''], // 回本率(范围)
74
+      reset: false,
75
+    }
76
+  },
77
+  created () {
78
+    this.height = document.documentElement.clientHeight - 200 > 400 ? document.documentElement.clientHeight - 200 : 400
79
+    this.time = this.default_time
80
+    this.init(1)
81
+  },
82
+  methods: {
83
+    handleReset() {
84
+      this.reset = !this.reset
85
+      this.time = this.default_time
86
+      this.firstDayRoi = ['', ''] // 首日ROI(范围)
87
+      this.firstOrderCost = ['', ''] // 下单成本(范围)
88
+      this.firstOrderCostUnique = ['', ''] // 下单成本(去重)(范围)
89
+      this.perFollowCost = ['', ''] // 企微成本(范围)
90
+      this.totalRoi = ['', ''] // 回本率(范围)
91
+      this.init(1)
92
+    },
93
+    changeTime (time) {//筛选时间变化
94
+      if (!time || time && time.length == 0) {
95
+        this.time = []
96
+      } else {
97
+        this.time = time
98
+      }
99
+      this.init(1)
100
+    },
101
+    init (page, type) {
102
+      if (type != 'export') {
103
+        this.page = page ? page : this.page;
104
+      } else {
105
+        if (this.total == 0) {
106
+          this.$message({
107
+            message: '暂无数据可导出',
108
+            type: "warning"
109
+          })
110
+          return
111
+        }
112
+      }
113
+      this.loading = true
114
+      this.$axios.get(`${this.URL.BASEURL}${this.URL.statistics_reg_range_report_new}`, {
115
+        params: {
116
+          begin_date: this.time[0],
117
+          end_date: this.time[1],
118
+          first_day_roi_min: this.firstDayRoi[0],
119
+          first_day_roi_max: this.firstDayRoi[1],
120
+          first_order_cost_min: this.firstOrderCost[0],
121
+          first_order_cost_max: this.firstOrderCost[1],
122
+          first_order_cost_unique_min: this.firstOrderCostUnique[0],
123
+          first_order_cost_unique_max: this.firstOrderCostUnique[1],
124
+          per_follow_cost_min: this.perFollowCost[0],
125
+          per_follow_cost_max: this.perFollowCost[1],
126
+          total_roi_min: this.totalRoi[0],
127
+          total_roi_max: this.totalRoi[1],
128
+          page: type == 'export' ? 1 : this.page,
129
+          page_size: type == 'export' ? this.$store.state.exportNumber : this.page_size,
130
+        }
131
+      }).then((res) => {
132
+        var res = res.data
133
+        this.loading = false
134
+        if (res && res.errno == 0) {
135
+          if (type == 'export') {
136
+            this.exportEvent(res.rst.data.list)
137
+          } else {
138
+            this.desCol = res.rst.data.head;
139
+            this.$nextTick((item) => {
140
+              this.datas = res.rst.data.list // 知道为啥datas不在 data()方法里面定义吗?嘻嘻
141
+              this.$refs.plxTable.reloadData(this.datas)
142
+            })
143
+            this.total = res.rst.pageInfo.total;
144
+            this.pages = res.rst.pageInfo.pages;
145
+          }
146
+        } else if (res.errno != 4002) {
147
+          this.$message({
148
+            message: res.err,
149
+            type: "warning"
150
+          })
151
+        }
152
+      }).catch((err) => {
153
+        this.loading = false
154
+      });
155
+    },
156
+    handleCurrentChange (val) {
157
+      this.init(val)
158
+    },
159
+    sortFieldEvent (type) {
160
+      this.sort_field = type;
161
+      this.init(1)
162
+    },
163
+    exportEvent (data) {
164
+      let list = data;
165
+      let tHeader = this.desCol.map((v) => {
166
+        return v.name;
167
+      })
168
+      let filterVal = this.desCol.map((v) => {
169
+        return v.column
170
+      })
171
+      let excelDatas = [
172
+        {
173
+          tHeader: tHeader, // sheet表一头部
174
+          filterVal: filterVal, // 表一的数据字段
175
+          tableDatas: list, // 表一的整体json数据
176
+          sheetName: ''// 表一的sheet名字
177
+        }
178
+      ]
179
+      this.$exportOrder({ excelDatas, name: `数据循环统计(导出时间:${this.$getDay(0)})` })
180
+    }
181
+  }
182
+}
183
+</script>
184
+<style lang="scss" scoped>
185
+.screenBox {
186
+  position: relative;
187
+  background: #fff;
188
+  padding: 5px 20px;
189
+}
190
+.ml-10 {
191
+  margin-left: 10px;
192
+}
193
+.filter-wrap {
194
+  display: flex;
195
+  align-items: center;
196
+  flex-wrap: wrap;
197
+  padding-bottom: 10px;
198
+  & > div {
199
+    margin: 0 10px 10px 0;
200
+  }
201
+  & > button {
202
+    margin: -10px 0 0 10px;
203
+  }
204
+  .el-button+.el-button {
205
+    margin-left: 5px;
206
+  }
207
+}
208
+</style>