Ver código fonte

feat(merge): merge xyh

lind 3 anos atrás
pai
commit
9ec3a8fbab

+ 14 - 3
src/components/ProTableCard/CardItems/AlarmConfig.tsx

@@ -2,8 +2,9 @@ import React from 'react';
 import { TableCard } from '@/components';
 import { TableCard } from '@/components';
 import '@/style/common.less';
 import '@/style/common.less';
 import '../index.less';
 import '../index.less';
+import { StatusColorEnum } from '@/components/BadgeStatus';
 
 
-export interface AlarmConfigProps extends TemplateItem {
+export interface AlarmConfigProps extends ConfigurationItem {
   detail?: React.ReactNode;
   detail?: React.ReactNode;
   actions?: React.ReactNode[];
   actions?: React.ReactNode[];
   avatarSize?: number;
   avatarSize?: number;
@@ -13,10 +14,20 @@ export const aliyunSms = require('/public/images/notice/sms.png');
 
 
 export default (props: AlarmConfigProps) => {
 export default (props: AlarmConfigProps) => {
   return (
   return (
-    <TableCard actions={props.actions} showStatus={false} detail={props.detail} showMask={false}>
+    <TableCard
+      actions={props.actions}
+      detail={props.detail}
+      status={props.state.value}
+      statusText={props.state.text}
+      statusNames={{
+        enabled: StatusColorEnum.success,
+        disabled: StatusColorEnum.error,
+      }}
+      showMask={false}
+    >
       <div className={'pro-table-card-item'}>
       <div className={'pro-table-card-item'}>
         <div className={'card-item-avatar'}>
         <div className={'card-item-avatar'}>
-          <img width={88} height={88} src={aliyunSms} alt={props.type} />
+          <img width={88} height={88} src={aliyunSms} alt={''} />
         </div>
         </div>
         <div className={'card-item-body'}>
         <div className={'card-item-body'}>
           <div className={'card-item-header'}>
           <div className={'card-item-header'}>

+ 16 - 14
src/components/ProTableCard/TableCard.tsx

@@ -1,8 +1,8 @@
 import React, { useState } from 'react';
 import React, { useState } from 'react';
 import classNames from 'classnames';
 import classNames from 'classnames';
 import { BadgeStatus } from '@/components';
 import { BadgeStatus } from '@/components';
-import { StatusColorEnum } from '@/components/BadgeStatus';
 import type { StatusColorType } from '@/components/BadgeStatus';
 import type { StatusColorType } from '@/components/BadgeStatus';
+import { StatusColorEnum } from '@/components/BadgeStatus';
 import './index.less';
 import './index.less';
 
 
 export interface TableCardProps {
 export interface TableCardProps {
@@ -20,19 +20,21 @@ export interface TableCardProps {
 }
 }
 
 
 function getAction(actions: React.ReactNode[]) {
 function getAction(actions: React.ReactNode[]) {
-  return actions.map((item: any) => {
-    return (
-      <div
-        className={classNames('card-button', {
-          delete: item.key === 'delete',
-          disabled: item.disabled,
-        })}
-        key={item.key}
-      >
-        {item}
-      </div>
-    );
-  });
+  return actions
+    .filter((item) => item)
+    .map((item: any) => {
+      return (
+        <div
+          className={classNames('card-button', {
+            delete: item.key === 'delete',
+            disabled: item.disabled,
+          })}
+          key={item.key}
+        >
+          {item}
+        </div>
+      );
+    });
 }
 }
 
 
 export default (props: TableCardProps) => {
 export default (props: TableCardProps) => {

+ 37 - 22
src/pages/rule-engine/Alarm/Configuration/index.tsx

@@ -12,7 +12,7 @@ import {
 } from '@ant-design/icons';
 } from '@ant-design/icons';
 import { useIntl } from '@@/plugin-locale/localeExports';
 import { useIntl } from '@@/plugin-locale/localeExports';
 import { useRef, useState } from 'react';
 import { useRef, useState } from 'react';
-import { message, Space } from 'antd';
+import { Badge, message, Space } from 'antd';
 import ProTableCard from '@/components/ProTableCard';
 import ProTableCard from '@/components/ProTableCard';
 import Save from './Save';
 import Save from './Save';
 import Service from '@/pages/rule-engine/Alarm/Configuration/service';
 import Service from '@/pages/rule-engine/Alarm/Configuration/service';
@@ -46,7 +46,9 @@ const Configuration = () => {
     {
     {
       title: '状态',
       title: '状态',
       dataIndex: 'state',
       dataIndex: 'state',
-      renderText: (state) => state.text,
+      renderText: (state) => (
+        <Badge text={state?.text} status={state?.value === 'disabled' ? 'error' : 'success'} />
+      ),
     },
     },
     {
     {
       title: '说明',
       title: '说明',
@@ -60,6 +62,8 @@ const Configuration = () => {
         record.sceneTriggerType === 'manual' && (
         record.sceneTriggerType === 'manual' && (
           <PermissionButton
           <PermissionButton
             key="trigger"
             key="trigger"
+            type="link"
+            style={{ padding: 0 }}
             isPermission={true}
             isPermission={true}
             popConfirm={{
             popConfirm={{
               title: '确认手动触发?',
               title: '确认手动触发?',
@@ -103,18 +107,16 @@ const Configuration = () => {
           popConfirm={{
           popConfirm={{
             title: intl.formatMessage({
             title: intl.formatMessage({
               id: `pages.data.option.${
               id: `pages.data.option.${
-                record?.state?.value === 'disable' ? 'disabled' : 'enabled'
+                record.state?.value !== 'disabled' ? 'disabled' : 'disabled'
               }.tips`,
               }.tips`,
-              defaultMessage: `确认${record?.state?.value === 'disable' ? '禁用' : '启用'}?`,
+              defaultMessage: `确认${record.state?.value !== 'disabled' ? '禁用' : '启用'}?`,
             }),
             }),
             onConfirm: async () => {
             onConfirm: async () => {
-              if (record?.state?.value === 'disable') {
+              if (record.state?.value === 'disabled') {
                 await service._enable(record.id);
                 await service._enable(record.id);
               } else {
               } else {
                 await service._disable(record.id);
                 await service._disable(record.id);
               }
               }
-              setVisible(true);
-              setCurrent(record);
               message.success(
               message.success(
                 intl.formatMessage({
                 intl.formatMessage({
                   id: 'pages.data.option.success',
                   id: 'pages.data.option.success',
@@ -127,19 +129,20 @@ const Configuration = () => {
           tooltip={{
           tooltip={{
             title: intl.formatMessage({
             title: intl.formatMessage({
               id: `pages.data.option.${
               id: `pages.data.option.${
-                record?.state?.value === 'disable' ? 'disabled' : 'enabled'
+                record.state?.value !== 'disabled' ? 'disabled' : 'enabled'
               }`,
               }`,
-              defaultMessage: record?.state?.value === 'disable' ? '禁用' : '启用',
+              defaultMessage: record.state?.value !== 'disabled' ? '禁用' : '启用',
             }),
             }),
           }}
           }}
           type="link"
           type="link"
         >
         >
-          {record.state.value === 'disable' ? <CloseCircleOutlined /> : <PlayCircleOutlined />}
+          {record.state?.value === 'disabled' ? <CloseCircleOutlined /> : <PlayCircleOutlined />}
         </PermissionButton>,
         </PermissionButton>,
         <PermissionButton
         <PermissionButton
           type="link"
           type="link"
           isPermission={true}
           isPermission={true}
           key="delete"
           key="delete"
+          disabled={record.state?.value !== 'disabled'}
           style={{ padding: 0 }}
           style={{ padding: 0 }}
           popConfirm={{
           popConfirm={{
             title: '确认删除?',
             title: '确认删除?',
@@ -181,9 +184,10 @@ const Configuration = () => {
           <AlarmConfig
           <AlarmConfig
             {...record}
             {...record}
             actions={[
             actions={[
-              record.sceneTriggerType === 'manual' && (
+              record.sceneTriggerType === 'manual' ? (
                 <PermissionButton
                 <PermissionButton
                   key="trigger"
                   key="trigger"
+                  type="link"
                   isPermission={true}
                   isPermission={true}
                   popConfirm={{
                   popConfirm={{
                     title: '确认手动触发?',
                     title: '确认手动触发?',
@@ -202,10 +206,11 @@ const Configuration = () => {
                   <LikeOutlined />
                   <LikeOutlined />
                   手动触发
                   手动触发
                 </PermissionButton>
                 </PermissionButton>
-              ),
+              ) : null,
               <PermissionButton
               <PermissionButton
                 isPermission={true}
                 isPermission={true}
                 key="edit"
                 key="edit"
+                type="link"
                 onClick={() => {
                 onClick={() => {
                   setCurrent(record);
                   setCurrent(record);
                   setVisible(true);
                   setVisible(true);
@@ -220,18 +225,16 @@ const Configuration = () => {
                 popConfirm={{
                 popConfirm={{
                   title: intl.formatMessage({
                   title: intl.formatMessage({
                     id: `pages.data.option.${
                     id: `pages.data.option.${
-                      record.state?.value === 'disable' ? 'disabled' : 'enabled'
+                      record.state?.value !== 'disabled' ? 'disabled' : 'enabled'
                     }.tips`,
                     }.tips`,
-                    defaultMessage: `确认${record.state.value === 'disable' ? '禁用' : '启用'}?`,
+                    defaultMessage: `确认${record.state?.value !== 'disabled' ? '禁用' : '启用'}?`,
                   }),
                   }),
                   onConfirm: async () => {
                   onConfirm: async () => {
-                    if (record.state?.value === 'disable') {
+                    if (record.state?.value === 'disabled') {
                       await service._enable(record.id);
                       await service._enable(record.id);
                     } else {
                     } else {
                       await service._disable(record.id);
                       await service._disable(record.id);
                     }
                     }
-                    setVisible(true);
-                    setCurrent(record);
                     message.success(
                     message.success(
                       intl.formatMessage({
                       intl.formatMessage({
                         id: 'pages.data.option.success',
                         id: 'pages.data.option.success',
@@ -244,22 +247,27 @@ const Configuration = () => {
                 tooltip={{
                 tooltip={{
                   title: intl.formatMessage({
                   title: intl.formatMessage({
                     id: `pages.data.option.${
                     id: `pages.data.option.${
-                      record.state.value === 'disable' ? 'disabled' : 'enabled'
+                      record.state?.value !== 'disabled' ? 'disabled' : 'enabled'
                     }`,
                     }`,
-                    defaultMessage: record.state.value === 'disable' ? '禁用' : '启用',
+                    defaultMessage: record.state?.value !== 'disabled' ? '禁用' : '启用',
                   }),
                   }),
                 }}
                 }}
                 key="action"
                 key="action"
                 type="link"
                 type="link"
               >
               >
-                {record.state.value === 'disable' ? (
+                {record.state?.value !== 'disabled' ? (
                   <CloseCircleOutlined />
                   <CloseCircleOutlined />
                 ) : (
                 ) : (
                   <PlayCircleOutlined />
                   <PlayCircleOutlined />
                 )}
                 )}
-                {record.state.value === 'disable' ? '禁用' : '启用'}
+                {record.state?.value !== 'disabled' ? '禁用' : '启用'}
               </PermissionButton>,
               </PermissionButton>,
               <PermissionButton
               <PermissionButton
+                type="link"
+                tooltip={{
+                  title: '删除',
+                }}
+                disabled={record.state?.value !== 'disabled'}
                 popConfirm={{
                 popConfirm={{
                   title: '确认删除?',
                   title: '确认删除?',
                   onConfirm: async () => {
                   onConfirm: async () => {
@@ -295,7 +303,14 @@ const Configuration = () => {
           </Space>
           </Space>
         }
         }
       />
       />
-      <Save data={current} visible={visible} close={() => setVisible(false)} />
+      <Save
+        data={current}
+        visible={visible}
+        close={() => {
+          setVisible(false);
+          actionRef.current?.reset?.();
+        }}
+      />
     </PageContainer>
     </PageContainer>
   );
   );
 };
 };

+ 1 - 0
src/pages/rule-engine/Alarm/Configuration/service.ts

@@ -30,6 +30,7 @@ class Service extends BaseService<ConfigItem> {
   public _execute = (id: string) =>
   public _execute = (id: string) =>
     request(`/${SystemConst.API_BASE}/scene/${id}/_execute`, {
     request(`/${SystemConst.API_BASE}/scene/${id}/_execute`, {
       method: 'POST',
       method: 'POST',
+      data: {},
     });
     });
 }
 }
 
 

+ 6 - 6
src/pages/rule-engine/Scene/Save/components/TimingTrigger/index.tsx

@@ -67,7 +67,7 @@ export default (props: TimingTrigger) => {
         mod: PeriodModEnum.period,
         mod: PeriodModEnum.period,
         when: [],
         when: [],
         period: {
         period: {
-          unit: 'second',
+          unit: 'seconds',
         },
         },
       });
       });
     } else {
     } else {
@@ -87,7 +87,7 @@ export default (props: TimingTrigger) => {
           period: {
           period: {
             from: undefined,
             from: undefined,
             to: undefined,
             to: undefined,
-            unit: 'second',
+            unit: 'seconds',
           },
           },
         });
         });
       } else {
       } else {
@@ -105,11 +105,11 @@ export default (props: TimingTrigger) => {
 
 
   const TimeTypeAfter = (
   const TimeTypeAfter = (
     <Select
     <Select
-      value={data.period?.unit || 'second'}
+      value={data.period?.unit || 'seconds'}
       options={[
       options={[
-        { label: '秒', value: 'second' },
-        { label: '分', value: 'minute' },
-        { label: '小时', value: 'hour' },
+        { label: '秒', value: 'seconds' },
+        { label: '分', value: 'minutes' },
+        { label: '小时', value: 'hours' },
       ]}
       ]}
       onSelect={(key: string) => {
       onSelect={(key: string) => {
         onChange({
         onChange({

+ 1 - 0
src/pages/rule-engine/Scene/Save/index.tsx

@@ -95,6 +95,7 @@ export default () => {
       setLoading(false);
       setLoading(false);
       if (resp.status === 200) {
       if (resp.status === 200) {
         message.success('操作成功');
         message.success('操作成功');
+        form.setFieldsValue({ id: resp.result.id });
       } else {
       } else {
         message.error(resp.message);
         message.error(resp.message);
       }
       }