Ver código fonte

fix(modal): set Modal\Drawer maskClosable=true

Lind 3 anos atrás
pai
commit
5524e8d90d
30 arquivos alterados com 111 adições e 21 exclusões
  1. 1 0
      src/components/FRuleEditor/Advance/index.tsx
  2. 1 0
      src/components/FSelectDevice/index.tsx
  3. 1 0
      src/components/FSelectDevices/index.tsx
  4. 1 0
      src/pages/device/Category/Save/index.tsx
  5. 8 1
      src/pages/device/Command/cat/index.tsx
  6. 2 1
      src/pages/device/Command/create/index.tsx
  7. 7 1
      src/pages/device/Firmware/Detail/Task/Detail/index.tsx
  8. 1 0
      src/pages/device/Firmware/Detail/Task/Release/index.tsx
  9. 1 0
      src/pages/device/Firmware/Detail/Task/Save/index.tsx
  10. 1 0
      src/pages/device/Firmware/Save/index.tsx
  11. 1 0
      src/pages/device/Instance/Detail/ChildDevice/BindChildDevice/index.tsx
  12. 7 1
      src/pages/device/Instance/Detail/MetadataLog/Event/index.tsx
  13. 7 1
      src/pages/device/Instance/Detail/MetadataLog/Property/index.tsx
  14. 3 2
      src/pages/device/Instance/Detail/Running/Property/EditProperty.tsx
  15. 1 0
      src/pages/device/Instance/Export/index.tsx
  16. 1 0
      src/pages/device/Instance/Import/index.tsx
  17. 1 0
      src/pages/device/Instance/Process/index.tsx
  18. 1 0
      src/pages/device/Instance/Save/index.tsx
  19. 1 0
      src/pages/device/Product/Detail/PropertyImport/index.tsx
  20. 1 0
      src/pages/device/Product/Save/index.tsx
  21. 1 0
      src/pages/device/components/Alarm/Edit/index.tsx
  22. 1 0
      src/pages/device/components/Alarm/Record/index.tsx
  23. 30 3
      src/pages/device/components/Metadata/Base/Edit/index.tsx
  24. 13 2
      src/pages/device/components/Metadata/Base/columns.ts
  25. 6 1
      src/pages/device/components/Metadata/Cat/index.tsx
  26. 1 0
      src/pages/device/components/Metadata/Import/index.tsx
  27. 2 1
      src/pages/link/Protocol/Debug/index.tsx
  28. 4 3
      src/pages/system/Menu/Detail/buttons.tsx
  29. 2 1
      src/pages/system/OpenAPI/index.tsx
  30. 3 3
      src/pages/system/Tenant/index.tsx

+ 1 - 0
src/components/FRuleEditor/Advance/index.tsx

@@ -13,6 +13,7 @@ const Advance = (props: Props) => {
   const { model, onChange } = props;
   return (
     <Modal
+      maskClosable={false}
       visible={model === 'advance'}
       width="70vw"
       title="设置属性规则"

+ 1 - 0
src/components/FSelectDevice/index.tsx

@@ -85,6 +85,7 @@ const FSelectDevice = connect((props: Props) => {
       />
       {visible && (
         <Modal
+          maskClosable={false}
           visible
           title="选择设备"
           width="80vw"

+ 1 - 0
src/components/FSelectDevices/index.tsx

@@ -85,6 +85,7 @@ const FSelectDevices = connect((props: Props) => {
       />
       {visible && (
         <Modal
+          maskClosable={false}
           visible
           title="选择设备"
           width="80vw"

+ 1 - 0
src/pages/device/Category/Save/index.tsx

@@ -133,6 +133,7 @@ const Save = (props: Props) => {
 
   return (
     <Modal
+      maskClosable={false}
       title={intl.formatMessage({
         id: `pages.data.option.${props.data.id ? 'edit' : 'add'}`,
         defaultMessage: '新增',

+ 8 - 1
src/pages/device/Command/cat/index.tsx

@@ -11,7 +11,14 @@ interface Props {
 const Cat = (props: Props) => {
   const { close, data, visible } = props;
   return (
-    <Modal width="40vw" visible={visible} onCancel={() => close()} footer={null} title="查看指令">
+    <Modal
+      maskClosable={false}
+      width="40vw"
+      visible={visible}
+      onCancel={() => close()}
+      footer={null}
+      title="查看指令"
+    >
       下发指令:
       <MonacoEditor
         height={300}

+ 2 - 1
src/pages/device/Command/create/index.tsx

@@ -1,7 +1,7 @@
 import type { Field } from '@formily/core';
 import { createForm, onFieldValueChange } from '@formily/core';
 import { createSchemaField } from '@formily/react';
-import { Form, Input, FormItem, Select, Space, ArrayTable } from '@formily/antd';
+import { ArrayTable, Form, FormItem, Input, Select, Space } from '@formily/antd';
 import { action } from '@formily/reactive';
 import type { ISchema } from '@formily/json-schema';
 import { service } from '@/pages/device/Command';
@@ -243,6 +243,7 @@ const Create = (props: Props) => {
   };
   return (
     <Modal
+      maskClosable={false}
       onOk={sendCommand}
       onCancel={() => close()}
       width="50vw"

+ 7 - 1
src/pages/device/Firmware/Detail/Task/Detail/index.tsx

@@ -64,7 +64,13 @@ const Detail = (props: Props) => {
   }, [state.taskItem]);
 
   return (
-    <Modal width="30vw" visible={props.visible} onCancel={() => props.close()} title="任务详情">
+    <Modal
+      maskClosable={false}
+      width="30vw"
+      visible={props.visible}
+      onCancel={() => props.close()}
+      title="任务详情"
+    >
       <Row gutter={16}>
         {Object.keys(count)
           .reduce((previousValue: any[], currentValue) => {

+ 1 - 0
src/pages/device/Firmware/Detail/Task/Release/index.tsx

@@ -74,6 +74,7 @@ const Release = (props: Props) => {
   };
   return (
     <Modal
+      maskClosable={false}
       title="发布任务"
       onOk={save}
       visible={props.visible}

+ 1 - 0
src/pages/device/Firmware/Detail/Task/Save/index.tsx

@@ -69,6 +69,7 @@ const Save = (props: Props) => {
   };
   return (
     <Modal
+      maskClosable={false}
       onOk={save}
       width="40vw"
       visible={props.visible}

+ 1 - 0
src/pages/device/Firmware/Save/index.tsx

@@ -120,6 +120,7 @@ const Save = (props: Props) => {
 
   return (
     <Modal
+      maskClosable={false}
       width="50vw"
       title="新增固件版本"
       onCancel={() => close()}

+ 1 - 0
src/pages/device/Instance/Detail/ChildDevice/BindChildDevice/index.tsx

@@ -90,6 +90,7 @@ const BindChildDevice = (props: Props) => {
 
   return (
     <Modal
+      maskClosable={false}
       title="绑定子设备"
       visible={visible}
       width={1000}

+ 7 - 1
src/pages/device/Instance/Detail/MetadataLog/Event/index.tsx

@@ -37,7 +37,13 @@ const EventLog = (props: Props) => {
         ];
 
   return (
-    <Drawer title={data.name} visible={visible} onClose={() => close()} width="45vw">
+    <Drawer
+      maskClosable={false}
+      title={data.name}
+      visible={visible}
+      onClose={() => close()}
+      width="45vw"
+    >
       <ProTable
         size="small"
         rowKey="id"

+ 7 - 1
src/pages/device/Instance/Detail/MetadataLog/Property/index.tsx

@@ -69,7 +69,13 @@ const PropertyLog = (props: Props) => {
   }, [visible]);
 
   return (
-    <Modal title="详情" visible={visible} onCancel={() => close()} width="45vw">
+    <Modal
+      maskClosable={false}
+      title="详情"
+      visible={visible}
+      onCancel={() => close()}
+      width="45vw"
+    >
       <div style={{ marginBottom: '20px' }}>
         <Space>
           <Radio.Group

+ 3 - 2
src/pages/device/Instance/Detail/Running/Property/EditProperty.tsx

@@ -1,7 +1,7 @@
 import { Alert, message, Modal } from 'antd';
-import { Input, FormItem } from '@formily/antd';
+import { FormItem, Input } from '@formily/antd';
 import { createForm } from '@formily/core';
-import { FormProvider, createSchemaField } from '@formily/react';
+import { createSchemaField, FormProvider } from '@formily/react';
 import { service } from '@/pages/device/Instance';
 import { useParams } from 'umi';
 import type { PropertyMetadata } from '@/pages/device/Product/typings';
@@ -45,6 +45,7 @@ const EditProperty = (props: Props) => {
   };
   return (
     <Modal
+      maskClosable={false}
       title="编辑"
       visible={visible}
       onOk={async () => {

+ 1 - 0
src/pages/device/Instance/Export/index.tsx

@@ -102,6 +102,7 @@ const Export = (props: Props) => {
   };
   return (
     <Modal
+      maskClosable={false}
       visible={visible}
       onCancel={() => close()}
       width="35vw"

+ 1 - 0
src/pages/device/Instance/Import/index.tsx

@@ -254,6 +254,7 @@ const Import = (props: Props) => {
 
   return (
     <Modal
+      maskClosable={false}
       visible={visible}
       onCancel={() => close()}
       width="35vw"

+ 1 - 0
src/pages/device/Instance/Process/index.tsx

@@ -64,6 +64,7 @@ const Process = (props: Props) => {
   }, []);
   return (
     <Modal
+      maskClosable={false}
       title="当前进度"
       visible
       confirmLoading={flag}

+ 1 - 0
src/pages/device/Instance/Save/index.tsx

@@ -101,6 +101,7 @@ const Save = (props: Props) => {
 
   return (
     <Modal
+      maskClosable={false}
       visible={visible}
       onCancel={() => {
         form.resetFields();

+ 1 - 0
src/pages/device/Product/Detail/PropertyImport/index.tsx

@@ -177,6 +177,7 @@ const PropertyImport = (props: Props) => {
 
   return (
     <Modal
+      maskClosable={false}
       visible
       onCancel={() => (MetadataModel.importMetadata = false)}
       width="35vw"

+ 1 - 0
src/pages/device/Product/Save/index.tsx

@@ -102,6 +102,7 @@ const Save = (props: Props) => {
 
   return (
     <Modal
+      maskClosable={false}
       visible={visible}
       onCancel={() => {
         form.resetFields();

+ 1 - 0
src/pages/device/components/Alarm/Edit/index.tsx

@@ -310,6 +310,7 @@ const EditAlarm = (props: Props) => {
   };
   return (
     <Drawer
+      maskClosable={false}
       title="编辑告警"
       visible={visible}
       onClose={() => close()}

+ 1 - 0
src/pages/device/components/Alarm/Record/index.tsx

@@ -120,6 +120,7 @@ const Record = (props: Props) => {
         search={false}
       />
       <Modal
+        maskClosable={false}
         title="处理告警"
         visible={visible}
         onCancel={() => setVisible(false)}

+ 30 - 3
src/pages/device/components/Metadata/Base/Edit/index.tsx

@@ -2,7 +2,7 @@ import { Button, Drawer, Dropdown, Menu, message } from 'antd';
 import { createSchemaField, observer } from '@formily/react';
 import MetadataModel from '../model';
 import type { Field, IFieldState } from '@formily/core';
-import { createForm } from '@formily/core';
+import { createForm, registerValidateRules } from '@formily/core';
 import {
   ArrayItems,
   Editable,
@@ -133,6 +133,13 @@ const Edit = observer((props: Props) => {
     },
   });
 
+  registerValidateRules({
+    validateId(value) {
+      if (!value) return '';
+      const reg = new RegExp('^\\w{3,20}$');
+      return reg.exec(value) ? '' : 'ID只能由数字、26个英文字母或者下划线组成';
+    },
+  });
   const valueTypeConfig = {
     type: 'object',
     'x-index': 4,
@@ -142,7 +149,16 @@ const Edit = observer((props: Props) => {
         required: true,
         'x-decorator': 'FormItem',
         'x-component': 'Select',
-        enum: DataTypeList,
+        default: MetadataModel.type === 'events' ? 'object' : null,
+        enum:
+          MetadataModel.type === 'events'
+            ? [
+                {
+                  value: 'object',
+                  label: 'object(结构体)',
+                },
+              ]
+            : DataTypeList,
       },
       unit: {
         title: intl.formatMessage({
@@ -152,6 +168,12 @@ const Edit = observer((props: Props) => {
         'x-decorator': 'FormItem',
         'x-component': 'Select',
         'x-visible': false,
+        'x-component-props': {
+          showSearch: true,
+          showArrow: true,
+          filterOption: (input: string, option: any) =>
+            option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0,
+        },
         'x-reactions': [
           {
             dependencies: ['.type'],
@@ -329,7 +351,11 @@ const Edit = observer((props: Props) => {
         },
         {
           required: true,
-          message: '请输入ID',
+          message: '请输入标识',
+        },
+        {
+          validateId: true,
+          message: 'ID只能由数字、26个英文字母或者下划线组成',
         },
       ],
     },
@@ -764,6 +790,7 @@ const Edit = observer((props: Props) => {
   return (
     <>
       <Drawer
+        maskClosable={false}
         width="25vw"
         visible
         title={`${intl.formatMessage({

+ 13 - 2
src/pages/device/components/Metadata/Base/columns.ts

@@ -25,7 +25,15 @@ const BaseColumns: ProColumns<MetadataItem>[] = [
 const EventColumns: ProColumns<MetadataItem>[] = BaseColumns.concat([
   {
     title: '事件级别',
-    dataIndex: 'expands.level',
+    dataIndex: 'expands',
+    render: (text: any) => {
+      const map = {
+        ordinary: '普通',
+        warn: '警告',
+        urgent: '紧急',
+      };
+      return map[text?.level] || '-';
+    },
   },
 ]);
 
@@ -33,6 +41,7 @@ const FunctionColumns: ProColumns<MetadataItem>[] = BaseColumns.concat([
   {
     title: '是否异步',
     dataIndex: 'async',
+    render: (text) => (text ? '是' : '否'),
   },
   {
     title: '是否只读',
@@ -44,7 +53,8 @@ const FunctionColumns: ProColumns<MetadataItem>[] = BaseColumns.concat([
 const PropertyColumns: ProColumns<MetadataItem>[] = BaseColumns.concat([
   {
     title: '数据类型',
-    dataIndex: 'dataType',
+    dataIndex: 'valueType',
+    render: (text: any) => text?.type,
   },
   {
     title: '是否只读',
@@ -57,6 +67,7 @@ const TagColumns: ProColumns<MetadataItem>[] = BaseColumns.concat([
   {
     title: '数据类型',
     dataIndex: 'valueType',
+    render: (text: any) => text?.type,
   },
   {
     title: '是否只读',

+ 6 - 1
src/pages/device/components/Metadata/Cat/index.tsx

@@ -33,7 +33,12 @@ const Cat = (props: Props) => {
     }
   };
   return (
-    <Drawer title="查看物模型" onClose={() => props.close()} visible={props.visible}>
+    <Drawer
+      maskClosable={false}
+      title="查看物模型"
+      onClose={() => props.close()}
+      visible={props.visible}
+    >
       <div style={{ background: 'rgb(236, 237, 238)' }}>
         <p style={{ padding: 10 }}>
           物模型是对设备在云端的功能描述,包括设备的属性、服务和事件。物联网平台通过定义一种物的描述语言来描述物模型,称之为

+ 1 - 0
src/pages/device/components/Metadata/Import/index.tsx

@@ -188,6 +188,7 @@ const Import = (props: Props) => {
   };
   return (
     <Modal
+      maskClosable={false}
       title="导入物模型"
       destroyOnClose
       visible={props.visible}

+ 2 - 1
src/pages/link/Protocol/Debug/index.tsx

@@ -3,7 +3,7 @@ import type { ISchema } from '@formily/json-schema';
 import type { Field } from '@formily/core';
 import { createForm } from '@formily/core';
 import { createSchemaField } from '@formily/react';
-import { Input, Radio, Select, FormItem, Form, Space } from '@formily/antd';
+import { Form, FormItem, Input, Radio, Select, Space } from '@formily/antd';
 import FMonacoEditor from '@/components/FMonacoEditor';
 import type { ProtocolItem } from '@/pages/link/Protocol/typings';
 import { service } from '@/pages/link/Protocol';
@@ -169,6 +169,7 @@ const Debug = (props: Props) => {
 
   return (
     <Modal
+      maskClosable={false}
       title="调试"
       width="60vw"
       onCancel={() => close()}

+ 4 - 3
src/pages/system/Menu/Detail/buttons.tsx

@@ -1,10 +1,10 @@
-import { Form, Input, Button, message, Modal, Popconfirm, Tooltip } from 'antd';
+import { Button, Form, Input, message, Modal, Popconfirm, Tooltip } from 'antd';
 import { useIntl } from '@@/plugin-locale/localeExports';
 import { useCallback, useEffect, useState } from 'react';
 import { service } from '@/pages/system/Menu';
-import ProTable from '@jetlinks/pro-table';
 import type { ProColumns } from '@jetlinks/pro-table';
-import { SearchOutlined, PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons';
+import ProTable from '@jetlinks/pro-table';
+import { DeleteOutlined, EditOutlined, PlusOutlined, SearchOutlined } from '@ant-design/icons';
 import type { MenuButtonInfo, MenuItem } from '@/pages/system/Menu/typing';
 import Permission from '@/pages/system/Menu/components/permission';
 import { useRequest } from '@@/plugin-request/request';
@@ -249,6 +249,7 @@ export default (props: ButtonsProps) => {
         ]}
       />
       <Modal
+        maskClosable={false}
         width={660}
         visible={visible}
         title={handleTitle()}

+ 2 - 1
src/pages/system/OpenAPI/index.tsx

@@ -1,6 +1,6 @@
 import { PageContainer } from '@ant-design/pro-layout';
 import React, { useRef } from 'react';
-import type { ProColumns, ActionType } from '@jetlinks/pro-table';
+import type { ActionType, ProColumns } from '@jetlinks/pro-table';
 import type { OpenApiItem } from '@/pages/system/OpenAPI/typings';
 import { useIntl } from '@@/plugin-locale/localeExports';
 import { CurdModel } from '@/components/BaseCrud/model';
@@ -329,6 +329,7 @@ const OpenAPI: React.FC = observer(() => {
         actionRef={actionRef}
       />
       <Drawer
+        maskClosable={false}
         title={intl.formatMessage({
           id: 'pages.data.option.authorize',
           defaultMessage: '授权',

+ 3 - 3
src/pages/system/Tenant/index.tsx

@@ -1,7 +1,6 @@
 import { PageContainer } from '@ant-design/pro-layout';
-import type { ProColumns, ActionType } from '@jetlinks/pro-table';
-import type { TenantDetail } from '@/pages/system/Tenant/typings';
-import type { TenantItem } from '@/pages/system/Tenant/typings';
+import type { ActionType, ProColumns } from '@jetlinks/pro-table';
+import type { TenantDetail, TenantItem } from '@/pages/system/Tenant/typings';
 import BaseCrud from '@/components/BaseCrud';
 import { useRef } from 'react';
 import { Avatar, Drawer, Tooltip } from 'antd';
@@ -238,6 +237,7 @@ const Tenant = observer(() => {
         actionRef={actionRef}
       />
       <Drawer
+        maskClosable={false}
         title={intl.formatMessage({
           id: 'pages.data.option.authorize',
           defaultMessage: '授权',