Ver código fonte

feat: 开源功能前端修改

100011797 3 anos atrás
pai
commit
15d95328ce

+ 11 - 14
src/app.tsx

@@ -399,7 +399,6 @@ export const layout: RunTimeLayoutConfig = ({ initialState }) => {
 };
 
 export function patchRoutes(routes: any) {
-  // console.log(routes);
   if (extraRoutes && extraRoutes.length) {
     const basePath = routes.routes.find((_route: any) => _route.path === '/')!;
 
@@ -448,20 +447,18 @@ export function render(oldRender: any) {
         localStorage.setItem(SystemConst.AMAP_KEY, res.result.api);
       }
     });
-    MenuService.queryOwnThree({ paging: false, terms: params }).then((res) => {
-      if (res && res.status === 200) {
-        // if (isDev) {
-        //   res.result.push({
-        //     code: 'iframe',
-        //     id: 'iframe',
-        //     name: '例子',
-        //     url: '/iframe',
-        //   });
-        // }
-        extraRoutes = handleRoutes([...res.result, ...extraRouteArr]);
-        saveMenusCache(extraRoutes);
+    Service.getSystemVersion().then((resp) => {
+      if (resp && resp.status === 200 && resp.result) {
+        localStorage.setItem(SystemConst.Version_Code, resp.result.edition);
+        const isCommunity = resp.result?.edition === 'community';
+        MenuService.queryOwnThree({ paging: false, terms: params }).then((res) => {
+          if (res && res.status === 200) {
+            extraRoutes = handleRoutes([...res.result, ...extraRouteArr], isCommunity);
+            saveMenusCache(extraRoutes);
+          }
+          oldRender();
+        });
       }
-      oldRender();
     });
   } else {
     oldRender();

+ 84 - 82
src/pages/account/Center/index.tsx

@@ -24,7 +24,7 @@ import moment from 'moment';
 import { useModel } from 'umi';
 import usePermissions from '@/hooks/permission';
 import { Ellipsis, PermissionButton } from '@/components';
-import { onlyMessage } from '@/utils/util';
+import { isNoCommunity, onlyMessage } from '@/utils/util';
 import AccountInit from '@/pages/home/init/accountInit';
 
 export const service = new Service();
@@ -238,90 +238,92 @@ const Center = () => {
           </div>
         </div>
       </Card>
-      <Card
-        className={styles.info}
-        title={
-          <div style={{ fontSize: '22px' }}>
-            <Divider type="vertical" style={{ backgroundColor: '#2F54EB', width: 3 }} />
-            绑定三方账号
-          </div>
-        }
-      >
-        <Row gutter={[24, 24]}>
-          {bindList.map((item: any) => (
-            <Col key={item.id}>
-              <Card
-                style={{
-                  background: `url(${
-                    bGroundMap.get(item.provider) ||
-                    require('/public/images/notice/dingtalk-background.png')
-                  }) no-repeat`,
-                  backgroundSize: '100% 100%',
-                  width: 415,
-                }}
-              >
-                <div className={styles.bind}>
-                  <div>
-                    <img style={{ height: 56 }} src={iconMap.get(item.provider)} />
-                  </div>
-                  <div>
-                    {item.bound ? (
-                      <div>
-                        <div style={{ fontSize: '22px' }}>绑定名:{item.others.name}</div>
-                        <div
-                          style={{
-                            fontSize: '14px',
-                            lineHeight: '20px',
-                            marginTop: '5px',
-                            color: '#00000073',
+      {isNoCommunity && (
+        <Card
+          className={styles.info}
+          title={
+            <div style={{ fontSize: '22px' }}>
+              <Divider type="vertical" style={{ backgroundColor: '#2F54EB', width: 3 }} />
+              绑定三方账号
+            </div>
+          }
+        >
+          <Row gutter={[24, 24]}>
+            {bindList.map((item: any) => (
+              <Col key={item.id}>
+                <Card
+                  style={{
+                    background: `url(${
+                      bGroundMap.get(item.provider) ||
+                      require('/public/images/notice/dingtalk-background.png')
+                    }) no-repeat`,
+                    backgroundSize: '100% 100%',
+                    width: 415,
+                  }}
+                >
+                  <div className={styles.bind}>
+                    <div>
+                      <img style={{ height: 56 }} src={iconMap.get(item.provider)} />
+                    </div>
+                    <div>
+                      {item.bound ? (
+                        <div>
+                          <div style={{ fontSize: '22px' }}>绑定名:{item.others.name}</div>
+                          <div
+                            style={{
+                              fontSize: '14px',
+                              lineHeight: '20px',
+                              marginTop: '5px',
+                              color: '#00000073',
+                            }}
+                          >
+                            绑定时间: {moment(item.bindTime).format('YYYY-MM-DD HH:mm:ss')}
+                          </div>
+                        </div>
+                      ) : (
+                        <div style={{ fontSize: '22px', width: 150 }}>
+                          <Ellipsis title={`${item.name}未绑定`} />
+                        </div>
+                      )}
+                    </div>
+                    <div>
+                      {item.bound ? (
+                        <Popconfirm
+                          title="确认解除绑定嘛?"
+                          onConfirm={() => {
+                            unBind(item.id);
                           }}
                         >
-                          绑定时间: {moment(item.bindTime).format('YYYY-MM-DD HH:mm:ss')}
-                        </div>
-                      </div>
-                    ) : (
-                      <div style={{ fontSize: '22px', width: 150 }}>
-                        <Ellipsis title={`${item.name}未绑定`} />
-                      </div>
-                    )}
-                  </div>
-                  <div>
-                    {item.bound ? (
-                      <Popconfirm
-                        title="确认解除绑定嘛?"
-                        onConfirm={() => {
-                          unBind(item.id);
-                        }}
-                      >
-                        <Button>解除绑定</Button>
-                      </Popconfirm>
-                    ) : (
-                      <Button
-                        type="primary"
-                        onClick={() => {
-                          window.open(
-                            `/${SystemConst.API_BASE}/application/sso/${item.id}/login?autoCreateUser=false`,
-                          );
-                          // window.open(`/#/account/center/bind`);
-                          localStorage.setItem('onBind', 'false');
-                          localStorage.setItem('onLogin', 'yes');
-                          window.onstorage = (e) => {
-                            if (e.newValue) {
-                              getBindInfo();
-                            }
-                          };
-                        }}
-                      >
-                        立即绑定
-                      </Button>
-                    )}
+                          <Button>解除绑定</Button>
+                        </Popconfirm>
+                      ) : (
+                        <Button
+                          type="primary"
+                          onClick={() => {
+                            window.open(
+                              `/${SystemConst.API_BASE}/application/sso/${item.id}/login?autoCreateUser=false`,
+                            );
+                            // window.open(`/#/account/center/bind`);
+                            localStorage.setItem('onBind', 'false');
+                            localStorage.setItem('onLogin', 'yes');
+                            window.onstorage = (e) => {
+                              if (e.newValue) {
+                                getBindInfo();
+                              }
+                            };
+                          }}
+                        >
+                          立即绑定
+                        </Button>
+                      )}
+                    </div>
                   </div>
-                </div>
-              </Card>
-            </Col>
-          ))}
-        </Row>
-      </Card>
+                </Card>
+              </Col>
+            ))}
+          </Row>
+        </Card>
+      )}
       <Card
         style={{ marginTop: 15 }}
         title={

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

@@ -13,6 +13,7 @@ import { AMap } from '@/components';
 import { Marker } from 'react-amap';
 import { EnvironmentOutlined } from '@ant-design/icons';
 import SystemConst from '@/utils/const';
+import { isNoCommunity } from '@/utils/util';
 
 type RefType = {
   getValues: Function;
@@ -401,7 +402,9 @@ const DeviceBoard = () => {
     productStatus();
     getOnline();
     getDevice();
-    geo({});
+    if (isNoCommunity) {
+      geo({});
+    }
   }, []);
 
   useEffect(() => {
@@ -488,7 +491,7 @@ const DeviceBoard = () => {
           showTimeTool={true}
           onParamsChange={getEcharts}
         />
-        {amapKey && (
+        {amapKey && isNoCommunity && (
           <Card style={{ marginTop: 10 }}>
             <div
               style={{

+ 31 - 9
src/pages/device/Instance/index.tsx

@@ -50,6 +50,7 @@ export const InstanceModel = model<{
   metadataItem: MetadataItem;
   params: Set<string>; // 处理无限循环Card
   active?: string; // 当前编辑的Card
+  selectedRows: Map<string, any>;
 }>({
   current: {},
   detail: {},
@@ -57,6 +58,7 @@ export const InstanceModel = model<{
   metadataItem: {},
   active: 'detail',
   params: new Set<string>(['test']),
+  selectedRows: new Map(),
 });
 export const service = new Service('device-instance');
 const Instance = () => {
@@ -70,7 +72,6 @@ const Instance = () => {
   const [current, setCurrent] = useState<Partial<DeviceInstance>>({});
   const [searchParams, setSearchParams] = useState<any>({});
   const [bindKeys, setBindKeys] = useState<any[]>([]);
-  const [selectedRows, setSelectedRows] = useState<any[]>([]);
   const history = useHistory<Record<string, string>>();
   const { permission } = PermissionButton.usePermission('device/Instance');
 
@@ -533,11 +534,13 @@ const Instance = () => {
             popConfirm={{
               title: '已启用的设备无法删除,确认删除选中的禁用状态设备?',
               onConfirm: () => {
-                const list = (selectedRows || [])
-                  .filter((item) => item.state?.value === 'notActive')
-                  .map((i) => i.id);
-                if (!list.length) return;
-                service.batchDeleteDevice(list).then((resp) => {
+                InstanceModel.selectedRows.forEach((value, key) => {
+                  if (value !== 'notActive') {
+                    InstanceModel.selectedRows.delete(key);
+                  }
+                });
+                if (!InstanceModel.selectedRows.size) return;
+                service.batchDeleteDevice([...InstanceModel.selectedRows.keys()]).then((resp) => {
                   if (resp.status === 200) {
                     onlyMessage('操作成功');
                     actionRef.current?.reset?.();
@@ -651,9 +654,28 @@ const Instance = () => {
         pagination={{ pageSize: 10 }}
         rowSelection={{
           selectedRowKeys: bindKeys,
-          onChange: (selectedRowKeys, selectedRow) => {
-            setBindKeys(selectedRowKeys);
-            setSelectedRows(selectedRow);
+          // onChange: (selectedRowKeys) => {
+          //   setBindKeys(selectedRowKeys);
+          // },
+          onSelect: (record, selected) => {
+            if (selected) {
+              InstanceModel.selectedRows.set(record.id, record?.state?.value);
+            } else {
+              InstanceModel.selectedRows.delete(record.id);
+            }
+            setBindKeys([...InstanceModel.selectedRows.keys()]);
+          },
+          onSelectAll: (selected, _, changeRows) => {
+            if (selected) {
+              changeRows.forEach((item) => {
+                InstanceModel.selectedRows.set(item.id, item?.state?.value);
+              });
+            } else {
+              changeRows.forEach((item) => {
+                InstanceModel.selectedRows.delete(item.id);
+              });
+            }
+            setBindKeys([...InstanceModel.selectedRows.keys()]);
           },
         }}
         headerTitle={[

+ 43 - 24
src/pages/link/AccessConfig/Detail/Provider/index.tsx

@@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';
 import { TitleComponent } from '@/components';
 import { Button, Card, Col, Row, Tooltip } from 'antd';
 import styles from './index.less';
+import { isNoCommunity } from '@/utils/util';
 
 interface Props {
   data: any[];
@@ -12,7 +13,6 @@ const Provider = (props: Props) => {
   const [dataSource, setDataSource] = useState<any[]>([]);
 
   useEffect(() => {
-    console.log(props.data);
     const media: any[] = [];
     const network: any[] = [];
     const cloud: any[] = [];
@@ -28,29 +28,48 @@ const Provider = (props: Props) => {
         network.push(item);
       }
     });
-
-    setDataSource([
-      {
-        type: 'network',
-        list: [...network],
-        title: '自定义设备接入',
-      },
-      {
-        type: 'media',
-        list: [...media],
-        title: '视频类设备接入',
-      },
-      {
-        type: 'cloud',
-        list: [...cloud],
-        title: '云平台接入',
-      },
-      {
-        type: 'channel',
-        list: [...channel],
-        title: '通道类设备接入',
-      },
-    ]);
+    if (!isNoCommunity) {
+      const list = network.filter(
+        (item) =>
+          item.id &&
+          [
+            'mqtt-server-gateway',
+            'http-server-gateway',
+            'mqtt-client-gateway',
+            'tcp-server-gateway',
+          ].includes(item.id),
+      );
+      setDataSource([
+        {
+          type: 'network',
+          list: [...list],
+          title: '自定义设备接入',
+        },
+      ]);
+    } else {
+      setDataSource([
+        {
+          type: 'network',
+          list: [...network],
+          title: '自定义设备接入',
+        },
+        {
+          type: 'media',
+          list: [...media],
+          title: '视频类设备接入',
+        },
+        {
+          type: 'cloud',
+          list: [...cloud],
+          title: '云平台接入',
+        },
+        {
+          type: 'channel',
+          list: [...channel],
+          title: '通道类设备接入',
+        },
+      ]);
+    }
   }, [props.data]);
 
   const backMap = new Map();

+ 8 - 6
src/pages/link/Type/Detail/index.tsx

@@ -20,7 +20,7 @@ import { onFormInit } from '@formily/core';
 import { createForm, onFieldReact, onFieldValueChange } from '@formily/core';
 import { Card, Col, Row } from 'antd';
 import styles from './index.less';
-import { onlyMessage, useAsyncDataSource } from '@/utils/util';
+import { isNoCommunity, onlyMessage, useAsyncDataSource } from '@/utils/util';
 import { service } from '../index';
 import _ from 'lodash';
 import FAutoComplete from '@/components/FAutoComplete';
@@ -94,7 +94,7 @@ const Save = observer(() => {
           value: item.id,
         }));
         Store.set('resources-cluster', _data);
-        return _data.filter((j: any) => !checked.includes(j.value));
+        return (_data || []).filter((j: any) => !checked.includes(j.value));
       });
     }
   };
@@ -868,10 +868,12 @@ const Save = observer(() => {
             'x-component': 'Radio.Group',
             required: true,
             default: true,
-            enum: [
-              { label: '共享配置', value: true },
-              { label: '独立配置', value: false },
-            ],
+            enum: isNoCommunity
+              ? [
+                  { label: '共享配置', value: true },
+                  { label: '独立配置', value: false },
+                ]
+              : [{ label: '共享配置', value: true }],
             'x-component-props': {
               buttonStyle: 'solid',
               optionType: 'button',

+ 10 - 5
src/pages/rule-engine/Scene/Save/action/device/index.tsx

@@ -7,6 +7,7 @@ import TagModal from './tagModal';
 import { ItemGroup } from '@/pages/rule-engine/Scene/Save/components';
 import RelationSelect from './relationSelect';
 import encodeQuery from '@/utils/encodeQuery';
+import { isNoCommunity } from '@/utils/util';
 
 interface DeviceProps {
   name: number;
@@ -86,11 +87,15 @@ export default (props: DeviceProps) => {
 
   useEffect(() => {
     if (props.triggerType === 'device') {
-      setSourceList([
-        ...DefaultSourceOptions,
-        { label: '按关系', value: SourceEnum.relation },
-        { label: '按标签', value: SourceEnum.tag },
-      ]);
+      if (isNoCommunity) {
+        setSourceList([
+          ...DefaultSourceOptions,
+          { label: '按关系', value: SourceEnum.relation },
+          { label: '按标签', value: SourceEnum.tag },
+        ]);
+      } else {
+        setSourceList([...DefaultSourceOptions, { label: '按标签', value: SourceEnum.tag }]);
+      }
     } else {
       setSourceList(DefaultSourceOptions);
     }

+ 20 - 16
src/pages/system/Department/Assets/deivce/index.tsx

@@ -12,7 +12,7 @@ import Bind from './bind';
 import SearchComponent from '@/components/SearchComponent';
 import { ExtraDeviceCard, handlePermissionsMap } from '@/components/ProTableCard/CardItems/device';
 import { PermissionButton, ProTableCard } from '@/components';
-import { onlyMessage } from '@/utils/util';
+import { isNoCommunity, onlyMessage } from '@/utils/util';
 import { ASSETS_TABS_ENUM, AssetsModel } from '@/pages/system/Department/Assets';
 import UpdateModal from '@/pages/system/Department/Assets/updateModal';
 import encodeQuery from '@/utils/encodeQuery';
@@ -398,21 +398,25 @@ export default observer((props: { parentId: string }) => {
           />
         )}
         toolBarRender={() => [
-          <PermissionButton
-            onClick={() => {
-              Models.bind = true;
-            }}
-            icon={<PlusOutlined />}
-            type="primary"
-            key="bind"
-            disabled={!props.parentId}
-            isPermission={permission.assert}
-          >
-            {intl.formatMessage({
-              id: 'pages.data.option.assets',
-              defaultMessage: '资产分配',
-            })}
-          </PermissionButton>,
+          <>
+            {isNoCommunity && (
+              <PermissionButton
+                onClick={() => {
+                  Models.bind = true;
+                }}
+                icon={<PlusOutlined />}
+                type="primary"
+                key="bind"
+                disabled={!props.parentId}
+                isPermission={permission.assert}
+              >
+                {intl.formatMessage({
+                  id: 'pages.data.option.assets',
+                  defaultMessage: '资产分配',
+                })}
+              </PermissionButton>
+            )}
+          </>,
           <PermissionButton
             icon={<DisconnectOutlined />}
             key="unBind"

+ 20 - 16
src/pages/system/Department/Assets/product/index.tsx

@@ -15,7 +15,7 @@ import {
   handlePermissionsMap,
 } from '@/components/ProTableCard/CardItems/product';
 import { ProTableCard, PermissionButton } from '@/components';
-import { onlyMessage } from '@/utils/util';
+import { isNoCommunity, onlyMessage } from '@/utils/util';
 import { ASSETS_TABS_ENUM, AssetsModel } from '@/pages/system/Department/Assets';
 import UpdateModal from '../updateModal';
 
@@ -366,21 +366,25 @@ export default observer((props: { parentId: string }) => {
           />
         )}
         toolBarRender={() => [
-          <PermissionButton
-            onClick={() => {
-              Models.bind = true;
-            }}
-            icon={<PlusOutlined />}
-            type="primary"
-            key="bind"
-            disabled={!props.parentId}
-            isPermission={permission.assert}
-          >
-            {intl.formatMessage({
-              id: 'pages.data.option.assets',
-              defaultMessage: '资产分配',
-            })}
-          </PermissionButton>,
+          <>
+            {isNoCommunity && (
+              <PermissionButton
+                onClick={() => {
+                  Models.bind = true;
+                }}
+                icon={<PlusOutlined />}
+                type="primary"
+                key="bind"
+                disabled={!props.parentId}
+                isPermission={permission.assert}
+              >
+                {intl.formatMessage({
+                  id: 'pages.data.option.assets',
+                  defaultMessage: '资产分配',
+                })}
+              </PermissionButton>
+            )}
+          </>,
           <PermissionButton
             icon={<DisconnectOutlined />}
             key="unBind"

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

@@ -12,7 +12,7 @@ import Service from '@/pages/system/Department/Assets/service';
 import Bind from './bind';
 import SearchComponent from '@/components/SearchComponent';
 import { difference } from 'lodash';
-import { onlyMessage } from '@/utils/util';
+import { isNoCommunity, onlyMessage } from '@/utils/util';
 import { ASSETS_TABS_ENUM, AssetsModel } from '@/pages/system/Department/Assets';
 
 export const service = new Service<ProductCategoryItem>('assets');
@@ -280,20 +280,24 @@ export default observer((props: { parentId: string }) => {
           );
         }}
         toolBarRender={() => [
-          <Button
-            onClick={() => {
-              Models.bind = true;
-            }}
-            icon={<PlusOutlined />}
-            type="primary"
-            disabled={!props.parentId}
-            key="bind"
-          >
-            {intl.formatMessage({
-              id: 'pages.data.option.assets',
-              defaultMessage: '资产分配',
-            })}
-          </Button>,
+          <>
+            {isNoCommunity && (
+              <Button
+                onClick={() => {
+                  Models.bind = true;
+                }}
+                icon={<PlusOutlined />}
+                type="primary"
+                disabled={!props.parentId}
+                key="bind"
+              >
+                {intl.formatMessage({
+                  id: 'pages.data.option.assets',
+                  defaultMessage: '资产分配',
+                })}
+              </Button>
+            )}
+          </>,
           <Popconfirm
             title={intl.formatMessage({
               id: 'pages.system.role.option.unBindUser',

+ 1 - 0
src/pages/system/Menu/typing.d.ts

@@ -61,6 +61,7 @@ export type MenuItem = {
   children?: MenuItem[];
   accessSupport?: { text: string; value: string };
   appId?: string; //应用id
+  isShow?: boolean;
 };
 
 /**

+ 90 - 85
src/pages/system/Role/Detail/Permission/Allocate/MenuPermission.tsx

@@ -3,6 +3,7 @@ import { Checkbox, Radio, Select, Tooltip } from 'antd';
 import type { CheckboxValueType } from 'antd/lib/checkbox/Group';
 import _ from 'lodash';
 import { useEffect, useState } from 'react';
+import { isNoCommunity } from '@/utils/util';
 
 interface Props {
   value: any;
@@ -93,8 +94,10 @@ const MenuPermission = (props: Props) => {
           style={{
             display: 'flex',
             alignItems: 'center',
-            width: `calc(50% - ${(props?.level || 0) * 5}px)`,
-            borderRight: '1px solid #f0f0f0',
+            width: isNoCommunity
+              ? `calc(50% - ${(props?.level || 0) * 5}px)`
+              : `calc(100% - ${(props?.level || 0) * 5}px)`,
+            borderRight: isNoCommunity ? '1px solid #f0f0f0' : 'none',
           }}
         >
           <div>
@@ -222,92 +225,94 @@ const MenuPermission = (props: Props) => {
             )}
           </div>
         </div>
-        <div
-          style={{
-            width: `calc(50% - ${(props?.level || 0) * 10}px - 20px)`,
-            padding: '10px 0 10px 20px',
-          }}
-        >
-          {value.id === 'menu-permission' ? (
-            <div style={{ display: 'flex', alignItems: 'center' }}>
-              <span style={{ fontWeight: value.id === 'menu-permission' ? 600 : 400 }}>
-                数据权限
-                <Tooltip title="勾选任意数据权限均能看到自己创建的数据权限">
-                  <QuestionCircleOutlined />
-                </Tooltip>
-              </span>
-              <Checkbox
-                checked={checkbox}
-                style={{ margin: '0 10px' }}
-                onChange={(e) => {
-                  setCheckbox(e.target.checked);
-                  setCheckValue('');
-                }}
-              >
-                批量设置
-              </Checkbox>
-              {checkbox && (
-                <Select
-                  showSearch
-                  allowClear
-                  placeholder="请选择"
-                  optionFilterProp="children"
-                  style={{ width: 200 }}
-                  onChange={(val: string) => {
-                    setCheckValue(val);
-                    if (props.checkChange) {
-                      props.checkChange(val);
-                    }
-                  }}
-                  filterOption={(input: any, option: any) =>
-                    (option?.children || '').toLowerCase().indexOf(input.toLowerCase()) >= 0
-                  }
-                >
-                  {(props?.assetsList || []).map((item) => (
-                    <Select.Option key={`${item?.supportId}`} value={item?.supportId}>
-                      {item?.name}
-                    </Select.Option>
-                  ))}
-                </Select>
-              )}
-            </div>
-          ) : (
-            <div>
-              {value?.accessSupport?.value !== 'support' ? (
-                <div>
-                  {value?.accessDescription
-                    ? `${value?.accessDescription}`
-                    : '不支持数据权限配置,默认可查看全部数据'}
-                </div>
-              ) : (
-                <Radio.Group
-                  defaultValue={'creator'}
-                  value={checkValue}
+        {isNoCommunity && (
+          <div
+            style={{
+              width: `calc(50% - ${(props?.level || 0) * 10}px - 20px)`,
+              padding: '10px 0 10px 20px',
+            }}
+          >
+            {value.id === 'menu-permission' ? (
+              <div style={{ display: 'flex', alignItems: 'center' }}>
+                <span style={{ fontWeight: value.id === 'menu-permission' ? 600 : 400 }}>
+                  数据权限
+                  <Tooltip title="勾选任意数据权限均能看到自己创建的数据权限">
+                    <QuestionCircleOutlined />
+                  </Tooltip>
+                </span>
+                <Checkbox
+                  checked={checkbox}
+                  style={{ margin: '0 10px' }}
                   onChange={(e) => {
-                    setCheckValue(e.target.value);
-                    const access = (value?.assetAccesses || []).map((i: any) => {
-                      return {
-                        ...i,
-                        granted: i.supportId === e.target.value,
-                      };
-                    });
-                    const d = {
-                      ...value,
-                      assetAccesses: [...access],
-                    };
-                    props.change(d);
+                    setCheckbox(e.target.checked);
+                    setCheckValue('');
                   }}
                 >
-                  {value?.assetAccesses.map((item: any) => (
-                    <Radio value={item?.supportId} key={item?.supportId}>
-                      {item?.name}
-                    </Radio>
-                  ))}
-                </Radio.Group>
-              )}
-            </div>
-          )}
-        </div>
+                  批量设置
+                </Checkbox>
+                {checkbox && (
+                  <Select
+                    showSearch
+                    allowClear
+                    placeholder="请选择"
+                    optionFilterProp="children"
+                    style={{ width: 200 }}
+                    onChange={(val: string) => {
+                      setCheckValue(val);
+                      if (props.checkChange) {
+                        props.checkChange(val);
+                      }
+                    }}
+                    filterOption={(input: any, option: any) =>
+                      (option?.children || '').toLowerCase().indexOf(input.toLowerCase()) >= 0
+                    }
+                  >
+                    {(props?.assetsList || []).map((item) => (
+                      <Select.Option key={`${item?.supportId}`} value={item?.supportId}>
+                        {item?.name}
+                      </Select.Option>
+                    ))}
+                  </Select>
+                )}
+              </div>
+            ) : (
+              <div>
+                {value?.accessSupport?.value !== 'support' ? (
+                  <div>
+                    {value?.accessDescription
+                      ? `${value?.accessDescription}`
+                      : '不支持数据权限配置,默认可查看全部数据'}
+                  </div>
+                ) : (
+                  <Radio.Group
+                    defaultValue={'creator'}
+                    value={checkValue}
+                    onChange={(e) => {
+                      setCheckValue(e.target.value);
+                      const access = (value?.assetAccesses || []).map((i: any) => {
+                        return {
+                          ...i,
+                          granted: i.supportId === e.target.value,
+                        };
+                      });
+                      const d = {
+                        ...value,
+                        assetAccesses: [...access],
+                      };
+                      props.change(d);
+                    }}
+                  >
+                    {value?.assetAccesses.map((item: any) => (
+                      <Radio value={item?.supportId} key={item?.supportId}>
+                        {item?.name}
+                      </Radio>
+                    ))}
+                  </Radio.Group>
+                )}
+              </div>
+            )}
+          </div>
+        )}
       </div>
       {visible &&
         value?.children &&

+ 2 - 2
src/pages/system/Role/Detail/Permission/index.tsx

@@ -45,12 +45,12 @@ const Permission = () => {
 
   const getDataList: any = (data1: any[]) => {
     if (Array.isArray(data1) && data1.length > 0) {
-      return data1
+      return (data1 || [])
         .filter(
           (i) =>
             i.check === 1 ||
             (i?.buttons || []).filter((it: any) => it.granted).length > 0 ||
-            (i?.assetAccesses).filter((it: any) => it.granted).length > 0,
+            (i?.assetAccesses || []).filter((it: any) => it.granted).length > 0,
         )
         .map((item) => {
           const check = item.check;

+ 4 - 0
src/pages/user/Login/service.ts

@@ -61,6 +61,10 @@ const Service = {
     request(`/${SystemConst.API_BASE}/system/config/${scopes}`, {
       method: 'GET',
     }),
+  getSystemVersion: () =>
+    request(`/${SystemConst.API_BASE}/system/version`, {
+      method: 'GET',
+    }),
   userDetail: () =>
     request(`/${SystemConst.API_BASE}/user/detail`, {
       method: 'GET',

+ 2 - 0
src/utils/const.ts

@@ -28,6 +28,8 @@ class SystemConst {
   static REFRESH_DEVICE = 'refresh_device';
 
   static AMAP_KEY = 'amap_key';
+
+  static Version_Code = 'version_code';
 }
 
 export default SystemConst;

+ 14 - 7
src/utils/menu/index.ts

@@ -2,7 +2,7 @@
 import type { IRouteProps } from 'umi';
 import type { MenuItem } from '@/pages/system/Menu/typing';
 import type { BUTTON_PERMISSION, MENUS_CODE_TYPE } from './router';
-import { getDetailNameByCode, MENUS_CODE } from './router';
+import { getDetailNameByCode, MENUS_CODE, CommunityCodeList } from './router';
 
 /** localStorage key */
 export const MENUS_DATA_CACHE = 'MENUS_DATA_CACHE';
@@ -191,10 +191,10 @@ const findExtraRoutes = (baseCode: string, children: any[], url: string) => {
  * @param routes
  * @param level
  */
-export const handleRoutes = (routes?: MenuItem[], level = 1): MenuItem[] => {
-  // console.log(routes)
-  return routes
-    ? routes.map((item) => {
+export const handleRoutes = (routes?: MenuItem[], isCommunity?: boolean, level = 1): MenuItem[] => {
+  if (routes) {
+    const list = routes
+      .map((item) => {
         // 判断当前是否有额外子路由
         const extraRoutes = extraRouteObj[item.code];
 
@@ -212,7 +212,11 @@ export const handleRoutes = (routes?: MenuItem[], level = 1): MenuItem[] => {
 
         // eslint-disable-next-line @typescript-eslint/no-unused-vars
         if (item.children) {
-          item.children = handleRoutes(item.children, level + 1);
+          const children = handleRoutes(item.children, isCommunity, level + 1);
+          item.children = children;
+          item.isShow = !!children.filter((i) => i.isShow).length;
+        } else {
+          item.isShow = !(isCommunity && !CommunityCodeList.includes(item.code));
         }
         item.level = level;
 
@@ -221,7 +225,10 @@ export const handleRoutes = (routes?: MenuItem[], level = 1): MenuItem[] => {
         }
         return item;
       })
-    : [];
+      .filter((item) => item.isShow);
+    return list;
+  }
+  return [];
 };
 
 /**

+ 37 - 0
src/utils/menu/router.ts

@@ -183,3 +183,40 @@ export const getDetailNameByCode = {
   'Northbound/AliCloud/Detail': '阿里云详情',
   'link/Certificate/Detail': '证书详情',
 };
+
+// 开源版路由
+export const CommunityCodeList = [
+  'account/Center',
+  'account/NotificationSubscription',
+  'system/Basis',
+  'system/User',
+  'system/Department',
+  'system/Department/Detail',
+  'system/Role',
+  'system/Role/Detail',
+  'system/Menu',
+  'system/Menu/Detail',
+  'system/Menu/Setting',
+  'system/Permission',
+  'home',
+  'rule-engine/DashBoard',
+  'rule-engine/Alarm/Configuration',
+  'rule-engine/Alarm/Log',
+  'rule-engine/Alarm/Log/Detail',
+  'device/DashBoard',
+  'device/Category',
+  'device/Instance',
+  'device/Instance/Detail',
+  'device/Product',
+  'device/Product/Detail',
+  'link/AccessConfig',
+  'link/AccessConfig/Detail',
+  'link/Protocol',
+  'Log',
+  'link/Type',
+  'link/Type/Detail',
+  'link/Certificate',
+  'link/Certificate/Detail',
+  'rule-engine/Scene',
+  'rule-engine/Scene/Save',
+];

+ 3 - 0
src/utils/util.ts

@@ -3,6 +3,7 @@ import type { Field, FieldDataSource } from '@formily/core';
 import { action } from '@formily/reactive';
 import Token from '@/utils/token';
 import { message } from 'antd';
+import SystemConst from '@/utils/const';
 /**
  * 下载文件
  * @param url 下载链接
@@ -127,3 +128,5 @@ export const onlyMessage = (
     content: msg,
     key: key,
   });
+
+export const isNoCommunity = !(localStorage.getItem(SystemConst.Version_Code) === 'community');