Bläddra i källkod

fix: merge next

wzyyy 3 år sedan
förälder
incheckning
39007b13af

+ 1 - 1
src/components/FMonacoEditor/index.tsx

@@ -12,7 +12,7 @@ export const JMonacoEditor = (props: Props) => {
   const monacoEditorRef = useRef<any>();
   const monacoEditorRef = useRef<any>();
 
 
   const editorFormat = (editor: any) => {
   const editorFormat = (editor: any) => {
-    editor.getAction('editor.action.formatDocument').run();
+    editor.getAction('editor.action.formatDocument')?.run();
   };
   };
 
 
   useEffect(() => {
   useEffect(() => {

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

@@ -24,6 +24,7 @@ interface Props {
 const Save = (props: Props) => {
 const Save = (props: Props) => {
   const { data, close, visible } = props;
   const { data, close, visible } = props;
   const fileInfo = useRef<any>({});
   const fileInfo = useRef<any>({});
+  // const disabled = useRef<boolean>(false);
   const signMethod = useRef<'md5' | 'sha256'>('md5');
   const signMethod = useRef<'md5' | 'sha256'>('md5');
 
 
   const form = createForm({
   const form = createForm({
@@ -32,6 +33,12 @@ const Save = (props: Props) => {
     effects: () => {
     effects: () => {
       onFormInit(async (form1) => {
       onFormInit(async (form1) => {
         if (!data?.id) return;
         if (!data?.id) return;
+        // const resp = await service.task({terms: [{ column: 'firmwareId', value: data?.id }]})
+        // if(resp.status === 200 && resp.result?.total){
+        //   disabled.current = true
+        // } else {
+        //   disabled.current = false
+        // }
         form1.setInitialValues({ ...data, upload: { url: data?.url } });
         form1.setInitialValues({ ...data, upload: { url: data?.url } });
       });
       });
       onFieldValueChange('signMethod', (field, f) => {
       onFieldValueChange('signMethod', (field, f) => {
@@ -424,7 +431,7 @@ const Save = (props: Props) => {
             terms: [{ terms: [{ column: 'firmwareId', value: data.id }] }],
             terms: [{ terms: [{ column: 'firmwareId', value: data.id }] }],
           });
           });
           if (res.status === 200 && res.result.data && res.result.data.length !== 0) {
           if (res.status === 200 && res.result.data && res.result.data.length !== 0) {
-            onlyMessage('该固件有升级任务,不可编辑', 'warning');
+            onlyMessage('该固件有升级任务,不可编辑', 'error');
           } else {
           } else {
             save();
             save();
           }
           }

+ 1 - 1
src/pages/device/Firmware/Task/Save/SelectDevices.tsx

@@ -60,7 +60,7 @@ const SelectDevices = observer((props: Props) => {
       title: '固件版本',
       title: '固件版本',
       dataIndex: 'firmwareInfo',
       dataIndex: 'firmwareInfo',
       ellipsis: true,
       ellipsis: true,
-      render: (text: any, record: any) => record?.version || '',
+      render: (text: any, record: any) => record?.firmwareInfo?.version || '',
     },
     },
     {
     {
       title: intl.formatMessage({
       title: intl.formatMessage({

+ 4 - 2
src/pages/device/Instance/Detail/Diagnose/Status/index.tsx

@@ -82,6 +82,7 @@ const Status = observer((props: Props) => {
   const modifyArrayList = (oldList: ListProps[], item: ListProps, index?: number) => {
   const modifyArrayList = (oldList: ListProps[], item: ListProps, index?: number) => {
     let newList: ListProps[] = [];
     let newList: ListProps[] = [];
     if (index !== 0 && !index) {
     if (index !== 0 && !index) {
+      // 添加
       for (let i = 0; i < oldList.length; i++) {
       for (let i = 0; i < oldList.length; i++) {
         const dt = oldList[i];
         const dt = oldList[i];
         if (item.key === dt.key) {
         if (item.key === dt.key) {
@@ -91,6 +92,7 @@ const Status = observer((props: Props) => {
         }
         }
       }
       }
     } else {
     } else {
+      // 修改
       oldList.splice(index, 0, item);
       oldList.splice(index, 0, item);
       newList = [...oldList];
       newList = [...oldList];
     }
     }
@@ -875,9 +877,9 @@ const Status = observer((props: Props) => {
         const response = await queryProductConfigRun(device.productId);
         const response = await queryProductConfigRun(device.productId);
         if (response.status === 200 && response.result.length > 0) {
         if (response.status === 200 && response.result.length > 0) {
           DiagnoseStatusModel.configuration.product = response.result;
           DiagnoseStatusModel.configuration.product = response.result;
-          const list = [...DiagnoseStatusModel.list];
           const configuration = DiagnoseStatusModel.product?.configuration || {};
           const configuration = DiagnoseStatusModel.product?.configuration || {};
           response.result.map((item: any, i: number) => {
           response.result.map((item: any, i: number) => {
+            const list = [...DiagnoseStatusModel.list];
             if (!_.map(list, 'key').includes(`product-auth${i}`)) {
             if (!_.map(list, 'key').includes(`product-auth${i}`)) {
               DiagnoseStatusModel.list = modifyArrayList(
               DiagnoseStatusModel.list = modifyArrayList(
                 DiagnoseStatusModel.list,
                 DiagnoseStatusModel.list,
@@ -1039,9 +1041,9 @@ const Status = observer((props: Props) => {
         const response = await queryDeviceConfigRun(device.id);
         const response = await queryDeviceConfigRun(device.id);
         if (response.status === 200 && response.result.length > 0) {
         if (response.status === 200 && response.result.length > 0) {
           DiagnoseStatusModel.configuration.device = response.result;
           DiagnoseStatusModel.configuration.device = response.result;
-          const list = [...DiagnoseStatusModel.list];
           const configuration = device?.configuration || {};
           const configuration = device?.configuration || {};
           response.result.map((item: any, i: number) => {
           response.result.map((item: any, i: number) => {
+            const list = [...DiagnoseStatusModel.list];
             if (!_.map(list, 'key').includes(`device-auth${i}`)) {
             if (!_.map(list, 'key').includes(`device-auth${i}`)) {
               DiagnoseStatusModel.list = modifyArrayList(
               DiagnoseStatusModel.list = modifyArrayList(
                 DiagnoseStatusModel.list,
                 DiagnoseStatusModel.list,

+ 3 - 0
src/pages/device/Instance/Detail/Info/index.tsx

@@ -114,6 +114,9 @@ const Info = observer(() => {
           >
           >
             {InstanceModel.detail?.deviceType?.text}
             {InstanceModel.detail?.deviceType?.text}
           </Descriptions.Item>
           </Descriptions.Item>
+          <Descriptions.Item label={'固件版本'}>
+            {InstanceModel.detail?.firmwareInfo?.version || ''}
+          </Descriptions.Item>
           <Descriptions.Item
           <Descriptions.Item
             label={intl.formatMessage({
             label={intl.formatMessage({
               id: 'pages.device.instanceDetail.transportProtocol',
               id: 'pages.device.instanceDetail.transportProtocol',

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

@@ -93,7 +93,8 @@ const NormalUpload = (props: any) => {
           setErrMessage(res.message || '失败');
           setErrMessage(res.message || '失败');
         }
         }
       };
       };
-      source.onerror = () => {
+      source.onerror = (e) => {
+        if (e.status === 403) setErrMessage('暂无权限,请联系管理员');
         setFlag(false);
         setFlag(false);
         source.close();
         source.close();
       };
       };

+ 3 - 0
src/pages/device/Instance/typings.d.ts

@@ -45,6 +45,9 @@ export type DeviceInstance = {
   features?: any[];
   features?: any[];
   parentId?: string;
   parentId?: string;
   classifiedName?: string;
   classifiedName?: string;
+  firmwareInfo?: {
+    version?: string;
+  };
 };
 };
 
 
 type Unit = {
 type Unit = {

+ 88 - 29
src/pages/device/components/Metadata/Base/Edit/index.tsx

@@ -22,6 +22,7 @@ import {
   Radio,
   Radio,
   Select,
   Select,
   Space,
   Space,
+  Switch,
 } from '@formily/antd';
 } from '@formily/antd';
 import type { ISchema } from '@formily/json-schema';
 import type { ISchema } from '@formily/json-schema';
 import {
 import {
@@ -174,6 +175,7 @@ const Edit = observer((props: Props) => {
       Checkbox,
       Checkbox,
       FormGrid,
       FormGrid,
       DatePicker,
       DatePicker,
+      Switch,
       FIndicators,
       FIndicators,
       InputSelect,
       InputSelect,
     },
     },
@@ -615,11 +617,12 @@ const Edit = observer((props: Props) => {
             type: 'object',
             type: 'object',
             title: '规则配置',
             title: '规则配置',
             'x-visible': false,
             'x-visible': false,
-            'x-component': 'Editable.Popover',
+            // 'x-component': 'Editable.Popover',
             'x-reactions': {
             'x-reactions': {
               dependencies: ['.source'],
               dependencies: ['.source'],
               fulfill: {
               fulfill: {
                 state: {
                 state: {
+                  // visible: '{{$deps[0]}}',
                   visible: '{{$deps[0]==="rule"}}',
                   visible: '{{$deps[0]==="rule"}}',
                 },
                 },
               },
               },
@@ -643,16 +646,37 @@ const Edit = observer((props: Props) => {
               //     },
               //     },
               //   ],
               //   ],
               // },
               // },
-
+              isVirtualRule: {
+                type: 'boolean',
+                title: '规则配置',
+                'x-decorator': 'FormItem',
+                'x-component': 'Switch',
+              },
               windowType: {
               windowType: {
                 type: 'string',
                 type: 'string',
                 title: '窗口',
                 title: '窗口',
                 'x-decorator': 'FormItem',
                 'x-decorator': 'FormItem',
                 'x-component': 'Select',
                 'x-component': 'Select',
+                required: true,
+                'x-validator': [
+                  {
+                    required: true,
+                    message: `请选择窗口`,
+                  },
+                ],
                 enum: [
                 enum: [
                   { label: '时间窗口', value: 'time' },
                   { label: '时间窗口', value: 'time' },
                   { label: '次数窗口', value: 'num' },
                   { label: '次数窗口', value: 'num' },
                 ],
                 ],
+                'x-visible': false,
+                'x-reactions': {
+                  dependencies: ['.isVirtualRule'],
+                  fulfill: {
+                    state: {
+                      visible: '{{$deps[0]}}',
+                    },
+                  },
+                },
                 'x-component-props': {
                 'x-component-props': {
                   allowClear: true,
                   allowClear: true,
                 },
                 },
@@ -675,29 +699,60 @@ const Edit = observer((props: Props) => {
                 title: '聚合函数',
                 title: '聚合函数',
                 'x-decorator': 'FormItem',
                 'x-decorator': 'FormItem',
                 'x-component': 'Select',
                 'x-component': 'Select',
-                'x-reactions': '{{useAsyncDataSource(getStreamingAggType)}}',
+                required: true,
+                'x-visible': false,
+                'x-validator': [
+                  {
+                    required: true,
+                    message: `请选择聚合函数`,
+                  },
+                ],
+                'x-reactions': [
+                  {
+                    dependencies: ['.isVirtualRule'],
+                    fulfill: {
+                      state: {
+                        visible: '{{$deps[0]}}',
+                      },
+                    },
+                  },
+                  '{{useAsyncDataSource(getStreamingAggType)}}',
+                ],
               },
               },
               window: {
               window: {
                 type: 'object',
                 type: 'object',
+                'x-visible': false,
+                'x-reactions': {
+                  dependencies: ['.isVirtualRule'],
+                  fulfill: {
+                    state: {
+                      visible: '{{$deps[0]}}',
+                    },
+                  },
+                },
                 properties: {
                 properties: {
                   span: {
                   span: {
                     title: '窗口长度',
                     title: '窗口长度',
-                    'x-component': 'Input',
+                    'x-component': 'NumberPicker',
                     'x-decorator': 'FormItem',
                     'x-decorator': 'FormItem',
-                    format: 'number',
+                    required: true,
+                    'x-component-props': {
+                      style: {
+                        width: '100%',
+                      },
+                    },
                     'x-validator': [
                     'x-validator': [
                       {
                       {
-                        // triggerType: 'onBlur',
-                        validator: (value: any) => {
-                          return new Promise((resolve) => {
-                            const number = Number(value);
-                            if (number <= 0 || value.length > 64 || /[.]/.test(value)) {
-                              resolve('请输入非0正整数,最多可输入64个字符');
-                            } else {
-                              resolve('');
-                            }
-                          });
-                        },
+                        required: true,
+                        message: `请输入窗口长度`,
+                      },
+                      {
+                        format: 'integer',
+                        message: '请输入正整数',
+                      },
+                      {
+                        min: 1,
+                        message: '请输入正整数',
                       },
                       },
                     ],
                     ],
                     'x-reactions': [
                     'x-reactions': [
@@ -732,22 +787,26 @@ const Edit = observer((props: Props) => {
                   },
                   },
                   every: {
                   every: {
                     title: '步长',
                     title: '步长',
-                    'x-component': 'Input',
+                    'x-component': 'NumberPicker',
                     'x-decorator': 'FormItem',
                     'x-decorator': 'FormItem',
-                    format: 'number',
+                    required: true,
+                    'x-component-props': {
+                      style: {
+                        width: '100%',
+                      },
+                    },
                     'x-validator': [
                     'x-validator': [
                       {
                       {
-                        // triggerType: 'onBlur',
-                        validator: (value: any) => {
-                          return new Promise((resolve) => {
-                            const number = Number(value);
-                            if (number <= 0 || value.length > 64 || /[.]/.test(value)) {
-                              resolve('请输入非0正整数,最多可输入64个字符');
-                            } else {
-                              resolve('');
-                            }
-                          });
-                        },
+                        required: true,
+                        message: `请输入步长`,
+                      },
+                      {
+                        format: 'integer',
+                        message: '请输入正整数',
+                      },
+                      {
+                        min: 1,
+                        message: '请输入正整数',
                       },
                       },
                     ],
                     ],
                     'x-reactions': [
                     'x-reactions': [

+ 1 - 1
src/pages/link/DashBoard/index.tsx

@@ -260,7 +260,7 @@ export default () => {
         type: 'value',
         type: 'value',
       },
       },
       grid: {
       grid: {
-        left: 50,
+        left: 60,
         right: 0,
         right: 0,
         top: 10,
         top: 10,
         bottom: 20,
         bottom: 20,

+ 45 - 43
src/pages/media/Device/Channel/index.tsx

@@ -8,7 +8,7 @@ import { ChannelItem } from '@/pages/media/Device/Channel/typings';
 import { useHistory, useIntl, useLocation } from 'umi';
 import { useHistory, useIntl, useLocation } from 'umi';
 import { AIcon, BadgeStatus } from '@/components';
 import { AIcon, BadgeStatus } from '@/components';
 import { StatusColorEnum } from '@/components/BadgeStatus';
 import { StatusColorEnum } from '@/components/BadgeStatus';
-import { Button, message, Popconfirm, Tooltip } from 'antd';
+import { Button, message, Tooltip } from 'antd';
 import {
 import {
   DeleteOutlined,
   DeleteOutlined,
   EditOutlined,
   EditOutlined,
@@ -20,11 +20,11 @@ import Save from './Save';
 import Service from './service';
 import Service from './service';
 import { ProviderValue } from '../index';
 import { ProviderValue } from '../index';
 import Live from './Live';
 import Live from './Live';
-import { getButtonPermission, getMenuPathByCode, MENUS_CODE } from '@/utils/menu';
+import { getMenuPathByCode, MENUS_CODE } from '@/utils/menu';
 import Tree from './Tree';
 import Tree from './Tree';
 import { useDomFullHeight } from '@/hooks';
 import { useDomFullHeight } from '@/hooks';
 import classnames from 'classnames';
 import classnames from 'classnames';
-
+import { PermissionButton } from '@/components';
 export const service = new Service('media');
 export const service = new Service('media');
 
 
 export default () => {
 export default () => {
@@ -39,7 +39,8 @@ export default () => {
   const [type, setType] = useState('');
   const [type, setType] = useState('');
   const { minHeight } = useDomFullHeight(`.channelDevice`, 24);
   const { minHeight } = useDomFullHeight(`.channelDevice`, 24);
   const [show, setShow] = useState(false);
   const [show, setShow] = useState(false);
-
+  const permissionCode = 'media/Device';
+  const { permission } = PermissionButton.usePermission(permissionCode);
   const location = useLocation();
   const location = useLocation();
   const history = useHistory();
   const history = useHistory();
 
 
@@ -140,25 +141,24 @@ export default () => {
       align: 'left',
       align: 'left',
       width: 160,
       width: 160,
       render: (_, record) => [
       render: (_, record) => [
-        <Tooltip
-          key="edit"
-          title={intl.formatMessage({
-            id: 'pages.data.option.edit',
-            defaultMessage: '编辑',
-          })}
+        <PermissionButton
+          key="editable"
+          tooltip={{
+            title: intl.formatMessage({
+              id: 'pages.data.option.edit',
+              defaultMessage: '编辑',
+            }),
+          }}
+          isPermission={permission.update}
+          style={{ padding: 0 }}
+          type="link"
+          onClick={() => {
+            setCurrent(record);
+            setVisible(true);
+          }}
         >
         >
-          <Button
-            style={{ padding: 0 }}
-            type="link"
-            onClick={() => {
-              setCurrent(record);
-              setVisible(true);
-            }}
-            disabled={getButtonPermission('media/Device', 'update')}
-          >
-            <EditOutlined />
-          </Button>
-        </Tooltip>,
+          <EditOutlined />
+        </PermissionButton>,
         <Tooltip key={'live'} title={'播放'}>
         <Tooltip key={'live'} title={'播放'}>
           <a
           <a
             onClick={() => {
             onClick={() => {
@@ -185,27 +185,29 @@ export default () => {
           </a>
           </a>
         </Tooltip>,
         </Tooltip>,
         type === ProviderValue.FIXED ? (
         type === ProviderValue.FIXED ? (
-          <Popconfirm
+          <PermissionButton
+            type="link"
             key="delete"
             key="delete"
-            title={intl.formatMessage({
-              id: 'page.table.isDelete',
-              defaultMessage: '是否删除?',
-            })}
-            onConfirm={async () => {
-              deleteItem(record.id);
+            style={{ padding: 0 }}
+            popConfirm={{
+              title: intl.formatMessage({
+                id: 'pages.system.role.option.delete',
+                defaultMessage: '确定要删除吗',
+              }),
+              onConfirm: () => {
+                deleteItem(record.id);
+              },
+            }}
+            tooltip={{
+              title: intl.formatMessage({
+                id: 'pages.data.option.delete',
+                defaultMessage: '删除',
+              }),
             }}
             }}
-            disabled={getButtonPermission('media/Device', 'delete')}
+            isPermission={permission.delete || permission.update}
           >
           >
-            <Tooltip title="删除">
-              <Button
-                type={'link'}
-                style={{ padding: 0 }}
-                disabled={getButtonPermission('media/Device', 'delete')}
-              >
-                <DeleteOutlined />
-              </Button>
-            </Tooltip>
-          </Popconfirm>
+            <DeleteOutlined />
+          </PermissionButton>
         ) : null,
         ) : null,
       ],
       ],
     },
     },
@@ -289,13 +291,13 @@ export default () => {
                   </Button>
                   </Button>
                 </Tooltip>
                 </Tooltip>
               ) : (
               ) : (
-                <Button
+                <PermissionButton
                   onClick={() => {
                   onClick={() => {
                     setCurrent(undefined);
                     setCurrent(undefined);
                     setVisible(true);
                     setVisible(true);
                   }}
                   }}
+                  isPermission={permission.add || permission.update}
                   key="button"
                   key="button"
-                  disabled={getButtonPermission('media/Device', 'add')}
                   icon={<PlusOutlined />}
                   icon={<PlusOutlined />}
                   type="primary"
                   type="primary"
                 >
                 >
@@ -303,7 +305,7 @@ export default () => {
                     id: 'pages.data.option.add',
                     id: 'pages.data.option.add',
                     defaultMessage: '新增',
                     defaultMessage: '新增',
                   })}
                   })}
-                </Button>
+                </PermissionButton>
               ),
               ),
             ]}
             ]}
           />
           />