wzyyy 3 лет назад
Родитель
Сommit
eeecbac854

+ 6 - 1
src/components/DashBoard/baseCard.tsx

@@ -5,6 +5,7 @@ import Echarts from './echarts';
 import Style from './index.less';
 import classNames from 'classnames';
 import React, { forwardRef, useEffect, useState } from 'react';
+import { Empty } from '@/components';
 
 interface BaseCardProps extends HeaderProps, EchartsProps {
   height: number;
@@ -30,7 +31,11 @@ export default forwardRef((props: BaseCardProps, ref) => {
     >
       <Header ref={ref} {...formProps} />
       <div className={Style['echarts-content']}>
-        <Echarts options={myOptions} className={Style['echarts']} />
+        {!!myOptions?.series?.[0]?.data?.length ? (
+          <Echarts options={myOptions} className={Style['echarts']} />
+        ) : (
+          <Empty />
+        )}
         {props.echartsAfter}
       </div>
     </div>

+ 1 - 0
src/components/DashBoard/echarts.tsx

@@ -61,6 +61,7 @@ export default (props: EchartsProps) => {
   const [loading, setLoading] = useState(false);
 
   const initEcharts = (dom: HTMLDivElement) => {
+    if (!dom) return;
     chartsRef.current = chartsRef.current || echarts.init(dom);
     // chartsRef.current.clear()
     if (props.options) {

+ 4 - 2
src/components/Metadata/EditTable/index.tsx

@@ -152,8 +152,10 @@ Editable.Popover = observer((props) => {
   const openPopover = () => {
     setVisible(true);
   };
-  if (field.title === '配置参数' && !props.title) {
-    const path = field.path.segments.filter((key: any) => key !== 'config');
+  if ((field.title === '配置参数' || field.title === '指标数据') && !props.title) {
+    const filterKeys = ['config', 'edit'];
+    const path = field.path.segments.filter((key: any) => !filterKeys.includes(key));
+    console.log('EditTable', path, field.form.values);
     const value = get(field.form.values, path)?.name;
     title = value || '配置参数';
   }

+ 2 - 2
src/pages/device/Instance/Save/index.tsx

@@ -16,7 +16,7 @@ interface Props {
   data?: Partial<DeviceInstance>;
 }
 
-const defaultImage = require('/public/images/device-type-3-big.png');
+const defaultImage = '/images/device-product.png';
 
 const Save = (props: Props) => {
   const { visible, close, data } = props;
@@ -25,7 +25,7 @@ const Save = (props: Props) => {
   const [form] = Form.useForm();
 
   useEffect(() => {
-    if (visible && data) {
+    if (visible && data && Object.keys(data).length) {
       form.setFieldsValue({
         ...data,
       });

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

@@ -17,7 +17,7 @@ interface Props {
   model: 'add' | 'edit';
 }
 
-const defaultImage = require('/public/images/device-product.png');
+const defaultImage = '/images/device-product.png';
 
 const Save = (props: Props) => {
   const { visible, close, data } = props;

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

@@ -8,6 +8,7 @@ import type { ISchema } from '@formily/json-schema';
 import service from '@/pages/link/DataCollect/service';
 import { onlyMessage, testDomain, testIP, testIPv6 } from '@/utils/util';
 import { action } from '@formily/reactive';
+import { RadioCard } from '@/components';
 
 interface Props {
   data: Partial<ChannelItem>;
@@ -17,7 +18,7 @@ interface Props {
 
 export default (props: Props) => {
   const [data, setData] = useState<Partial<ChannelItem>>(props.data);
-  // const [loading, setLoading] = useState<boolean>(false);
+  const [authTypeList, setAuthTypeList] = useState<any[]>([]);
 
   useEffect(() => {
     if (props.data?.id) {
@@ -27,6 +28,18 @@ export default (props: Props) => {
         }
       });
     }
+    service.queryAuthTypeList({}).then((resp) => {
+      if (resp.status === 200) {
+        setAuthTypeList(
+          (resp.result || []).map((item: any) => {
+            return {
+              label: item.text,
+              value: item.value,
+            };
+          }),
+        );
+      }
+    });
   }, [props.data]);
 
   const form = createForm({
@@ -35,7 +48,6 @@ export default (props: Props) => {
   });
 
   const getSecurityPolicyList = () => service.querySecurityPolicyList({});
-  const getAuthTypeList = () => service.queryAuthTypeList({});
   const getSecurityModesList = () => service.querySecurityModesList({});
   const getCertificateList = () => service.queryCertificateList({});
 
@@ -60,6 +72,7 @@ export default (props: Props) => {
       NumberPicker,
       Password,
       FormGrid,
+      RadioCard,
     },
     scope: {
       icon(name: any) {
@@ -126,8 +139,8 @@ export default (props: Props) => {
             },
             'x-disabled': props.data?.id,
             enum: [
-              { label: 'OPC_UA', value: 'OPC_UA' },
-              { label: 'MODBUS_TCP', value: 'MODBUS_TCP' },
+              { label: 'OPC UA', value: 'OPC_UA' },
+              { label: 'MODBUS TCP', value: 'MODBUS_TCP' },
             ],
             'x-validator': [
               {
@@ -314,12 +327,19 @@ export default (props: Props) => {
           },
           'configuration.authType': {
             title: '权限认证',
-            'x-component': 'Select',
+            'x-component': 'RadioCard',
             'x-decorator': 'FormItem',
             'x-decorator-props': {
               gridSpan: 2,
             },
             'x-component-props': {
+              model: 'singular',
+              itemStyle: {
+                display: 'flex',
+                flexDirection: 'column',
+                justifyContent: 'space-around',
+                minWidth: '130px',
+              },
               placeholder: '请选择权限认证',
             },
             'x-validator': [
@@ -329,12 +349,24 @@ export default (props: Props) => {
               },
             ],
             'x-reactions': [
-              '{{useAsyncDataSource(getAuthTypeList)}}',
+              // '{{useAsyncDataSource(getAuthTypeList)}}',
               {
                 dependencies: ['..provider'],
                 fulfill: {
                   state: {
                     visible: '{{$deps[0]==="OPC_UA"}}',
+                    componentProps: {
+                      model: 'singular',
+                      itemStyle: {
+                        display: 'flex',
+                        flexDirection: 'column',
+                        justifyContent: 'space-around',
+                        minWidth: '130px',
+                        height: '50px',
+                      },
+                      placeholder: '请选择权限认证',
+                      options: [...authTypeList],
+                    },
                   },
                 },
               },
@@ -459,7 +491,7 @@ export default (props: Props) => {
           scope={{
             useAsyncDataSource,
             getSecurityPolicyList,
-            getAuthTypeList,
+            // getAuthTypeList,
             getSecurityModesList,
             getCertificateList,
           }}

+ 18 - 8
src/pages/link/DataCollect/components/Device/Save/index.tsx

@@ -7,6 +7,7 @@ import { Form, FormGrid, FormItem, Input, Select, NumberPicker, Password } from
 import type { ISchema } from '@formily/json-schema';
 import service from '@/pages/link/DataCollect/service';
 import { onlyMessage } from '@/utils/util';
+import { RadioCard } from '@/components';
 
 interface Props {
   channelId?: string;
@@ -56,6 +57,7 @@ export default (props: Props) => {
       NumberPicker,
       Password,
       FormGrid,
+      RadioCard,
     },
     scope: {
       icon(name: any) {
@@ -124,21 +126,29 @@ export default (props: Props) => {
             ],
           },
           'circuitBreaker.type': {
-            title: '处理方式',
-            'x-component': 'Select',
+            title: '故障处理',
+            'x-component': 'RadioCard',
             'x-decorator': 'FormItem',
             'x-decorator-props': {
               gridSpan: 2,
             },
             'x-component-props': {
-              placeholder: '请选择处理方式',
+              placeholder: '请选择故障处理',
+              model: 'singular',
+              itemStyle: {
+                display: 'flex',
+                flexDirection: 'column',
+                justifyContent: 'space-around',
+                minWidth: '130px',
+                height: '50px',
+              },
+              options: [
+                { label: '降频', value: 'LowerFrequency' },
+                { label: '熔断', value: 'Break' },
+                { label: '忽略', value: 'Ignore' },
+              ],
             },
             default: 'LowerFrequency',
-            enum: [
-              { label: '降频', value: 'LowerFrequency' },
-              { label: '熔断', value: 'Break' },
-              { label: '忽略', value: 'Ignore' },
-            ],
             'x-validator': [
               {
                 required: true,

+ 16 - 7
src/pages/link/DataCollect/components/Point/Save/modbus.tsx

@@ -17,6 +17,7 @@ import type { ISchema } from '@formily/json-schema';
 import service from '@/pages/link/DataCollect/service';
 import { onlyMessage } from '@/utils/util';
 import { action } from '@formily/reactive';
+import { RadioCard } from '@/components';
 
 interface Props {
   data: Partial<PointItem>;
@@ -49,6 +50,7 @@ export default (props: Props) => {
       Password,
       FormGrid,
       Checkbox,
+      RadioCard,
     },
     scope: {
       icon(name: any) {
@@ -260,20 +262,27 @@ export default (props: Props) => {
           accessModes: {
             title: '访问类型',
             type: 'array',
-            'x-component': 'Select',
+            'x-component': 'RadioCard',
             'x-decorator': 'FormItem',
             'x-decorator-props': {
               gridSpan: 2,
             },
             'x-component-props': {
               placeholder: '请选择访问类型',
-              mode: 'multiple',
+              model: 'multiple',
+              itemStyle: {
+                display: 'flex',
+                flexDirection: 'column',
+                justifyContent: 'space-around',
+                minWidth: '130px',
+                height: '50px',
+              },
+              options: [
+                { label: '读', value: 'read' },
+                { label: '写', value: 'write' },
+                { label: '订阅', value: 'subscribe' },
+              ],
             },
-            enum: [
-              { label: '读', value: 'read' },
-              { label: '写', value: 'write' },
-              { label: '订阅', value: 'subscribe' },
-            ],
             'x-validator': [
               {
                 required: true,

+ 17 - 8
src/pages/link/DataCollect/components/Point/Save/opc-ua.tsx

@@ -17,6 +17,7 @@ import type { ISchema } from '@formily/json-schema';
 import service from '@/pages/link/DataCollect/service';
 import { onlyMessage } from '@/utils/util';
 import { action } from '@formily/reactive';
+import { RadioCard } from '@/components';
 
 interface Props {
   data: Partial<PointItem>;
@@ -50,6 +51,7 @@ export default (props: Props) => {
       Password,
       FormGrid,
       Checkbox,
+      RadioCard,
     },
     scope: {
       icon(name: any) {
@@ -145,20 +147,27 @@ export default (props: Props) => {
           accessModes: {
             title: '访问类型',
             type: 'array',
-            'x-component': 'Select',
+            'x-component': 'RadioCard',
             'x-decorator': 'FormItem',
             'x-decorator-props': {
               gridSpan: 2,
             },
             'x-component-props': {
               placeholder: '请选择访问类型',
-              mode: 'multiple',
+              model: 'multiple',
+              itemStyle: {
+                display: 'flex',
+                flexDirection: 'column',
+                justifyContent: 'space-around',
+                minWidth: '130px',
+                height: '50px',
+              },
+              options: [
+                { label: '读', value: 'read' },
+                { label: '写', value: 'write' },
+                { label: '订阅', value: 'subscribe' },
+              ],
             },
-            enum: [
-              { label: '读', value: 'read' },
-              { label: '写', value: 'write' },
-              { label: '订阅', value: 'subscribe' },
-            ],
             'x-validator': [
               {
                 required: true,
@@ -175,7 +184,7 @@ export default (props: Props) => {
             },
             default: 3000,
             'x-reactions': {
-              dependencies: ['.accessModes'],
+              dependencies: ['..accessModes'],
               fulfill: {
                 state: {
                   visible: '{{($deps[0] || []).includes("subscribe")}}',

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

@@ -159,7 +159,7 @@ export default observer((props: Props) => {
                   key="button"
                   type="primary"
                 >
-                  新增
+                  {props?.provider === 'OPC_UA' ? '扫描' : '新增'}
                 </PermissionButton>
               </div>
             )}

+ 1 - 1
src/pages/media/Device/Save/index.tsx

@@ -12,7 +12,7 @@ import styles from '../../Cascade/Save/index.less';
 import { useDomFullHeight } from '@/hooks';
 
 const DefaultAccessType = 'gb28181-2016';
-const defaultImage = require('/public/images/device-media.png');
+const defaultImage = '/images/device-media.png';
 
 const Save = () => {
   const location: any = useLocation();