Просмотр исходного кода

feat: 开源功能前端修改-2

100011797 3 лет назад
Родитель
Сommit
b2987f2fd0

+ 4 - 4
config/proxy.ts

@@ -15,10 +15,10 @@ export default {
       // target: 'http://120.79.18.123:8844/',
       // target: 'http://120.79.18.123:8844/',
       // ws: 'ws://120.79.18.123:8844/',
       // ws: 'ws://120.79.18.123:8844/',
       // 测试环境
       // 测试环境
-      target: 'http://120.77.179.54:8844/',
-      ws: 'ws://120.77.179.54:8844/',
-      // target: 'http://192.168.32.65:8845/',
-      // ws: 'ws://192.168.32.65:8845/',
+      // target: 'http://120.77.179.54:8844/',
+      // ws: 'ws://120.77.179.54:8844/',
+      target: 'http://192.168.32.65:8848/',
+      ws: 'ws://192.168.32.65:8848/',
       //v2环境
       //v2环境
       // ws: 'ws://47.109.52.230:8844',
       // ws: 'ws://47.109.52.230:8844',
       // target: 'http://47.109.52.230:8844',
       // target: 'http://47.109.52.230:8844',

+ 3 - 1
src/pages/account/Center/index.tsx

@@ -132,7 +132,9 @@ const Center = () => {
 
 
   useEffect(() => {
   useEffect(() => {
     getDetail();
     getDetail();
-    getBindInfo();
+    if (isNoCommunity) {
+      getBindInfo();
+    }
   }, []);
   }, []);
 
 
   useEffect(() => {
   useEffect(() => {

+ 34 - 31
src/pages/home/index.tsx

@@ -8,6 +8,7 @@ import Api from './Api';
 import Service from './service';
 import Service from './service';
 import { Skeleton } from 'antd';
 import { Skeleton } from 'antd';
 import { useModel } from '@@/plugin-model/useModel';
 import { useModel } from '@@/plugin-model/useModel';
+import { isNoCommunity } from '@/utils/util';
 
 
 export const service = new Service();
 export const service = new Service();
 const Home = () => {
 const Home = () => {
@@ -50,40 +51,42 @@ const Home = () => {
     });
     });
   }, []);
   }, []);
   useEffect(() => {
   useEffect(() => {
-    service.userDetail().then((res) => {
-      if (res.status === 200) {
-        //三方用户
-        service
-          .apiDetail({
-            terms: [
-              {
-                column: 'userId',
-                value: res.result.id,
-              },
-            ],
-          })
-          .then((response) => {
-            if (response.status === 200) {
-              setDetail(response.result?.data);
-              service.queryViews().then((resp) => {
-                setLoading(false);
-                if (resp.status === 200) {
-                  if (resp.result) {
-                    setCurrent(resp.result?.content);
-                  } else {
-                    if (res.result.username === 'admin') {
-                      setCurrent('comprehensive');
-                      adminView();
+    if (isNoCommunity) {
+      service.userDetail().then((res) => {
+        if (res.status === 200) {
+          //三方用户
+          service
+            .apiDetail({
+              terms: [
+                {
+                  column: 'userId',
+                  value: res.result.id,
+                },
+              ],
+            })
+            .then((response) => {
+              if (response.status === 200) {
+                setDetail(response.result?.data);
+                service.queryViews().then((resp) => {
+                  setLoading(false);
+                  if (resp.status === 200) {
+                    if (resp.result) {
+                      setCurrent(resp.result?.content);
                     } else {
                     } else {
-                      setCurrent('init');
+                      if (res.result.username === 'admin') {
+                        setCurrent('comprehensive');
+                        adminView();
+                      } else {
+                        setCurrent('init');
+                      }
                     }
                     }
                   }
                   }
-                }
-              });
-            }
-          });
-      }
-    });
+                });
+              }
+            });
+        }
+      });
+    }
   }, []);
   }, []);
 
 
   return (
   return (

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

@@ -12,7 +12,7 @@ import Bind from './bind';
 import SearchComponent from '@/components/SearchComponent';
 import SearchComponent from '@/components/SearchComponent';
 import { ExtraDeviceCard, handlePermissionsMap } from '@/components/ProTableCard/CardItems/device';
 import { ExtraDeviceCard, handlePermissionsMap } from '@/components/ProTableCard/CardItems/device';
 import { PermissionButton, ProTableCard } from '@/components';
 import { PermissionButton, ProTableCard } from '@/components';
-import { isNoCommunity, onlyMessage } from '@/utils/util';
+import { onlyMessage } from '@/utils/util';
 import { ASSETS_TABS_ENUM, AssetsModel } from '@/pages/system/Department/Assets';
 import { ASSETS_TABS_ENUM, AssetsModel } from '@/pages/system/Department/Assets';
 import UpdateModal from '@/pages/system/Department/Assets/updateModal';
 import UpdateModal from '@/pages/system/Department/Assets/updateModal';
 import encodeQuery from '@/utils/encodeQuery';
 import encodeQuery from '@/utils/encodeQuery';
@@ -398,25 +398,21 @@ export default observer((props: { parentId: string }) => {
           />
           />
         )}
         )}
         toolBarRender={() => [
         toolBarRender={() => [
-          <>
-            {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
+            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
           <PermissionButton
             icon={<DisconnectOutlined />}
             icon={<DisconnectOutlined />}
             key="unBind"
             key="unBind"

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

@@ -8,6 +8,7 @@ import { model } from '@formily/reactive';
 import { observer } from '@formily/react';
 import { observer } from '@formily/react';
 // import { ExclamationCircleOutlined } from '@ant-design/icons';
 // import { ExclamationCircleOutlined } from '@ant-design/icons';
 import { useEffect } from 'react';
 import { useEffect } from 'react';
+import { isNoCommunity } from '@/utils/util';
 
 
 interface AssetsProps {
 interface AssetsProps {
   parentId: string;
   parentId: string;
@@ -25,11 +26,13 @@ export const AssetsModel = model<{
   bindModal: boolean;
   bindModal: boolean;
   parentId: string;
   parentId: string;
   params: any;
   params: any;
+  tabsArray: any[];
 }>({
 }>({
   tabsIndex: ASSETS_TABS_ENUM.Product,
   tabsIndex: ASSETS_TABS_ENUM.Product,
   bindModal: false,
   bindModal: false,
   parentId: '',
   parentId: '',
   params: {},
   params: {},
+  tabsArray: [],
 });
 });
 
 
 const Assets = observer((props: AssetsProps) => {
 const Assets = observer((props: AssetsProps) => {
@@ -64,6 +67,23 @@ const Assets = observer((props: AssetsProps) => {
   ];
   ];
 
 
   useEffect(() => {
   useEffect(() => {
+    if (isNoCommunity) {
+      AssetsModel.tabsIndex = ASSETS_TABS_ENUM.Product;
+      AssetsModel.tabsArray = [...TabsArray];
+    } else {
+      AssetsModel.tabsIndex = ASSETS_TABS_ENUM.User;
+      AssetsModel.tabsArray = [
+        {
+          intlTitle: '1',
+          defaultMessage: '用户',
+          key: ASSETS_TABS_ENUM.User,
+          components: Member,
+        },
+      ];
+    }
+  }, []);
+
+  useEffect(() => {
     AssetsModel.parentId = props.parentId;
     AssetsModel.parentId = props.parentId;
   }, [props.parentId]);
   }, [props.parentId]);
 
 
@@ -79,7 +99,7 @@ const Assets = observer((props: AssetsProps) => {
           AssetsModel.tabsIndex = key;
           AssetsModel.tabsIndex = key;
         }}
         }}
       >
       >
-        {TabsArray.map((item) => (
+        {(AssetsModel?.tabsArray || []).map((item) => (
           <Tabs.TabPane
           <Tabs.TabPane
             tab={intl.formatMessage({
             tab={intl.formatMessage({
               id: item.intlTitle,
               id: item.intlTitle,

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

@@ -15,7 +15,7 @@ import {
   handlePermissionsMap,
   handlePermissionsMap,
 } from '@/components/ProTableCard/CardItems/product';
 } from '@/components/ProTableCard/CardItems/product';
 import { ProTableCard, PermissionButton } from '@/components';
 import { ProTableCard, PermissionButton } from '@/components';
-import { isNoCommunity, onlyMessage } from '@/utils/util';
+import { onlyMessage } from '@/utils/util';
 import { ASSETS_TABS_ENUM, AssetsModel } from '@/pages/system/Department/Assets';
 import { ASSETS_TABS_ENUM, AssetsModel } from '@/pages/system/Department/Assets';
 import UpdateModal from '../updateModal';
 import UpdateModal from '../updateModal';
 
 
@@ -366,25 +366,21 @@ export default observer((props: { parentId: string }) => {
           />
           />
         )}
         )}
         toolBarRender={() => [
         toolBarRender={() => [
-          <>
-            {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
+            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
           <PermissionButton
             icon={<DisconnectOutlined />}
             icon={<DisconnectOutlined />}
             key="unBind"
             key="unBind"

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

+ 10 - 3
src/pages/user/Login/index.tsx

@@ -87,9 +87,16 @@ const Login: React.FC = () => {
 
 
   useEffect(() => {
   useEffect(() => {
     localStorage.clear();
     localStorage.clear();
-    Service.bindInfo().then((res) => {
-      if (res.status === 200) {
-        setBindings(res.result);
+    Service.getSystemVersion().then((resp) => {
+      if (resp && resp.status === 200 && resp.result) {
+        localStorage.setItem(SystemConst.Version_Code, resp.result.edition);
+        if (resp.result.edition !== 'community') {
+          Service.bindInfo().then((res) => {
+            if (res.status === 200) {
+              setBindings(res.result);
+            }
+          });
+        }
       }
       }
     });
     });
     Service.settingDetail('front').then((res) => {
     Service.settingDetail('front').then((res) => {