Prechádzať zdrojové kódy

fix: 修改bug3.25下午

sun-chaochao 3 rokov pred
rodič
commit
386d8d4efe

+ 0 - 5
src/pages/device/Instance/Detail/ChildDevice/BindChildDevice/index.tsx

@@ -24,11 +24,6 @@ const BindChildDevice = (props: Props) => {
 
   const columns: ProColumns<DeviceInstance>[] = [
     {
-      dataIndex: 'index',
-      valueType: 'indexBorder',
-      width: 48,
-    },
-    {
       title: 'ID',
       dataIndex: 'id',
     },

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

@@ -29,11 +29,6 @@ const ChildDevice = () => {
 
   const columns: ProColumns<LogItem>[] = [
     {
-      dataIndex: 'index',
-      valueType: 'indexBorder',
-      width: 48,
-    },
-    {
       title: 'ID',
       dataIndex: 'id',
     },
@@ -184,6 +179,7 @@ const ChildDevice = () => {
         data={{}}
         onCancel={() => {
           setVisible(false);
+          actionRef.current?.reload?.();
         }}
       />
     </Card>

+ 12 - 5
src/pages/device/Instance/Detail/Config/index.tsx

@@ -37,7 +37,15 @@ const Config = () => {
     initialValues: InstanceModel.detail?.configuration,
   });
 
-  const id = InstanceModel.detail?.id;
+  const id = InstanceModel.detail?.id || params?.id;
+
+  const getDetail = () => {
+    service.detail(id || '').then((resp) => {
+      if (resp.status === 200) {
+        InstanceModel.detail = { id, ...resp.result };
+      }
+    });
+  };
 
   useEffect(() => {
     if (id) {
@@ -115,10 +123,7 @@ const Config = () => {
                           configuration: { ...values },
                         });
                         if (resp.status === 200) {
-                          InstanceModel.detail = {
-                            ...InstanceModel.detail,
-                            configuration: { ...values },
-                          };
+                          getDetail();
                         }
                       }
                       setState(!state);
@@ -133,6 +138,7 @@ const Config = () => {
                         const resp = await service.deployDevice(id || '');
                         if (resp.status === 200) {
                           message.success('操作成功');
+                          getDetail();
                         }
                       }}
                     >
@@ -149,6 +155,7 @@ const Config = () => {
                         const resp = await service.configurationReset(id || '');
                         if (resp.status === 200) {
                           message.success('恢复默认配置成功');
+                          getDetail();
                         }
                       }}
                     >

+ 5 - 11
src/pages/device/Instance/Detail/Log/index.tsx

@@ -16,32 +16,27 @@ const Log = () => {
   const [searchParams, setSearchParams] = useState<any>({});
 
   useEffect(() => {
-    service.getLogType().then((resp) => {
+    service.queryLogsType().then((resp) => {
       if (resp.status === 200) {
-        const list = (resp.result as { text: string; type: string }[]).reduce(
+        const list = (resp.result as { text: string; value: string }[]).reduce(
           (previousValue, currentValue) => {
-            previousValue[currentValue.type] = currentValue;
+            previousValue[currentValue.value] = currentValue;
             return previousValue;
           },
           {},
         );
-        setType(list);
+        setType({ ...list });
       }
     });
   }, []);
 
   const columns: ProColumns<LogItem>[] = [
     {
-      dataIndex: 'index',
-      valueType: 'indexBorder',
-      width: 48,
-    },
-    {
       title: '类型',
       dataIndex: 'type',
       renderText: (text) => text.text,
       valueType: 'select',
-      valueEnum: type,
+      valueEnum: { ...type },
     },
     {
       title: '时间',
@@ -49,7 +44,6 @@ const Log = () => {
       defaultSortOrder: 'descend',
       valueType: 'dateTime',
       sorter: true,
-      hideInSearch: true,
     },
     {
       title: '内容',

+ 7 - 5
src/pages/device/Instance/Detail/index.tsx

@@ -139,6 +139,7 @@ const InstanceDetail = observer(() => {
     if (!InstanceModel.current && !params.id) {
       history.goBack();
     } else {
+      setTab('detail');
       getDetail(InstanceModel.current?.id || params.id);
     }
     return () => {
@@ -151,9 +152,10 @@ const InstanceDetail = observer(() => {
       onBack={history.goBack}
       onTabChange={setTab}
       tabList={list}
+      tabActiveKey={tab}
       content={
         <Descriptions size="small" column={4}>
-          <Descriptions.Item label={'ID'}>{InstanceModel.detail.id}</Descriptions.Item>
+          <Descriptions.Item label={'ID'}>{InstanceModel.detail?.id}</Descriptions.Item>
           <Descriptions.Item label={'所属产品'}>
             <Button
               type={'link'}
@@ -161,21 +163,21 @@ const InstanceDetail = observer(() => {
               onClick={() => {
                 const url = getMenuPathByParams(
                   MENUS_CODE['device/Product/Detail'],
-                  InstanceModel.detail.productId,
+                  InstanceModel.detail?.productId,
                 );
                 history.replace(url);
               }}
             >
-              {InstanceModel.detail.productName}
+              {InstanceModel.detail?.productName}
             </Button>
           </Descriptions.Item>
         </Descriptions>
       }
       title={
         <>
-          {InstanceModel.detail.name}
+          {InstanceModel.detail?.name}
           <Divider type="vertical" />
-          {deviceStatus.get(InstanceModel.detail.state?.value)}
+          {deviceStatus.get(InstanceModel.detail?.state?.value)}
         </>
       }
       // extra={[

+ 4 - 0
src/pages/device/Instance/Export/index.tsx

@@ -62,6 +62,10 @@ const Export = (props: Props) => {
             enum: [...productList],
             'x-component-props': {
               allowClear: true,
+              showSearch: true,
+              showArrow: true,
+              filterOption: (input: string, option: any) =>
+                option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0,
             },
           },
           fileType: {

+ 6 - 0
src/pages/device/Instance/Import/index.tsx

@@ -233,6 +233,12 @@ const Import = (props: Props) => {
             'x-decorator': 'FormItem',
             'x-component': 'Select',
             enum: [...productList],
+            'x-component-props': {
+              showSearch: true,
+              showArrow: true,
+              filterOption: (input: string, option: any) =>
+                option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0,
+            },
           },
           fileType: {
             title: '文件格式',

+ 1 - 1
src/pages/device/Instance/service.ts

@@ -130,7 +130,7 @@ class Service extends BaseService<DeviceInstance> {
       data: params,
     });
 
-  public getLogType = () =>
+  public queryLogsType = () =>
     request(`/${SystemConst.API_BASE}/dictionary/device-log-type/items`, {
       method: 'GET',
     });

+ 6 - 6
src/pages/device/Product/Detail/index.tsx

@@ -56,11 +56,16 @@ const ProductDetail = observer(() => {
     service.getProductDetail(param?.id).subscribe((data) => {
       if (data.metadata) {
         const metadata: DeviceMetadata = JSON.parse(data.metadata);
-        productModel.current = data;
         MetadataAction.insert(metadata);
       }
+      service.instanceCount(encodeQuery({ terms: { productId: param?.id } })).then((res: any) => {
+        if (res.status === 200) {
+          productModel.current = { ...data, count: res.result };
+        }
+      });
     });
   };
+
   useEffect(() => {
     const subscription = Store.subscribe(SystemConst.GET_METADATA, () => {
       MetadataAction.clean();
@@ -73,11 +78,6 @@ const ProductDetail = observer(() => {
       history.goBack();
     } else {
       initMetadata();
-      service.instanceCount(encodeQuery({ terms: { productId: param?.id } })).then((res: any) => {
-        if (res.status === 200) {
-          productModel.current!.count = res.result;
-        }
-      });
     }
     return () => {
       MetadataAction.clean();

+ 4 - 0
src/pages/link/AccessConfig/Detail/Access/index.less

@@ -19,7 +19,11 @@
 }
 
 .title {
+  width: '100%';
+  overflow: hidden;
   font-weight: 800;
+  white-space: nowrap;
+  text-overflow: ellipsis;
 }
 
 .desc {

+ 30 - 25
src/pages/link/Protocol/FileUpload/index.tsx

@@ -2,7 +2,7 @@ import SystemConst from '@/utils/const';
 import Token from '@/utils/token';
 import { useState } from 'react';
 import { connect } from '@formily/react';
-import { Button, Input, message, Upload } from 'antd';
+import { Button, Input, message, Spin, Upload } from 'antd';
 import type { UploadChangeParam } from 'antd/lib/upload/interface';
 
 interface Props {
@@ -13,41 +13,46 @@ interface Props {
 
 const FileUpload = connect((props: Props) => {
   const [url, setUrl] = useState<string>(props?.value);
+  const [loading, setLoading] = useState<boolean>(false);
 
   const handleChange = (info: UploadChangeParam) => {
+    setLoading(true);
     if (info.file.status === 'done') {
       message.success('上传成功!');
       info.file.url = info.file.response?.result;
       setUrl(info.file.response?.result);
+      setLoading(false);
       props.onChange(info.file.response?.result);
     }
   };
 
   return (
-    <Upload
-      accept={props?.accept || '*'}
-      listType={'text'}
-      action={`/${SystemConst.API_BASE}/file/static`}
-      headers={{
-        'X-Access-Token': Token.get(),
-      }}
-      onChange={handleChange}
-      showUploadList={false}
-    >
-      <Input.Group compact>
-        <Input
-          style={{ width: 'calc(100% - 100px)' }}
-          value={url}
-          onClick={(e) => {
-            e.preventDefault();
-            e.stopPropagation();
-          }}
-        />
-        <Button shape="round" style={{ width: '100px', textAlign: 'center' }} type="primary">
-          上传jar包
-        </Button>
-      </Input.Group>
-    </Upload>
+    <Spin spinning={loading}>
+      <Upload
+        accept={props?.accept || '*'}
+        listType={'text'}
+        action={`/${SystemConst.API_BASE}/file/static`}
+        headers={{
+          'X-Access-Token': Token.get(),
+        }}
+        onChange={handleChange}
+        showUploadList={false}
+      >
+        <Input.Group compact>
+          <Input
+            style={{ width: 'calc(100% - 100px)' }}
+            value={url}
+            onClick={(e) => {
+              e.preventDefault();
+              e.stopPropagation();
+            }}
+          />
+          <Button shape="round" style={{ width: '100px', textAlign: 'center' }} type="primary">
+            上传jar包
+          </Button>
+        </Input.Group>
+      </Upload>
+    </Spin>
   );
 });
 export default FileUpload;

+ 260 - 0
src/pages/system/Permission/Save/index.tsx

@@ -0,0 +1,260 @@
+import { message, Modal } from 'antd';
+import { useIntl } from 'umi';
+import { createForm, onFormSubmitStart } from '@formily/core';
+import { createSchemaField } from '@formily/react';
+import React, { useEffect, useState } from 'react';
+import * as ICONS from '@ant-design/icons';
+import { ArrayTable, Form, FormItem, Input, Editable } from '@formily/antd';
+import type { ISchema } from '@formily/json-schema';
+import type { PermissionItem } from '@/pages/system/Permission/typings';
+import { service } from '@/pages/system/Permission';
+
+interface Props {
+  model: 'add' | 'edit' | 'query';
+  data: Partial<PermissionItem>;
+  close: () => void;
+}
+
+const defaultAction = [
+  { action: 'query', name: '查询', describe: '查询' },
+  { action: 'save', name: '保存', describe: '保存' },
+  { action: 'delete', name: '删除', describe: '删除' },
+];
+
+const Save = (props: Props) => {
+  const { model } = props;
+  const intl = useIntl();
+
+  const [data, setData] = useState<Partial<PermissionItem>>(props.data);
+
+  useEffect(() => {
+    if (model === 'edit') {
+      setData(props.data);
+    } else {
+      setData({});
+    }
+  }, [props.data, props.model]);
+
+  const form = createForm({
+    validateFirst: true,
+    initialValues: data,
+    effects: () => {
+      onFormSubmitStart((formEffect) => {
+        formEffect.values.actions = formEffect.values.actions?.filter(
+          (item: any) => Object.keys(item).length > 0,
+        );
+      });
+    },
+  });
+
+  const SchemaField = createSchemaField({
+    components: {
+      FormItem,
+      Input,
+      ArrayTable,
+      Editable,
+    },
+    scope: {
+      icon(name: any) {
+        return React.createElement(ICONS[name]);
+      },
+    },
+  });
+
+  const schema: ISchema = {
+    type: 'object',
+    properties: {
+      id: {
+        title: intl.formatMessage({
+          id: 'pages.system.permission.id',
+          defaultMessage: '标识(ID)',
+        }),
+        type: 'string',
+        'x-decorator': 'FormItem',
+        'x-component': 'Input',
+        name: 'id',
+        'x-decorator-props': {
+          tooltip: <div>标识ID需与代码中的标识ID一致</div>,
+        },
+        'x-validator': [
+          {
+            max: 64,
+            message: '最多可输入64个字符',
+          },
+          {
+            required: true,
+            message: '请输入标识(ID)',
+          },
+        ],
+      },
+      name: {
+        title: intl.formatMessage({
+          id: 'pages.table.name',
+          defaultMessage: '名称',
+        }),
+        type: 'string',
+        'x-decorator': 'FormItem',
+        'x-component': 'Input',
+        name: 'name',
+        'x-validator': [
+          {
+            max: 64,
+            message: '最多可输入64个字符',
+          },
+          {
+            required: true,
+            message: '请输入名称',
+          },
+        ],
+      },
+      actions: {
+        type: 'array',
+        'x-decorator': 'FormItem',
+        'x-component': 'ArrayTable',
+        default: defaultAction,
+        title: '操作类型',
+        items: {
+          type: 'object',
+          properties: {
+            column1: {
+              type: 'void',
+              'x-component': 'ArrayTable.Column',
+              'x-component-props': { width: 80, title: '-', align: 'center' },
+              properties: {
+                index: {
+                  type: 'void',
+                  'x-component': 'ArrayTable.Index',
+                },
+              },
+            },
+            column2: {
+              type: 'void',
+              'x-component': 'ArrayTable.Column',
+              'x-component-props': {
+                width: 200,
+                title: intl.formatMessage({
+                  id: 'pages.system.permission.addConfigurationType',
+                  defaultMessage: '操作类型',
+                }),
+              },
+              properties: {
+                action: {
+                  type: 'string',
+                  'x-decorator': 'Editable',
+                  'x-component': 'Input',
+                },
+              },
+            },
+            column3: {
+              type: 'void',
+              'x-component': 'ArrayTable.Column',
+              'x-component-props': {
+                width: 200,
+                title: intl.formatMessage({
+                  id: 'pages.table.name',
+                  defaultMessage: '名称',
+                }),
+              },
+              properties: {
+                name: {
+                  type: 'string',
+
+                  'x-decorator': 'Editable',
+                  'x-component': 'Input',
+                },
+              },
+            },
+            column4: {
+              type: 'void',
+              'x-component': 'ArrayTable.Column',
+              'x-component-props': {
+                width: 200,
+                title: intl.formatMessage({
+                  id: 'pages.table.describe',
+                  defaultMessage: '描述',
+                }),
+              },
+              properties: {
+                describe: {
+                  type: 'string',
+                  'x-decorator': 'Editable',
+                  'x-component': 'Input',
+                },
+              },
+            },
+            column5: {
+              type: 'void',
+              'x-component': 'ArrayTable.Column',
+              'x-component-props': {
+                title: intl.formatMessage({
+                  id: 'pages.data.option',
+                  defaultMessage: '操作',
+                }),
+                dataIndex: 'operations',
+                width: 200,
+                fixed: 'right',
+              },
+              properties: {
+                item: {
+                  type: 'void',
+                  'x-component': 'FormItem',
+                  properties: {
+                    remove: {
+                      type: 'void',
+                      'x-component': 'ArrayTable.Remove',
+                    },
+                  },
+                },
+              },
+            },
+          },
+        },
+        properties: {
+          add: {
+            type: 'void',
+            'x-component': 'ArrayTable.Addition',
+            title: intl.formatMessage({
+              id: 'pages.system.permission.add',
+              defaultMessage: '添加条目',
+            }),
+          },
+        },
+      },
+    },
+  };
+
+  const save = async () => {
+    const value = await form.submit<UserItem>();
+    const response = await service.update(value);
+    if (response.status === 200) {
+      message.success(
+        intl.formatMessage({
+          id: 'pages.data.option.success',
+          defaultMessage: '操作成功',
+        }),
+      );
+      props.close();
+    } else {
+      message.error('操作失败!');
+    }
+  };
+
+  return (
+    <Modal
+      title={intl.formatMessage({
+        id: `pages.data.option.${model}`,
+        defaultMessage: '编辑',
+      })}
+      maskClosable={false}
+      visible={model !== 'query'}
+      onCancel={props.close}
+      onOk={save}
+      width="1000px"
+    >
+      <Form form={form} layout="vertical">
+        <SchemaField schema={schema} />
+      </Form>
+    </Modal>
+  );
+};
+export default Save;

+ 63 - 247
src/pages/system/Permission/index.tsx

@@ -1,56 +1,39 @@
 import { PageContainer } from '@ant-design/pro-layout';
-import React, { useEffect, useRef } from 'react';
+import React, { useRef, useState } from 'react';
 import {
   CloseCircleOutlined,
   DeleteOutlined,
   EditOutlined,
   PlayCircleOutlined,
+  PlusOutlined,
 } from '@ant-design/icons';
-import { Badge, Button, Menu, message, Popconfirm, Tooltip, Upload } from 'antd';
+import { Badge, Button, Dropdown, Menu, message, Popconfirm, Tooltip, Upload } from 'antd';
 import type { ActionType, ProColumns } from '@jetlinks/pro-table';
 import { useIntl } from '@@/plugin-locale/localeExports';
-import BaseCrud from '@/components/BaseCrud';
-import { CurdModel } from '@/components/BaseCrud/model';
 import type { PermissionItem } from '@/pages/system/Permission/typings';
-import { FormTab } from '@formily/antd';
-import type { ISchema } from '@formily/json-schema';
 import Service from '@/pages/system/Permission/service';
-import { model } from '@formily/reactive';
 import { observer } from '@formily/react';
+import SearchComponent from '@/components/SearchComponent';
+import ProTable from '@jetlinks/pro-table';
+import Save from './Save';
 import SystemConst from '@/utils/const';
-import Token from '@/utils/token';
 import { downloadObject } from '@/utils/util';
-import { onFormSubmitStart } from '@formily/core';
+import Token from '@/utils/token';
 
 export const service = new Service('permission');
-
-const defaultAction = [
-  { action: 'query', name: '查询', describe: '查询' },
-  { action: 'save', name: '保存', describe: '保存' },
-  { action: 'delete', name: '删除', describe: '删除' },
-];
-
-const PermissionModel = model<{
-  assetsTypesList: { label: string; value: string }[];
-}>({
-  assetsTypesList: [],
-});
 const Permission: React.FC = observer(() => {
-  useEffect(() => {
-    service.getAssetTypes().subscribe((resp) => {
-      if (resp.status === 200) {
-        PermissionModel.assetsTypesList = resp.result.map((item: { name: string; id: string }) => {
-          return {
-            label: item.name,
-            value: item.id,
-          };
-        });
-      }
-    });
-  }, []);
   const intl = useIntl();
   const actionRef = useRef<ActionType>();
 
+  const [param, setParam] = useState({});
+  const [model, setMode] = useState<'add' | 'edit' | 'query'>('query');
+  const [current, setCurrent] = useState<Partial<PermissionItem>>({});
+
+  const edit = async (record: PermissionItem) => {
+    setMode('edit');
+    setCurrent(record);
+  };
+
   const menu = (
     <Menu>
       <Menu.Item key="import">
@@ -86,7 +69,7 @@ const Permission: React.FC = observer(() => {
         <Popconfirm
           title={'确认导出?'}
           onConfirm={() => {
-            service.getPermission().subscribe((resp) => {
+            service.getPermission({ ...param, paging: false }).subscribe((resp) => {
               if (resp.status === 200) {
                 downloadObject(resp.result, '权限数据');
                 message.success('导出成功');
@@ -162,7 +145,7 @@ const Permission: React.FC = observer(() => {
         <a
           key="editable"
           onClick={() => {
-            CurdModel.update(record);
+            edit(record);
           }}
         >
           <Tooltip
@@ -241,224 +224,57 @@ const Permission: React.FC = observer(() => {
     },
   ];
 
-  const formTab = FormTab.createFormTab!();
-
-  const schema: ISchema = {
-    type: 'object',
-    properties: {
-      id: {
-        title: intl.formatMessage({
-          id: 'pages.system.permission.id',
-          defaultMessage: '标识(ID)',
-        }),
-        type: 'string',
-        'x-decorator': 'FormItem',
-        'x-component': 'Input',
-        name: 'id',
-        'x-decorator-props': {
-          tooltip: <div>标识ID需与代码中的标识ID一致</div>,
-        },
-        'x-validator': [
-          {
-            max: 64,
-            message: '最多可输入64个字符',
-          },
-          {
-            required: true,
-            message: '请输入标识(ID)',
-          },
-        ],
-      },
-      name: {
-        title: intl.formatMessage({
-          id: 'pages.table.name',
-          defaultMessage: '名称',
-        }),
-        type: 'string',
-        'x-decorator': 'FormItem',
-        'x-component': 'Input',
-        name: 'name',
-        'x-validator': [
-          {
-            max: 64,
-            message: '最多可输入64个字符',
-          },
-          {
-            required: true,
-            message: '请输入名称',
-          },
-        ],
-      },
-      // status: {
-      //   title: '状态',
-      //   'x-decorator': 'FormItem',
-      //   'x-component': 'Switch',
-      //   required: true,
-      //   default: 1,
-      //   enum: [
-      //     { label: '1', value: 1 },
-      //     { label: '0', value: 0 },
-      //   ],
-      // },
-      // 'properties.assetTypes': {
-      //   type: 'string',
-      //   title: '关联资产',
-      //   'x-decorator': 'FormItem',
-      //   'x-component': 'Select',
-      //   name: 'properties.assetTypes',
-      //   required: false,
-      //   enum: PermissionModel.assetsTypesList,
-      //   'x-decorator-props': {
-      //     tooltip: <div>关联资产为角色权限中的权限分配提供数据支持</div>,
-      //   },
-      //   'x-component-props': {
-      //     showSearch: true,
-      //     mode: 'multiple',
-      //   },
-      // },
-      actions: {
-        type: 'array',
-        'x-decorator': 'FormItem',
-        'x-component': 'ArrayTable',
-        default: defaultAction,
-        title: '操作类型',
-        items: {
-          type: 'object',
-          properties: {
-            column1: {
-              type: 'void',
-              'x-component': 'ArrayTable.Column',
-              'x-component-props': { width: 80, title: '-', align: 'center' },
-              properties: {
-                index: {
-                  type: 'void',
-                  'x-component': 'ArrayTable.Index',
-                },
-              },
-            },
-            column2: {
-              type: 'void',
-              'x-component': 'ArrayTable.Column',
-              'x-component-props': {
-                width: 200,
-                title: intl.formatMessage({
-                  id: 'pages.system.permission.addConfigurationType',
-                  defaultMessage: '操作类型',
-                }),
-              },
-              properties: {
-                action: {
-                  type: 'string',
-                  'x-decorator': 'Editable',
-                  'x-component': 'Input',
-                },
-              },
-            },
-            column3: {
-              type: 'void',
-              'x-component': 'ArrayTable.Column',
-              'x-component-props': {
-                width: 200,
-                title: intl.formatMessage({
-                  id: 'pages.table.name',
-                  defaultMessage: '名称',
-                }),
-              },
-              properties: {
-                name: {
-                  type: 'string',
-
-                  'x-decorator': 'Editable',
-                  'x-component': 'Input',
-                },
-              },
-            },
-            column4: {
-              type: 'void',
-              'x-component': 'ArrayTable.Column',
-              'x-component-props': {
-                width: 200,
-                title: intl.formatMessage({
-                  id: 'pages.table.describe',
-                  defaultMessage: '描述',
-                }),
-              },
-              properties: {
-                describe: {
-                  type: 'string',
-                  'x-decorator': 'Editable',
-                  'x-component': 'Input',
-                },
-              },
-            },
-            column5: {
-              type: 'void',
-              'x-component': 'ArrayTable.Column',
-              'x-component-props': {
-                title: intl.formatMessage({
-                  id: 'pages.data.option',
-                  defaultMessage: '操作',
-                }),
-                dataIndex: 'operations',
-                width: 200,
-                fixed: 'right',
-              },
-              properties: {
-                item: {
-                  type: 'void',
-                  'x-component': 'FormItem',
-                  properties: {
-                    remove: {
-                      type: 'void',
-                      'x-component': 'ArrayTable.Remove',
-                    },
-                  },
-                },
-              },
-            },
-          },
-        },
-        properties: {
-          add: {
-            type: 'void',
-            'x-component': 'ArrayTable.Addition',
-            title: intl.formatMessage({
-              id: 'pages.system.permission.add',
-              defaultMessage: '添加条目',
-            }),
-          },
-        },
-      },
-    },
-  };
   return (
     <PageContainer>
-      <BaseCrud<PermissionItem>
-        moduleName="permission"
-        actionRef={actionRef}
-        columns={columns}
-        service={service}
-        defaultParams={{ sorts: [{ name: 'id', order: 'desc' }] }}
-        title={intl.formatMessage({
-          id: 'pages.system.permission',
-          defaultMessage: '',
-        })}
-        schemaConfig={{
-          scope: { formTab },
+      <SearchComponent<PermissionItem>
+        field={columns}
+        target="permission"
+        onSearch={(data) => {
+          // 重置分页数据
+          actionRef.current?.reset?.();
+          setParam(data);
         }}
-        modelConfig={{
-          width: 1000,
+        onReset={() => {
+          // 重置分页及搜索参数
+          actionRef.current?.reset?.();
+          setParam({});
         }}
+      />
+      <ProTable<PermissionItem>
+        actionRef={actionRef}
+        params={param}
+        columns={columns}
         search={false}
-        menu={menu}
-        formEffect={() => {
-          onFormSubmitStart((form) => {
-            form.values.actions = form.values.actions?.filter(
-              (item: any) => Object.keys(item).length > 0,
-            );
-          });
+        headerTitle={'权限列表'}
+        request={async (params) =>
+          service.query({ ...params, sorts: [{ name: 'id', order: 'asc' }] })
+        }
+        toolBarRender={() => [
+          <Button
+            onClick={() => {
+              setMode('add');
+            }}
+            key="button"
+            icon={<PlusOutlined />}
+            type="primary"
+          >
+            {intl.formatMessage({
+              id: 'pages.data.option.add',
+              defaultMessage: '新增',
+            })}
+          </Button>,
+          <Dropdown key={'more'} overlay={menu} placement="bottom">
+            <Button>批量操作</Button>
+          </Dropdown>,
+        ]}
+      />
+      <Save
+        model={model}
+        close={() => {
+          setMode('query');
+          actionRef.current?.reload();
         }}
-        schema={schema}
+        data={current}
       />
     </PageContainer>
   );

+ 4 - 3
src/pages/system/Permission/service.ts

@@ -6,11 +6,12 @@ import SystemConst from '@/utils/const';
 import { map } from 'rxjs/operators';
 
 class Service extends BaseService<PermissionItem> {
-  public getPermission = () =>
+  public getPermission = (data: any) =>
     defer(() =>
       from(
-        request(`/${SystemConst.API_BASE}/permission/_query/for-grant`, {
-          method: 'GET',
+        request(`/${SystemConst.API_BASE}/permission/_query/no-paging`, {
+          method: 'POST',
+          data,
         }),
       ),
     ).pipe(map((item) => item));

+ 16 - 0
src/pages/system/Role/index.tsx

@@ -139,6 +139,16 @@ const Role: React.FC = observer(() => {
         'x-decorator-props': {},
         name: 'name',
         required: true,
+        'x-validator': [
+          {
+            max: 64,
+            message: '最多可输入64个字符',
+          },
+          {
+            required: true,
+            message: '请输入名称',
+          },
+        ],
       },
       description: {
         type: 'string',
@@ -154,6 +164,12 @@ const Role: React.FC = observer(() => {
         'x-decorator-props': {},
         name: 'password',
         required: false,
+        'x-validator': [
+          {
+            max: 200,
+            message: '最多可输入200个字符',
+          },
+        ],
       },
     },
   };

+ 5 - 5
src/pages/system/User/index.tsx

@@ -181,11 +181,11 @@ const User = observer(() => {
           actionRef.current?.reset?.();
           setParam(data);
         }}
-        // onReset={() => {
-        //   // 重置分页及搜索参数
-        //   actionRef.current?.reset?.();
-        //   setParam({});
-        // }}
+        onReset={() => {
+          // 重置分页及搜索参数
+          actionRef.current?.reset?.();
+          setParam({});
+        }}
       />
       <ProTable<UserItem>
         actionRef={actionRef}