Browse Source

调整营期单独注册功能

yfh 2 ngày trước cách đây
mục cha
commit
d87db4853d
1 tập tin đã thay đổi với 49 bổ sung56 xóa
  1. 49 56
      src/views/course/userCoursePeriod/index.vue

+ 49 - 56
src/views/course/userCoursePeriod/index.vue

@@ -33,40 +33,6 @@
     </el-form>
 
     <el-row :gutter="10" class="mb8">
-<!--      <el-col :span="1.5">-->
-<!--        <el-button-->
-<!--          type="primary"-->
-<!--          plain-->
-<!--          icon="el-icon-plus"-->
-<!--          size="mini"-->
-<!--          @click="handleAdd"-->
-<!--          v-hasPermi="['course:period:add']"-->
-<!--        >新增-->
-<!--        </el-button>-->
-<!--      </el-col>-->
-<!--      <el-col :span="1.5">-->
-<!--        <el-button-->
-<!--          type="warning"-->
-<!--          plain-->
-<!--          icon="el-icon-download"-->
-<!--          size="mini"-->
-<!--          @click="handleExport"-->
-<!--          v-hasPermi="['course:period:export']"-->
-<!--        >导出-->
-<!--        </el-button>-->
-<!--      </el-col>-->
-<!--      <el-col :span="1.5">-->
-<!--        <el-button-->
-<!--          type="primary"-->
-<!--          plain-->
-<!--          icon="el-icon-edit"-->
-<!--          size="mini"-->
-<!--          @click="handleBatchSetRedPacket"-->
-<!--          v-hasPermi="['course:period:export']"-->
-<!--          :disabled="batchSetRedPacketDisabled"-->
-<!--        >批量设置红包-->
-<!--        </el-button>-->
-<!--      </el-col>-->
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
@@ -95,6 +61,31 @@
             @click="handlePeriodSettings(scope.row)"
           >营期相关设置
           </el-button>
+          <!-- 根据 isNeedRegisterMember 动态显示按钮 -->
+          <el-button
+            v-if="scope.row.isNeedRegisterMember === 0"
+            size="mini"
+            type="text"
+            icon="el-icon-open"
+            @click="handlePeriodUser(scope.row, 1)"
+          >开启单独注册会员
+          </el-button>
+          <el-button
+            v-else-if="scope.row.isNeedRegisterMember === 1"
+            size="mini"
+            type="text"
+            icon="el-icon-turn-off"
+            @click="handlePeriodUser(scope.row, 0)"
+          >关闭单独注册会员
+          </el-button>
+          <el-button
+            v-else
+            size="mini"
+            type="text"
+            icon="el-icon-open"
+            @click="handlePeriodUser(scope.row, 1)"
+          >开启单独注册会员
+          </el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -248,13 +239,6 @@
       </div>
     </el-dialog>
 
-    <!--    <red-packet-->
-    <!--      :visible.sync="redPacketVisible"-->
-    <!--      :periodId="currentRedPacketData.periodId"-->
-    <!--      :videoId="currentRedPacketData.videoId"-->
-    <!--      @success="handleRedPacketSuccess"-->
-    <!--    />-->
-
     <!-- 营期相关设置抽屉 -->
     <el-drawer
       title="营期相关设置"
@@ -455,7 +439,6 @@ export default {
     };
   },
   created() {
-
     courseList().then(response => {
       this.courseList = response.list;
     });
@@ -569,6 +552,30 @@ export default {
         this.isDisabledDateRange = true;
       });
     },
+    /** 处理单独注册会员开关 */
+    handlePeriodUser(data, open) {
+      const actionText = open === 1 ? '开启' : '关闭';
+      this.$confirm(`确定要${actionText}【${data.periodName}】的单独注册会员功能吗?`, '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        data.isNeedRegisterMember = open;
+        updatePeriod(data).then(response => {
+          if (response.code === 200) {
+            this.msgSuccess(`${actionText}成功`);
+            this.getList();
+          } else {
+            this.msgError(response.msg || `${actionText}失败`);
+          }
+        }).catch(error => {
+          console.error(`${actionText}单独注册会员失败:`, error);
+          this.msgError(`${actionText}失败`);
+        });
+      }).catch(() => {
+        this.$message.info('已取消操作');
+      });
+    },
     /** 提交按钮 */
     submitForm() {
       this.$refs["form"].validate(valid => {
@@ -646,19 +653,6 @@ export default {
       this.batchRedPacketVisible = true;
     },
 
-    /** 处理批量设置红包保存 */
-    // handleBatchRedPacketSave(data) {
-    //   // 这里等待接口提供后补充具体实现
-    //   // 示例代码:
-    //   // batchSetRedPacket(data).then(response => {
-    //   //   if (response.code === 200) {
-    //   //     this.$message.success('批量设置成功');
-    //   //     this.getList();
-    //   //   }
-    //   // });
-    //   this.batchRedPacketVisible = false;
-    // },
-
     /** 获取公司下拉列表*/
     getCompanyList() {
       this.loading = true;
@@ -942,7 +936,6 @@ export default {
         this.form.periodStartingTime = this.form.dateRange[0];
         this.form.periodEndTime = this.form.dateRange[1];
 
-
         // 转换为天数
         let days = this.getDiff(this.form.periodStartingTime, this.form.periodEndTime);
         for (let i = 0; i < days; i++) {