|
@@ -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(() => {
|