Browse Source

调度服务2.0 优化,增加账号删除功能

hechuanqi 1 tháng trước cách đây
mục cha
commit
dbe2466c44

+ 30 - 3
src/pages/PlatformAccount/index.tsx

@@ -13,8 +13,7 @@ import React, { useEffect, useRef, useState } from 'react';
  * - GET  /collect_platform_account/index?platform=&account_username=&page=&limit=
  * - POST /collect_platform_account/set_status       启用/禁用账号
  * - POST /collect_platform_account/handle_exceptions 处理异常
- *
- * 注意:不提供新增/编辑/删除功能,账号数据由心跳上报自动维护
+ * - POST /collect_platform_account/delete           硬删除账号
  */
 const PlatformAccount: React.FC = () => {
   const actionRef = useRef<ActionType>();
@@ -94,7 +93,7 @@ const PlatformAccount: React.FC = () => {
       key: 'option',
       valueType: 'option',
       fixed: 'right',
-      width: 180,
+      width: 260,
       render: (text, record) => {
         void text;
         return (
@@ -144,6 +143,34 @@ const PlatformAccount: React.FC = () => {
             >
               处理异常
             </Typography.Link>
+            <Typography.Link
+              style={{ color: 'red' }}
+              onClick={() => {
+                Modal.show({
+                  title: '删除账号',
+                  content: (
+                    <p>
+                      确认要删除账号 <b>{record.account_username}</b> 吗?
+                      <br />
+                      此操作不可恢复,将永久删除该账号。
+                    </p>
+                  ),
+                  onOk: async () => {
+                    const response = await API.CollectPlatformAccount.delete({
+                      id: record.id,
+                    });
+                    if (response.code === 'success') {
+                      message.success('删除成功');
+                      actionRef.current?.reload();
+                      return;
+                    }
+                    throw new Error(response?.msg || '删除失败');
+                  },
+                });
+              }}
+            >
+              删除
+            </Typography.Link>
           </Space>
         );
       },

+ 9 - 2
src/services/collect_platform_account.ts

@@ -6,8 +6,7 @@ import BaseAPI from './BaseAPI';
  * - GET  /collect_platform_account/index            账号分页列表(支持 platform、account_username 筛选)
  * - POST /collect_platform_account/set_status       启用/禁用账号
  * - POST /collect_platform_account/handle_exception 处理异常(针对某个账号清空异常计数)
- *
- * 注意:不提供新增/编辑/删除接口,账号数据由心跳上报自动维护
+ * - POST /collect_platform_account/delete           硬删除账号
  */
 class CollectPlatformAccountAPI extends BaseAPI {
   constructor() {
@@ -37,6 +36,14 @@ class CollectPlatformAccountAPI extends BaseAPI {
       data,
     }).then((data) => data);
   }
+
+  /** 硬删除账号 */
+  delete(data: { id: number }) {
+    return this._post({
+      path: `/collect_platform_account/delete`,
+      data,
+    }).then((data) => data);
+  }
 }
 
 export default new CollectPlatformAccountAPI();