Browse Source

fix(crud): crud

Lind 3 years atrás
parent
commit
41ab338972

+ 1 - 1
package.json

@@ -70,7 +70,7 @@
     "@formily/reactive-react": "2.0.0-rc.17",
     "@formily/shared": "2.0.0-rc.17",
     "@jetlinks/pro-list": "^1.10.8",
-    "@jetlinks/pro-table": "^2.63.9",
+    "@jetlinks/pro-table": "^2.63.10",
     "@umijs/route-utils": "^1.0.36",
     "ahooks": "^2.10.9",
     "antd": "^4.18.8",

+ 3 - 2
src/components/BaseCrud/index.tsx

@@ -76,8 +76,9 @@ const BaseCrud = <T extends Record<string, any>>(props: Props<T>) => {
       <SearchComponent<T>
         field={columns}
         onSearch={async (data) => {
-          actionRef.current?.reset?.();
-          setParam({ terms: data });
+          // actionRef.current?.reset?.();
+          actionRef.current?.setPageInfo?.({ pageSize: 10 });
+          setParam(data);
         }}
         target={moduleName}
         onReset={() => {

+ 18 - 14
src/pages/system/Department/index.tsx

@@ -4,7 +4,7 @@ import ProTable from '@jetlinks/pro-table';
 import type { ActionType, ProColumns } from '@jetlinks/pro-table';
 import { useEffect, useRef, useState } from 'react';
 import { useIntl } from '@@/plugin-locale/localeExports';
-import { Button, message, Popconfirm, Tooltip, Card, Divider } from 'antd';
+import { Button, message, Popconfirm, Tooltip } from 'antd';
 import {
   EditOutlined,
   PlusOutlined,
@@ -38,9 +38,7 @@ export const State = model<ModelType>({
 export default observer(() => {
   const actionRef = useRef<ActionType>();
   const intl = useIntl();
-  const [param, setParam] = useState({
-    terms: [{ column: 'typeId', value: 'org' }],
-  });
+  const [param, setParam] = useState({});
 
   /**
    * 根据部门ID删除数据
@@ -73,6 +71,7 @@ export default observer(() => {
         defaultMessage: '排序',
       }),
       search: false,
+      valueType: 'digit',
       dataIndex: 'sortIndex',
     },
     {
@@ -193,16 +192,21 @@ export default observer(() => {
 
   return (
     <PageContainer>
-      <Card>
-        <SearchComponent<DepartmentItem>
-          field={columns}
-          onSearch={async (data) => {
-            setParam({ terms: [...data, { column: 'typeId', value: 'org' }] });
-          }}
-          target="department"
-        />
-      </Card>
-      <Divider />
+      <SearchComponent<DepartmentItem>
+        field={columns}
+        defaultParam={[{ column: 'typeId', value: 'org', termType: 'eq' }]}
+        onSearch={async (data) => {
+          // 重置分页数据
+          actionRef.current?.reset?.();
+          setParam(data);
+        }}
+        onReset={() => {
+          // 重置分页及搜索参数
+          actionRef.current?.reset?.();
+          setParam({});
+        }}
+        target="department"
+      />
       <ProTable<DepartmentItem>
         columns={columns}
         actionRef={actionRef}

+ 1 - 40
src/pages/system/Permission/index.tsx

@@ -121,11 +121,6 @@ const Permission: React.FC = observer(() => {
 
   const columns: ProColumns<PermissionItem>[] = [
     {
-      dataIndex: 'index',
-      valueType: 'indexBorder',
-      width: 48,
-    },
-    {
       title: intl.formatMessage({
         id: 'pages.system.permission.id',
         defaultMessage: '标识',
@@ -134,19 +129,8 @@ const Permission: React.FC = observer(() => {
       copyable: true,
       ellipsis: true,
       align: 'center',
-      sorter: true,
+      // sorter: true,
       defaultSortOrder: 'ascend',
-      formItemProps: {
-        rules: [
-          {
-            required: true,
-            message: '此项为必填项',
-          },
-        ],
-      },
-      search: {
-        transform: (value) => ({ id$LIKE: value }),
-      },
     },
     {
       title: intl.formatMessage({
@@ -157,21 +141,6 @@ const Permission: React.FC = observer(() => {
       copyable: true,
       ellipsis: true,
       align: 'center',
-      tip: intl.formatMessage({
-        id: 'pages.system.permission.name.tip',
-        defaultMessage: '名称过长会自动收缩',
-      }),
-      formItemProps: {
-        rules: [
-          {
-            required: true,
-            message: '此项为必填项',
-          },
-        ],
-      },
-      search: {
-        transform: (value) => ({ name$LIKE: value }),
-      },
     },
     {
       title: intl.formatMessage({
@@ -181,16 +150,8 @@ const Permission: React.FC = observer(() => {
       dataIndex: 'status',
       filters: true,
       align: 'center',
-      onFilter: true,
       valueType: 'select',
       valueEnum: {
-        all: {
-          text: intl.formatMessage({
-            id: 'pages.searchTable.titleStatus.all',
-            defaultMessage: '全部',
-          }),
-          status: 'Default',
-        },
         1: {
           text: intl.formatMessage({
             id: 'pages.searchTable.titleStatus.normal',

+ 6 - 40
src/pages/system/Role/index.tsx

@@ -7,10 +7,6 @@ import BaseCrud from '@/components/BaseCrud';
 import BaseService from '@/utils/BaseService';
 import { useIntl } from '@@/plugin-locale/localeExports';
 import { observer } from '@formily/react';
-// import autzModel from '@/components/Authorization/autz';
-// import Authorization from '@/components/Authorization';
-// import { BindModel } from '@/components/BindUser/model';
-// import BindUser from '@/components/BindUser';
 import { Link, useLocation } from 'umi';
 import { Store } from 'jetlinks-store';
 import SystemConst from '@/utils/const';
@@ -23,11 +19,11 @@ const Role: React.FC = observer(() => {
   const actionRef = useRef<ActionType>();
 
   const columns: ProColumns<RoleItem>[] = [
-    {
-      dataIndex: 'index',
-      valueType: 'indexBorder',
-      width: 48,
-    },
+    // {
+    //   dataIndex: 'index',
+    //   valueType: 'indexBorder',
+    //   width: 48,
+    // },
     {
       title: intl.formatMessage({
         id: 'pages.system.role.id',
@@ -186,40 +182,10 @@ const Role: React.FC = observer(() => {
         search={false}
         title={intl.formatMessage({
           id: 'pages.system.role',
-          defaultMessage: '角色管理',
+          defaultMessage: '角色列表',
         })}
         schema={schema}
-        // defaultParams={{ typeId: 'role' }}
       />
-      {/* <Modal
-        visible={BindModel.visible}
-        closable={false}
-        onCancel={() => {
-          BindModel.visible = false;
-          BindModel.bind = false;
-        }}
-        width={BindModel.bind ? '90vw' : '60vw'}
-      >
-        <BindUser />
-      </Modal> */}
-      {/* <Drawer
-        title={intl.formatMessage({
-          id: 'pages.data.option.authorize',
-          defaultMessage: '授权',
-        })}
-        width="70vw"
-        visible={autzModel.visible}
-        onClose={() => {
-          autzModel.visible = false;
-        }}
-      >
-        <Authorization
-          close={() => {
-            autzModel.visible = false;
-          }}
-          target={autzModel.autzTarget}
-        />
-      </Drawer> */}
     </PageContainer>
   );
 });

+ 1 - 1
src/pages/system/User/Save/index.tsx

@@ -312,7 +312,7 @@ const Save = (props: Props) => {
       visible={model !== 'query'}
       onCancel={props.close}
       onOk={save}
-      width="30vw"
+      width="35vw"
     >
       <Form form={form} labelCol={4} wrapperCol={18}>
         <SchemaField schema={schema} scope={{ useAsyncDataSource, getRole, getOrg }} />

+ 17 - 15
src/pages/system/User/index.tsx

@@ -3,7 +3,7 @@ import { PageContainer } from '@ant-design/pro-layout';
 import SearchComponent from '@/components/SearchComponent';
 import type { ActionType, ProColumns } from '@jetlinks/pro-table';
 import ProTable from '@jetlinks/pro-table';
-import { Button, Card, message, Popconfirm, Tooltip } from 'antd';
+import { Button, message, Popconfirm, Tooltip } from 'antd';
 import {
   CloseCircleOutlined,
   DeleteOutlined,
@@ -176,27 +176,29 @@ const User = observer(() => {
   ];
 
   const [param, setParam] = useState({});
+
   return (
     <PageContainer>
-      <Card style={{ marginBottom: '20px' }}>
-        <SearchComponent
-          field={columns}
-          onSearch={(data) => {
-            actionRef.current?.reset?.();
-            setParam({ terms: data, total: null });
-          }}
-          target="user"
-          onReset={() => {
-            actionRef.current?.reset?.();
-            setParam({});
-          }}
-        />
-      </Card>
+      <SearchComponent<UserItem>
+        field={columns}
+        target="user"
+        onSearch={(data) => {
+          // 重置分页数据
+          actionRef.current?.reset?.();
+          setParam(data);
+        }}
+        // onReset={() => {
+        //   // 重置分页及搜索参数
+        //   actionRef.current?.reset?.();
+        //   setParam({});
+        // }}
+      />
       <ProTable<UserItem>
         actionRef={actionRef}
         params={param}
         columns={columns}
         search={false}
+        headerTitle={'用户列表'}
         request={async (params) =>
           service.query({ ...params, sorts: [{ name: 'createTime', order: 'desc' }] })
         }