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

1、批量拉黑user-company-user表更改状态

yys пре 6 дана
родитељ
комит
022944c29f
2 измењених фајлова са 75 додато и 6 уклоњено
  1. 9 0
      src/api/user/fsUser.js
  2. 66 6
      src/views/member/mylist.vue

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

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

+ 66 - 6
src/views/member/mylist.vue

@@ -147,6 +147,17 @@
               @click="batchSend"
               >批量IM发送</el-button>
             </el-col>
+            <el-col :span="1.5">
+              <el-button
+              type="danger"
+              plain
+              icon="el-icon-lock"
+              size="mini"
+              :disabled="multiple"
+              @click="handleBatchBlacklist"
+              v-hasPermi="['user:fsUser:edit']"
+              >批量拉黑</el-button>
+            </el-col>
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
@@ -179,8 +190,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 ? '正常' : '禁止' }}
+          <el-tag :type="statusType(scope.row.status)">
+            {{ statusText(scope.row.status) }}
           </el-tag>
         </template>
       </el-table-column>
@@ -295,7 +306,8 @@
         <el-form-item label="状态">
           <el-radio-group v-model="form.status">
             <el-radio :label="1">正常</el-radio>
-            <el-radio :label="0">禁止</el-radio>
+            <el-radio :label="0">小黑屋</el-radio>
+            <el-radio :label="2">拉黑</el-radio>
           </el-radio-group>
         </el-form-item>
       </el-form>
@@ -326,7 +338,7 @@
 </template>
 
 <script>
-import { listUser, getMemberUser, addUser, updateMemberUser, delUser, exportUser, auditUser,myListUser } from "@/api/user/fsUser";
+import { listUser, getMemberUser, addUser, updateMemberUser, delUser, exportUser, auditUser,myListUser, batchUpdateUserStatus } from "@/api/user/fsUser";
 import {transferUser} from "@/api/users/user";
 import {getUserList} from "@/api/company/companyUser";
 import userDetails from '@/views/store/components/userDetails.vue';
@@ -357,6 +369,8 @@ export default {
       loading: true,
       // 选中数组
       ids: [],
+      // 选中的会员id数组
+      memberIds: [],
       companyUserId:null,
       companyId:null,
       // 非单个禁用
@@ -432,6 +446,23 @@ export default {
     this.getSalesOptions();
   },
   methods: {
+
+    statusType(status) {
+      const map = {
+        1: 'success',
+        2: 'danger',
+        0: 'info'
+      }
+      return map[status] || 'info'
+    },
+    statusText(status) {
+      const map = {
+        1: '正常',
+        2: '黑名单',
+        0: '小黑屋'
+      }
+      return map[status] || '未知'
+    },
     handledetails(row){
             this.show.open=true;
             setTimeout(() => {
@@ -589,10 +620,11 @@ export default {
     // 多选框选中数据
     handleSelectionChange(selection) {
       this.ids = selection.map(item => item.userId);
+      this.memberIds = selection.map(item => item.id);
       this.single = selection.length !== 1;
       this.multiple = !selection.length;
-      this.companyId = selection[0].companyId;
-      this.companyUserId = selection[0].companyUserId;
+      this.companyId = selection[0]?.companyId;
+      this.companyUserId = selection[0]?.companyUserId;
     },
 
     /** 新增按钮操作 */
@@ -694,6 +726,34 @@ export default {
     },
     handleClose(){
       this.dialogVisible = false;
+    },
+    /** 批量拉黑操作 */
+    handleBatchBlacklist() {
+      if (this.memberIds.length === 0) {
+        this.$message.warning("请至少选择一个用户");
+        return;
+      }
+
+      this.$confirm('是否确认将选中的 ' + this.memberIds.length + ' 个用户拉黑?', "警告", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(() => {
+        const data = {
+          ids: this.memberIds,
+          status: 2 // 2表示禁止/拉黑
+        };
+        return batchUpdateUserStatus(data);
+      }).then(response => {
+        if (response.code === 200) {
+          this.$message.success("批量拉黑成功");
+          this.getList();
+        } else {
+          this.$message.error(response.msg || "批量拉黑失败");
+        }
+      }).catch(() => {
+        this.$message.info("已取消操作");
+      });
     }
   }
 };