wzyyy 3 år sedan
förälder
incheckning
19cc1f92ab

+ 8 - 7
package.json

@@ -54,6 +54,7 @@
     "not ie <= 10"
   ],
   "dependencies": {
+    "@ahooksjs/use-url-state": "^3.5.0",
     "@amap/amap-jsapi-loader": "^1.0.1",
     "@amap/amap-jsapi-types": "^0.0.8",
     "@ant-design/charts": "^1.3.1",
@@ -63,13 +64,13 @@
     "@ant-design/pro-form": "^1.18.3",
     "@ant-design/pro-layout": "^6.27.2",
     "@ant-design/pro-list": "^1.21.61",
-    "@formily/antd": "2.1.2",
-    "@formily/core": "2.1.2",
-    "@formily/json-schema": "2.1.2",
-    "@formily/react": "2.1.2",
-    "@formily/reactive": "2.1.2",
-    "@formily/reactive-react": "2.1.2",
-    "@formily/shared": "2.1.2",
+    "@formily/antd": "2.1.6",
+    "@formily/core": "2.1.6",
+    "@formily/json-schema": "2.1.6",
+    "@formily/react": "2.1.6",
+    "@formily/reactive": "2.1.6",
+    "@formily/reactive-react": "2.1.6",
+    "@formily/shared": "2.1.6",
     "@jetlinks/pro-list": "^1.10.8",
     "@jetlinks/pro-table": "^2.63.11",
     "@liveqing/liveplayer": "^2.6.4",

+ 1 - 1
src/components/NoticeIcon/NoticeIcon.tsx

@@ -26,7 +26,7 @@ export type NoticeIconProps = {
   viewMoreText?: string;
   clearClose?: boolean;
   emptyImage?: string;
-  children?: React.ReactElement<NoticeIconTabProps>[];
+  children?: React.ReactElement<NoticeIconTabProps>[] | React.ReactElement<NoticeIconTabProps>;
 };
 
 const NoticeIcon: React.FC<NoticeIconProps> & {

+ 2 - 6
src/components/NoticeIcon/NoticeList.tsx

@@ -23,7 +23,7 @@ const NoticeList: React.FC<NoticeIconTabProps> = ({
   list = [],
   onClick,
   onClear,
-  title,
+  // title,
   onViewMore,
   emptyText,
   showClear = true,
@@ -89,11 +89,7 @@ const NoticeList: React.FC<NoticeIconTabProps> = ({
         }}
       />
       <div className={styles.bottomBar}>
-        {showClear ? (
-          <div onClick={onClear}>
-            {clearText} {title}
-          </div>
-        ) : null}
+        {showClear ? <div onClick={onClear}>{clearText}</div> : null}
         {showViewMore ? (
           <div
             onClick={(e) => {

+ 134 - 90
src/components/NoticeIcon/index.tsx

@@ -1,12 +1,16 @@
 import { useEffect, useState } from 'react';
-import { Tag, message } from 'antd';
+import { Button, message, notification } from 'antd';
 import { groupBy } from 'lodash';
 import moment from 'moment';
-import { useRequest } from 'umi';
-import { getNotices } from '@/services/ant-design-pro/api';
-
+import Service from '@/services/notice';
 import NoticeIcon from './NoticeIcon';
 import styles from './index.less';
+import encodeQuery from '@/utils/encodeQuery';
+import { getMenuPathByCode, MENUS_CODE } from '@/utils/menu';
+import useHistory from '@/hooks/route/useHistory';
+import { throttleTime } from 'rxjs/operators';
+import Icon from '@ant-design/icons';
+import useSendWebsocketMessage from '@/hooks/websocket/useSendWebsocketMessage';
 
 export type GlobalHeaderRightProps = {
   fetchingNotices?: boolean;
@@ -22,130 +26,170 @@ const getNoticeData = (notices: API.NoticeIconItem[]): Record<string, API.Notice
   const newNotices = notices.map((notice) => {
     const newNotice = { ...notice };
 
-    if (newNotice.datetime) {
-      newNotice.datetime = moment(notice.datetime as string).fromNow();
+    if (newNotice.notifyTime) {
+      newNotice.notifyTime = moment(notice.notifyTime as string).fromNow();
     }
 
     if (newNotice.id) {
       newNotice.key = newNotice.id;
     }
 
-    if (newNotice.extra && newNotice.status) {
-      const color = {
-        todo: '',
-        processing: 'blue',
-        urgent: 'red',
-        doing: 'gold',
-      }[newNotice.status];
-      newNotice.extra = (
-        <Tag
-          color={color}
-          style={{
-            marginRight: 0,
-          }}
-        >
-          {newNotice.extra}
-        </Tag>
-      ) as any;
-    }
-
+    // newNotice.avatar = 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg';
+    newNotice.title = notice.topicName;
+    newNotice.description = notice.message;
     return newNotice;
   });
-  return groupBy(newNotices, 'type');
+  return groupBy(
+    newNotices.map((item) => ({ ...item, state: item.state.value })),
+    'state',
+  );
 };
 
-const getUnreadData = (noticeData: Record<string, API.NoticeIconItem[]>) => {
-  const unreadMsg: Record<string, number> = {};
-  Object.keys(noticeData).forEach((key) => {
-    const value = noticeData[key];
+// const getUnreadData = (noticeData: Record<string, API.NoticeIconItem[]>) => {
+//   const unreadMsg: Record<string, number> = {};
+//   Object.keys(noticeData).forEach((key) => {
+//     const value = noticeData[key];
 
-    if (!unreadMsg[key]) {
-      unreadMsg[key] = 0;
-    }
+//     if (!unreadMsg[key]) {
+//       unreadMsg[key] = 0;
+//     }
 
-    if (Array.isArray(value)) {
-      unreadMsg[key] = value.filter((item) => !item.read).length;
-    }
-  });
-  return unreadMsg;
-};
+//     if (Array.isArray(value)) {
+//       // unreadMsg[key] = value.filter((item) => !item.read).length;
+//     }
+//   });
+//   return unreadMsg;
+// };
+
+export const service = new Service('notifications');
 
 const NoticeIconView = () => {
   // const { initialState } = useModel('@@initialState');
   // const { currentUser } = initialState || {};
   const [notices, setNotices] = useState<API.NoticeIconItem[]>([]);
-  const { data } = useRequest(getNotices);
+  const [unreadCount, setUnreadCount] = useState<number>(0);
+  const [visible, setVisible] = useState<boolean>(false);
+  const [loading, setLoading] = useState<boolean>(true);
+  // const { data } = useRequest(getNotices);
+
+  const history = useHistory();
+  const [subscribeTopic] = useSendWebsocketMessage();
+
+  const getUnread = () => {
+    setLoading(true);
+    service
+      .fetchNotices(
+        encodeQuery({
+          terms: { state: 'unread' },
+          sorts: { notifyTime: 'desc' },
+        }),
+      )
+      .then((resp) => {
+        if (resp.status === 200) {
+          setNotices(resp.result?.data || []);
+          setUnreadCount(resp.result?.total || 0);
+        }
+        setLoading(false);
+      });
+  };
+
+  const subscribeNotice = () => {
+    const id = `notification`;
+    const topic = `/notifications`;
+    subscribeTopic!(id, topic, {})
+      ?.pipe(throttleTime(2000))
+      .subscribe((resp: any) => {
+        getUnread();
+        notification.open({
+          message: resp?.payload?.topicName,
+          description: resp?.payload?.message,
+          key: resp.payload.id,
+          top: 60,
+          btn: (
+            <Button
+              type="primary"
+              onClick={() => {
+                service.changeNoticeReadState(resp.payload.id).then((response) => {
+                  if (response.status === 200) {
+                    notification.close(resp.payload.id);
+                    getUnread();
+                  }
+                });
+              }}
+            >
+              标记已读
+            </Button>
+          ),
+          icon: <Icon type="exclamation-circle" style={{ color: '#E23D38' }} />,
+        });
+      });
+  };
 
   useEffect(() => {
-    setNotices(data || []);
-  }, [data]);
+    getUnread();
+    subscribeNotice();
+  }, []);
 
   const noticeData = getNoticeData(notices);
-  const unreadMsg = getUnreadData(noticeData || {});
-
-  const changeReadState = (id: string) => {
-    setNotices(
-      notices.map((item) => {
-        const notice = { ...item };
-        if (notice.id === id) {
-          notice.read = true;
-        }
-        return notice;
-      }),
-    );
+  // const unreadMsg = getUnreadData(noticeData || {});
+
+  const changeReadState = async (item: any) => {
+    const resp = await service.changeNoticeReadState(item.id);
+    if (resp.status === 200) {
+      getUnread();
+    }
+    const url = getMenuPathByCode(MENUS_CODE['account/NotificationRecord']);
+    history.push(url, { ...item });
+    setVisible(false);
   };
 
-  const clearReadState = (title: string, key: string) => {
-    setNotices(
-      notices.map((item) => {
-        const notice = { ...item };
-        if (notice.type === key) {
-          notice.read = true;
-        }
-        return notice;
-      }),
-    );
-    message.success(`${'清空了'} ${title}`);
+  const clearReadState = async (title: string) => {
+    const clearIds = (getNoticeData(notices).unread || []).map((item) => item.id) || [];
+    const resp = await service.clearNotices(clearIds);
+    if (resp.status === 200) {
+      message.success(`${'清空了'} ${title}`);
+      getUnread();
+    }
   };
 
   return (
     <NoticeIcon
       className={styles.action}
-      count={10}
+      count={unreadCount}
       onItemClick={(item) => {
-        changeReadState(item.id!);
+        changeReadState(item!);
       }}
-      onClear={(title: string, key: string) => clearReadState(title, key)}
-      loading={false}
-      clearText="清空"
+      onClear={(title: string) => clearReadState(title)}
+      loading={loading}
+      clearText="当前标记为已读"
       viewMoreText="查看更多"
-      onViewMore={() => message.info('Click on view more')}
+      onViewMore={() => {
+        const url = getMenuPathByCode(MENUS_CODE['account/NotificationRecord']);
+        history.push(url);
+        setVisible(false);
+      }}
+      popupVisible={visible}
+      onPopupVisibleChange={(see: boolean) => {
+        setVisible(see);
+      }}
       clearClose
     >
       <NoticeIcon.Tab
-        tabKey="notification"
-        count={unreadMsg.notification}
-        list={noticeData.notification}
-        title="通知"
-        emptyText="你已查看所有通知"
-        showViewMore
-      />
-      <NoticeIcon.Tab
-        tabKey="message"
-        count={unreadMsg.message}
-        list={noticeData.message}
-        title="消息"
+        tabKey="read"
+        count={0}
+        list={noticeData.unread}
+        title="未读消息"
         emptyText="您已读完所有消息"
         showViewMore
       />
-      <NoticeIcon.Tab
-        tabKey="event"
-        title="待办"
-        emptyText="你已完成所有待办"
-        count={unreadMsg.event}
-        list={noticeData.event}
+      {/* <NoticeIcon.Tab
+        tabKey="handle"
+        title="待办消息"
+        emptyText="暂无消息"
+        count={0}
+        list={noticeData.handle}
         showViewMore
-      />
+      /> */}
     </NoticeIcon>
   );
 };

+ 1 - 0
src/components/ProTableCard/CardItems/mediaDevice.tsx

@@ -24,6 +24,7 @@ export default (props: ProductCardProps) => {
       statusNames={{
         offline: StatusColorEnum.error,
         online: StatusColorEnum.processing,
+        notActive: StatusColorEnum.processing,
       }}
     >
       <div className={'pro-table-card-item'}>

+ 4 - 0
src/components/RightContent/index.tsx

@@ -6,6 +6,7 @@ import Avatar from './AvatarDropdown';
 import styles from './index.less';
 import useSendWebsocketMessage from '@/hooks/websocket/useSendWebsocketMessage';
 import { Store } from 'jetlinks-store';
+import NoticeIcon from '../NoticeIcon';
 
 // export type SiderTheme = 'light' | 'dark';
 
@@ -60,6 +61,9 @@ const GlobalHeaderRight: React.FC = () => {
       >
         <QuestionCircleOutlined />
       </span>
+      <span>
+        <NoticeIcon />
+      </span>
       <Avatar menu={true} />
       <SelectLang className={styles.action} />
     </Space>

+ 22 - 17
src/components/SearchComponent/index.tsx

@@ -34,6 +34,7 @@ import _ from 'lodash';
 import { useIntl } from '@@/plugin-locale/localeExports';
 import classnames from 'classnames';
 import { onlyMessage, randomString } from '@/utils/util';
+import useUrlState from '@ahooksjs/use-url-state';
 
 const ui2Server = (source: SearchTermsUI): SearchTermsServer => [
   { terms: source.terms1 },
@@ -436,13 +437,6 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
     uiParamRef.current = ui2Server(log);
     const _expand =
       (log.terms1 && log.terms1?.length > 1) || (log.terms2 && log.terms2?.length > 1);
-    console.log(
-      _expand,
-      '展开',
-      log,
-      (log.terms1 && log.terms1?.length > 1) || (log.terms2 && log.terms2?.length > 1),
-    );
-    console.log(log.terms1, log.terms2, 'log-terms');
     if (_expand) {
       setExpand(false);
     }
@@ -500,18 +494,21 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
 
     return _value
       .filter((i) => i.terms && i.terms?.length > 0)
-      .map((term) => {
-        term.terms?.map((item) => {
-          if (item.termType === 'like') {
-            item.value = `%${item.value}%`;
+      .map((_term) => {
+        _term.terms = _term.terms
+          ?.filter((term) => term.value !== '')
+          .map((item) => {
+            if (item.termType === 'like' && item.value && item.value !== '') {
+              item.value = `%${item.value}%`;
+              return item;
+            }
             return item;
-          }
-          return item;
-        });
-        return term;
+          });
+        return _term;
       });
   };
 
+  const [url, setUrl] = useUrlState();
   const handleSearch = async () => {
     const value = form.values;
     const filterTerms = (data: Partial<Term>[] | undefined) =>
@@ -519,11 +516,19 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
     const _terms = _.cloneDeep(value);
     _terms.terms1 = filterTerms(_terms.terms1);
     _terms.terms2 = filterTerms(_terms.terms2);
-
-    onSearch({ terms: formatValue(_terms) });
+    const _temp = formatValue(_terms);
+    setUrl({ q: JSON.stringify(value) });
+    onSearch({ terms: _temp });
   };
 
   useEffect(() => {
+    if (url.q) {
+      form.setValues(JSON.parse(url.q));
+      handleSearch();
+    }
+  }, [url]);
+
+  useEffect(() => {
     if (defaultParam) {
       handleSearch();
     }

+ 1 - 1
src/hooks/document/useDomFullHeight.tsx

@@ -1,5 +1,5 @@
-import { useEffect, useState } from 'react';
 import type { MutableRefObject } from 'react';
+import { useEffect, useState } from 'react';
 
 type TargetValue<T> = T | undefined | null;
 

+ 9 - 7
src/pages/Northbound/DuerOS/Detail/index.tsx

@@ -63,8 +63,9 @@ const Save = () => {
 
   const getProduct = () =>
     service.getProduct().then((resp) => {
-      Store.set('product-list', resp.result);
-      return resp.result;
+      const _temp = resp.result.map((item: any) => ({ label: item.name, value: item.id }));
+      Store.set('product-list', _temp);
+      return _temp;
     });
 
   const getTypes = () =>
@@ -88,7 +89,8 @@ const Save = () => {
             if (_data) {
               _data.applianceType = _data?.applianceType?.value;
             }
-            form1.setInitialValues(_data);
+            console.log(_data, 'data');
+            form1.setValues(_data);
           });
           onFieldReact('actionMappings.*.layout.action', (field, f) => {
             const productType = field.query('applianceType').value();
@@ -255,10 +257,10 @@ const Save = () => {
             'x-component': 'Select',
             'x-component-props': {
               placeholder: '请选择产品',
-              fieldNames: {
-                label: 'name',
-                value: 'id',
-              },
+              // fieldNames: {
+              //   label: 'name',
+              //   value: 'id',
+              // },
               showSearch: true,
               showArrow: true,
               filterOption: (input: string, option: any) =>

+ 11 - 2
src/pages/account/NotificationRecord/index.tsx

@@ -13,10 +13,12 @@ import encodeQuery from '@/utils/encodeQuery';
 import { useDomFullHeight } from '@/hooks';
 import { onlyMessage } from '@/utils/util';
 import type { CustomIconComponentProps } from '@ant-design/icons/lib/components/Icon';
+import { historyStateModel } from '@/hooks/route/useHistory';
+import { observer } from '@formily/reactive-react';
 
 export const service = new Service('notifications');
 
-const NotificationRecord = () => {
+const NotificationRecord = observer(() => {
   const intl = useIntl();
   const actionRef = useRef<ActionType>();
   const [param, setParam] = useState({});
@@ -35,6 +37,13 @@ const NotificationRecord = () => {
     });
   }, []);
 
+  useEffect(() => {
+    if (historyStateModel.state.id) {
+      setVisible(true);
+      setCurrent(historyStateModel.state);
+    }
+  }, [historyStateModel.state]);
+
   const ReadSvg = () => (
     <svg
       width="1em"
@@ -189,6 +198,6 @@ const NotificationRecord = () => {
       )}
     </PageContainer>
   );
-};
+});
 
 export default NotificationRecord;

+ 1 - 4
src/pages/device/Instance/Detail/Functions/AdvancedMode.tsx

@@ -117,10 +117,7 @@ export default (props: FunctionProps) => {
               setValue('');
             }}
           >
-            {intl.formatMessage({
-              id: 'pages.data.option.cancel',
-              defaultMessage: '取消',
-            })}
+            清空
           </Button>
         </div>
       </div>

+ 1 - 0
src/pages/device/Instance/Export/index.tsx

@@ -9,6 +9,7 @@ import type { DeviceInstance } from '../typings';
 import SystemConst from '@/utils/const';
 import encodeQuery from '@/utils/encodeQuery';
 import { downloadFile } from '@/utils/util';
+
 interface Props {
   visible: boolean;
   close: () => void;

+ 21 - 2
src/pages/device/Product/Detail/Access/AccessConfig/index.tsx

@@ -29,7 +29,10 @@ const AccessConfig = (props: Props) => {
     pageIndex: 0,
     total: 0,
   });
-  const [param, setParam] = useState<any>({ pageSize: 4, terms: [] });
+  const [param, setParam] = useState<any>({
+    pageSize: 4,
+    terms: [],
+  });
 
   const [currrent, setCurrrent] = useState<any>({
     id: productModel.current?.accessId,
@@ -56,10 +59,26 @@ const AccessConfig = (props: Props) => {
                     termType: 'eq',
                     value: 'child-device',
                   },
+                  {
+                    column: 'state',
+                    termType: 'eq',
+                    value: 'enabled',
+                  },
                 ],
               },
             ]
-          : [...params?.terms],
+          : [
+              ...params?.terms,
+              {
+                terms: [
+                  {
+                    column: 'state',
+                    termType: 'eq',
+                    value: 'enabled',
+                  },
+                ],
+              },
+            ],
     };
     service.queryList({ ...temp, sorts: [{ name: 'createTime', order: 'desc' }] }).then((resp) => {
       setDataSource(resp?.result);

+ 1 - 0
src/pages/home/init/index.less

@@ -9,6 +9,7 @@
   padding: 20px;
   background-color: white;
 }
+
 .title {
   margin-top: 28px;
   margin-bottom: 48px;

+ 2 - 2
src/pages/link/AccessConfig/Detail/Cloud/OneNet/index.tsx

@@ -1,5 +1,5 @@
 import { QuestionCircleOutlined } from '@ant-design/icons';
-import { Button, Col, Form, Input, Row, Tooltip, Image } from 'antd';
+import { Button, Col, Form, Image, Input, Row, Tooltip } from 'antd';
 import { useEffect } from 'react';
 import styles from './index.less';
 
@@ -16,7 +16,7 @@ const OneNet = (props: Props) => {
   useEffect(() => {
     form.setFieldsValue({
       ...props.data,
-      apiAddress: 'https://ag-api.ctwing.cn/',
+      apiAddress: 'https://api.heclouds.com/',
     });
   }, [props.data]);
 

+ 33 - 8
src/pages/link/DashBoard/index.tsx

@@ -169,6 +169,26 @@ export default () => {
     formatResult: (res) => res.result.map((item: any) => ({ label: item.name, value: item.id })),
   });
 
+  const arrayReverse = (data: any[]): any[] => {
+    const newArray = [];
+    for (let i = data.length - 1; i >= 0; i--) {
+      newArray.push(data[i]);
+    }
+    return newArray;
+  };
+
+  const getInterval = (type: string) => {
+    switch (type) {
+      case 'year':
+        return '30d';
+      case 'week':
+      case 'month':
+        return '1d';
+      default:
+        return '1h';
+    }
+  };
+
   const handleNetworkOptions = (data: Record<string, any>, xAxis: string[]) => {
     setNetworkOptions({
       xAxis: {
@@ -194,11 +214,11 @@ export default () => {
         areaStyle: {
           color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
             {
-              offset: 0,
+              offset: 1,
               color: 'rgba(151, 154, 255, 0)',
             },
             {
-              offset: 1,
+              offset: 0,
               color: 'rgba(151, 154, 255, .24)',
             },
           ]),
@@ -211,7 +231,7 @@ export default () => {
     setJvmOptions({
       xAxis: {
         type: 'category',
-        data: xAxis,
+        data: arrayReverse(xAxis),
       },
       tooltip: {
         trigger: 'axis',
@@ -236,7 +256,7 @@ export default () => {
       ],
       color: ['#60DFC7'],
       series: Object.keys(data).map((key) => ({
-        data: data[key],
+        data: arrayReverse(data[key]),
         name: key,
         type: 'line',
         smooth: true,
@@ -260,7 +280,7 @@ export default () => {
     setCpuOptions({
       xAxis: {
         type: 'category',
-        data: xAxis,
+        data: arrayReverse(xAxis),
       },
       tooltip: {
         trigger: 'axis',
@@ -285,7 +305,7 @@ export default () => {
       ],
       color: ['#2CB6E0'],
       series: Object.keys(data).map((key) => ({
-        data: data[key],
+        data: arrayReverse(data[key]),
         name: key,
         type: 'line',
         smooth: true,
@@ -320,7 +340,7 @@ export default () => {
           group: 'network',
           params: {
             type: networkData.type,
-            interval: networkData.time.type === 'today' ? '1h' : '1d',
+            interval: getInterval(networkData.time.type),
             from: networkData.time.start,
             to: networkData.time.end,
           },
@@ -334,6 +354,7 @@ export default () => {
           params: {
             from: cpuData.time.start,
             to: cpuData.time.end,
+            interval: getInterval(cpuData.time.type),
           },
         },
         {
@@ -345,6 +366,7 @@ export default () => {
           params: {
             from: jvmData.time.start,
             to: jvmData.time.end,
+            interval: getInterval(jvmData.time.type),
           },
         },
       ])
@@ -400,6 +422,7 @@ export default () => {
 
   const getNetworkEcharts = () => {
     const data = NETWORKRef.current!.getValues();
+
     if (data) {
       service
         .queryMulti([
@@ -411,7 +434,7 @@ export default () => {
             group: 'network',
             params: {
               type: data.type,
-              interval: data.time.type === 'today' ? '1h' : '1d',
+              interval: getInterval(data.time.type),
               from: data.time.start,
               to: data.time.end,
             },
@@ -456,6 +479,7 @@ export default () => {
             params: {
               from: data.time.start,
               to: data.time.end,
+              interval: getInterval(data.time.type),
             },
           },
         ])
@@ -492,6 +516,7 @@ export default () => {
             params: {
               from: data.time.start,
               to: data.time.end,
+              interval: getInterval(data.time.type),
             },
           },
         ])

+ 1 - 0
src/pages/link/Protocol/FileUpload/index.tsx

@@ -33,6 +33,7 @@ const FileUpload = connect((props: Props) => {
       <Upload
         accept={props?.accept || '*'}
         listType={'text'}
+        disabled={props?.disabled}
         action={`/${SystemConst.API_BASE}/file/static`}
         headers={{
           'X-Access-Token': Token.get(),

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

@@ -1,5 +1,5 @@
 import { useCallback, useEffect, useState } from 'react';
-import { Button, Card, Col, Form, Input, Radio, Row, Select, Tooltip, Image } from 'antd';
+import { Button, Card, Col, Form, Image, Input, Radio, Row, Select, Tooltip } from 'antd';
 import { useIntl, useLocation } from 'umi';
 import { RadioCard, UploadImage } from '@/components';
 import { PlusOutlined } from '@ant-design/icons';

+ 18 - 7
src/pages/media/Device/index.tsx

@@ -159,6 +159,13 @@ const Device = () => {
       ),
       valueType: 'select',
       valueEnum: {
+        notActive: {
+          text: intl.formatMessage({
+            id: 'pages.device.instance.status.notActive',
+            defaultMessage: '禁用',
+          }),
+          status: 'notActive',
+        },
         offline: {
           text: intl.formatMessage({
             id: 'pages.device.instance.status.offLine',
@@ -267,13 +274,17 @@ const Device = () => {
             title: '删除',
           }}
           popConfirm={{
-            title: intl.formatMessage({
-              id:
-                record.state.value !== 'offline'
-                  ? 'pages.device.instance.deleteTip'
-                  : 'page.table.isDelete',
-              defaultMessage: '是否删除?',
-            }),
+            title: (
+              <div style={{ width: 100 }}>
+                {intl.formatMessage({
+                  id:
+                    record.state.value !== 'offline'
+                      ? 'pages.device.instance.deleteTip'
+                      : 'page.table.isDelete',
+                  defaultMessage: '是否删除?',
+                })}
+              </div>
+            ),
             onConfirm: async () => {
               if (record.state.value === 'offline') {
                 await deleteItem(record.id);

+ 1 - 1
src/pages/notice/Config/index.tsx

@@ -78,7 +78,7 @@ const list = {
   },
   email: {
     embedded: {
-      text: '默认',
+      text: '邮件',
       status: 'embedded',
     },
   },

+ 1 - 1
src/pages/notice/Template/index.tsx

@@ -74,7 +74,7 @@ const list = {
   },
   email: {
     embedded: {
-      text: '默认',
+      text: '邮件',
       status: 'embedded',
     },
   },

+ 1 - 1
src/pages/system/Department/Assets/productCategory/index.tsx

@@ -13,7 +13,7 @@ import Bind from './bind';
 import SearchComponent from '@/components/SearchComponent';
 import { difference } from 'lodash';
 import { onlyMessage } from '@/utils/util';
-import { AssetsModel, ASSETS_TABS_ENUM } from '@/pages/system/Department/Assets';
+import { ASSETS_TABS_ENUM, AssetsModel } from '@/pages/system/Department/Assets';
 
 export const service = new Service<ProductCategoryItem>('assets');
 

+ 1 - 2
src/pages/system/Department/Tree/tree.tsx

@@ -9,11 +9,10 @@ import {
 import { useEffect, useRef, useState } from 'react';
 import { service } from '@/pages/system/Department';
 import { Empty, PermissionButton } from '@/components';
-import { useIntl } from 'umi';
+import { useIntl, useLocation } from 'umi';
 import { debounce } from 'lodash';
 import Save from '../save';
 import { ISchema } from '@formily/json-schema';
-import { useLocation } from 'umi';
 import { DepartmentItem } from '@/pages/system/Department/typings';
 import { onlyMessage } from '@/utils/util';
 import classnames from 'classnames';

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

@@ -9,6 +9,7 @@ import type { PermissionItem } from '@/pages/system/Permission/typings';
 import { service } from '@/pages/system/Permission';
 import { Modal } from '@/components';
 import { onlyMessage } from '@/utils/util';
+
 interface Props {
   model: 'add' | 'edit' | 'query';
   data: Partial<PermissionItem>;

+ 2 - 2
src/pages/system/Platforms/Api/basePage.tsx

@@ -128,14 +128,14 @@ export default (props: TableProps) => {
               return (
                 <Button
                   type={'link'}
-                  style={{ padding: 0 }}
+                  style={{ padding: 0, width: '100%' }}
                   onClick={() => {
                     console.log(record);
                     ApiModel.swagger = record;
                     ApiModel.showTable = false;
                   }}
                 >
-                  {text}
+                  <span className={'ellipsis'}>{text}</span>
                 </Button>
               );
             },

+ 2 - 1
src/pages/system/Platforms/Api/leftTree.tsx

@@ -64,7 +64,7 @@ export default (props: LeftTreeType) => {
   );
 
   const handleTreeData = (data: any) => {
-    if (data && Object.keys(data).length) {
+    if (!data || !(data && Object.keys(data).length)) {
       return [];
     }
     const newArr = data.tags.map((item: any) => ({ id: item.name, name: item.name, isLeaf: true }));
@@ -93,6 +93,7 @@ export default (props: LeftTreeType) => {
       if (resp) {
         ApiModel.components = { ...ApiModel.components, ...resp.components.schemas };
         const handleData = handleTreeData(resp);
+        console.log(handleData);
         setTreeData((origin) => {
           const data = updateTreeData(origin, key, handleData);
 

+ 11 - 1
src/services/ant-design-pro/typings.d.ts

@@ -84,7 +84,7 @@ declare namespace API {
     success?: boolean;
   };
 
-  type NoticeIconItemType = 'notification' | 'message' | 'event';
+  type NoticeIconItemType = 'read' | 'handle';
 
   type NoticeIconItem = {
     id?: string;
@@ -97,5 +97,15 @@ declare namespace API {
     datetime?: string;
     description?: string;
     type?: NoticeIconItemType;
+
+    state: any;
+    message: string;
+    dataId: string;
+    notifyTime: number | string;
+    subscribeId: string;
+    subscriber: string;
+    subscriberType: string;
+    topicName: any;
+    topicProvider: string;
   };
 }

+ 24 - 0
src/services/notice/index.ts

@@ -0,0 +1,24 @@
+import BaseService from '@/utils/BaseService';
+import { request } from 'umi';
+import SystemConst from '@/utils/const';
+
+class Service extends BaseService<API.NoticeIconItem> {
+  public fetchNotices = (params?: any) =>
+    request(`/${SystemConst.API_BASE}/notifications/_query`, {
+      method: 'GET',
+      params,
+    });
+
+  public clearNotices = (data?: any[]) =>
+    request(`/${SystemConst.API_BASE}/notifications/_read`, {
+      method: 'POST',
+      data,
+    });
+
+  public changeNoticeReadState = (id: string) =>
+    request(`/${SystemConst.API_BASE}/notifications/${id}/read`, {
+      method: 'GET',
+    });
+}
+
+export default Service;

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 106 - 75
yarn.lock