yjwang před 1 dnem
rodič
revize
f396d89894

+ 9 - 0
src/api/user/fsUser.js

@@ -103,3 +103,12 @@ export function batchSendCourse(data) {
     data: data
   })
 }
+
+// 批量更新用户状态
+export function batchUpdateUserStatus(data) {
+  return request({
+    url: '/user/fsUser/batchUpdateStatus',
+    method: 'post',
+    data: data
+  })
+}

+ 0 - 0
src/views/live/liveOrder/index.vue


+ 98 - 5
src/views/member/list.vue

@@ -147,6 +147,16 @@
       <!--          v-hasPermi="['user:fsUser:export']"-->
       <!--        >导出</el-button>-->
       <!--      </el-col>-->
+      <el-col :span="1.5">
+        <el-button
+          type="warning"
+          plain
+          icon="el-icon-s-tools"
+          size="mini"
+          :disabled="multiple"
+          @click="handleBatchUpdateStatus"
+        >批量更新状态</el-button>
+      </el-col>
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
@@ -179,8 +189,8 @@
       <el-table-column label="参与营期数量" align="center" prop="partCourseCount" />
       <el-table-column label="状态" align="center">
         <template slot-scope="scope">
-          <el-tag :type="scope.row.status === 1 ? 'success' : 'danger'">
-            {{ scope.row.status === 1 ? '正常' : scope.row.status === 2?'拉黑':'小黑屋' }}
+          <el-tag :type="getStatusType(scope.row.status)">
+            {{ getStatusText(scope.row.status) }}
           </el-tag>
         </template>
       </el-table-column>
@@ -306,11 +316,31 @@
       <userDetails  ref="userDetails" />
     </el-drawer>
 
+    <!-- 批量更新状态弹窗 -->
+    <el-dialog title="批量更新状态" :visible.sync="batchStatusOpen" width="400px" append-to-body>
+      <el-form ref="batchStatusForm" :model="batchStatusForm" label-width="100px">
+        <el-form-item label="选中用户">
+          <el-tag type="info">{{ this.ids.length }} 人</el-tag>
+        </el-form-item>
+        <el-form-item label="新状态" prop="status">
+          <el-radio-group v-model="batchStatusForm.status">
+            <el-radio :label="1">正常</el-radio>
+            <el-radio :label="2">拉黑</el-radio>
+            <el-radio :label="0">小黑屋</el-radio>
+          </el-radio-group>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitBatchStatus">确 定</el-button>
+        <el-button @click="cancelBatchStatus">取 消</el-button>
+      </div>
+    </el-dialog>
+
   </div>
 </template>
 
 <script>
-import { listUser, getUser, addUser, updateUser, delUser, exportUser, auditUser } from "@/api/user/fsUser";
+import { listUser, getUser, addUser, updateUser, delUser, exportUser, auditUser, batchUpdateUserStatus } from "@/api/user/fsUser";
 import {getUserList} from "@/api/company/companyUser";
 import userDetails from '@/views/store/components/userDetails.vue';
 export default {
@@ -392,7 +422,13 @@ export default {
           { required: true, message: "状态不能为空", trigger: "change" }
         ]
       },
-      projectOptions: []
+      projectOptions: [],
+      // 批量更新状态弹窗显示
+      batchStatusOpen: false,
+      // 批量更新状态表单
+      batchStatusForm: {
+        status: 1
+      }
     };
   },
   created() {
@@ -503,6 +539,63 @@ export default {
       return "未知状态";
     },
 
+    /** 获取状态类型 */
+    getStatusType(status) {
+      if (status === 1) return "success";
+      if (status === 2) return "danger";
+      if (status === 0) return "info";
+      return "warning";
+    },
+
+    /** 获取状态文本 */
+    getStatusText(status) {
+      if (status === 1) return "正常";
+      if (status === 2) return "拉黑";
+      if (status === 0) return "小黑屋";
+      return "未知状态";
+    },
+
+    /** 批量更新状态按钮操作 */
+    handleBatchUpdateStatus() {
+      if (this.ids.length === 0) {
+        this.$message.warning("请至少选择一个用户");
+        return;
+      }
+      this.batchStatusForm.status = 1;
+      this.batchStatusOpen = true;
+    },
+
+    /** 提交批量更新状态 */
+    submitBatchStatus() {
+      if (this.batchStatusForm.status === undefined || this.batchStatusForm.status === null) {
+        this.$message.warning("请选择状态");
+        return;
+      }
+      this.$confirm('是否确认将选中的 ' + this.ids.length + ' 个用户状态更新为"' + this.getStatusText(this.batchStatusForm.status) + '"?', "警告", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(() => {
+        const params = {
+          userIds: this.ids,
+          status: parseInt(this.batchStatusForm.status)
+        };
+        return batchUpdateUserStatus(params);
+      }).then((response) => {
+        if (response.code === 200) {
+          this.$message.success("批量更新成功");
+          this.batchStatusOpen = false;
+          this.getList();
+        }
+      }).catch(() => {});
+    },
+
+    /** 取消批量更新状态 */
+    cancelBatchStatus() {
+      this.batchStatusOpen = false;
+      this.batchStatusForm.status = 1;
+    },
+
     // 取消按钮
     cancel() {
       this.open = false;
@@ -545,7 +638,7 @@ export default {
 
     // 多选框选中数据
     handleSelectionChange(selection) {
-      this.ids = selection.map(item => item.userId);
+      this.ids = selection.map(item => item.ucuId);
       this.single = selection.length !== 1;
       this.multiple = !selection.length;
     },