Explorar o código

fix: 权限管理

100011797 %!s(int64=3) %!d(string=hai) anos
pai
achega
4dba6d700c

+ 4 - 2
src/components/ProTableCard/CardItems/Scene/index.tsx

@@ -278,8 +278,10 @@ const actionRender = (action: ActionsType, index: number) => {
 const conditionsRender = (when: any[], index: number) => {
   if (when.length && when[index]) {
     let str: string = '';
-    (when[index]?.terms || []).map((i: any) => {
-      str += `${i?.terms[0] || ''}${i?.termType || ''}`;
+    (when[index]?.terms || []).map((i: any, _index: number) => {
+      str += `${i?.terms[0] || ''}${
+        i?.termType && when[index]?.terms.length !== _index + 1 ? i?.termType : ''
+      }`;
     });
     return str;
   }

+ 0 - 2
src/hooks/document/useDomFullHeight.tsx

@@ -32,14 +32,12 @@ const useDomFullHeight = (target: BasicTarget | string, extraHeight: number = 0)
 
   useEffect(() => {
     const el = getTargetElement(target);
-    console.log(target, 'target', el);
     let resizeObserver: ResizeObserver | undefined;
     if (el) {
       resizeObserver = new ResizeObserver((entries) => {
         entries.forEach((entry) => {
           const bodyClient = document.body.getBoundingClientRect();
           const domClient = entry.target.getBoundingClientRect();
-          console.log(domClient, 'domClient', bodyClient);
           if (domClient.y < 50) {
             setState(100);
           } else {

+ 1 - 1
src/pages/link/DataCollect/components/Channel/Save/index.tsx

@@ -107,7 +107,7 @@ export default (props: Props) => {
         },
         properties: {
           name: {
-            title: '名称',
+            title: '通道名称',
             'x-component': 'Input',
             'x-decorator': 'FormItem',
             'x-decorator-props': {

+ 1 - 1
src/pages/link/DataCollect/components/Channel/index.tsx

@@ -40,7 +40,7 @@ export default observer((props: Props) => {
 
   const columns: ProColumns<ChannelItem>[] = [
     {
-      title: '名称',
+      title: '通道名称',
       dataIndex: 'name',
     },
     {

+ 32 - 1
src/pages/link/DataCollect/components/Device/Save/index.tsx

@@ -89,7 +89,7 @@ export default (props: Props) => {
         },
         properties: {
           name: {
-            title: '名称',
+            title: '采集器名称',
             'x-component': 'Input',
             'x-decorator': 'FormItem',
             'x-decorator-props': {
@@ -166,6 +166,37 @@ export default (props: Props) => {
               },
             ],
           },
+          'configuration.endian': {
+            title: '大小端',
+            'x-component': 'RadioCard',
+            'x-decorator': 'FormItem',
+            'x-decorator-props': {
+              gridSpan: 2,
+            },
+            'x-component-props': {
+              placeholder: '请选择大小端',
+              model: 'singular',
+              itemStyle: {
+                display: 'flex',
+                flexDirection: 'column',
+                justifyContent: 'space-around',
+                minWidth: '130px',
+                height: '50px',
+              },
+              options: [
+                { label: '大端', value: 'BIG' },
+                { label: '小端', value: 'LITTLE' },
+              ],
+            },
+            'x-visible': props.provider === 'MODBUS_TCP',
+            default: 'BIG',
+            'x-validator': [
+              {
+                required: true,
+                message: '请选择大小端',
+              },
+            ],
+          },
           description: {
             title: '说明',
             'x-component': 'Input.TextArea',

+ 12 - 5
src/pages/link/DataCollect/components/Device/index.tsx

@@ -7,7 +7,13 @@ import service from '@/pages/link/DataCollect/service';
 import CollectorCard from '@/components/ProTableCard/CardItems/DataCollect/device';
 import { Empty, PermissionButton } from '@/components';
 import { useIntl } from '@@/plugin-locale/localeExports';
-import { DeleteOutlined, EditOutlined, PlayCircleOutlined, StopOutlined } from '@ant-design/icons';
+import {
+  DeleteOutlined,
+  EditOutlined,
+  PlayCircleOutlined,
+  PlusOutlined,
+  StopOutlined,
+} from '@ant-design/icons';
 import { onlyMessage } from '@/utils/util';
 import { Card, Col, Pagination, Row } from 'antd';
 import { model } from '@formily/reactive';
@@ -45,7 +51,7 @@ export default observer((props: Props) => {
   const columns: ProColumns<CollectorItem>[] = props.type
     ? [
         {
-          title: '名称',
+          title: '采集器名称',
           dataIndex: 'name',
         },
         {
@@ -108,7 +114,7 @@ export default observer((props: Props) => {
       ]
     : [
         {
-          title: '名称',
+          title: '采集器名称',
           dataIndex: 'name',
         },
         {
@@ -226,8 +232,9 @@ export default observer((props: Props) => {
                   }}
                   key="button"
                   type="primary"
+                  icon={<PlusOutlined />}
                 >
-                  新增
+                  新增采集器
                 </PermissionButton>
               </div>
             )}
@@ -390,7 +397,7 @@ export default observer((props: Props) => {
         <Save
           data={CollectorModel.current}
           channelId={props.id}
-          provider={props.provider}
+          provider={props.provider || CollectorModel.current?.provider}
           close={() => {
             CollectorModel.visible = false;
           }}

+ 5 - 4
src/pages/link/DataCollect/components/Point/index.tsx

@@ -16,7 +16,7 @@ import OpcSave from '@/pages/link/DataCollect/components/Point/Save/opc-ua';
 import WritePoint from '@/pages/link/DataCollect/components/Point/CollectorCard/WritePoint';
 import BatchUpdate from './Save/BatchUpdate';
 import { onlyMessage } from '@/utils/util';
-import { DeleteOutlined, EditOutlined, RedoOutlined } from '@ant-design/icons';
+import { DeleteOutlined, EditOutlined, PlusOutlined, RedoOutlined } from '@ant-design/icons';
 interface Props {
   type: boolean; // true: 综合查询  false: 数据采集
   data?: Partial<CollectorItem>;
@@ -234,8 +234,9 @@ const PointCard = observer((props: PointCardProps) => {
                   }}
                   key="button"
                   type="primary"
+                  icon={<PlusOutlined />}
                 >
-                  {props?.provider === 'OPC_UA' ? '扫描' : '新增'}
+                  {props?.provider === 'OPC_UA' ? '扫描' : '新增点位'}
                 </PermissionButton>
                 {props.provider === 'OPC_UA' && (
                   <Dropdown key={'more'} overlay={menu} placement="bottom">
@@ -362,7 +363,7 @@ export default observer((props: Props) => {
   const columns: ProColumns<PointItem>[] = props.type
     ? [
         {
-          title: '名称',
+          title: '点位名称',
           dataIndex: 'name',
         },
         {
@@ -444,7 +445,7 @@ export default observer((props: Props) => {
       ]
     : [
         {
-          title: '名称',
+          title: '点位名称',
           dataIndex: 'name',
         },
         {

+ 42 - 22
src/pages/link/DataCollect/components/Tree/index.tsx

@@ -6,10 +6,10 @@ import {
   StopOutlined,
   PlayCircleOutlined,
 } from '@ant-design/icons';
-import { Button, Input, Tree, Space, Popconfirm, Tooltip } from 'antd';
+import { Button, Input, Tree, Space, Popconfirm, Tooltip, Tag } from 'antd';
 import { observer } from '@formily/react';
 import { model } from '@formily/reactive';
-import { Empty, PermissionButton } from '@/components';
+import { Ellipsis, Empty, PermissionButton } from '@/components';
 import styles from './index.less';
 import service from '@/pages/link/DataCollect/service';
 import { useEffect } from 'react';
@@ -96,6 +96,29 @@ export default observer((props: Props) => {
   //   };
   // };
 
+  const getState = (record: any) => {
+    if (record) {
+      const colorMap = new Map();
+      colorMap.set('running', 'success');
+      colorMap.set('partialError', 'warning');
+      colorMap.set('failed', 'error');
+      colorMap.set('stopped', 'default');
+      if (record?.state?.value === 'enabled') {
+        return (
+          record?.runningState && (
+            <Tag color={colorMap.get(record?.runningState?.value)}>
+              {record?.runningState?.text}
+            </Tag>
+          )
+        );
+      } else {
+        return <Tag color="processing">禁用</Tag>;
+      }
+    } else {
+      return '';
+    }
+  };
+
   return (
     <div>
       <div>
@@ -113,6 +136,7 @@ export default observer((props: Props) => {
       <div style={{ margin: '16px 0' }}>
         <Button
           type="primary"
+          ghost
           style={{ width: '100%' }}
           icon={<PlusOutlined />}
           onClick={() => {
@@ -120,7 +144,7 @@ export default observer((props: Props) => {
             TreeModel.current = {};
           }}
         >
-          新增
+          新增通道
         </Button>
       </div>
       <div>
@@ -145,23 +169,9 @@ export default observer((props: Props) => {
                         }}
                       >
                         <img width={'20px'} style={{ marginRight: 5 }} src={channelImg} />
-                        <div className={'ellipsis'}>
-                          {/* <BadgeStatus
-                            status={
-                              item && getState(item) && getState(item)?.value
-                                ? getState(item).value
-                                : ''
-                            }
-                            text={item.name}
-                            statusNames={{
-                              running: StatusColorEnum.success,
-                              disabled: StatusColorEnum.processing,
-                              partialError: StatusColorEnum.warning,
-                              failed: StatusColorEnum.error,
-                              stopped: StatusColorEnum.default,
-                            }}
-                          /> */}
-                          {item.name}
+                        <div style={{ display: 'flex' }}>
+                          <Ellipsis title={item.name} style={{ marginRight: 5, maxWidth: 120 }} />
+                          {getState(item)}
                         </div>
                       </div>
                       <div>
@@ -211,8 +221,18 @@ export default observer((props: Props) => {
                             }}
                           >
                             <img width={'20px'} style={{ marginRight: 5 }} src={deviceImg} />
-                            <div style={{ width: '120px' }} className={'ellipsis'}>
-                              {i.name}
+                            <div style={{ display: 'flex' }}>
+                              <span
+                                className={'ellipsis'}
+                                style={{
+                                  marginRight: 5,
+                                  maxWidth: 90,
+                                  color: 'rgba(0, 0, 0, 0.6)',
+                                }}
+                              >
+                                {i.name}
+                              </span>
+                              {getState(i)}
                             </div>
                           </div>
                           <div>

+ 29 - 4
src/pages/system/Permission/Save/index.tsx

@@ -147,8 +147,18 @@ const Save = (props: Props) => {
               properties: {
                 action: {
                   type: 'string',
-                  'x-decorator': 'Editable',
+                  'x-decorator': 'FormItem',
                   'x-component': 'Input',
+                  'x-validator': [
+                    {
+                      required: true,
+                      message: '请输入操作类型',
+                    },
+                    {
+                      max: 64,
+                      message: '最多可输入64个字符',
+                    },
+                  ],
                 },
               },
             },
@@ -165,9 +175,18 @@ const Save = (props: Props) => {
               properties: {
                 name: {
                   type: 'string',
-
-                  'x-decorator': 'Editable',
+                  'x-decorator': 'FormItem',
                   'x-component': 'Input',
+                  'x-validator': [
+                    {
+                      required: true,
+                      message: '请输入名称',
+                    },
+                    {
+                      max: 64,
+                      message: '最多可输入64个字符',
+                    },
+                  ],
                 },
               },
             },
@@ -184,8 +203,14 @@ const Save = (props: Props) => {
               properties: {
                 describe: {
                   type: 'string',
-                  'x-decorator': 'Editable',
+                  'x-decorator': 'FormItem',
                   'x-component': 'Input',
+                  'x-validator': [
+                    {
+                      max: 64,
+                      message: '最多可输入64个字符',
+                    },
+                  ],
                 },
               },
             },

+ 1 - 1
src/pages/system/Permission/index.tsx

@@ -120,7 +120,7 @@ const Permission: React.FC = observer(() => {
       fixed: 'left',
       width: '30%',
       // sorter: true,
-      defaultSortOrder: 'ascend',
+      // defaultSortOrder: 'ascend',
     },
     {
       title: intl.formatMessage({