lind 3 лет назад
Родитель
Сommit
aeb0bb1b13

+ 88 - 3
src/pages/rule-engine/Alarm/Configuration/index.tsx

@@ -2,10 +2,16 @@ import { PageContainer } from '@ant-design/pro-layout';
 import SearchComponent from '@/components/SearchComponent';
 import { ActionType, ProColumns } from '@jetlinks/pro-table';
 import { PermissionButton } from '@/components';
-import { DeleteOutlined, EditOutlined, PlusOutlined } from '@ant-design/icons';
+import {
+  CloseCircleOutlined,
+  DeleteOutlined,
+  EditOutlined,
+  PlayCircleOutlined,
+  PlusOutlined,
+} from '@ant-design/icons';
 import { useIntl } from '@@/plugin-locale/localeExports';
 import { useRef, useState } from 'react';
-import { Space } from 'antd';
+import { message, Space } from 'antd';
 import ProTableCard from '@/components/ProTableCard';
 import Save from './Save';
 import Service from '@/pages/rule-engine/Alarm/Configuration/service';
@@ -18,7 +24,7 @@ const Configuration = () => {
   const [visible, setVisible] = useState<boolean>(false);
 
   const [current, setCurrent] = useState<any>();
-  const columns: ProColumns<ConfigItem>[] = [
+  const columns: ProColumns<ConfigurationItem>[] = [
     {
       dataIndex: 'name',
       title: '名称',
@@ -67,6 +73,42 @@ const Configuration = () => {
           <EditOutlined />
         </PermissionButton>,
         <PermissionButton
+          isPermission={true}
+          style={{ padding: 0 }}
+          popConfirm={{
+            title: intl.formatMessage({
+              id: `pages.data.option.${
+                record.state?.value === 'disable' ? 'disabled' : 'enabled'
+              }.tips`,
+              defaultMessage: `确认${record.state.value === 'disable' ? '禁用' : '启用'}?`,
+            }),
+            onConfirm: async () => {
+              // await service.update({
+              //   id: record.id,
+              //   status: record.status ? 0 : 1,
+              // });
+              setVisible(true);
+              setCurrent(record);
+              message.success(
+                intl.formatMessage({
+                  id: 'pages.data.option.success',
+                  defaultMessage: '操作成功!',
+                }),
+              );
+              // actionRef.current?.reload();
+            },
+          }}
+          tooltip={{
+            title: intl.formatMessage({
+              id: `pages.data.option.${record.state.value === 'disable' ? 'disabled' : 'enabled'}`,
+              defaultMessage: record.state.value === 'disable' ? '禁用' : '启用',
+            }),
+          }}
+          type="link"
+        >
+          {record.state.value === 'disable' ? <CloseCircleOutlined /> : <PlayCircleOutlined />}
+        </PermissionButton>,
+        <PermissionButton
           type="link"
           isPermission={true}
           style={{ padding: 0 }}
@@ -124,6 +166,49 @@ const Configuration = () => {
                 编辑
               </PermissionButton>,
               <PermissionButton
+                isPermission={true}
+                style={{ padding: 0 }}
+                popConfirm={{
+                  title: intl.formatMessage({
+                    id: `pages.data.option.${
+                      record.state?.value === 'disable' ? 'disabled' : 'enabled'
+                    }.tips`,
+                    defaultMessage: `确认${record.state.value === 'disable' ? '禁用' : '启用'}?`,
+                  }),
+                  onConfirm: async () => {
+                    // await service.update({
+                    //   id: record.id,
+                    //   status: record.status ? 0 : 1,
+                    // });
+                    setVisible(true);
+                    setCurrent(record);
+                    message.success(
+                      intl.formatMessage({
+                        id: 'pages.data.option.success',
+                        defaultMessage: '操作成功!',
+                      }),
+                    );
+                    actionRef.current?.reload();
+                  },
+                }}
+                tooltip={{
+                  title: intl.formatMessage({
+                    id: `pages.data.option.${
+                      record.state.value === 'disable' ? 'disabled' : 'enabled'
+                    }`,
+                    defaultMessage: record.state.value === 'disable' ? '禁用' : '启用',
+                  }),
+                }}
+                type="link"
+              >
+                {record.state.value === 'disable' ? (
+                  <CloseCircleOutlined />
+                ) : (
+                  <PlayCircleOutlined />
+                )}
+                {record.state.value === 'disable' ? '禁用' : '启用'}
+              </PermissionButton>,
+              <PermissionButton
                 popConfirm={{
                   title: '确认删除?',
                   onConfirm: async () => {

+ 3 - 2
src/pages/rule-engine/Alarm/Configuration/typings.d.ts

@@ -1,9 +1,10 @@
-type ConfigItem = {
+type ConfigurationItem = {
   name: string;
   targetType: string;
   level: number;
   sceneName: string;
   sceneId: string;
-  state: string;
+  state: { text: string; value: string };
   description: string;
+  id: string;
 };