yuhongqi 13 часов назад
Родитель
Сommit
531b5a4a55

+ 29 - 18
src/views/live/liveConfig/liveLotteryConf.vue

@@ -67,17 +67,17 @@
           v-hasPermi="['live:liveLotteryConf:edit']"
           v-hasPermi="['live:liveLotteryConf:edit']"
         >修改</el-button>
         >修改</el-button>
       </el-col>
       </el-col>
-<!--      <el-col :span="1.5">
+      <el-col :span="1.5">
         <el-button
         <el-button
           type="danger"
           type="danger"
           plain
           plain
           icon="el-icon-delete"
           icon="el-icon-delete"
           size="mini"
           size="mini"
-          :disabled="multiple"
+          :disabled="multiple || isViewOnly"
           @click="handleDelete"
           @click="handleDelete"
           v-hasPermi="['live:liveLotteryConf:remove']"
           v-hasPermi="['live:liveLotteryConf:remove']"
         >删除</el-button>
         >删除</el-button>
-      </el-col>-->
+      </el-col>
       <el-col :span="1.5">
       <el-col :span="1.5">
         <el-button
         <el-button
           :disabled="isViewOnly"
           :disabled="isViewOnly"
@@ -833,15 +833,22 @@ export default {
         }
         }
       });
       });
     },
     },
-    /** 删除按钮操作 */
+    /** 删除按钮操作(单条/批量),仅未开始(lotteryStatus=0)可删 */
     handleDelete(row) {
     handleDelete(row) {
-      //如果抽奖状态不为0,则不能删除
-      if(row.lotteryStatus+"" !== "0"){
-        this.msgError("只能删除未开始的抽奖配置");
+      const rows = row && row.lotteryId != null
+        ? [row]
+        : this.liveLotteryConfList.filter(item => this.ids.indexOf(item.lotteryId) > -1);
+      if (!rows.length) {
+        this.msgError("请选择要删除的数据");
         return;
         return;
       }
       }
-      const lotteryIds = row.lotteryId || this.ids;
-      this.$confirm('是否确认删除直播抽奖配置编号为"' + lotteryIds + '"的数据项?', "警告", {
+      const invalid = rows.filter(item => String(item.lotteryStatus) !== "0");
+      if (invalid.length) {
+        this.msgError("只能删除未开始的抽奖配置,请取消选中进行中/已结束/暂停的项");
+        return;
+      }
+      const lotteryIds = rows.map(item => item.lotteryId);
+      this.$confirm('是否确认删除直播抽奖配置编号为"' + lotteryIds.join(",") + '"的数据项?', "警告", {
           confirmButtonText: "确定",
           confirmButtonText: "确定",
           cancelButtonText: "取消",
           cancelButtonText: "取消",
           type: "warning"
           type: "warning"
@@ -850,15 +857,19 @@ export default {
         }).then(() => {
         }).then(() => {
           this.getList();
           this.getList();
           this.msgSuccess("删除成功");
           this.msgSuccess("删除成功");
-          const msg = {
-            cmd: 'lottery',
-            data: {
-              lotteryId: row.lotteryId,
-              lotteryStatus: 2,
-              duration: row.duration
-            }
-          };
-          this.$store.state.liveWs[this.liveId].send(JSON.stringify(msg));
+          if (this.$store.state.liveWs[this.liveId]) {
+            rows.forEach(item => {
+              const msg = {
+                cmd: 'lottery',
+                data: {
+                  lotteryId: item.lotteryId,
+                  lotteryStatus: 2,
+                  duration: item.duration
+                }
+              };
+              this.$store.state.liveWs[this.liveId].send(JSON.stringify(msg));
+            });
+          }
         }).catch(() => {});
         }).catch(() => {});
     },
     },
 
 

+ 66 - 38
src/views/live/liveConfig/liveRedConf.vue

@@ -58,6 +58,17 @@
           v-hasPermi="['live:liveRedConf:edit']"
           v-hasPermi="['live:liveRedConf:edit']"
         >修改</el-button>
         >修改</el-button>
       </el-col>
       </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="danger"
+          plain
+          icon="el-icon-delete"
+          size="mini"
+          :disabled="multiple"
+          @click="handleDelete"
+          v-hasPermi="['live:liveRedConf:remove']"
+        >删除</el-button>
+      </el-col>
       <el-col :span="1.5" v-if="!isPasswordBagMode">
       <el-col :span="1.5" v-if="!isPasswordBagMode">
         <el-button
         <el-button
           type="warning"
           type="warning"
@@ -73,7 +84,7 @@
     </el-row>
     </el-row>
 
 
     <el-table border v-loading="loading" :data="liveRedConfList" @selection-change="handleSelectionChange">
     <el-table border v-loading="loading" :data="liveRedConfList" @selection-change="handleSelectionChange">
-      <el-table-column type="selection" width="55" align="center" v-if="!isPasswordBagMode" />
+      <el-table-column type="selection" width="55" align="center" />
       <el-table-column label="红包ID" align="center" prop="redId" />
       <el-table-column label="红包ID" align="center" prop="redId" />
       <el-table-column label="红包状态" align="center" prop="redStatus" :formatter="redStatusFormatter"/>
       <el-table-column label="红包状态" align="center" prop="redStatus" :formatter="redStatusFormatter"/>
       <el-table-column :label="isPasswordBagMode ? '持续时间(分)' : '有效时间 单位:分'" align="center" prop="duration" />
       <el-table-column :label="isPasswordBagMode ? '持续时间(分)' : '有效时间 单位:分'" align="center" prop="duration" />
@@ -186,7 +197,7 @@
           <el-radio-group v-model="form.distributeType" :disabled="form.redId != null">
           <el-radio-group v-model="form.distributeType" :disabled="form.redId != null">
             <el-radio :label="1">普通均分</el-radio>
             <el-radio :label="1">普通均分</el-radio>
             <el-radio :label="2">拼手气</el-radio>
             <el-radio :label="2">拼手气</el-radio>
-            <el-radio :label="3">口令福袋</el-radio>
+<!--            <el-radio :label="3">口令福袋</el-radio>-->
           </el-radio-group>
           </el-radio-group>
         </el-form-item>
         </el-form-item>
         <el-form-item label="口令" prop="passwordCmd" v-if="showPasswordFields">
         <el-form-item label="口令" prop="passwordCmd" v-if="showPasswordFields">
@@ -324,6 +335,7 @@ export default {
         liveId: null,
         liveId: null,
         desc: null,
         desc: null,
         distributeType: null,
         distributeType: null,
+        excludeDistributeType: null,
         createTime: null,
         createTime: null,
         updateTime: null,
         updateTime: null,
       },
       },
@@ -378,9 +390,7 @@ export default {
         }
         }
         this.queryParams.liveId = this.liveId;
         this.queryParams.liveId = this.liveId;
         this.parentLiveId = this.liveId;
         this.parentLiveId = this.liveId;
-        if (this.isPasswordBagMode) {
-          this.queryParams.distributeType = 3
-        }
+        this.applyDistributeQueryFilter()
         if(this.queryParams.liveId){
         if(this.queryParams.liveId){
           this.form.liveId = this.parentLiveId;
           this.form.liveId = this.parentLiveId;
           //设置查询条件直播间ID不可修改
           //设置查询条件直播间ID不可修改
@@ -396,9 +406,7 @@ export default {
     }
     }
   },
   },
   created() {
   created() {
-    if (this.isPasswordBagMode) {
-      this.queryParams.distributeType = 3
-    }
+    this.applyDistributeQueryFilter()
     this.getDicts("sys_live_red_status").then(response => {
     this.getDicts("sys_live_red_status").then(response => {
       this.redStatusOptions = response.data;
       this.redStatusOptions = response.data;
     });
     });
@@ -457,11 +465,15 @@ export default {
       };
       };
       updateLiveRedConf(doRedParam).then(response => {
       updateLiveRedConf(doRedParam).then(response => {
         if(response.code === 200){
         if(response.code === 200){
-          const msg = {
-            cmd: 'red',
-            data: doRedParam
-          };
-          this.$store.state.liveWs[this.liveId].send(JSON.stringify(msg));
+          // 口令福袋:服务端会推 passwordBag / passwordBagEnd,前端不再发 red
+          const isPasswordBag = this.isPasswordBagMode || String(row.distributeType) === '3'
+          if (!isPasswordBag && this.$store.state.liveWs[this.liveId]) {
+            const msg = {
+              cmd: 'red',
+              data: doRedParam
+            };
+            this.$store.state.liveWs[this.liveId].send(JSON.stringify(msg));
+          }
 
 
           this.msgSuccess("修改成功");
           this.msgSuccess("修改成功");
         }else{
         }else{
@@ -480,12 +492,20 @@ export default {
     distributeTypeFormatter(row) {
     distributeTypeFormatter(row) {
       return this.distributeTypeMap[row.distributeType] || this.distributeTypeMap[1]
       return this.distributeTypeMap[row.distributeType] || this.distributeTypeMap[1]
     },
     },
-    /** 查询直播红包记录配置列表 */
-    getList() {
-      this.loading = true;
+    /** 口令福袋页只查 type=3;红包配置页排除口令福袋 */
+    applyDistributeQueryFilter() {
       if (this.isPasswordBagMode) {
       if (this.isPasswordBagMode) {
         this.queryParams.distributeType = 3
         this.queryParams.distributeType = 3
+        this.queryParams.excludeDistributeType = null
+      } else {
+        this.queryParams.distributeType = null
+        this.queryParams.excludeDistributeType = 3
       }
       }
+    },
+    /** 查询直播红包记录配置列表 */
+    getList() {
+      this.loading = true;
+      this.applyDistributeQueryFilter()
       listLiveRedConf(this.queryParams).then(response => {
       listLiveRedConf(this.queryParams).then(response => {
         this.liveRedConfList = response.rows;
         this.liveRedConfList = response.rows;
         this.total = response.total;
         this.total = response.total;
@@ -535,9 +555,7 @@ export default {
     resetQuery() {
     resetQuery() {
       this.resetForm("queryForm");
       this.resetForm("queryForm");
       this.checkParentLiveId();
       this.checkParentLiveId();
-      if (this.isPasswordBagMode) {
-        this.queryParams.distributeType = 3
-      }
+      this.applyDistributeQueryFilter()
       this.handleQuery();
       this.handleQuery();
     },
     },
     // 多选框选中数据
     // 多选框选中数据
@@ -598,15 +616,22 @@ export default {
         }
         }
       });
       });
     },
     },
-    /** 删除按钮操作 */
+    /** 删除按钮操作(单条/批量),仅未发放(redStatus=0)可删 */
     handleDelete(row) {
     handleDelete(row) {
-      // 口令福袋允许按状态删除;普通红包仅未发放可删
-      if (!this.isPasswordBagMode && row.redStatus+"" !== "0") {
-        this.msgError("只能删除未发放的红包");
+      const rows = row && row.redId != null
+        ? [row]
+        : this.liveRedConfList.filter(item => this.ids.indexOf(item.redId) > -1);
+      if (!rows.length) {
+        this.msgError("请选择要删除的数据");
         return;
         return;
       }
       }
-      const redIds = row.redId || this.ids;
-      this.$confirm('是否确认删除直播红包记录配置编号为"' + redIds + '"的数据项?', "警告", {
+      const invalid = rows.filter(item => String(item.redStatus) !== "0");
+      if (invalid.length) {
+        this.msgError("只能删除未发放的红包,请取消选中进行中/已结束/暂停的项");
+        return;
+      }
+      const redIds = rows.map(item => item.redId);
+      this.$confirm('是否确认删除直播红包记录配置编号为"' + redIds.join(",") + '"的数据项?', "警告", {
           confirmButtonText: "确定",
           confirmButtonText: "确定",
           cancelButtonText: "取消",
           cancelButtonText: "取消",
           type: "warning"
           type: "warning"
@@ -615,19 +640,22 @@ export default {
         }).then(() => {
         }).then(() => {
           this.getList();
           this.getList();
           this.msgSuccess("删除成功");
           this.msgSuccess("删除成功");
-          if (this.$store.state.liveWs[this.liveId]) {
-            const msg = {
-              cmd: 'red',
-              data: {
-                redId: row.redId,
-                redStatus: 2,
-                totalLots: row.totalLots,
-                duration: row.duration,
-                distributeType: row.distributeType,
-                passwordCmd: row.passwordCmd
-              }
-            };
-            this.$store.state.liveWs[this.liveId].send(JSON.stringify(msg));
+          // 口令福袋不发 red;普通红包通知前端收起
+          if (!this.isPasswordBagMode && this.$store.state.liveWs[this.liveId]) {
+            rows.forEach(item => {
+              const msg = {
+                cmd: 'red',
+                data: {
+                  redId: item.redId,
+                  redStatus: 2,
+                  totalLots: item.totalLots,
+                  duration: item.duration,
+                  distributeType: item.distributeType,
+                  passwordCmd: item.passwordCmd
+                }
+              };
+              this.$store.state.liveWs[this.liveId].send(JSON.stringify(msg));
+            });
           }
           }
         }).catch(() => {});
         }).catch(() => {});
     },
     },

+ 35 - 3
src/views/live/liveConfig/vote.vue

@@ -10,10 +10,21 @@
           @click="handleAdd"
           @click="handleAdd"
         >新增</el-button>
         >新增</el-button>
       </el-col>
       </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="danger"
+          plain
+          icon="el-icon-delete"
+          size="mini"
+          :disabled="multiple"
+          @click="handleDelete"
+        >删除</el-button>
+      </el-col>
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
     </el-row>
 
 
-    <el-table border v-loading="loading" :data="voteList">
+    <el-table border v-loading="loading" :data="voteList" @selection-change="handleSelectionChange">
+      <el-table-column type="selection" width="55" align="center" />
       <el-table-column label="描述" align="center" prop="description" :show-overflow-tooltip="true" min-width="120" />
       <el-table-column label="描述" align="center" prop="description" :show-overflow-tooltip="true" min-width="120" />
       <el-table-column label="选项A" align="center" prop="optionA" min-width="100" />
       <el-table-column label="选项A" align="center" prop="optionA" min-width="100" />
       <el-table-column label="选项B" align="center" prop="optionB" min-width="100" />
       <el-table-column label="选项B" align="center" prop="optionB" min-width="100" />
@@ -60,6 +71,7 @@
             @click="handleEnd(scope.row)"
             @click="handleEnd(scope.row)"
           >结束</el-button>
           >结束</el-button>
           <el-button
           <el-button
+            v-if="String(scope.row.status) === '0'"
             size="mini"
             size="mini"
             type="text"
             type="text"
             icon="el-icon-delete"
             icon="el-icon-delete"
@@ -128,6 +140,8 @@ export default {
       title: '',
       title: '',
       open: false,
       open: false,
       liveId: null,
       liveId: null,
+      ids: [],
+      multiple: true,
       statusMap: {
       statusMap: {
         0: '未开始',
         0: '未开始',
         1: '进行中',
         1: '进行中',
@@ -248,13 +262,31 @@ export default {
         this.getList()
         this.getList()
       }).catch(() => {})
       }).catch(() => {})
     },
     },
+    handleSelectionChange(selection) {
+      this.ids = selection.map(item => item.id)
+      this.multiple = !selection.length
+    },
+    /** 删除(单条/批量),仅未开始可删 */
     handleDelete(row) {
     handleDelete(row) {
-      this.$confirm('是否确认删除该投票?', '警告', {
+      const rows = row && row.id != null
+        ? [row]
+        : this.voteList.filter(item => this.ids.indexOf(item.id) > -1)
+      if (!rows.length) {
+        this.msgError('请选择要删除的数据')
+        return
+      }
+      const invalid = rows.filter(item => String(item.status) !== '0')
+      if (invalid.length) {
+        this.msgError('只能删除未开始的投票,请取消选中进行中/已结束的项')
+        return
+      }
+      const ids = rows.map(item => item.id)
+      this.$confirm('是否确认删除投票编号为"' + ids.join(',') + '"的数据项?', '警告', {
         confirmButtonText: '确定',
         confirmButtonText: '确定',
         cancelButtonText: '取消',
         cancelButtonText: '取消',
         type: 'warning'
         type: 'warning'
       }).then(() => {
       }).then(() => {
-        return delVote(row.id)
+        return delVote(ids)
       }).then(() => {
       }).then(() => {
         this.getList()
         this.getList()
         this.msgSuccess('删除成功')
         this.msgSuccess('删除成功')