nieyuge il y a 1 mois
Parent
commit
4b1bea381b
2 fichiers modifiés avec 57 ajouts et 13 suppressions
  1. 1 0
      src/http/api.ts
  2. 56 13
      src/views/account/dialog/config.tsx

+ 1 - 0
src/http/api.ts

@@ -4,3 +4,4 @@ export const userLogin = `${import.meta.env.VITE_API_URL}/risk-control/user/logi
 /* 公众号管理 */
 export const wechatUserInfoPage = `${import.meta.env.VITE_API_URL}/risk-control/work/wechat/user/info/page`
 export const wechatChatRoomPage = `${import.meta.env.VITE_API_URL}/risk-control/work/wechat/chat/room/page`
+export const updateAutoRemoveUserStatus = `${import.meta.env.VITE_API_URL}/risk-control/work/wechat/updateAutoRemoveUserStatus`

+ 56 - 13
src/views/account/dialog/config.tsx

@@ -1,9 +1,9 @@
 import React, { useEffect, useState } from "react";
 import http from '@src/http';
-import { Button, Table, Input, message, ConfigProvider, Drawer, Switch } from "antd";
+import { Button, Table, Input, message, ConfigProvider, Drawer, Switch, Popconfirm } from "antd";
 import zhCN from 'antd/locale/zh_CN';
-import { SearchOutlined } from '@ant-design/icons';
-import { wechatChatRoomPage } from '@src/http/api';
+import { SearchOutlined, QuestionCircleOutlined } from '@ant-design/icons';
+import { wechatChatRoomPage, updateAutoRemoveUserStatus } from '@src/http/api';
 import type { TableProps, TablePaginationConfig } from 'antd';
 
 interface ChatRoomDataType {
@@ -63,14 +63,34 @@ const ChatRoomConfig: React.FC<ChatRoomConfigProps> = ({ visible, onClose, uuid
       title: '自动踢群',
       dataIndex: 'autoRemoveUserSwitch',
       key: 'autoRemoveUserSwitch',
-      render: (value, record) => (
-        <Switch 
-          checked={value === 1} 
-          onChange={(checked) => handleSwitchChange(checked, record)}
-        />
-      ),
+      render: (value, record) => {
+        return value === 1 ? (
+          <Switch
+            checked={true}
+            onChange={(checked) => handleSwitchChange(checked, record)}
+          />
+        ) : (
+          <Popconfirm
+            title="确认开启自动踢群"
+            description="开启后,系统将自动踢出异常用户,是否确认开启?"
+            icon={<QuestionCircleOutlined style={{ color: 'red' }} />}
+            onConfirm={() => handleSwitchChange(true, record)}
+            okText="确认"
+            cancelText="取消"
+          >
+            <Switch
+              checked={false}
+              onChange={(checked) => {
+                if (!checked) {
+                  handleSwitchChange(checked, record);
+                }
+              }}
+            />
+          </Popconfirm>
+        );
+      },
     },
-		{
+    {
       title: '异常用户',
     },
   ];
@@ -115,9 +135,32 @@ const ChatRoomConfig: React.FC<ChatRoomConfigProps> = ({ visible, onClose, uuid
     });
   };
 
-  const handleSwitchChange = (checked: boolean, record: ChatRoomDataType) => {
-    // 这里可以添加修改开关状态的接口调用
-    message.success(`${record.roomName} 自动踢人开关已${checked ? '开启' : '关闭'}`);
+  const handleSwitchChange = async (checked: boolean, record: ChatRoomDataType) => {
+    try {
+      setLoading(true);
+      const res = await http.post(updateAutoRemoveUserStatus, {
+        uuid: uuid,
+        roomId: record.roomId,
+        autoRemoveUserSwitch: checked ? 1 : 0
+      });
+
+      if (res.success) {
+        message.success(`${record.roomName} 自动踢群已${checked ? '开启' : '关闭'}`);
+        // 更新列表
+        fetchChatRoomList({
+          currentPage: pagination.current,
+          pageSize: pagination.pageSize,
+          uuid,
+          chatRoomName: searchRoomName
+        });
+      } else {
+        message.error(res.msg || '操作失败');
+      }
+    } catch (error) {
+      message.error('操作失败');
+    } finally {
+      setLoading(false);
+    }
   };
 
   useEffect(() => {