Преглед изворни кода

直播优惠券添加 积分管理

yuhongqi пре 1 недеља
родитељ
комит
ee5cee1d0f

+ 19 - 0
src/api/live/liveRewardRecord.js

@@ -0,0 +1,19 @@
+import request from '@/utils/request'
+
+
+export function statistics(data) {
+  return request({
+    url: '/live/record/statistics',
+    method: 'post',
+    data: data
+  })
+}
+
+export function exportLiveIntegral(data) {
+  return request({
+    url: '/live/record/export',
+    method: 'post',
+    data: data
+  })
+}
+

+ 2 - 0
src/views/live/liveConfig/goods.vue

@@ -1,4 +1,5 @@
 <template>
+  <div class="app-container">
   <div class="el-container-md">
 
     <div class="selection-toolbar">
@@ -246,6 +247,7 @@
       </div>
     </el-dialog>
   </div>
+  </div>
 </template>
 
 <script>

+ 3 - 0
src/views/live/liveConfig/liveCoupon.vue

@@ -1,4 +1,5 @@
 <template>
+  <div class="app-container">
   <div class="el-container-md">
 
     <div class="selection-toolbar">
@@ -185,6 +186,7 @@
           <el-select
             v-model="goodsForm.goodsId"
             placeholder="请选择商品"
+            filterable
             style="width: 100%;"
             @change="handleGoodsChange"
           >
@@ -203,6 +205,7 @@
       </div>
     </el-dialog>
   </div>
+  </div>
 </template>
 
 <script>

+ 13 - 0
src/views/live/liveConsole/index.vue

@@ -148,6 +148,10 @@
           <i class="el-icon-goods" style="font-size: 20px;"></i>
           <span style="font-size: 12px; margin-top: 4px;">直播订单</span>
         </div>
+        <div style="display: flex; flex-direction: column; align-items: center; cursor: pointer;" @click="handleClickCoupon">
+          <i class="el-icon-goods" style="font-size: 20px;"></i>
+          <span style="font-size: 12px; margin-top: 4px;">直播优惠券</span>
+        </div>
       </div>
       <el-radio-group v-model="tableRadio" >
         <el-radio-button label="订单数">订单数</el-radio-button>
@@ -265,6 +269,7 @@ import LiveLotteryConf from '@/views/live/liveConfig/liveLotteryConf.vue'
 import LiveRedConf from '@/views/live/liveConfig/liveRedConf.vue'
 import LiveGoods from '@/views/live/liveConfig/goods.vue'
 import LiveOrder from '@/views/live/liveOrder/index.vue'
+import LiveCoupon from '@/views/live/liveConfig/liveCoupon.vue'
 import echarts from 'echarts'
 
 
@@ -402,6 +407,14 @@ export default {
     })
   },
   methods: {
+    handleClickCoupon(){
+      this.$router.push({
+        name: 'LiveCoupon',
+        query: {
+          liveId: this.liveId
+        }
+      })
+    },
     // 保存聊天滚动位置
     saveChatScrollPosition() {
       if (this.$refs.manageRightRef && this.$refs.manageRightRef.wrap) {

+ 151 - 0
src/views/live/liveRewardRecord/index.vue

@@ -0,0 +1,151 @@
+<template>
+  <div class="app-container">
+    <div class="reward-container">
+      <!-- 时间步长选择 -->
+      <span class="demonstration">月份选择(可多选)</span>
+      <el-date-picker
+        type="months"
+        v-model="selectedTimeStep"
+        @change="handleTimeStepChange"
+        placeholder="选择一个或多个日期">
+      </el-date-picker>
+
+      <el-button
+        type="warning"
+        plain
+        icon="el-icon-download"
+        size="mini"
+        :loading="exportLoading"
+        @click="handleExport"
+        style="margin-left: 10px"
+        v-hasPermi="['live:liveRewardRecord:export']"
+      >导出</el-button>
+
+
+
+    </div>
+
+    <!-- 直播间数据表格 + 总消耗 -->
+    <div style="margin-top: 24px;">
+      <h3 style="font-size: 16px; font-weight: 600; margin-bottom: 12px;">直播间积分消耗明细</h3>
+      <el-table
+        :data="tableData"
+        border
+        show-summary
+        stripe
+        style="width: 100%; margin-bottom: 12px;"
+      >
+        <el-table-column label="直播名称" prop="liveNameAndId" width="100" align="center" />
+        <el-table-column
+          v-for="(date, index) in timeSeries"
+          :key="index"
+          :label="date"
+          align="center"
+        >
+          <template #default="scope">
+            {{ scope.row.dailyData[index] || '-' }}
+          </template>
+        </el-table-column>
+        <el-table-column label="单直播间总计" prop="total" width="120" align="center" />
+      </el-table>
+    </div>
+  </div>
+</template>
+
+<script>
+import { statistics,exportLiveIntegral } from '@/api/live/liveRewardRecord'
+
+export default {
+  name: 'liveRewardRecord',
+  data() {
+    return {
+      exportLoading: false,
+      selectedTimeStep: [],
+      tableData: [],
+      chartSeries: [],
+      timeSeries: [],
+      colorList: [
+        '#34a853', '#fbbc05', '#4285f4', '#ea4335', '#9c27b0',
+        '#ff9800', '#673ab7', '#e91e63', '#00bcd4', '#8bc34a'
+      ]
+    }
+  },
+  computed: {
+  },
+  mounted() {
+    this.selectedTimeStep.push(new Date())
+    this.initData()
+  },
+  methods: {
+    handleExport(){
+      if(this.selectedTimeStep == null || this.selectedTimeStep.length < 1) {
+        this.$message.error('请选择导出月份')
+        return
+      }
+      var date = []
+      if (this.selectedTimeStep == null || this.selectedTimeStep.length === 0) {
+        date.push(new Date());
+      } else {
+        date = this.selectedTimeStep
+      }
+      this.$confirm('是否确认导出所有直播积分记录?', "警告", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(() => {
+        this.exportLoading = true;
+        return exportLiveIntegral({ 'step': date, companyId:0});
+      }).then(response => {
+        this.download(response.msg);
+        this.exportLoading = false;
+      }).catch(() => {});
+    },
+    initData() {
+      var date = []
+      if (this.selectedTimeStep == null || this.selectedTimeStep.length === 0) {
+        date.push(new Date());
+      } else {
+        date = this.selectedTimeStep
+      }
+      statistics({ 'step': date, companyId:0}).then(res => {
+        this.timeSeries = res.timeSeries || []
+        this.tableData = res.data || []
+
+
+        this.processTableData()
+      }).catch(err => {
+        console.error('数据加载失败:', err)
+        this.$message.error('数据加载失败,请重试')
+      })
+    },
+    processTableData() {
+      const liveList = this.tableData
+      this.tableData = liveList.map(liveItem => {
+        const dailyData = liveItem.dataList || []
+        const total = dailyData.reduce((sum, num) => sum + (num || 0), 0)
+        return { liveNameAndId: liveItem.liveNameAndId, dailyData, total }
+      })
+    },
+    handleTimeStepChange() {
+      console.log(this.selectedTimeStep)
+      this.initData()
+    },
+  }
+}
+</script>
+
+<style>
+/* 基础布局样式 */
+.reward-container {
+  padding: 20px;
+  background-color: #fff;
+}
+.charts-container {
+  display: flex;
+  gap: 24px;
+  margin-bottom: 24px;
+}
+.chart-wrapper {
+  flex: 1;
+}
+</style>