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

+ 25 - 10
src/app.tsx

@@ -19,6 +19,7 @@ import getRoutes, {
   getMenus,
   handleRoutes,
   saveMenusCache,
+  getRoutesLayout,
 } from '@/utils/menu';
 import { AIcon } from '@/components';
 import React from 'react';
@@ -282,7 +283,6 @@ export const layout: RunTimeLayoutConfig = ({ initialState }) => {
     onPageChange: () => {
       const { location } = history;
       // 如果没有登录,重定向到 login
-      console.log(location, 'location');
       if (
         !initialState?.currentUser &&
         location.pathname !== loginPath &&
@@ -298,7 +298,6 @@ export const layout: RunTimeLayoutConfig = ({ initialState }) => {
     menuItemRender: (menuItemProps, defaultDom) => {
       return MenuItemIcon(menuItemProps, defaultDom, {
         onClick: () => {
-          console.log('menuItemProps', menuItemProps);
           history.push(menuItemProps.path!);
         },
       });
@@ -348,7 +347,7 @@ export const layout: RunTimeLayoutConfig = ({ initialState }) => {
 };
 
 export function patchRoutes(routes: any) {
-  // console.log(routes,'11111111111')
+  console.log(routes);
   if (extraRoutes && extraRoutes.length) {
     const basePath = routes.routes.find((_route: any) => _route.path === '/')!;
 
@@ -417,10 +416,26 @@ export function render(oldRender: any) {
   }
 }
 
-// export function onRouteChange({ routes, location }) {
-//   console.log(routes,location,'onRouteChange')
-//   // const route = matchRoutes(clientRoutes, location.pathname)?.pop()?.route
-//   // if (route) {
-//   //   document.title = route.title || '';
-//   // }
-// }
+export function onRouteChange({ routes, location }: any) {
+  // console.log(11111111111)
+  // debugger;
+  if (location.query && location.query.layout === 'false') {
+    // console.log(routes, 'onRouteChange')
+    const basePath = routes.find((_route: any) => _route.path === '/')!;
+    const _routes = getRoutesLayout(extraRoutes);
+    const baseRedirect = {
+      path: '/',
+      layout: false,
+      routes: [
+        ..._routes,
+        {
+          path: '/',
+          layout: false,
+          redirect: _routes[0].path,
+        },
+      ],
+    };
+    // debugger
+    basePath.routes = [...basePath.routes, baseRedirect];
+  }
+}

+ 7 - 2
src/components/ProTableCard/CardItems/Stream/index.tsx

@@ -2,6 +2,7 @@ import React from 'react';
 import { Ellipsis, TableCard } from '@/components';
 import '@/style/common.less';
 import './index.less';
+import { StatusColorEnum } from '@/components/BadgeStatus';
 
 export interface StreamCardProps extends StreamItem {
   detail?: React.ReactNode;
@@ -16,8 +17,12 @@ export default (props: StreamCardProps) => {
     <TableCard
       detail={props.detail}
       actions={props.actions}
-      showStatus={false}
-      showMask={false}
+      status={props?.state?.value}
+      statusText={props?.state?.text}
+      statusNames={{
+        enabled: StatusColorEnum.success,
+        disabled: StatusColorEnum.error,
+      }}
       className={'stream-card-item'}
     >
       <div className="context-stream">

+ 2 - 2
src/pages/document.ejs

@@ -224,11 +224,11 @@
           </div>
         </div>
         <div style="display: flex; align-items: center; justify-content: center">
-          <img
+          <!-- <img
             src="<%= context.config.publicPath + 'logo.svg' %>"
             width="200"
             style="margin-right: 8px"
-          />
+          /> -->
         </div>
       </div>
     </div>

+ 14 - 9
src/pages/link/Channel/Opcua/Export/index.tsx

@@ -26,15 +26,20 @@ const Export = (props: Props) => {
   });
 
   useEffect(() => {
-    service.noPagingOpcua({ paging: false }).then((resp) => {
-      if (resp.status === 200) {
-        const items = resp.result.map((item: { name: any; id: any }) => ({
-          label: item.name,
-          value: item.id,
-        }));
-        setList(items);
-      }
-    });
+    service
+      .noPagingOpcua({
+        paging: false,
+        sorts: [{ name: 'createTime', order: 'desc' }],
+      })
+      .then((resp) => {
+        if (resp.status === 200) {
+          const items = resp.result.map((item: { name: any; id: any }) => ({
+            label: item.name,
+            value: item.id,
+          }));
+          setList(items);
+        }
+      });
   }, []);
 
   const form = createForm();

+ 3 - 9
src/pages/link/Channel/Opcua/index.tsx

@@ -195,15 +195,9 @@ const NewOpc = () => {
             }),
             onConfirm: async () => {
               if (record.state.value === 'disabled') {
-                await service.editPoint(record.id, {
-                  ...record,
-                  state: 'enabled',
-                });
+                await service._enable([record.id]);
               } else {
-                await service.editPoint(record.id, {
-                  ...record,
-                  state: 'disabled',
-                });
+                await service._disabled([record.id]);
               }
               onlyMessage(
                 intl.formatMessage({
@@ -367,7 +361,7 @@ const NewOpc = () => {
                 isPermission={permission.add}
                 key="add"
                 icon={<PlusOutlined />}
-                type="default"
+                type="primary"
                 style={{ width: '100%', marginTop: 16, marginBottom: 16 }}
               >
                 新增

+ 4 - 4
src/pages/link/Channel/Opcua/savePoint.tsx

@@ -183,16 +183,16 @@ const SavePoint = (props: Props) => {
                 <Select.Option value="pull" key={'pull'}>
                   拉取
                 </Select.Option>
-                <Select.Option value="pullChange" key={'pullChange'}>
+                <Select.Option value="pullChanged" key={'pullChanged'}>
                   拉取变更值
                 </Select.Option>
-                <Select.Option value="pullPassive" key={'pullPassive'}>
+                <Select.Option value="active" key={'active'}>
                   被动读取
                 </Select.Option>
               </Select>
             </Form.Item>
           </Col>
-          {dataMode !== 'pullPassive' && (
+          {dataMode !== 'active' && (
             <Col span={12}>
               {dataMode === 'sub' && (
                 <Form.Item
@@ -217,7 +217,7 @@ const SavePoint = (props: Props) => {
                   />
                 </Form.Item>
               )}
-              {(dataMode === 'pullChange' || dataMode === 'pull') && (
+              {(dataMode === 'pullChanged' || dataMode === 'pull') && (
                 <Form.Item
                   label="拉取频率"
                   name="interval"

+ 10 - 0
src/pages/link/Channel/Opcua/service.ts

@@ -37,6 +37,16 @@ class Service extends BaseService<OpaUa> {
       method: 'POST',
       data: params,
     });
+  _enable = (params: any) =>
+    request(`${SystemConst.API_BASE}/opc/point/_enable`, {
+      method: 'POST',
+      data: params,
+    });
+  _disabled = (params: any) =>
+    request(`${SystemConst.API_BASE}/opc/point/_disable`, {
+      method: 'POST',
+      data: params,
+    });
   PointList = (params: any) =>
     request(`${SystemConst.API_BASE}/opc/point/_query`, {
       method: 'POST',

+ 52 - 1
src/pages/media/Stream/index.tsx

@@ -6,7 +6,13 @@ import { useEffect, useState } from 'react';
 import Service from '@/pages/media/Stream/service';
 import { getMenuPathByParams, MENUS_CODE } from '@/utils/menu';
 import { useHistory } from 'umi';
-import { DeleteOutlined, EditOutlined, PlusOutlined } from '@ant-design/icons';
+import {
+  CloseCircleOutlined,
+  DeleteOutlined,
+  EditOutlined,
+  PlayCircleOutlined,
+  PlusOutlined,
+} from '@ant-design/icons';
 import { model } from '@formily/reactive';
 import { PermissionButton } from '@/components';
 import { useDomFullHeight } from '@/hooks';
@@ -34,6 +40,21 @@ const Stream = () => {
       title: '名称',
       ellipsis: true,
     },
+    {
+      dataIndex: 'state',
+      title: '状态',
+      valueType: 'select',
+      valueEnum: {
+        disabled: {
+          text: '禁用',
+          status: 'disabled',
+        },
+        enabled: {
+          text: '正常',
+          status: 'enabled',
+        },
+      },
+    },
   ];
 
   const [dataSource, setDataSource] = useState<any>({
@@ -120,6 +141,36 @@ const Stream = () => {
                             编辑
                           </PermissionButton>,
                           <PermissionButton
+                            isPermission={permission.action}
+                            key="action"
+                            type={'link'}
+                            popConfirm={{
+                              title: `确认${item?.state?.value === 'enabled' ? '禁用' : '启用'}?`,
+                              onConfirm: async () => {
+                                if (item?.state?.value === 'enabled') {
+                                  const res = await service.disable(item.id);
+                                  if (res.status === 200) {
+                                    onlyMessage('操作成功');
+                                    handleSearch(param);
+                                  }
+                                } else {
+                                  const res = await service.enalbe(item.id);
+                                  if (res.status === 200) {
+                                    onlyMessage('操作成功');
+                                    handleSearch(param);
+                                  }
+                                }
+                              },
+                            }}
+                          >
+                            {item?.state?.value === 'enabled' ? (
+                              <CloseCircleOutlined />
+                            ) : (
+                              <PlayCircleOutlined />
+                            )}
+                            {item?.state?.value === 'enabled' ? '禁用' : '启用'}
+                          </PermissionButton>,
+                          <PermissionButton
                             isPermission={permission.delete}
                             popConfirm={{
                               title: '确认删除',

+ 4 - 0
src/pages/media/Stream/typings.d.ts

@@ -12,4 +12,8 @@ type StreamItem = {
     dynamicRtpPort: boolean;
     dynamicRtpPortRange: number[];
   };
+  state: {
+    value: string;
+    text: string;
+  };
 };

+ 1 - 1
src/pages/notice/Template/Detail/doc/DingTalk.tsx

@@ -29,7 +29,7 @@ const DingTalk = () => {
       <div> 使用固定的通知配置发送此通知模板</div>
       <h2> 2、Agentid</h2>
       <div> 应用唯一标识</div>
-      <div> 获取路径:“钉钉开平台”--“应用开发”--“查看应用”</div>
+      <div> 获取路径:“钉钉开平台”--“应用开发”--“查看应用”</div>
       <div className="image">
         <Image width="100%" src={agentId} />
       </div>

+ 1 - 1
src/pages/notice/Template/Detail/doc/DingTalkRebot.tsx

@@ -15,7 +15,7 @@ const DingTalkRebot = () => {
         通知模板结合通知配置为告警消息通知提供支撑。通知模板只能调用同一类型的通知配置服务。
       </div>
       <div>
-        使用钉钉群机器人消息通知时需在钉钉开平台中创建好对应的机器人,再到钉钉客户端在对应的群众绑定智能机器人。
+        使用钉钉群机器人消息通知时需在钉钉开平台中创建好对应的机器人,再到钉钉客户端在对应的群众绑定智能机器人。
       </div>
       <h1>2.模板配置说明</h1>
       <div>

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

@@ -795,7 +795,7 @@ const Detail = observer(() => {
                     properties: {
                       departmentIdList: {
                         title: '收信部门',
-                        required: true,
+                        // required: true,
                         'x-component': 'Select',
                         'x-decorator': 'FormItem',
                         // 'x-decorator-props': {

+ 10 - 0
src/pages/system/Menu/Setting/baseMenu.ts

@@ -510,6 +510,11 @@ export default [
                 name: '新增',
                 permissions: [{ permission: 'certificate', actions: ['save'] }],
               },
+              {
+                id: 'view',
+                name: '查看',
+                permissions: [{ permission: 'certificate', actions: ['query'] }],
+              },
             ],
           },
           {
@@ -538,6 +543,11 @@ export default [
                 permissions: [{ permission: 'media-server', actions: ['query', 'save'] }],
               },
               {
+                id: 'action',
+                name: '启/禁用',
+                permissions: [{ permission: 'media-server', actions: ['save'] }],
+              },
+              {
                 id: 'add',
                 name: '新增',
                 permissions: [{ permission: 'media-server', actions: ['query', 'save'] }],

+ 36 - 0
src/utils/menu/index.ts

@@ -270,6 +270,42 @@ const getRoutes = (extraRoutes: MenuItem[], level = 1): IRouteProps[] => {
     return _route;
   });
 };
+export const getRoutesLayout = (extraRoutes: MenuItem[], level = 1): IRouteProps[] => {
+  const allComponents = findComponents(require.context('@/pages', true, /index(\.tsx)$/));
+  return extraRoutes.map((route) => {
+    const component = allComponents[route.code] || null;
+    const _route: IRouteProps = {
+      key: route.url,
+      name: route.name,
+      path: route.url,
+      layout: false,
+    };
+
+    // console.log(_route,'layout')
+    if (route.children && route.children.length) {
+      const flatRoutes = getRoutes(flatRoute(route.children || []), level + 1);
+      const redirect = flatRoutes.filter((r) => r.component)[0]?.path;
+      _route.children = redirect
+        ? [
+            ...flatRoutes,
+            {
+              path: _route.path,
+              exact: true,
+              redirect: redirect,
+            },
+          ]
+        : flatRoutes;
+    } else if (component) {
+      _route.component = component;
+    }
+
+    if (level !== 1) {
+      _route.exact = true;
+    }
+    // console.log(_route);
+    return _route;
+  });
+};
 
 export const getMenus = (extraRoutes: IRouteProps[]): any[] => {
   return extraRoutes.map((route) => {