cloudroam
2024-10-28 491df5ea13a34c46cab555469fc310fa985c20e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
<template>
  <div class="home-page">
    <div class="top-container">
      <div class="top-container__item">
        <div class="top-container__label">今日销售额</div>
        <div class="top-container__value">{{ statistic.saleAmount || 0 }}</div>
      </div>
      <div class="top-container__item">
        <div class="top-container__label">今日销售扎数</div>
        <div class="top-container__value">
          {{ statistic.saleFlowerCount || 0 }}
        </div>
      </div>
      <div
        class="top-container__item cursor-pointer"
        @click="toRoute('/goods/list')"
      >
        <div class="top-container__label">商品管理</div>
        <div class="top-container__value">{{ statistic.flowerCount || 0 }}</div>
      </div>
      <div
        class="top-container__item cursor-pointer"
        @click="toRoute('/shop/list')"
      >
        <div class="top-container__label">用户管理</div>
        <div class="top-container__value">
          {{ statistic.customerCount || 0 }}
        </div>
      </div>
      <div
        class="top-container__item cursor-pointer"
        @click="toRoute('/order/list')"
      >
        <div class="top-container__label">订单管理</div>
        <div class="top-container__value">
          {{ statistic.orderCount || 0 }}
        </div>
      </div>
    </div>
    <el-row :gutter="22" class="mt-22">
      <el-col :span="6">
        <div
          class="statistic-container cursor-pointer"
          @click="toRoute('/order/list?statusBackend=SEND')"
        >
          <div class="statistic-title">待发货</div>
          <div class="statistic-num">{{ statistic.orderSendCount || 0 }}</div>
        </div>
      </el-col>
      <el-col :span="6">
        <div
          class="statistic-container cursor-pointer"
          @click="toRoute('/goods/list?status=UP')"
        >
          <div class="statistic-title">在售商品</div>
          <div class="statistic-num">{{ statistic.flowerUpCount || 0 }}</div>
        </div>
      </el-col>
      <el-col :span="6">
        <div
          class="statistic-container cursor-pointer"
          @click="toRoute('/goods/list?status=PENDING')"
        >
          <div class="statistic-title">待审核商品</div>
          <div class="statistic-num">
            {{ statistic.flowerPendingCount || 0 }}
          </div>
        </div>
      </el-col>
      <el-col :span="6">
        <div
          class="statistic-container cursor-pointer"
          @click="toRoute('/order/after-sale?status=PENDING')"
        >
          <div class="statistic-title">待售后处理</div>
          <div class="statistic-num">{{ statistic.orderSalesCount || 0 }}</div>
        </div>
      </el-col>
      <el-col :span="6">
        <div class="statistic-container">
          <div class="statistic-title">总销售金额</div>
          <div class="statistic-num">{{ statistic.totalSaleAmount || 0 }}</div>
        </div>
      </el-col>
      <el-col :span="6">
        <div class="statistic-container">
          <div class="statistic-title">总销售扎数</div>
          <div class="statistic-num">
            {{ statistic.totalSaleFlowerCount || 0 }}
          </div>
        </div>
      </el-col>
      <el-col :span="6">
        <div class="statistic-container">
          <div class="statistic-title">供应商待提现</div>
          <div class="statistic-num">
            {{ statistic.supplierPendingAmount || 0 }}
          </div>
        </div>
      </el-col>
      <el-col :span="6">
        <div class="statistic-container">
          <div class="statistic-title">供应商已提现</div>
          <div class="statistic-num">
            {{ statistic.supplierCompleteAmount || 0 }}
          </div>
        </div>
      </el-col>
    </el-row>
    <el-row :gutter="22">
      <el-col :span="8">
        <div class="rate-container">
          <div class="flex items-center justify-between mb-16">
            <div class="text-20 text-mainTitle font-bold">
              订单量:<span class="text-primary">{{
                orderStatistic.count || 0
              }}</span>
            </div>
            <el-tag type="primary">今日</el-tag>
          </div>
          <div class="text-14 text-subTitle leading-22">
            新增订单量:{{ orderStatistic.countToday || 0 }}
          </div>
          <div class="text-14 text-subTitle leading-22">
            日环比:<span :class="getRateClass(orderStatistic.countRate)"
              >{{ orderStatistic.countRate || 0 }}%</span
            >
          </div>
        </div>
      </el-col>
      <el-col :span="8">
        <div class="rate-container">
          <div class="flex items-center justify-between mb-16">
            <div class="text-20 text-mainTitle font-bold">
              供应商数量:<span class="text-primary">{{
                supplierStatistic.count || 0
              }}</span>
            </div>
            <el-tag type="primary">今日</el-tag>
          </div>
          <div class="text-14 text-subTitle leading-22">
            新增供应商:{{ supplierStatistic.countToday || 0 }}
          </div>
          <div class="text-14 text-subTitle leading-22">
            日环比:<span :class="getRateClass(supplierStatistic.countRate)"
              >{{ supplierStatistic.countRate || 0 }}%</span
            >
          </div>
        </div>
      </el-col>
      <el-col :span="8">
        <div class="rate-container">
          <div class="flex items-center justify-between mb-16">
            <div class="text-20 text-mainTitle font-bold">
              全部用户量:<span class="text-primary">{{
                userStatistic.count || 0
              }}</span>
            </div>
            <el-tag type="primary">今日</el-tag>
          </div>
          <div class="text-14 text-subTitle leading-22">
            新增用户量:{{ userStatistic.countToday || 0 }}
          </div>
          <div class="text-14 text-subTitle leading-22">
            日环比:<span :class="getRateClass(userStatistic.countRate)"
              >{{ userStatistic.countRate || 0 }}%</span
            >
          </div>
        </div>
      </el-col>
      <el-col :span="8">
        <div class="rate-container">
          <div class="flex items-center justify-between mb-16">
            <div class="text-20 text-mainTitle font-bold">
              用户访问量:<span class="text-primary">{{
                visitStatistic.count || 0
              }}</span>
            </div>
            <el-tag type="primary">今日</el-tag>
          </div>
          <div class="text-14 text-subTitle leading-22">
            昨日访问量:{{ visitStatistic.countToday || 0 }}
          </div>
          <div class="text-14 text-subTitle leading-22">
            日环比:<span :class="getRateClass(visitStatistic.countRate)"
              >{{ visitStatistic.countRate || 0 }}%</span
            >
          </div>
        </div>
      </el-col>
      <el-col :span="8">
        <div class="rate-container">
          <div class="flex items-center justify-between mb-16">
            <div class="text-20 text-mainTitle font-bold">
              售后订单数量:<span class="text-primary">{{
                saleStatistic.count || 0
              }}</span>
            </div>
            <el-tag type="primary">今日</el-tag>
          </div>
          <div class="text-14 text-subTitle leading-22">
            新增售后量:{{ saleStatistic.countToday || 0 }}
          </div>
          <div class="text-14 text-subTitle leading-22">
            日环比:<span :class="getRateClass(saleStatistic.countRate)"
              >{{ saleStatistic.countRate || 0 }}%</span
            >
          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>
 
<script>
export default {
  data() {
    return {
      currentDate: this.$elBusUtil.toDate(),
      statistic: {},
      orderStatistic: {},
      supplierStatistic: {},
      userStatistic: {},
      visitStatistic: {},
      saleStatistic: {},
    }
  },
  head() {
    return {
      title: '首页',
    }
  },
  mounted() {
    this.init()
  },
  methods: {
    async init() {
      const [
        res1,
        res2,
        res3,
        orderRes,
        supplierRes,
        userRes,
        visitRes,
        saleRes,
      ] = await Promise.all([
        this.$elBusHttp.request('flower/api/statistics/sale/date', {
          params: { date: this.currentDate },
        }),
        this.$elBusHttp.request('flower/api/statistics/flower/count'),
        this.$elBusHttp.request('flower/api/statistics/order/amount'),
        this.$elBusHttp.request('flower/api/statistics/order/rate', {
          params: { date: this.currentDate },
        }),
        this.$elBusHttp.request('flower/api/statistics/supplier/rate', {
          params: { date: this.currentDate },
        }),
        this.$elBusHttp.request('flower/api/statistics/customer/rate', {
          params: { date: this.currentDate },
        }),
        this.$elBusHttp.request('flower/api/statistics/customer/visit/rate', {
          params: { date: this.currentDate },
        }),
        this.$elBusHttp.request('flower/api/statistics/sales/rate', {
          params: { date: this.currentDate },
        }),
      ])
      this.statistic = { ...res1?.data, ...res2?.data, ...res3?.data }
      this.orderStatistic = orderRes?.data || {}
      this.supplierStatistic = supplierRes?.data || {}
      this.userStatistic = userRes?.data || {}
      this.visitStatistic = visitRes?.data || {}
      this.saleStatistic = saleRes?.data || {}
    },
    getRateClass(rate) {
      if (rate > 0) {
        return 'text-success'
      } else if (rate === 0) {
        return ''
      } else {
        return 'text-danger'
      }
    },
    toRoute(url) {
      this.$router.push(url)
    },
  },
}
</script>
 
<style lang="scss" scoped>
@import '@/assets/statistic/index.scss';
.home-page {
  .top-container {
    width: 100%;
    display: flex;
    background-color: #fff;
    border-radius: 4px;
    box-shadow: 0px 2px 12px 0px rgba(75, 76, 77, 0.1);
    padding: 30px;
    &__item {
      background-color: #f4faff;
      border-radius: 2px;
      text-align: center;
      flex: 1;
      height: 110px;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      &:not(:last-child) {
        margin-right: 22px;
      }
    }
    &__label {
      font-size: 20px;
      color: $main-title-color;
      font-weight: bold;
      margin-bottom: 6px;
    }
    &__value {
      font-size: 16px;
      color: $primary-color;
    }
  }
  .statistic-container {
    background-color: #fff;
    box-shadow: 0px 2px 12px 0px rgba(75, 76, 77, 0.1);
    border-radius: 4px;
    height: 110px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 22px;
  }
  .rate-container {
    width: 100%;
    background-color: #fff;
    box-shadow: 0px 2px 12px 0px rgba(75, 76, 77, 0.1);
    padding: 20px;
    margin-bottom: 22px;
  }
}
</style>