wzyyy 3 lat temu
rodzic
commit
37de368ac6

+ 1 - 1
src/pages/device/Instance/Detail/Parsing/index.tsx

@@ -360,7 +360,7 @@ const Parsing = (props: Props) => {
           <Button
             type="primary"
             loading={loading}
-            disabled={!value || !simulation}
+            disabled={value !== '' && !simulation}
             onClick={() => {
               if (type === 'MQTT') {
                 if (topic !== '') {

+ 1 - 1
src/pages/device/data.ts

@@ -70,7 +70,7 @@ export const PropertySource: { label: string; value: string }[] = [
 
 export const FileTypeList: { label: string; value: string }[] = [
   {
-    label: '文件类型',
+    label: 'URL(链接)',
     value: 'url',
   },
   {

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

@@ -1,6 +1,6 @@
 import { Modal, Spin } from 'antd';
 import { useEffect, useMemo, useRef, useState } from 'react';
-import { createForm, Field, onFieldReact, onFieldValueChange } from '@formily/core';
+import { createForm, Field, FormPath, onFieldReact, onFieldValueChange } from '@formily/core';
 import { createSchemaField, observer } from '@formily/react';
 import {
   ArrayTable,
@@ -109,6 +109,16 @@ const Debug = observer(() => {
               }
             }
           });
+          onFieldReact('variableDefinitions.*.value', (field: any) => {
+            const path = FormPath.transform(
+              field.path,
+              /\d+/,
+              (index) => `variableDefinitions.${parseInt(index)}.required`,
+            );
+            const item = field.query(path).get('value');
+            field.required = item;
+            // console.log(item)
+          });
         },
       }),
     [state.debug, state.current],
@@ -244,6 +254,12 @@ const Debug = observer(() => {
                   'x-decorator': 'FormItem',
                   'x-component': 'Input',
                 },
+                required: {
+                  'x-hidden': true,
+                  type: 'string',
+                  'x-decorator': 'FormItem',
+                  'x-component': 'Input',
+                },
               },
             },
           },

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

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

+ 42 - 38
src/pages/system/Department/Assets/deivce/index.tsx

@@ -1,7 +1,7 @@
 // 资产分配-设备管理
 import type { ActionType, ProColumns } from '@jetlinks/pro-table';
 import { useIntl } from '@@/plugin-locale/localeExports';
-import { Badge, Button, Popconfirm, Tooltip } from 'antd';
+import { Badge } from 'antd';
 import { useEffect, useRef, useState } from 'react';
 import { observer } from '@formily/react';
 import type { DeviceItem } from '@/pages/system/Department/typings';
@@ -36,7 +36,7 @@ export const DeviceBadge = (props: DeviceBadgeProps) => {
 export default observer((props: { parentId: string }) => {
   const intl = useIntl();
   const actionRef = useRef<ActionType>();
-
+  const { permission } = PermissionButton.usePermission('system/Department');
   const [searchParam, setSearchParam] = useState({});
 
   const [updateVisible, setUpdateVisible] = useState(false);
@@ -201,31 +201,26 @@ export default observer((props: { parentId: string }) => {
             setPermissions(record.grantedPermissions!);
             setUpdateVisible(true);
           }}
-          isPermission={true}
+          isPermission={permission.edit}
         >
           <EditOutlined />
         </PermissionButton>,
-        <Popconfirm
-          title={intl.formatMessage({
-            id: 'pages.system.role.option.unBindUser',
-            defaultMessage: '是否解除绑定',
-          })}
-          key="unBind"
-          onConfirm={() => {
-            singleUnBind(record.id);
+        <PermissionButton
+          key="unbind"
+          type={'link'}
+          popConfirm={{
+            title: intl.formatMessage({
+              id: 'pages.system.role.option.unBindUser',
+              defaultMessage: '是否解除绑定',
+            }),
+            onConfirm: () => {
+              singleUnBind(record.id);
+            },
           }}
+          isPermission={permission.bind}
         >
-          <Button type={'link'} style={{ padding: 0 }}>
-            <Tooltip
-              title={intl.formatMessage({
-                id: 'pages.system.role.option.unBindUser',
-                defaultMessage: '解绑',
-              })}
-            >
-              <DisconnectOutlined />
-            </Tooltip>
-          </Button>
-        </Popconfirm>,
+          <DisconnectOutlined />
+        </PermissionButton>,
       ],
     },
   ];
@@ -373,7 +368,7 @@ export default observer((props: { parentId: string }) => {
                   setPermissions(record.grantedPermissions!);
                   setUpdateVisible(true);
                 }}
-                isPermission={true}
+                isPermission={permission.edit}
               >
                 <EditOutlined />
               </PermissionButton>,
@@ -395,7 +390,7 @@ export default observer((props: { parentId: string }) => {
                 onClick={(e) => {
                   e?.stopPropagation();
                 }}
-                isPermission={true}
+                isPermission={permission.bind}
               >
                 <DisconnectOutlined />
               </PermissionButton>,
@@ -403,7 +398,7 @@ export default observer((props: { parentId: string }) => {
           />
         )}
         toolBarRender={() => [
-          <Button
+          <PermissionButton
             onClick={() => {
               Models.bind = true;
             }}
@@ -411,27 +406,36 @@ export default observer((props: { parentId: string }) => {
             type="primary"
             key="bind"
             disabled={!props.parentId}
+            isPermission={permission.assert}
           >
             {intl.formatMessage({
               id: 'pages.data.option.assets',
               defaultMessage: '资产分配',
             })}
-          </Button>,
-          <Popconfirm
-            title={intl.formatMessage({
-              id: 'pages.system.role.option.unBindUser',
-              defaultMessage: '是否批量解除绑定',
-            })}
+          </PermissionButton>,
+          <PermissionButton
+            icon={<DisconnectOutlined />}
             key="unBind"
-            onConfirm={handleUnBind}
-          >
-            <Button icon={<DisconnectOutlined />}>
-              {intl.formatMessage({
+            popConfirm={{
+              title: intl.formatMessage({
+                id: 'pages.system.role.option.unBindUser',
+                defaultMessage: '是否批量解除绑定',
+              }),
+              onConfirm: handleUnBind,
+            }}
+            tooltip={{
+              title: intl.formatMessage({
                 id: 'pages.system.role.option.unBindUser',
                 defaultMessage: '批量解绑',
-              })}
-            </Button>
-          </Popconfirm>,
+              }),
+            }}
+            isPermission={permission.bind}
+          >
+            {intl.formatMessage({
+              id: 'pages.system.role.option.unBindUser',
+              defaultMessage: '批量解绑',
+            })}
+          </PermissionButton>,
         ]}
       />
     </>

+ 78 - 38
src/pages/system/Department/Assets/product/index.tsx

@@ -1,7 +1,7 @@
 // 资产分配-产品分类
 import type { ActionType, ProColumns } from '@jetlinks/pro-table';
 import { useIntl } from '@@/plugin-locale/localeExports';
-import { Button, Modal, Popconfirm, Tooltip } from 'antd';
+import { Modal } from 'antd';
 import { useEffect, useRef, useState } from 'react';
 import { observer } from '@formily/react';
 import type { ProductItem } from '@/pages/system/Department/typings';
@@ -24,7 +24,7 @@ export const service = new Service<ProductItem>('assets');
 export default observer((props: { parentId: string }) => {
   const intl = useIntl();
   const actionRef = useRef<ActionType>();
-
+  const { permission } = PermissionButton.usePermission('system/Department');
   const [searchParam, setSearchParam] = useState({});
   const [deviceVisible, setDeviceVisible] = useState(false);
   const [updateVisible, setUpdateVisible] = useState(false);
@@ -131,31 +131,47 @@ export default observer((props: { parentId: string }) => {
             setPermissions(record.grantedPermissions!);
             setUpdateVisible(true);
           }}
-          isPermission={true}
+          isPermission={permission.edit}
         >
           <EditOutlined />
         </PermissionButton>,
-        <Popconfirm
-          title={intl.formatMessage({
-            id: 'pages.system.role.option.unBindUser',
-            defaultMessage: '是否解除绑定',
-          })}
-          key="unBind"
-          onConfirm={() => {
-            singleUnBind(record.id);
+        <PermissionButton
+          key="unbind"
+          type={'link'}
+          popConfirm={{
+            title: intl.formatMessage({
+              id: 'pages.system.role.option.unBindUser',
+              defaultMessage: '是否解除绑定',
+            }),
+            onConfirm: () => {
+              singleUnBind(record.id);
+            },
           }}
+          isPermission={permission.bind}
         >
-          <Button type={'link'} style={{ padding: 0 }}>
-            <Tooltip
-              title={intl.formatMessage({
-                id: 'pages.system.role.option.unBindUser',
-                defaultMessage: '解绑',
-              })}
-            >
-              <DisconnectOutlined />
-            </Tooltip>
-          </Button>
-        </Popconfirm>,
+          <DisconnectOutlined />
+        </PermissionButton>,
+        // <Popconfirm
+        //   title={intl.formatMessage({
+        //     id: 'pages.system.role.option.unBindUser',
+        //     defaultMessage: '是否解除绑定',
+        //   })}
+        //   key="unBind"
+        //   onConfirm={() => {
+        //     singleUnBind(record.id);
+        //   }}
+        // >
+        //   <Button type={'link'} style={{ padding: 0 }}>
+        //     <Tooltip
+        //       title={intl.formatMessage({
+        //         id: 'pages.system.role.option.unBindUser',
+        //         defaultMessage: '解绑',
+        //       })}
+        //     >
+        //       <DisconnectOutlined />
+        //     </Tooltip>
+        //   </Button>
+        // </Popconfirm>,
       ],
     },
   ];
@@ -320,7 +336,7 @@ export default observer((props: { parentId: string }) => {
                   setPermissions(record.grantedPermissions!);
                   setUpdateVisible(true);
                 }}
-                isPermission={true}
+                isPermission={permission.edit}
               >
                 <EditOutlined />
               </PermissionButton>,
@@ -342,7 +358,7 @@ export default observer((props: { parentId: string }) => {
                 onClick={(e) => {
                   e?.stopPropagation();
                 }}
-                isPermission={true}
+                isPermission={permission.bind}
               >
                 <DisconnectOutlined />
               </PermissionButton>,
@@ -350,7 +366,7 @@ export default observer((props: { parentId: string }) => {
           />
         )}
         toolBarRender={() => [
-          <Button
+          <PermissionButton
             onClick={() => {
               Models.bind = true;
             }}
@@ -358,27 +374,51 @@ export default observer((props: { parentId: string }) => {
             type="primary"
             key="bind"
             disabled={!props.parentId}
+            isPermission={permission.assert}
           >
             {intl.formatMessage({
               id: 'pages.data.option.assets',
               defaultMessage: '资产分配',
             })}
-          </Button>,
-          <Popconfirm
-            title={intl.formatMessage({
-              id: 'pages.system.role.option.unBindUser',
-              defaultMessage: '是否批量解除绑定',
-            })}
+          </PermissionButton>,
+          <PermissionButton
+            icon={<DisconnectOutlined />}
             key="unBind"
-            onConfirm={handleUnBind}
-          >
-            <Button icon={<DisconnectOutlined />}>
-              {intl.formatMessage({
+            popConfirm={{
+              title: intl.formatMessage({
+                id: 'pages.system.role.option.unBindUser',
+                defaultMessage: '是否批量解除绑定',
+              }),
+              onConfirm: handleUnBind,
+            }}
+            tooltip={{
+              title: intl.formatMessage({
                 id: 'pages.system.role.option.unBindUser',
                 defaultMessage: '批量解绑',
-              })}
-            </Button>
-          </Popconfirm>,
+              }),
+            }}
+            isPermission={permission.bind}
+          >
+            {intl.formatMessage({
+              id: 'pages.system.role.option.unBindUser',
+              defaultMessage: '批量解绑',
+            })}
+          </PermissionButton>,
+          // <Popconfirm
+          //   title={intl.formatMessage({
+          //     id: 'pages.system.role.option.unBindUser',
+          //     defaultMessage: '是否批量解除绑定',
+          //   })}
+          //   key="unBind"
+          //   onConfirm={handleUnBind}
+          // >
+          //   <Button icon={<DisconnectOutlined />}>
+          //     {intl.formatMessage({
+          //       id: 'pages.system.role.option.unBindUser',
+          //       defaultMessage: '批量解绑',
+          //     })}
+          //   </Button>
+          // </Popconfirm>,
         ]}
       />
     </>

+ 77 - 35
src/pages/system/Department/Member/index.tsx

@@ -2,7 +2,7 @@
 import type { ActionType, ProColumns } from '@jetlinks/pro-table';
 import ProTable from '@jetlinks/pro-table';
 import { useIntl } from '@@/plugin-locale/localeExports';
-import { Badge, Button, Popconfirm, Tooltip } from 'antd';
+import { Badge } from 'antd';
 import { useEffect, useRef, useState } from 'react';
 import { observer } from '@formily/react';
 import MemberModel from '@/pages/system/Department/Member/model';
@@ -13,13 +13,14 @@ import Bind from './bind';
 import SearchComponent from '@/components/SearchComponent';
 import Models from '@/pages/system/Department/Assets/productCategory/model';
 import { onlyMessage } from '@/utils/util';
+import PermissionButton from '@/components/PermissionButton';
 
 export const service = new Service('tenant');
 
 const Member = observer((props: { parentId: string }) => {
   const intl = useIntl();
   const actionRef = useRef<ActionType>();
-
+  const { permission } = PermissionButton.usePermission('system/Department');
   const [searchParam, setSearchParam] = useState({});
 
   const handleUnBind = () => {
@@ -54,6 +55,7 @@ const Member = observer((props: { parentId: string }) => {
     },
     {
       dataIndex: 'username',
+      ellipsis: true,
       title: intl.formatMessage({
         id: 'pages.system.username',
         defaultMessage: '用户名',
@@ -123,27 +125,43 @@ const Member = observer((props: { parentId: string }) => {
       ellipsis: true,
       fixed: 'right',
       render: (text, record) => [
-        <Popconfirm
-          title={intl.formatMessage({
-            id: 'pages.system.role.option.unBindUser',
-            defaultMessage: '是否解除绑定',
-          })}
-          key="unBindUser"
-          onConfirm={() => {
-            singleUnBind(record.id);
+        <PermissionButton
+          key="unbind"
+          type={'link'}
+          popConfirm={{
+            title: intl.formatMessage({
+              id: 'pages.system.role.option.unBindUser',
+              defaultMessage: '是否解除绑定',
+            }),
+            onConfirm: () => {
+              singleUnBind(record.id);
+            },
           }}
+          isPermission={permission.bind}
         >
-          <Button type={'link'} style={{ padding: 0 }}>
-            <Tooltip
-              title={intl.formatMessage({
-                id: 'pages.system.role.option.unBindUser',
-                defaultMessage: '解绑',
-              })}
-            >
-              <DisconnectOutlined />
-            </Tooltip>
-          </Button>
-        </Popconfirm>,
+          <DisconnectOutlined />
+        </PermissionButton>,
+        // <Popconfirm
+        //   title={intl.formatMessage({
+        //     id: 'pages.system.role.option.unBindUser',
+        //     defaultMessage: '是否解除绑定',
+        //   })}
+        //   key="unBindUser"
+        //   onConfirm={() => {
+        //     singleUnBind(record.id);
+        //   }}
+        // >
+        //   <Button type={'link'} style={{ padding: 0 }}>
+        //     <Tooltip
+        //       title={intl.formatMessage({
+        //         id: 'pages.system.role.option.unBindUser',
+        //         defaultMessage: '解绑',
+        //       })}
+        //     >
+        //       <DisconnectOutlined />
+        //     </Tooltip>
+        //   </Button>
+        // </Popconfirm>,
       ],
     },
   ];
@@ -217,7 +235,7 @@ const Member = observer((props: { parentId: string }) => {
         }}
         params={searchParam}
         toolBarRender={() => [
-          <Button
+          <PermissionButton
             onClick={() => {
               MemberModel.bind = true;
             }}
@@ -225,27 +243,51 @@ const Member = observer((props: { parentId: string }) => {
             type="primary"
             key="bind"
             disabled={!props.parentId}
+            isPermission={permission['bind-user']}
           >
             {intl.formatMessage({
               id: 'pages.system.role.option.bindUser',
               defaultMessage: '绑定用户',
             })}
-          </Button>,
-          <Popconfirm
-            title={intl.formatMessage({
-              id: 'pages.system.role.option.unBinds',
-              defaultMessage: '是否批量解除绑定',
-            })}
+          </PermissionButton>,
+          <PermissionButton
+            icon={<DisconnectOutlined />}
             key="unBind"
-            onConfirm={handleUnBind}
-          >
-            <Button icon={<DisconnectOutlined />}>
-              {intl.formatMessage({
+            popConfirm={{
+              title: intl.formatMessage({
+                id: 'pages.system.role.option.unBindUser',
+                defaultMessage: '是否批量解除绑定',
+              }),
+              onConfirm: handleUnBind,
+            }}
+            tooltip={{
+              title: intl.formatMessage({
                 id: 'pages.system.role.option.unBindUser',
                 defaultMessage: '批量解绑',
-              })}
-            </Button>
-          </Popconfirm>,
+              }),
+            }}
+            isPermission={permission.bind}
+          >
+            {intl.formatMessage({
+              id: 'pages.system.role.option.unBindUser',
+              defaultMessage: '批量解绑',
+            })}
+          </PermissionButton>,
+          // <Popconfirm
+          //   title={intl.formatMessage({
+          //     id: 'pages.system.role.option.unBinds',
+          //     defaultMessage: '是否批量解除绑定',
+          //   })}
+          //   key="unBind"
+          //   onConfirm={handleUnBind}
+          // >
+          //   <Button icon={<DisconnectOutlined />}>
+          //     {intl.formatMessage({
+          //       id: 'pages.system.role.option.unBindUser',
+          //       defaultMessage: '批量解绑',
+          //     })}
+          //   </Button>
+          // </Popconfirm>,
         ]}
       />
     </>

+ 15 - 3
src/pages/system/Department/Tree/tree.tsx

@@ -1,4 +1,4 @@
-import { Button, Input, Tree } from 'antd';
+import { Input, Tree } from 'antd';
 import {
   DeleteOutlined,
   EditOutlined,
@@ -193,7 +193,19 @@ export default (props: TreeProps) => {
         suffix={<SearchOutlined />}
         onChange={debounce(onSearchChange, 500)}
       />
-      <Button
+      <PermissionButton
+        key={'add'}
+        style={{ width: '100%', margin: '24px 0' }}
+        type="primary"
+        isPermission={permission.add}
+        onClick={() => {
+          setData({ sortIndex: treeData && treeData.length + 1 });
+          setVisible(true);
+        }}
+      >
+        新增
+      </PermissionButton>
+      {/* <Button
         style={{ width: '100%', margin: '24px 0' }}
         type={'primary'}
         onClick={() => {
@@ -202,7 +214,7 @@ export default (props: TreeProps) => {
         }}
       >
         新增
-      </Button>
+      </Button> */}
       {treeData ? (
         <div className={'left-tree-body'}>
           <Tree

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

@@ -153,6 +153,7 @@ export enum BUTTON_PERMISSION_ENUM {
   'tigger' = 'tigger',
   'empowerment' = 'empowerment',
   'bind' = 'bind',
+  'edit' = 'edit',
 }
 
 // 调试按钮、通知记录、批量导出、批量导入、选择通道、推送、分配资产、绑定用户对应的ID是啥