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

+ 1 - 0
src/components/ProTableCard/CardItems/Scene/index.tsx

@@ -117,6 +117,7 @@ const actionRender = (action: ActionsType) => {
 };
 // 过滤器
 const actionFilter = (terms: any, isLast: boolean, index: number) => {
+  if (!Array.isArray(terms)) return '';
   let str = `动作${index + 1} `;
   terms?.forEach((item: any, iindex: number) => {
     if (isArray(item.terms)) {

+ 4 - 10
src/pages/device/Category/Save/index.tsx

@@ -123,14 +123,11 @@ const Save = (props: Props) => {
         name: 'name',
       },
       sortIndex: {
-        title: intl.formatMessage({
-          id: 'pages.device.category.sortIndex',
-          defaultMessage: '排序',
-        }),
+        title: '排序',
         'x-decorator': 'FormItem',
         'x-component': 'NumberPicker',
         'x-component-props': {
-          placeholder: '请输入分类排序',
+          placeholder: '请输入排序',
           min: 1,
         },
         name: 'sortIndex',
@@ -145,7 +142,7 @@ const Save = (props: Props) => {
         type: 'string',
         title: intl.formatMessage({
           id: 'pages.table.describe',
-          defaultMessage: '描述信息',
+          defaultMessage: '说明',
         }),
         'x-decorator': 'FormItem',
         'x-component': 'Input.TextArea',
@@ -163,10 +160,7 @@ const Save = (props: Props) => {
   return (
     <Modal
       maskClosable={false}
-      title={intl.formatMessage({
-        id: `pages.data.option.${props.data.id ? 'edit' : 'add'}`,
-        defaultMessage: '新增',
-      })}
+      title={`${!props.data.id ? '新增' : '编辑'}${state.parentId ? '子分类' : '分类'}`}
       visible={props.visible}
       onCancel={() => props.close()}
       onOk={save}

+ 2 - 5
src/pages/device/Category/index.tsx

@@ -60,15 +60,12 @@ const Category = observer(() => {
 
   const columns: ProColumns<CategoryItem>[] = [
     {
-      title: intl.formatMessage({
-        id: 'pages.device.category.name',
-        defaultMessage: '分类名称',
-      }),
+      title: '名称',
       dataIndex: 'name',
       ellipsis: true,
     },
     {
-      title: '分类排序',
+      title: '排序',
       dataIndex: 'sortIndex',
       valueType: 'digit',
       sorter: true,

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

@@ -89,6 +89,8 @@ const Instance = () => {
         });
       });
 
+      console.log(_terms);
+
       if (location.state && location.state?.save) {
         setVisible(true);
         setCurrent({});

+ 2 - 3
src/pages/device/Product/index.tsx

@@ -84,7 +84,6 @@ const Product = observer(() => {
 
   useEffect(() => {
     const { state } = location;
-    console.log(state);
 
     if (state && state.save) {
       setCurrent(undefined);
@@ -248,7 +247,7 @@ const Product = observer(() => {
     {
       title: 'ID',
       dataIndex: 'id',
-      width: 300,
+      width: 200,
       ellipsis: true,
       fixed: 'left',
     },
@@ -324,7 +323,7 @@ const Product = observer(() => {
           status: 'gateway',
         },
       },
-      width: 150,
+      width: 120,
       render: (_, row) => <>{row.deviceType ? row.deviceType.text : undefined}</>,
     },
     {

+ 11 - 0
src/pages/device/components/Metadata/Base/columns.tsx

@@ -2,6 +2,12 @@ import type { ProColumns } from '@jetlinks/pro-table';
 import type { MetadataItem } from '@/pages/device/Product/typings';
 import { Tag } from 'antd';
 
+const SourceMap = {
+  device: '设备',
+  manual: '手动',
+  rule: '规则',
+};
+
 const BaseColumns: ProColumns<MetadataItem>[] = [
   // {
   //   dataIndex: 'index',
@@ -66,6 +72,11 @@ const PropertyColumns: ProColumns<MetadataItem>[] = BaseColumns.concat([
     render: (text: any) => text?.type,
   },
   {
+    title: '数据类型',
+    dataIndex: 'expands',
+    render: (text: any) => SourceMap[text?.source],
+  },
+  {
     title: '读写类型',
     dataIndex: 'expands',
     render: (text: any) =>

+ 2 - 1
src/pages/device/components/Metadata/Base/index.tsx

@@ -121,6 +121,7 @@ const BaseMetadata = observer((props: Props) => {
 
   const initData = useCallback(async () => {
     const result = await DB.getDB().table(`${type}`).toArray();
+    console.log(result);
     setData(result.sort((a, b) => b?.sortsIndex - a?.sortsIndex));
   }, [param.id, type]);
 
@@ -178,7 +179,7 @@ const BaseMetadata = observer((props: Props) => {
           },
         }}
         toolBarRender={() => [
-          props.type === 'properties' && (
+          props.type === 'properties' && target === 'device' && (
             <PermissionButton
               isPermission={props.permission.update}
               onClick={() => {

+ 7 - 0
src/pages/device/components/Metadata/index.less

@@ -1,4 +1,11 @@
 @import '~antd/es/style/themes/default.less';
+.metadataNav {
+  :global {
+    .ant-card-body {
+      padding: 0;
+    }
+  }
+}
 
 .tips {
   position: absolute;

+ 19 - 23
src/pages/link/Certificate/Detail/index.tsx

@@ -1,7 +1,7 @@
 import PermissionButton from '@/components/PermissionButton';
 import usePermissions from '@/hooks/permission';
 import { PageContainer } from '@ant-design/pro-layout';
-import { Form, FormButtonGroup, FormItem } from '@formily/antd';
+import { Form, FormItem } from '@formily/antd';
 import type { ISchema } from '@formily/json-schema';
 import { Card, Col, Input, Row } from 'antd';
 import { createSchemaField, observer } from '@formily/react';
@@ -144,28 +144,24 @@ const Detail = observer(() => {
           <Col span={12}>
             <Form form={form} layout="vertical">
               <SchemaField schema={schema} />
-              <FormButtonGroup.Sticky>
-                <FormButtonGroup.FormItem>
-                  {!view && (
-                    <PermissionButton
-                      type="primary"
-                      isPermission={getOtherPermission(['add', 'update'])}
-                      onClick={async () => {
-                        const data: any = await form.submit();
-                        const response: any = data.id
-                          ? await service.update(data)
-                          : await service.save(data);
-                        if (response.status === 200) {
-                          onlyMessage('操作成功');
-                          history.back();
-                        }
-                      }}
-                    >
-                      保存
-                    </PermissionButton>
-                  )}
-                </FormButtonGroup.FormItem>
-              </FormButtonGroup.Sticky>
+              {!view && (
+                <PermissionButton
+                  type="primary"
+                  isPermission={getOtherPermission(['add', 'update'])}
+                  onClick={async () => {
+                    const data: any = await form.submit();
+                    const response: any = data.id
+                      ? await service.update(data)
+                      : await service.save(data);
+                    if (response.status === 200) {
+                      onlyMessage('操作成功');
+                      history.back();
+                    }
+                  }}
+                >
+                  保存
+                </PermissionButton>
+              )}
             </Form>
           </Col>
           <Col span={12}>

+ 17 - 9
src/pages/link/Type/Detail/index.tsx

@@ -130,15 +130,23 @@ const Save = observer(() => {
             if (param?.id && param.id !== ':id') {
               const resp = await service.detail(param.id);
               const data = resp?.result || {};
+              // if (data?.shareCluster === false) {
+              //   const cluster = (data?.cluster || []).map((item: any) => {
+              //     return {
+              //       ...item.configuration,
+              //       configuration: item,
+              //     };
+              //   });
+              //   console.log(cluster, 'cluster')
+              //   const obj = _.cloneDeep({ ...data, cluster });
+              //   form1.setValues({ ...obj });
+              // }
               if (data?.shareCluster === false) {
-                const cluster = (data?.cluster || []).map((item: any) => {
-                  return {
-                    ...item.configuration,
-                    configuration: item,
-                  };
-                });
-                const obj = _.cloneDeep({ ...data, cluster });
-                form1.setValues(obj);
+                const _cluster = _.cloneDeep(data.cluster[0]);
+                data.cluster[0] = {
+                  ..._cluster.configuration,
+                };
+                form1.setValues({ ...data });
               } else {
                 form1.setValues({ ...data });
               }
@@ -225,7 +233,7 @@ const Save = observer(() => {
           });
         },
       }),
-    [],
+    [param.id],
   );
 
   const SchemaField = createSchemaField({

+ 30 - 29
src/pages/rule-engine/Alarm/Config/index.tsx

@@ -2,7 +2,7 @@ import { PageContainer } from '@ant-design/pro-layout';
 import { Badge, Card, Col, Descriptions, Divider, Image, Row, Table, Tooltip } from 'antd';
 import TitleComponent from '@/components/TitleComponent';
 import { createSchemaField } from '@formily/react';
-import { ArrayItems, Form, FormButtonGroup, FormGrid, FormItem, Input } from '@formily/antd';
+import { ArrayItems, Form, FormGrid, FormItem, Input } from '@formily/antd';
 import type { ISchema } from '@formily/json-schema';
 import { useEffect, useMemo, useState } from 'react';
 import { createForm, onFormInit } from '@formily/core';
@@ -213,7 +213,7 @@ const Config = () => {
               'x-decorator': 'FormItem',
               'x-component': 'FLevelInput',
               'x-decorator-props': {
-                gridSpan: 23,
+                gridSpan: 24,
               },
               'x-validator': [
                 {
@@ -314,22 +314,15 @@ const Config = () => {
           <TitleComponent data={'告警级别配置'} />
           <Form form={levelForm}>
             <SchemaField schema={levelSchema} />
-            <FormButtonGroup.Sticky>
-              <FormButtonGroup.FormItem>
-                <PermissionButton
-                  key={'update'}
-                  type={'primary'}
-                  style={{ padding: 0, width: 50 }}
-                  isPermission={permission.update}
-                  onClick={handleSaveLevel}
-                >
-                  保存
-                </PermissionButton>
-                {/* <Button type="primary" onClick={handleSaveLevel}>
-                  保存
-                </Button> */}
-              </FormButtonGroup.FormItem>
-            </FormButtonGroup.Sticky>
+            <PermissionButton
+              key={'update'}
+              type={'primary'}
+              style={{ padding: 0, width: 50 }}
+              isPermission={permission.update}
+              onClick={handleSaveLevel}
+            >
+              保存
+            </PermissionButton>
           </Form>
         </Card>
       </Col>
@@ -377,21 +370,25 @@ const Config = () => {
                 </span>
               }
             />
-            <Descriptions bordered column={2}>
-              <Descriptions.Item label="kafka地址">
+            <Descriptions key={'output'} bordered column={2} labelStyle={{ width: 112 }}>
+              <Descriptions.Item label="kafka地址" contentStyle={{ minWidth: 200 }}>
                 {output?.data?.config?.config?.address && (
-                  <Badge status={output?.running ? 'success' : 'error'} />
+                  <Badge
+                    status={output?.running ? 'success' : 'error'}
+                    text={output?.data?.config?.config?.address || ''}
+                  />
                 )}
-                {output?.data?.config?.config?.address || ''}
               </Descriptions.Item>
               <Descriptions.Item label="topic">
                 {output?.data?.config?.config?.topic || ''}
               </Descriptions.Item>
               <Descriptions.Item label="状态" span={2}>
                 {output?.data?.state && (
-                  <Badge status={output?.data?.state?.value === 'enabled' ? 'success' : 'error'} />
+                  <Badge
+                    status={output?.data?.state?.value === 'enabled' ? 'success' : 'error'}
+                    text={output?.data?.state?.text || ''}
+                  />
                 )}
-                {output?.data?.state?.text || ''}
               </Descriptions.Item>
             </Descriptions>
             <Divider />
@@ -424,21 +421,25 @@ const Config = () => {
                 </span>
               }
             />
-            <Descriptions bordered column={2}>
+            <Descriptions key={'input'} bordered column={2} labelStyle={{ width: 112 }}>
               <Descriptions.Item label="kafka地址">
                 {input?.data?.config?.config?.address && (
-                  <Badge status={input?.running ? 'success' : 'error'} />
+                  <Badge
+                    status={input?.running ? 'success' : 'error'}
+                    text={input?.data?.config?.config?.address || ''}
+                  />
                 )}
-                {input?.data?.config?.config?.address || ''}
               </Descriptions.Item>
               <Descriptions.Item label="topic">
                 {input?.data?.config?.config?.topic || ''}
               </Descriptions.Item>
               <Descriptions.Item label="状态" span={2}>
                 {input?.data?.state && (
-                  <Badge status={input?.data?.state?.value === 'enabled' ? 'success' : 'error'} />
+                  <Badge
+                    status={input?.data?.state?.value === 'enabled' ? 'success' : 'error'}
+                    text={input?.data?.state?.text || ''}
+                  />
                 )}
-                {input?.data?.state?.text || ''}
               </Descriptions.Item>
             </Descriptions>
           </Card>

+ 19 - 14
src/pages/rule-engine/Alarm/Configuration/Save/Base/index.tsx

@@ -1,10 +1,10 @@
 import Service from '@/pages/rule-engine/Alarm/Configuration/service';
 import { Typography } from 'antd';
 import { service as ConfigService } from '@/pages/rule-engine/Alarm/Config';
-import { useMemo } from 'react';
+import { useMemo, useState } from 'react';
 import { createForm, onFormInit } from '@formily/core';
 import { createSchemaField } from '@formily/react';
-import { Form, FormButtonGroup, FormGrid, FormItem, Input, Radio, Select } from '@formily/antd';
+import { Form, FormGrid, FormItem, Input, Radio, Select } from '@formily/antd';
 import { onlyMessage, useAsyncDataSource } from '@/utils/util';
 import { PermissionButton } from '@/components';
 import { ISchema } from '@formily/json-schema';
@@ -13,6 +13,7 @@ import useLocation from '@/hooks/route/useLocation';
 import { getMenuPathByCode } from '@/utils/menu';
 import { useHistory } from 'umi';
 import { service as sceneService } from '@/pages/rule-engine/Scene';
+import { Store } from 'jetlinks-store';
 
 const alarm1 = require('/public/images/alarm/alarm1.png');
 const alarm2 = require('/public/images/alarm/alarm2.png');
@@ -38,6 +39,7 @@ export default () => {
   const history = useHistory();
   const location = useLocation();
   const id = location?.query?.id || '';
+  const [loading, setLoading] = useState<boolean>(false);
 
   const LevelMap = {
     1: alarm1,
@@ -69,6 +71,7 @@ export default () => {
           onFormInit(async (form1) => {
             if (!id) return;
             const resp = await service.detail(id);
+            Store.set('configuration-data', resp.result);
             form1.setInitialValues({ ...resp.result });
             const resp1 = await sceneService.query({
               terms: [
@@ -114,12 +117,17 @@ export default () => {
   });
 
   const handleSave = async () => {
+    setLoading(true);
     const data: any = await form.submit();
     const resp: any = await service.update({ ...data });
+    setLoading(false);
     if (resp.status === 200) {
       onlyMessage('操作成功');
       const url = getMenuPathByCode('rule-engine/Alarm/Configuration/Save');
-      history.push(`${url}?id=${resp.result?.id}`);
+      history.push(`${url}?id=${resp.result?.id || id}`);
+      if (!id) {
+        Store.set('configuration-data', resp.result);
+      }
     }
   };
 
@@ -221,17 +229,14 @@ export default () => {
     <div>
       <Form className={styles.form} form={form} layout="vertical">
         <SchemaField schema={schema} scope={{ useAsyncDataSource, getSupports, getLevel }} />
-        <FormButtonGroup.Sticky>
-          <FormButtonGroup.FormItem>
-            <PermissionButton
-              type="primary"
-              isPermission={getOtherPermission(['add', 'update'])}
-              onClick={() => handleSave()}
-            >
-              保存
-            </PermissionButton>
-          </FormButtonGroup.FormItem>
-        </FormButtonGroup.Sticky>
+        <PermissionButton
+          type="primary"
+          loading={loading}
+          isPermission={getOtherPermission(['add', 'update'])}
+          onClick={() => handleSave()}
+        >
+          保存
+        </PermissionButton>
       </Form>
     </div>
   );

+ 7 - 1
src/pages/rule-engine/Alarm/Configuration/Save/Scene/Save/index.tsx

@@ -12,6 +12,7 @@ interface Props {
   close: () => void;
   id: string;
   ok: () => void;
+  type: string;
 }
 
 export default (props: Props) => {
@@ -147,6 +148,12 @@ export default (props: Props) => {
                       column: 'id',
                       termType: 'alarm-bind-rule$not',
                       value: id,
+                      type: 'and',
+                    },
+                    {
+                      column: 'triggerType',
+                      termType: 'eq',
+                      value: props.type,
                     },
                   ],
                   type: 'and',
@@ -163,7 +170,6 @@ export default (props: Props) => {
           rowSelection={{
             selectedRowKeys: selectKeys,
             onChange: (selectedRowKeys) => {
-              console.log(selectedRowKeys);
               setSelectKeys(selectedRowKeys);
             },
           }}

+ 2 - 8
src/pages/rule-engine/Alarm/Configuration/Save/Scene/index.tsx

@@ -10,6 +10,7 @@ import { service as sceneService } from '@/pages/rule-engine/Scene';
 import Save from './Save';
 import { service } from '@/pages/rule-engine/Alarm/Configuration';
 import { onlyMessage } from '@/utils/util';
+import { Store } from 'jetlinks-store';
 
 export default () => {
   const intl = useIntl();
@@ -83,14 +84,6 @@ export default () => {
 
   return (
     <>
-      {/*<SearchComponent*/}
-      {/*  field={columns}*/}
-      {/*  target={'alarm-scene'}*/}
-      {/*  onSearch={(data) => {*/}
-      {/*    actionRef.current?.reset?.();*/}
-      {/*    setSearchParams(data);*/}
-      {/*  }}*/}
-      {/*/>*/}
       <ProTableCard<SceneItem>
         columns={columns}
         actionRef={actionRef}
@@ -186,6 +179,7 @@ export default () => {
       {visible && (
         <Save
           id={id}
+          type={Store.get('configuration-data')?.targetType}
           close={() => {
             setVisible(false);
           }}

+ 13 - 2
src/pages/rule-engine/DashBoard/index.less

@@ -107,8 +107,19 @@
 }
 
 .alarmRank {
-  width: 250px;
-  padding-left: 55px;
+  position: relative;
+  width: 300px;
+  padding-left: 48px;
+}
+
+.alarmRank::before {
+  position: absolute;
+  top: 150px;
+  left: 0;
+  width: 1px;
+  height: 187px;
+  background-color: #e0e4e8;
+  content: '';
 }
 
 .rankingList {

+ 1 - 1
src/pages/rule-engine/DashBoard/index.tsx

@@ -360,7 +360,7 @@ const Dashboard = observer(() => {
           top: '2%',
           bottom: '5%',
           left: '24px',
-          right: '24px',
+          right: '48px',
         },
         series: [
           {

+ 3 - 3
src/pages/system/Menu/Setting/baseMenu.ts

@@ -1375,7 +1375,7 @@ export default [
         permissions: [],
         children: [
           {
-            code: 'DataCollect/Dashboard',
+            code: 'link/DataCollect/Dashboard',
             name: '仪表盘',
             owner: 'iot',
             sortIndex: 1,
@@ -1398,7 +1398,7 @@ export default [
             buttons: [],
           },
           {
-            code: 'DataCollect/DataGathering',
+            code: 'link/DataCollect/DataGathering',
             name: '数据采集',
             owner: 'iot',
             sortIndex: 2,
@@ -1529,7 +1529,7 @@ export default [
             ],
           },
           {
-            code: 'DataCollect/IntegratedQuery',
+            code: 'link/DataCollect/IntegratedQuery',
             name: '综合查询',
             owner: 'iot',
             sortIndex: 3,