فهرست منبع

fix: bug修复3.29上午

sun-chaochao 3 سال پیش
والد
کامیت
c4d65075f3

+ 11 - 13
src/components/CheckButton/index.less

@@ -1,19 +1,17 @@
+@import '../../../node_modules/antd/lib/style/themes/variable';
+
 .box {
   display: flex;
   .item {
-    width: 30px;
-    height: 30px;
-    font-size: 20px;
-    line-height: 30px;
-    text-align: center;
-    border-top: 1px solid lightgray;
-    border-bottom: 1px solid lightgray;
+    color: rgba(0, 0, 0, 0.75);
+    font-size: 16px;
     cursor: pointer;
-  }
-  .left {
-    border-left: 1px solid lightgray;
-  }
-  .right {
-    border-right: 1px solid lightgray;
+
+    &.active {
+      color: @primary-color-active;
+    }
+    &:hover {
+      color: @primary-color-hover;
+    }
   }
 }

+ 11 - 14
src/components/CheckButton/index.tsx

@@ -1,36 +1,33 @@
-import { AppstoreFilled, UnorderedListOutlined } from '@ant-design/icons';
+import { AppstoreOutlined, BarsOutlined } from '@ant-design/icons';
 import classnames from 'classnames';
-import styles from './index.less';
+import './index.less';
 interface Props {
   value: boolean;
   change: (value: boolean) => void;
 }
 
 const CheckButton = (props: Props) => {
-  const activeStyle = {
-    border: '1px solid #1d39c4',
-    color: '#1d39c4',
-  };
-
   return (
-    <div className={styles.box}>
+    <div className="box">
       <div
-        className={classnames(styles.item, styles.left)}
-        style={props.value ? activeStyle : {}}
+        className={classnames('item', {
+          active: props.value,
+        })}
         onClick={() => {
           props.change(true);
         }}
       >
-        <AppstoreFilled />
+        <AppstoreOutlined />
       </div>
       <div
-        className={classnames(styles.item, styles.right)}
-        style={!props.value ? activeStyle : {}}
+        className={classnames('item', {
+          active: !props.value,
+        })}
         onClick={() => {
           props.change(false);
         }}
       >
-        <UnorderedListOutlined />
+        <BarsOutlined />
       </div>
     </div>
   );

+ 1 - 1
src/components/SearchComponent/index.tsx

@@ -55,7 +55,7 @@ interface Props<T> {
   target?: string;
   onReset?: () => void;
   /** @name 固定查询参数*/
-  defaultParam?: Term[];
+  defaultParam?: Term[] | any;
   pattern?: 'simple' | 'advance';
 }
 

+ 17 - 1
src/pages/device/Instance/Detail/ChildDevice/BindChildDevice/index.tsx

@@ -26,18 +26,22 @@ const BindChildDevice = (props: Props) => {
     {
       title: 'ID',
       dataIndex: 'id',
+      ellipsis: true,
     },
     {
       title: '设备名称',
+      ellipsis: true,
       dataIndex: 'name',
     },
     {
       title: '所属产品',
+      ellipsis: true,
       dataIndex: 'productName',
     },
     {
       title: '注册时间',
       dataIndex: 'registryTime',
+      ellipsis: true,
       width: '200px',
       render: (text: any) => (!!text ? moment(text).format('YYYY-MM-DD HH:mm:ss') : '/'),
       sorter: true,
@@ -45,6 +49,8 @@ const BindChildDevice = (props: Props) => {
     {
       title: '状态',
       dataIndex: 'state',
+      ellipsis: true,
+      width: 100,
       renderText: (record) =>
         record ? <Badge status={statusMap.get(record.value)} text={record.text} /> : '',
       valueType: 'select',
@@ -123,7 +129,17 @@ const BindChildDevice = (props: Props) => {
         field={[...columns]}
         target="child-device-bind"
         pattern={'simple'}
-        defaultParam={[{ column: 'parentId$isnull', value: '1' }]}
+        defaultParam={[
+          {
+            terms: [
+              { column: 'parentId$isnull', value: '' },
+              { column: 'parentId$not', value: InstanceModel.detail.id!, type: 'or' },
+            ],
+          },
+          {
+            terms: [{ column: 'id$not', value: InstanceModel.detail.id!, type: 'and' }],
+          },
+        ]}
         onSearch={(param) => {
           actionRef.current?.reset?.();
           setSearchParams(param);

+ 43 - 51
src/pages/device/Product/Detail/Access/index.tsx

@@ -1,9 +1,10 @@
-import { Badge, Descriptions, Empty, Table, Tooltip } from 'antd';
+import { Badge, Empty, Table, Tooltip } from 'antd';
 import { service } from '@/pages/link/AccessConfig';
 import styles from './index.less';
 import { useEffect, useState } from 'react';
 import { productModel } from '@/pages/device/Product';
 import AccessConfig from './AccessConfig';
+import ReactMarkdown from 'react-markdown';
 
 const Access = () => {
   const [visible, setVisible] = useState<boolean>(true);
@@ -91,11 +92,16 @@ const Access = () => {
       key: 'stream',
       ellipsis: true,
       align: 'center',
-      render: (text: any, record: any) => (
-        <span>
-          上行: {String(record?.upstream)}, 下行: {String(record?.downstream)}
-        </span>
-      ),
+      render: (text: any, record: any) => {
+        const list = [];
+        if (record?.upstream) {
+          list.push('上行');
+        }
+        if (record?.downstream) {
+          list.push('下行');
+        }
+        return <span>{list.join(',')}</span>;
+      },
     },
     {
       title: '说明',
@@ -216,52 +222,38 @@ const Access = () => {
         </div>
       ) : (
         <div className={styles.config}>
-          <div className={styles.title}>
-            配置概览
-            <a
-              style={{ marginLeft: 20 }}
-              onClick={() => {
-                setConfigVisible(true);
-              }}
-            >
-              更换
-            </a>
+          <div>
+            <div className={styles.title}>
+              接入方式
+              <a
+                style={{ marginLeft: 20 }}
+                onClick={() => {
+                  setConfigVisible(true);
+                }}
+              >
+                更换
+              </a>
+            </div>
+            {providers.find((i) => i.id === access?.provider)?.name || ''}
           </div>
-          <Descriptions column={1}>
-            <Descriptions.Item label="接入方式">
-              {providers.find((i) => i.id === access?.provider)?.name || ''}
-            </Descriptions.Item>
-            {providers.find((i) => i.id === access?.provider)?.description && (
-              <Descriptions.Item label="">
-                <span style={{ color: 'rgba(0,0,0,0.55)' }}>
-                  {providers.find((i) => i.id === access?.provider)?.description || ''}
-                </span>
-              </Descriptions.Item>
-            )}
-            <Descriptions.Item label="消息协议">
-              {access?.protocolDetail?.name || ''}
-            </Descriptions.Item>
-            {access?.protocolDetail?.description && (
-              <Descriptions.Item label="">
-                <span style={{ color: 'rgba(0,0,0,0.55)' }}>
-                  {access?.protocolDetail?.description || ''}
-                </span>
-              </Descriptions.Item>
-            )}
-            <Descriptions.Item label="网络组件">
-              {(networkList.find((i) => i.id === access?.channelId)?.addresses || []).map(
-                (item: any) => (
-                  <div key={item.address}>
-                    <Badge
-                      color={item.health === -1 ? 'red' : 'green'}
-                      text={item.address}
-                      style={{ marginLeft: '20px' }}
-                    />
-                  </div>
-                ),
-              )}
-            </Descriptions.Item>
-          </Descriptions>
+          {providers.find((i) => i.id === access?.provider)?.description && (
+            <span>{providers.find((i) => i.id === access?.provider)?.description || ''}</span>
+          )}
+          <div className={styles.title}>消息协议</div>
+          {access?.protocolDetail?.name || ''}
+          <ReactMarkdown>{config?.document}</ReactMarkdown>
+          <div className={styles.title}>网络组件</div>
+          {(networkList.find((i) => i.id === access?.channelId)?.addresses || []).map(
+            (item: any) => (
+              <div key={item.address}>
+                <Badge
+                  color={item.health === -1 ? 'red' : 'green'}
+                  text={item.address}
+                  style={{ marginLeft: '20px' }}
+                />
+              </div>
+            ),
+          )}
           {config?.routes && config?.routes?.length > 0 && (
             <div>
               <Table

+ 37 - 44
src/pages/link/AccessConfig/Detail/Access/index.tsx

@@ -4,7 +4,6 @@ import {
   Button,
   Card,
   Col,
-  Descriptions,
   Empty,
   Form,
   Input,
@@ -19,6 +18,7 @@ import styles from './index.less';
 import { service } from '@/pages/link/AccessConfig';
 import encodeQuery from '@/utils/encodeQuery';
 import { useHistory, useLocation } from 'umi';
+import ReactMarkdown from 'react-markdown';
 
 interface Props {
   change: () => void;
@@ -197,11 +197,16 @@ const Access = (props: Props) => {
       key: 'stream',
       ellipsis: true,
       align: 'center',
-      render: (text: any, record: any) => (
-        <span>
-          上行: {String(record?.upstream)}, 下行: {String(record?.downstream)}
-        </span>
-      ),
+      render: (text: any, record: any) => {
+        const list = [];
+        if (record?.upstream) {
+          list.push('上行');
+        }
+        if (record?.downstream) {
+          list.push('下行');
+        }
+        return <span>{list.join(',')}</span>;
+      },
     },
     {
       title: '说明',
@@ -539,44 +544,32 @@ const Access = (props: Props) => {
               </div>
             </div>
             <div className={styles.config}>
-              <div className={styles.title}>配置概览</div>
-              <Descriptions column={1}>
-                <Descriptions.Item label="接入方式">
-                  {props.data?.name || providers.find((i) => i.id === access?.provider)?.name}
-                </Descriptions.Item>
-                {(props.data?.description ||
-                  providers.find((i) => i.id === access?.provider)?.description) && (
-                  <Descriptions.Item>
-                    <span style={{ color: 'rgba(0,0,0,0.55)' }}>
-                      {props.data?.description ||
-                        providers.find((i) => i.id === access?.provider)?.description}
-                    </span>
-                  </Descriptions.Item>
-                )}
-                <Descriptions.Item label="消息协议">
-                  {procotolList.find((i) => i.id === procotolCurrent)?.name || ''}
-                </Descriptions.Item>
-                {procotolList.find((i) => i.id === procotolCurrent)?.description && (
-                  <Descriptions.Item style={{ color: 'rgba(0,0,0,0.55)' }}>
-                    <span style={{ color: 'rgba(0,0,0,0.55)' }}>
-                      {procotolList.find((i) => i.id === procotolCurrent)?.description || ''}
-                    </span>
-                  </Descriptions.Item>
-                )}
-                <Descriptions.Item label="网络组件">
-                  {(networkList.find((i) => i.id === networkCurrent)?.addresses || []).map(
-                    (item: any) => (
-                      <div key={item.address}>
-                        <Badge
-                          color={item.health === -1 ? 'red' : 'green'}
-                          text={item.address}
-                          style={{ marginLeft: '20px' }}
-                        />
-                      </div>
-                    ),
-                  )}
-                </Descriptions.Item>
-              </Descriptions>
+              <div className={styles.title}>接入方式</div>
+              <div>
+                {props.data?.name || providers.find((i) => i.id === access?.provider)?.name}
+              </div>
+              {(props.data?.description ||
+                providers.find((i) => i.id === access?.provider)?.description) && (
+                <span>
+                  {props.data?.description ||
+                    providers.find((i) => i.id === access?.provider)?.description}
+                </span>
+              )}
+              <div className={styles.title}>消息协议</div>
+              <div>{procotolList.find((i) => i.id === procotolCurrent)?.name || ''}</div>
+              <ReactMarkdown>{config?.document}</ReactMarkdown>
+              <div className={styles.title}>网络组件</div>
+              {(networkList.find((i) => i.id === networkCurrent)?.addresses || []).map(
+                (item: any) => (
+                  <div key={item.address}>
+                    <Badge
+                      color={item.health === -1 ? 'red' : 'green'}
+                      text={item.address}
+                      style={{ marginLeft: '20px' }}
+                    />
+                  </div>
+                ),
+              )}
               {config?.routes && config?.routes?.length > 0 && (
                 <div>
                   <Table

+ 2 - 2
src/pages/link/AccessConfig/index.tsx

@@ -70,7 +70,7 @@ const AccessConfig = () => {
           onSearch={(data: any) => {
             const dt = {
               pageSize: 10,
-              terms: [...data.terms],
+              terms: [...data?.terms],
             };
             handleSearch(dt);
           }}
@@ -89,7 +89,7 @@ const AccessConfig = () => {
           </Button>
         </div>
         <Row gutter={[16, 16]} style={{ marginTop: 10 }}>
-          {dataSource.data.map((item: any) => (
+          {(dataSource?.data || []).map((item: any) => (
             <Col key={item.name} span={12}>
               <Card hoverable>
                 <div className={styles.box}>

+ 43 - 38
src/pages/system/Role/Edit/Permission/Allocate/MenuPermission.tsx

@@ -99,7 +99,6 @@ const MenuPermission = (props: Props) => {
                     enabled: e.target.checked,
                   };
                 });
-                console.log(e.target.checked);
                 props.change({
                   ...value,
                   check: e.target.checked ? 1 : 3, // 1: 全选 2: 只选了部分 3: 一个都没选
@@ -112,44 +111,50 @@ const MenuPermission = (props: Props) => {
             </Checkbox>
           </div>
           <div>
-            <Checkbox.Group
-              name={value?.id}
-              value={_.map(
-                (value?.buttons || []).filter((i: any) => i?.enabled),
-                'id',
-              )}
-              onChange={(data: CheckboxValueType[]) => {
-                const buttons = value.buttons.map((i: any) => {
-                  return {
-                    ...i,
-                    enabled: data.includes(i.id),
+            {value.id === 'menu-permission' ? (
+              <span style={{ fontWeight: value.id === 'menu-permission' ? 600 : 400 }}>
+                权限数据
+              </span>
+            ) : (
+              <Checkbox.Group
+                name={value?.id}
+                value={_.map(
+                  (value?.buttons || []).filter((i: any) => i?.enabled),
+                  'id',
+                )}
+                onChange={(data: CheckboxValueType[]) => {
+                  const buttons = value.buttons.map((i: any) => {
+                    return {
+                      ...i,
+                      enabled: data.includes(i.id),
+                    };
+                  });
+                  const clen = (value?.children || []).filter((i: any) => i.check !== 3).length;
+                  let check: number = 3;
+                  if (data.length + clen === 0) {
+                    check = 3;
+                  } else if (
+                    data.length + clen <
+                    value?.buttons.length + (value?.children.length || 0)
+                  ) {
+                    check = 2;
+                  } else {
+                    check = 1;
+                  }
+                  const d = {
+                    ...value,
+                    check,
+                    buttons: [...buttons],
                   };
-                });
-                const clen = (value?.children || []).filter((i: any) => i.check !== 3).length;
-                let check: number = 3;
-                if (data.length + clen === 0) {
-                  check = 3;
-                } else if (
-                  data.length + clen <
-                  value?.buttons.length + (value?.children.length || 0)
-                ) {
-                  check = 2;
-                } else {
-                  check = 1;
-                }
-                const d = {
-                  ...value,
-                  check,
-                  buttons: [...buttons],
-                };
-                props.change(d);
-              }}
-              options={(value?.buttons || []).map((i: any) => ({
-                label: i.name,
-                value: i.id,
-                key: i.id,
-              }))}
-            />
+                  props.change(d);
+                }}
+                options={(value?.buttons || []).map((i: any) => ({
+                  label: i.name,
+                  value: i.id,
+                  key: i.id,
+                }))}
+              />
+            )}
           </div>
         </div>
         <div

src/pages/system/Role/Edit/Permission/Allocate/index.less → src/pages/system/Role/Detail/Permission/Allocate/index.less


src/pages/system/Role/Edit/Permission/Allocate/index.tsx → src/pages/system/Role/Detail/Permission/Allocate/index.tsx


src/pages/system/Role/Edit/Permission/index.less → src/pages/system/Role/Detail/Permission/index.less


+ 28 - 4
src/pages/system/Role/Edit/Permission/index.tsx

@@ -1,5 +1,5 @@
 import { Button, Card, Col, Form, Input, message, Row } from 'antd';
-import Allocate from '@/pages/system/Role/Edit/Permission/Allocate';
+import Allocate from '@/pages/system/Role/Detail/Permission/Allocate';
 import { useEffect, useState } from 'react';
 import { history, useParams } from 'umi';
 import { service } from '@/pages/system/Role';
@@ -38,6 +38,29 @@ const Permission = () => {
     }
   }, [params, params.id]);
 
+  // const getDataList: any = (data1: any[]) => {
+  //   if (Array.isArray(data1) && data1.length > 0) {
+  //     return data1.map((item) => {
+  //       const check = item.check;
+  //       delete item.check;
+  //       return {
+  //         ...item,
+  //         granted: check === 1 || check === 2,
+  //         children: item?.children ? getDataList(item.children) : [],
+  //       };
+  //     });
+  //   }
+  //   return [];
+  // };
+  /**
+   * 扁平化树数组
+   */
+  const flattenArray: any = (arr: any[]) => {
+    return arr.reduce((result, item) => {
+      return result.concat(item, Array.isArray(item.children) ? flattenArray(item.children) : []);
+    }, []);
+  };
+
   const getDataList: any = (data1: any[]) => {
     if (Array.isArray(data1) && data1.length > 0) {
       return data1.map((item) => {
@@ -45,8 +68,8 @@ const Permission = () => {
         delete item.check;
         return {
           ...item,
-          granted: check !== 3,
-          children: item?.children ? getDataList(item.children) : [],
+          granted: check === 1,
+          children: item?.children,
         };
       });
     }
@@ -63,9 +86,10 @@ const Permission = () => {
           name: values?.name,
           description: values?.description || '',
         });
+        const list = getDataList(flattenArray([...values.permission?.children]) || []) || [];
         service
           .saveGrantTree('role', params?.id, {
-            menus: getDataList([...values.permission?.children]),
+            menus: list.filter((item: any) => item.granted) || [],
           })
           .subscribe((resp) => {
             if (resp.status === 200) {

src/pages/system/Role/Edit/UserManage/BindUser.tsx → src/pages/system/Role/Detail/UserManage/BindUser.tsx


src/pages/system/Role/Edit/UserManage/index.tsx → src/pages/system/Role/Detail/UserManage/index.tsx


+ 2 - 2
src/pages/system/Role/Edit/index.tsx

@@ -2,8 +2,8 @@ import { observer } from '@formily/react';
 import { PageContainer } from '@ant-design/pro-layout';
 import { useState } from 'react';
 import { history } from 'umi';
-import UserManage from '@/pages/system/Role/Edit/UserManage';
-import Permission from '@/pages/system/Role/Edit/Permission';
+import UserManage from '@/pages/system/Role/Detail/UserManage';
+import Permission from '@/pages/system/Role/Detail/Permission';
 import { useIntl } from '@@/plugin-locale/localeExports';
 
 const RoleEdit = observer(() => {

+ 2 - 1
src/pages/system/Role/index.tsx

@@ -11,6 +11,7 @@ import { Link, useLocation } from 'umi';
 import { Store } from 'jetlinks-store';
 import SystemConst from '@/utils/const';
 import { CurdModel } from '@/components/BaseCrud/model';
+import { getMenuPathByParams, MENUS_CODE } from '@/utils/menu';
 
 export const service = new Service('role');
 
@@ -82,7 +83,7 @@ const Role: React.FC = observer(() => {
       valueType: 'option',
       width: 200,
       render: (text, record) => [
-        <Link to={`/system/role/edit/${record.id}`} key="link">
+        <Link to={`${getMenuPathByParams(MENUS_CODE['system/Role/Detail'], record.id)}`} key="link">
           <Tooltip
             title={intl.formatMessage({
               id: 'pages.data.option.edit',