From 9a90ba3b876efc9c9b82e128b22af0c84f2a179b Mon Sep 17 00:00:00 2001 From: powersir <1576775122@qq.com> Date: Wed, 6 Dec 2023 00:24:23 +0800 Subject: [PATCH] update:role list support page --- src/pages/system/role/index.tsx | 44 ++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/src/pages/system/role/index.tsx b/src/pages/system/role/index.tsx index 93def4a..af3a1d9 100644 --- a/src/pages/system/role/index.tsx +++ b/src/pages/system/role/index.tsx @@ -1,6 +1,7 @@ import React, { useState, useEffect } from 'react'; -import { Space, Table, Button, Input, Select, Divider, Tag, Card, Badge, Form } from 'antd'; +import { Space, Table, Button, Input, Select, Divider, Tag, Card, Badge, Form, DatePicker } from 'antd'; import type { TableColumnsType } from 'antd'; +import type { TableProps } from 'antd/es/table'; import { t } from '@/utils/i18n'; import { PlusOutlined, ExclamationCircleFilled, SearchOutlined, UndoOutlined } from '@ant-design/icons'; import { antdUtils } from '@/utils/antd'; @@ -10,23 +11,36 @@ import roleService from '@/request/service/role'; import { RoleVO } from '@/models'; import RoleEditor from './role-editor'; +const { RangePicker } = DatePicker; + export default () => { const [editorVisable, seEditorVisable] = useState(false); const [editRole, setEditRole] = useState(); const [dataSource, setDataSource] = useState([]); + const [total, setTotal] = useState(0); + const [page, setPage] = useState({ + pageNo: 1, + pageSize: 10 + }); const [searchFrom] = Form.useForm(); const { runAsync: getRoleList } = useRequest(roleService.getRoleList, { manual: true }); const { runAsync: deleteRole } = useRequest(roleService.deleteRole, { manual: true }); const loadRoles = async () => { - const [error, { code, msg, data }] = await getRoleList(searchFrom.getFieldsValue()); + const params = {...page, ...searchFrom.getFieldsValue()} + const createTime = searchFrom.getFieldValue("createTime"); + if(createTime) { + params["createTime"] = `[${createTime[0].format('YYYY-MM-DD 00:00:00')},${createTime[1].format('YYYY-MM-DD 23:59:59')}]`; + } + const [error, { code, msg, data }] = await getRoleList(params); if (error || code !== 0) { antdUtils.message?.open({ type: 'error', content: msg ?? '操作失败' }); return } setDataSource(data.list); + setTotal(data.total); }; const onReset = () => { @@ -159,14 +173,20 @@ export default () => { }, ]; + const onChange: TableProps['onChange'] = (pagination, filters, sorter, extra) => { + setPage({ + pageNo: pagination.current??1, + pageSize: pagination.pageSize??10 + }); + }; useEffect(() => { loadRoles(); - }, []); + }, [page]); return ( <> -
+
@@ -184,6 +204,9 @@ export default () => { 关闭 + + + @@ -198,13 +221,22 @@ export default () => {
- + + onChange={onChange} + pagination={{ + current: page.pageNo, + pageSize: page.pageSize, + total, + position: ['bottomRight'] + }} />