Ver código fonte

修改直播配置

yuhongqi 1 dia atrás
pai
commit
f889de0d4b

+ 1 - 1
src/views/live/liveConfig/liveRedConf.vue

@@ -106,7 +106,7 @@
       <el-table-column label="直播间ID" align="center" prop="liveId" />
       <el-table-column label="芳华币数量" align="center" prop="redNum" />
       <el-table-column label="可中奖份量" align="center" prop="totalLots" />
-      <el-table-column label="实际发放奖励份量" align="center" prop="totalSend" />
+      <el-table-column label="实际领取人数" align="center" prop="totalSend" />
       <el-table-column label="红包标题" align="center" prop="desc" />
       <el-table-column label="创建日期" align="center" prop="createTime" width="120">
         <template slot-scope="scope">

+ 26 - 20
src/views/live/liveConfig/watchReward.vue

@@ -19,7 +19,7 @@
     </div>
 
     <!-- 观看奖励设置 -->
-    <div v-if="watchRewardForm.enabled" class="section-block">
+    <div v-show="watchRewardForm.enabled" class="section-block">
       <div class="section-title">观看奖励设置</div>
 
       <!-- 表单内容 -->
@@ -235,12 +235,13 @@
           </template>
         </div>
 
-        <!-- 保存按钮 -->
-        <div class="form-actions">
-          <el-button type="primary" @click="saveWatchReward" v-show="!isViewOnly">保存</el-button>
-        </div>
       </el-form>
     </div>
+
+    <!-- 关闭奖励时也要能保存,按钮放在开关外 -->
+    <div class="form-actions" v-show="!isViewOnly">
+      <el-button type="primary" @click="saveWatchReward">保存</el-button>
+    </div>
   </div>
     </div>
 </div>
@@ -462,6 +463,7 @@ export default {
         bigGiftRewardId: null
       };
       const merged = Object.assign({}, defaults, data || {});
+      merged.enabled = merged.enabled === true || merged.enabled === 'true' || merged.enabled === 1 || merged.enabled === '1';
       merged.participateCondition = merged.participateCondition != null ? String(merged.participateCondition) : '1';
       merged.action = merged.action != null ? String(merged.action) : '2';
       merged.watchDuration = merged.watchDuration != null ? String(merged.watchDuration) : '';
@@ -502,25 +504,29 @@ export default {
         this.loading = false
       })
     },
+    persistWatchReward() {
+      const payload = this.buildSavePayload();
+      const req = this.watchRewardForm.id == null
+        ? addConfig(payload, this.liveId)
+        : updateConfig(payload, this.liveId);
+      req.then(res => {
+        if (res.code == 200) {
+          this.msgSuccess(this.watchRewardForm.enabled ? "修改成功" : "已关闭观看奖励");
+          this.getLiveConfig();
+        }
+      });
+    },
     saveWatchReward() {
+      // 关闭奖励时不校验表单,直接保存 enabled=false
+      if (!this.watchRewardForm.enabled) {
+        this.persistWatchReward();
+        return;
+      }
       this.$refs["watchRewardForm"].validate(valid => {
         if (valid) {
-          const payload = this.buildSavePayload();
-          if (this.watchRewardForm.id == null) {
-            addConfig(payload, this.liveId).then(res => {
-              if (res.code == 200) {
-                this.msgSuccess("修改成功");
-                this.getLiveConfig();
-              }
-            })
-          } else {
-            updateConfig(payload, this.liveId).then(response => {
-              this.msgSuccess("修改成功");
-              this.getLiveConfig();
-            });
-          }
+          this.persistWatchReward();
         }
-      })
+      });
     },
   }
 };

+ 22 - 4
src/views/live/liveConsole/index.vue

@@ -897,12 +897,12 @@ export default {
       }
 
       this.scrLoading[tabName].next = true;
+      // 与 liveUserTotals 口径一致:在线/离线仅非禁言;禁言不限在线状态
       const queryParams = {
         liveId: this.liveId,
         pageNum: params.currentPage,
         pageSize: 20,
-        online: tabName === 'online' ? 0 : 1,
-        msgStatus: tabName === 'silenced' ? 1 : 0
+        ...this.buildWatchUserQuery(tabName)
       };
       // 调用接口加载对应状态的分页数据(需后端支持按状态筛选)
       watchUserList(queryParams).then(response => {
@@ -911,6 +911,14 @@ export default {
 
         const { rows, total } = response;
         params.total = total; // 记录总数据量
+        // Tab 角标与列表接口 total 保持一致
+        if (tabName === 'online') {
+          this.userTotal.online = total || 0;
+        } else if (tabName === 'offline') {
+          this.userTotal.offline = total || 0;
+        } else if (tabName === 'silenced') {
+          this.userTotal.silenced = total || 0;
+        }
         // 过滤重复数据(基于userId)
         const newRows = rows.filter(row =>
           !displayList.some(u => u.userId === row.userId)
@@ -953,8 +961,7 @@ export default {
         liveId: this.liveId,
         pageNum: targetPage,
         pageSize: 20,
-        online: tabName === 'online' ? 0 : 1,
-        msgStatus: tabName === 'silenced' ? 1 : 0
+        ...this.buildWatchUserQuery(tabName)
       };
       watchUserList(queryParams).then(response => {
         this.scrLoading[tabName].prev = false;
@@ -997,6 +1004,17 @@ export default {
         this.scrLoading[tabName].prev = false;
       });
     },
+    // 与 liveUserTotals 统计口径一致的筛选条件
+    buildWatchUserQuery(tabName) {
+      if (tabName === 'silenced') {
+        return { msgStatus: 1 };
+      }
+      if (tabName === 'online') {
+        return { online: 0, msgStatus: 0 };
+      }
+      // offline
+      return { online: 1, msgStatus: 0 };
+    },
     // 辅助:获取Tab对应的滚动容器
     getScrollElement(tabName) {
       const scrollRefs = {