Przeglądaj źródła

feat(merge): merge sc

fix: 修改bug
Lind 3 lat temu
rodzic
commit
7456e5bea6

+ 6 - 0
src/global.less

@@ -109,3 +109,9 @@ ol {
     display: flex;
   }
 }
+
+.tabs-full-active {
+  .ant-tabs-tab-active {
+    background-color: @primary-1;
+  }
+}

+ 2 - 16
src/pages/Log/Access/index.tsx

@@ -72,7 +72,6 @@ const Access = () => {
       valueType: 'dateTime',
       defaultSortOrder: 'descend',
       ellipsis: true,
-      width: 200,
       renderText: (text: string) => moment(text).format('YYYY-MM-DD HH:mm:ss'),
     },
     {
@@ -80,7 +79,7 @@ const Access = () => {
         id: 'pages.log.access.requestTimeConsuming',
         defaultMessage: '请求耗时',
       }),
-      width: 80,
+      width: 100,
       renderText: (record: AccessLogItem) => (
         <Tag color="purple">{record.responseTime - record.requestTime}ms</Tag>
       ),
@@ -91,20 +90,7 @@ const Access = () => {
         defaultMessage: '请求用户',
       }),
       dataIndex: 'username',
-      render: (text, record: any) => (
-        <Tag color="geekblue">{record?.context?.username || '--'}</Tag>
-      ),
-    },
-    {
-      title: intl.formatMessage({
-        id: 'pages.table.description',
-        defaultMessage: '说明',
-      }),
-      dataIndex: 'describe',
-      ellipsis: true,
-      // render: (text, record) => {
-      //   return `${record.action}-${record.describe}`;
-      // },
+      render: (text, record: any) => <Tag color="geekblue">{record?.context?.username || ''}</Tag>,
     },
     {
       title: intl.formatMessage({

+ 21 - 4
src/pages/account/NotificationSubscription/save/index.tsx

@@ -6,6 +6,7 @@ import type { ISchema } from '@formily/react';
 import { createSchemaField } from '@formily/react';
 import { useAsyncDataSource } from '@/utils/util';
 import { service } from '@/pages/account/NotificationSubscription';
+import _ from 'lodash';
 
 interface Props {
   data: Partial<NotifitionSubscriptionItem>;
@@ -14,11 +15,19 @@ interface Props {
 }
 
 const Save = (props: Props) => {
-  const [data, setDada] = useState<Partial<NotifitionSubscriptionItem>>(props.data || {});
+  const [data, setDada] = useState<any>(props.data || {});
   const [dataList, setDataList] = useState<any[]>([]);
 
   useEffect(() => {
-    setDada(props.data);
+    if (props.data?.topicConfig) {
+      setDada({
+        ...props.data,
+        topicConfig: {
+          alarmConfigId: props.data?.topicConfig?.alarmConfigId.split(','),
+          alarmConfigName: props.data?.topicConfig?.alarmConfigName.split(','),
+        },
+      });
+    }
   }, [props.data]);
 
   const form = useMemo(
@@ -97,6 +106,7 @@ const Save = (props: Props) => {
           },
           'topicConfig.alarmConfigId': {
             title: '告警规则',
+            type: 'array',
             'x-component': 'Select',
             'x-decorator': 'FormItem',
             required: true,
@@ -106,7 +116,11 @@ const Save = (props: Props) => {
               layout: 'vertical',
             },
             'x-component-props': {
+              mode: 'multiple',
+              showArrow: true,
               placeholder: '请选择告警规则',
+              filterOption: (input: string, option: any) =>
+                option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0,
             },
             'x-reactions': ['{{useAsyncDataSource(queryAlarmConfigList)}}'],
             'x-validator': [
@@ -168,13 +182,16 @@ const Save = (props: Props) => {
   const handleSave = async () => {
     let param: any = await form.submit();
     delete param.notice;
-    const config = dataList.find((item) => item?.value === param?.topicConfig?.alarmConfigId);
+    const config = dataList.filter((item) =>
+      param?.topicConfig?.alarmConfigId.includes(item?.value),
+    );
     param = {
       ...data,
       ...param,
       topicConfig: {
         ...param?.topicConfig,
-        alarmConfigName: config.label || '',
+        alarmConfigId: param?.topicConfig.alarmConfigId.join(','),
+        alarmConfigName: _.map(config, 'label').join(','),
       },
     };
     const response: any = await service.saveData(param);

+ 9 - 19
src/pages/device/Instance/Detail/Log/index.tsx

@@ -5,38 +5,28 @@ import { Card, Input, Modal, Tooltip } from 'antd';
 import { SearchOutlined } from '@ant-design/icons';
 import { useIntl } from '@@/plugin-locale/localeExports';
 import { InstanceModel, service } from '@/pages/device/Instance';
-import { useEffect, useRef, useState } from 'react';
+import { useRef, useState } from 'react';
 import SearchComponent from '@/components/SearchComponent';
 
 const Log = () => {
   const intl = useIntl();
 
-  const [type, setType] = useState<any>({});
   const actionRef = useRef<ActionType>();
   const [searchParams, setSearchParams] = useState<any>({});
 
-  useEffect(() => {
-    service.queryLogsType().then((resp) => {
-      if (resp.status === 200) {
-        const list = (resp.result as { text: string; value: string }[]).reduce(
-          (previousValue, currentValue) => {
-            previousValue[currentValue.value] = currentValue;
-            return previousValue;
-          },
-          {},
-        );
-        setType({ ...list });
-      }
-    });
-  }, []);
-
   const columns: ProColumns<LogItem>[] = [
     {
       title: '类型',
       dataIndex: 'type',
-      renderText: (text) => text.text,
+      renderText: (text) => text?.text,
       valueType: 'select',
-      valueEnum: { ...type },
+      request: () =>
+        service.queryLogsType().then((resp: any) =>
+          (resp?.result || []).map((item: any) => ({
+            label: item.text,
+            value: item.value,
+          })),
+        ),
     },
     {
       title: '时间',

+ 33 - 16
src/pages/device/Instance/Detail/Running/Property/index.tsx

@@ -1,4 +1,4 @@
-import { Col, Input, message, Pagination, Row, Space, Spin, Table } from 'antd';
+import { Col, Empty, Input, message, Pagination, Row, Space, Spin, Table } from 'antd';
 import CheckButton from '@/components/CheckButton';
 import { useCallback, useEffect, useRef, useState } from 'react';
 import type { PropertyMetadata } from '@/pages/device/Product/typings';
@@ -250,19 +250,24 @@ const Property = (props: Props) => {
             }}
           />
         </div>
-        <div style={{ marginTop: '20px' }}>
-          {check ? (
-            <Row gutter={[16, 16]}>
-              {dataSource.data.map((item: any) => (
-                <Col {...ColResponsiveProps} key={item.id}>
-                  <PropertyCard data={item} value={item?.id ? propertyValue[item?.id] : '--'} />
-                </Col>
-              ))}
-            </Row>
-          ) : (
-            <Table pagination={false} columns={columns} dataSource={dataSource.data} rowKey="id" />
-          )}
-          {dataSource.data.length > 0 && (
+        {dataSource.data?.length > 0 ? (
+          <div style={{ marginTop: '20px' }}>
+            {check ? (
+              <Row gutter={[16, 16]}>
+                {dataSource.data.map((item: any) => (
+                  <Col {...ColResponsiveProps} key={item.id}>
+                    <PropertyCard data={item} value={item?.id ? propertyValue[item?.id] : '--'} />
+                  </Col>
+                ))}
+              </Row>
+            ) : (
+              <Table
+                pagination={false}
+                columns={columns}
+                dataSource={dataSource.data}
+                rowKey="id"
+              />
+            )}
             <div
               style={{
                 marginTop: '20px',
@@ -288,8 +293,20 @@ const Property = (props: Props) => {
                 }}
               />
             </div>
-          )}
-        </div>
+          </div>
+        ) : (
+          <div
+            style={{
+              height: 400,
+              display: 'flex',
+              alignItems: 'center',
+              width: '100%',
+              justifyContent: 'center',
+            }}
+          >
+            <Empty />
+          </div>
+        )}
       </Spin>
       {visible && (
         <EditProperty

+ 32 - 16
src/pages/device/Instance/Detail/Running/index.tsx

@@ -1,5 +1,5 @@
 import { InstanceModel } from '@/pages/device/Instance';
-import { Card, Input, Tabs } from 'antd';
+import { Card, Empty, Input, Tabs } from 'antd';
 import type { DeviceMetadata } from '@/pages/device/Product/typings';
 import Property from '@/pages/device/Instance/Detail/Running/Property';
 import Event from '@/pages/device/Instance/Detail/Running/Event';
@@ -33,21 +33,37 @@ const Running = () => {
 
   return (
     <Card>
-      <Tabs
-        defaultActiveKey="1"
-        tabPosition="left"
-        style={{ minHeight: 600 }}
-        tabBarExtraContent={{ left: operations() }}
-      >
-        <Tabs.TabPane tab="属性" key="1">
-          <Property data={metadata?.properties || []} />
-        </Tabs.TabPane>
-        {list?.map((item) => (
-          <Tabs.TabPane tab={item.name} key={item.id}>
-            <Event data={item} />
-          </Tabs.TabPane>
-        ))}
-      </Tabs>
+      {list?.length === 0 && (metadata?.properties || [])?.length === 0 ? (
+        <div
+          style={{
+            height: 480,
+            display: 'flex',
+            alignItems: 'center',
+            width: '100%',
+            justifyContent: 'center',
+          }}
+        >
+          <Empty />
+        </div>
+      ) : (
+        <div className="tabs-full-active">
+          <Tabs
+            defaultActiveKey="1"
+            tabPosition="left"
+            style={{ minHeight: 600 }}
+            tabBarExtraContent={{ left: operations() }}
+          >
+            <Tabs.TabPane tab="属性" key="1">
+              <Property data={metadata?.properties || []} />
+            </Tabs.TabPane>
+            {list?.map((item) => (
+              <Tabs.TabPane tab={item.name} key={item.id}>
+                <Event data={item} />
+              </Tabs.TabPane>
+            ))}
+          </Tabs>
+        </div>
+      )}
     </Card>
   );
 };

+ 14 - 9
src/pages/device/Product/Detail/Access/index.tsx

@@ -25,6 +25,7 @@ const Access = () => {
   const [config, setConfig] = useState<any>();
   const [access, setAccess] = useState<any>();
   const { permission } = usePermissions('link/AccessConfig');
+  const [dataSource, setDataSource] = useState<any[]>([]);
 
   const MetworkTypeMapping = new Map();
   MetworkTypeMapping.set('websocket-server', 'WEB_SOCKET_SERVER');
@@ -204,6 +205,11 @@ const Access = () => {
         productModel.current?.messageProtocol || '',
         productModel.current?.transportProtocol || '',
       );
+      service.getProviders().then((resp) => {
+        if (resp.status === 200) {
+          setDataSource(resp.result);
+        }
+      });
     }
   }, [productModel.current]);
 
@@ -386,16 +392,19 @@ const Access = () => {
                     </span>
                   }
                 />
-                <div className={styles.context}>{access?.name || '--'}</div>
-                <div className={styles.context}>{access?.description || '--'}</div>
+                <div className={styles.context}>{access?.name}</div>
+                <div className={styles.context}>
+                  {access?.description ||
+                    dataSource.find((item) => item?.id === access?.provider)?.description}
+                </div>
               </div>
 
               <div className={styles.item}>
                 <TitleComponent data={'消息协议'} />
-                <div className={styles.context}>{access?.protocolDetail?.name || '--'}</div>
+                <div className={styles.context}>{access?.protocolDetail?.name}</div>
                 {config?.document && (
                   <div className={styles.context}>
-                    <ReactMarkdown>{config?.document || '--'}</ReactMarkdown>
+                    <ReactMarkdown>{config?.document}</ReactMarkdown>
                   </div>
                 )}
               </div>
@@ -404,11 +413,7 @@ const Access = () => {
                 {(access?.channelInfo?.addresses || []).length > 0
                   ? (access?.channelInfo?.addresses || []).map((item: any) => (
                       <div key={item.address}>
-                        <Badge
-                          color={item.health === -1 ? 'red' : 'green'}
-                          text={item.address}
-                          style={{ marginLeft: '20px' }}
-                        />
+                        <Badge color={item.health === -1 ? 'red' : 'green'} text={item.address} />
                       </div>
                     ))
                   : '暂无连接信息'}

+ 4 - 7
src/pages/device/Product/Detail/index.tsx

@@ -208,6 +208,10 @@ const ProductDetail = observer(() => {
   ];
 
   useEffect(() => {
+    const { state } = location;
+    if (state && state?.tab) {
+      setMode(state?.tab);
+    }
     if ((location as any).query?.key) {
       setMode((location as any).query?.key || 'base');
     }
@@ -218,13 +222,6 @@ const ProductDetail = observer(() => {
       }
     });
     return () => subscription.unsubscribe();
-  }, []);
-
-  useEffect(() => {
-    const { state } = location;
-    if (state && state?.tab) {
-      setMode(state?.tab);
-    }
   }, [location]);
 
   return (

+ 1 - 1
src/pages/system/DataSource/Save/index.tsx

@@ -159,7 +159,7 @@ const Save = (props: Props) => {
               gridSpan: 2,
             },
             'x-component-props': {
-              placeholder: '请输入接地址,示例:localhost:5672',
+              placeholder: '请输入接地址,示例:localhost:5672',
             },
             'x-validator': [
               {

+ 10 - 2
src/pages/system/DataSource/index.tsx

@@ -189,8 +189,16 @@ const DataSource = observer(() => {
         >
           <Popconfirm
             onConfirm={async () => {
-              await service.remove(record.id);
-              actionRef.current?.reload();
+              const resp: any = await service.remove(record.id);
+              if (resp.status === 200) {
+                message.success(
+                  intl.formatMessage({
+                    id: 'pages.data.option.success',
+                    defaultMessage: '操作成功!',
+                  }),
+                );
+                actionRef.current?.reload();
+              }
             }}
             title="确认删除?"
           >

+ 3 - 2
src/pages/system/Role/Detail/Permission/Allocate/MenuPermission.tsx

@@ -59,7 +59,7 @@ const MenuPermission = (props: Props) => {
           paddingLeft: (props?.level || 0) * 10,
           transition: 'background .3s',
           borderBottom: '1px solid #f0f0f0',
-          height: 50,
+          minHeight: 50,
         }}
         key={value?.id}
       >
@@ -118,7 +118,7 @@ const MenuPermission = (props: Props) => {
               {value?.name}
             </Checkbox>
           </div>
-          <div>
+          <div style={{ padding: 5 }}>
             {value.id === 'menu-permission' ? (
               <span style={{ fontWeight: value.id === 'menu-permission' ? 600 : 400 }}>
                 操作权限
@@ -156,6 +156,7 @@ const MenuPermission = (props: Props) => {
                   };
                   props.change(d);
                 }}
+                style={{ width: '100%' }}
                 options={(value?.buttons || []).map((i: any) => ({
                   label: i.name,
                   value: i.id,