提交 70352c9a 作者: 郁骅焌

整体样式修改

上级 7831604d
...@@ -71,7 +71,7 @@ export default defineConfig({ ...@@ -71,7 +71,7 @@ export default defineConfig({
routes: [ routes: [
{ {
path: '/system/role', path: '/system/role',
name: 'role', name: '角色管理',
icon: 'SolutionOutlined', icon: 'SolutionOutlined',
component: './role', component: './role',
}, },
......
import React, { useEffect, useState, useImperativeHandle, useRef } from 'react' import React, { useEffect, useState, useImperativeHandle, useRef } from 'react';
import { ConfigProvider, Table, Card } from 'antd' import { ConfigProvider, Table, Card } from 'antd';
import { useFullscreen } from '@umijs/hooks' import { useFullscreen } from '@umijs/hooks';
import TableSearchForm from '@/components/Common/TableSearchForm' import TableSearchForm from '@/components/Common/TableSearchForm';
import TableTool from '@/components/Common/TableTool' import TableTool from '@/components/Common/TableTool';
import './style.less' import './style.less';
const initState = { const initState = {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
dataSource: [], dataSource: [],
pagination: { pagination: {
showQuickJumper: true showQuickJumper: true,
showTotal: (total) => `总共 ${total} 条记录`,
}, },
searchParams: {} searchParams: {},
} };
/** /**
* *
...@@ -32,12 +33,11 @@ const initState = { ...@@ -32,12 +33,11 @@ const initState = {
* 表格工具['reload', 'hiddensearch', 'density', 'fullScreen'] * 表格工具['reload', 'hiddensearch', 'density', 'fullScreen']
*/ */
const SageTable = React.forwardRef((props, ref) => { const SageTable = React.forwardRef((props, ref) => {
const rootRef = useRef(null);
const tableSearchFormRef = useRef();
const rootRef = useRef(null) const [selectedRowKeys, setSelectedRowKeys] = useState([]);
const tableSearchFormRef = useRef() const [selectedRows, setSelectedRows] = useState([]);
const [selectedRowKeys, setSelectedRowKeys] = useState([])
const [selectedRows, setSelectedRows] = useState([])
const { const {
request, request,
...@@ -67,68 +67,68 @@ const SageTable = React.forwardRef((props, ref) => { ...@@ -67,68 +67,68 @@ const SageTable = React.forwardRef((props, ref) => {
} = props; } = props;
const { isFullscreen, setFull, exitFull } = useFullscreen({ const { isFullscreen, setFull, exitFull } = useFullscreen({
dom: () => document.getElementsByClassName('ant-pro-page-header-wrap-children-content')[0] dom: () => document.getElementsByClassName('ant-pro-page-header-wrap-children-content')[0],
}) });
const [tableSize, setTableSize] = useState('default') const [tableSize, setTableSize] = useState('default');
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false);
const [tableState, setTableState] = useState(initState) const [tableState, setTableState] = useState(initState);
// 获取表格数据 // 获取表格数据
const queryTable = async (tableParams, status) => { const queryTable = async (tableParams, status) => {
if (request) { if (request) {
let queryParams = { let queryParams = {
pageNum: tableState.pageNum, pageNum: tableState.pageNum,
pageSize: tableState.pageSize pageSize: tableState.pageSize,
} };
// 是否有搜索条件 // 是否有搜索条件
const hasSearchCondition = tableParams !== undefined const hasSearchCondition = tableParams !== undefined;
if (hasSearchCondition) { if (hasSearchCondition) {
queryParams = Object.assign(queryParams, { queryParams = Object.assign(queryParams, {
...tableState.searchParams, ...tableState.searchParams,
...tableParams ...tableParams,
}) });
if (status === 'change') { if (status === 'change') {
if (!tableParams.sortOrder) { if (!tableParams.sortOrder) {
delete queryParams.sortOrder delete queryParams.sortOrder;
} }
if (!tableParams.sortField) { if (!tableParams.sortField) {
delete queryParams.sortField delete queryParams.sortField;
} }
} }
} }
// 如果是重置则只保留分页和排序条件 // 如果是重置则只保留分页和排序条件
if (status === 'reset') { if (status === 'reset') {
Object.keys(queryParams).forEach(item => { Object.keys(queryParams).forEach((item) => {
if (!(item === 'pageNum' || item === 'pageSize' || item === 'sortField' || item === 'sortOrder')) { if (
delete queryParams[item] !(
item === 'pageNum' ||
item === 'pageSize' ||
item === 'sortField' ||
item === 'sortOrder'
)
) {
delete queryParams[item];
} }
}) });
} }
setLoading(true);
setLoading(true) const res = await request(queryParams);
const res = await request(queryParams) setLoading(false);
setLoading(false)
if (res.isSuccess) { if (res.isSuccess) {
const { const { curPage: current, pageCount: pageSize, dataMaxCount: total } = res;
curPage: current,
pageCount: pageSize,
dataMaxCount: total,
} = res
const newSearchParams = Object.assign({}, queryParams) const newSearchParams = Object.assign({}, queryParams);
if (newSearchParams.pageNum) { if (newSearchParams.pageNum) {
delete newSearchParams.pageNum delete newSearchParams.pageNum;
} }
if (queryParams.pageSize) { if (queryParams.pageSize) {
delete newSearchParams.pageSize delete newSearchParams.pageSize;
} }
setTableState({ setTableState({
...@@ -139,45 +139,44 @@ const SageTable = React.forwardRef((props, ref) => { ...@@ -139,45 +139,44 @@ const SageTable = React.forwardRef((props, ref) => {
...tableState.pagination, ...tableState.pagination,
current, current,
pageSize, pageSize,
total total,
}, },
searchParams: hasSearchCondition ? { ...newSearchParams } : {} searchParams: hasSearchCondition ? { ...newSearchParams } : {},
}) });
}
} }
} }
};
// 改变表格数据 // 改变表格数据
const onChangeTable = async (pagination, filters, sorter) => { const onChangeTable = async (pagination, filters, sorter) => {
const tableParams = { const tableParams = {
pageNum: pagination.current, pageNum: pagination.current,
pageSize: pagination.pageSize pageSize: pagination.pageSize,
} };
// 如果有排序则添加排序属性 // 如果有排序则添加排序属性
if (Object.keys(sorter).length !== 0 && sorter.order) { if (Object.keys(sorter).length !== 0 && sorter.order) {
tableParams.sortField = sorter.column.sortField tableParams.sortField = sorter.column.sortField;
tableParams.sortOrder = sorter.order === 'ascend' ? 'asc' : 'desc' tableParams.sortOrder = sorter.order === 'ascend' ? 'asc' : 'desc';
} }
queryTable(tableParams, 'change') queryTable(tableParams, 'change');
} };
// 刷新当前表格数据 // 刷新当前表格数据
const reloadTable = () => { const reloadTable = () => {
queryTable(tableState.searchParams) queryTable(tableState.searchParams);
} };
// 获取选中keys // 获取选中keys
const getSelectedRowKeys = () => { const getSelectedRowKeys = () => {
return selectedRowKeys return selectedRowKeys;
} };
// 获取选中rows // 获取选中rows
const getSelectedRows = () => { const getSelectedRows = () => {
return selectedRows return selectedRows;
} };
// 工具方法 // 工具方法
const tableToolProps = { const tableToolProps = {
...@@ -185,52 +184,54 @@ const SageTable = React.forwardRef((props, ref) => { ...@@ -185,52 +184,54 @@ const SageTable = React.forwardRef((props, ref) => {
toolOptionConfig: toolOptionConfigProps, toolOptionConfig: toolOptionConfigProps,
// 刷新表格 // 刷新表格
onRefreshTable: () => { onRefreshTable: () => {
queryTable(tableState.searchParams) queryTable(tableState.searchParams);
}, },
// 隐藏搜索条件 // 隐藏搜索条件
onHiddeSearch: () => { onHiddeSearch: () => {
if (tableSearchFormRef.current) { if (tableSearchFormRef.current) {
tableSearchFormRef.current.hiddenSearch() tableSearchFormRef.current.hiddenSearch();
} }
}, },
// 改变表格密度 // 改变表格密度
onChangeSize: (size) => { onChangeSize: (size) => {
setTableSize(size) setTableSize(size);
}, },
// 全屏 // 全屏
setFull: () => setFull(), setFull: () => setFull(),
// 退出全屏 // 退出全屏
exitFull: () => exitFull(), exitFull: () => exitFull(),
} };
useEffect(() => { useEffect(() => {
queryTable() queryTable();
}, []) }, []);
const tableSizeState = tableSizeProps !== undefined ? tableSizeProps : tableSize const tableSizeState = tableSizeProps !== undefined ? tableSizeProps : tableSize;
const dataSourceState = dataSourceProps !== undefined ? dataSourceProps.slice() : tableState.dataSource const dataSourceState =
const paginationState = paginationProps !== undefined ? paginationProps : tableState.pagination dataSourceProps !== undefined ? dataSourceProps.slice() : tableState.dataSource;
const loadingState = loadingProps !== undefined ? loadingProps : loading const paginationState = paginationProps !== undefined ? paginationProps : tableState.pagination;
const loadingState = loadingProps !== undefined ? loadingProps : loading;
// 是否有序号 // 是否有序号
const columnsState = columnsProps !== undefined ? columnsProps.slice() : [] const columnsState = columnsProps !== undefined ? columnsProps.slice() : [];
if (hasNumber) { if (hasNumber) {
columnsState.unshift({ columnsState.unshift({
title: '序号', title: '序号',
render: (text, record, index) => `${(paginationState.current - 1) * paginationState.pageSize + index + 1}`, render: (text, record, index) =>
`${(paginationState.current - 1) * paginationState.pageSize + index + 1}`,
align: 'center', align: 'center',
width: 60, width: 60,
}) });
} }
const tableSearchFormProps = { const tableSearchFormProps = {
searchFields: searchFieldsProps, searchFields: searchFieldsProps,
onSearchTable: onSearchTableProps, onSearchTable: onSearchTableProps,
onResetTable: onResetTableProps, onResetTable: onResetTableProps,
} };
const lastTableState = { const lastTableState = {
...tableProps ...tableProps,
} };
const rowSelection = { const rowSelection = {
selectedRowKeys, selectedRowKeys,
...@@ -238,16 +239,16 @@ const SageTable = React.forwardRef((props, ref) => { ...@@ -238,16 +239,16 @@ const SageTable = React.forwardRef((props, ref) => {
type: selectionType, type: selectionType,
onChange: (selectedrowkeys, selectedrows) => { onChange: (selectedrowkeys, selectedrows) => {
// console.log(`selectedRowKeys: ${selectedrowkeys}`, 'selectedRows: ', selectedrows); // console.log(`selectedRowKeys: ${selectedrowkeys}`, 'selectedRows: ', selectedrows);
setSelectedRowKeys(selectedrowkeys) setSelectedRowKeys(selectedrowkeys);
setSelectedRows(selectedrows) setSelectedRows(selectedrows);
} },
}; };
if (hasCheck) { if (hasCheck) {
lastTableState.rowSelection = { lastTableState.rowSelection = {
...rowSelection, ...rowSelection,
...rowSelectionProps ...rowSelectionProps,
} };
} }
// 暴露给外部的方法 // 暴露给外部的方法
...@@ -258,13 +259,11 @@ const SageTable = React.forwardRef((props, ref) => { ...@@ -258,13 +259,11 @@ const SageTable = React.forwardRef((props, ref) => {
setSelectedRowKeys, setSelectedRowKeys,
getSelectedRows, getSelectedRows,
setSelectedRows, setSelectedRows,
getSearchFieldsValue: () => tableSearchFormRef.current.getFieldsValue() getSearchFieldsValue: () => tableSearchFormRef.current.getFieldsValue(),
})) }));
return ( return (
<ConfigProvider <ConfigProvider getPopupContainer={() => rootRef.current}>
getPopupContainer={() => rootRef.current}
>
<div className="sage-pro-table" ref={rootRef}> <div className="sage-pro-table" ref={rootRef}>
<Card <Card
bordered={false} bordered={false}
...@@ -275,21 +274,11 @@ const SageTable = React.forwardRef((props, ref) => { ...@@ -275,21 +274,11 @@ const SageTable = React.forwardRef((props, ref) => {
padding: 0, padding: 0,
}} }}
> >
{searchFieldsProps && searchFieldsProps.length !== 0 && (
<TableSearchForm ref={tableSearchFormRef} {...tableSearchFormProps} />
)}
{ <TableTool tableSize={tableSizeState} isFullscreen={isFullscreen} {...tableToolProps} />
searchFieldsProps && searchFieldsProps.length !== 0 &&
<TableSearchForm
ref={tableSearchFormRef}
{...tableSearchFormProps}
/>
}
<TableTool
tableSize={tableSizeState}
isFullscreen={isFullscreen}
{...tableToolProps}
/>
<Table <Table
size={tableSizeState} size={tableSizeState}
...@@ -298,41 +287,41 @@ const SageTable = React.forwardRef((props, ref) => { ...@@ -298,41 +287,41 @@ const SageTable = React.forwardRef((props, ref) => {
pagination={paginationState} pagination={paginationState}
loading={loadingState} loading={loadingState}
onChange={onChangeTable} onChange={onChangeTable}
onRow={record => { onRow={(record) => {
return { return {
// 点击行 // 点击行
onClick: event => { onClick: (event) => {
event.stopPropagation() event.stopPropagation();
if (onClickRowProps) { if (onClickRowProps) {
onClickRowProps(record) onClickRowProps(record);
} }
}, },
// 双击行 // 双击行
onDoubleClick: event => { onDoubleClick: (event) => {
event.stopPropagation() event.stopPropagation();
if (onDoubleClickRowProps) { if (onDoubleClickRowProps) {
onDoubleClickRowProps(record) onDoubleClickRowProps(record);
} }
}, },
// 鼠标右键 // 鼠标右键
onContextMenu: event => { onContextMenu: (event) => {
event.stopPropagation() event.stopPropagation();
if (onContextMenuRowProps) { if (onContextMenuRowProps) {
onContextMenuRowProps(record) onContextMenuRowProps(record);
} }
}, },
// 鼠标移入行 // 鼠标移入行
onMouseEnter: event => { onMouseEnter: (event) => {
event.stopPropagation() event.stopPropagation();
if (onMouseEnterRowProps) { if (onMouseEnterRowProps) {
onMouseEnterRowProps(record) onMouseEnterRowProps(record);
} }
}, },
// 鼠标移出行 // 鼠标移出行
onMouseLeave: event => { onMouseLeave: (event) => {
event.stopPropagation() event.stopPropagation();
if (onMouseLeaveRowProps) { if (onMouseLeaveRowProps) {
onMouseLeaveRowProps(record) onMouseLeaveRowProps(record);
} }
}, },
}; };
...@@ -342,8 +331,7 @@ const SageTable = React.forwardRef((props, ref) => { ...@@ -342,8 +331,7 @@ const SageTable = React.forwardRef((props, ref) => {
</Card> </Card>
</div> </div>
</ConfigProvider> </ConfigProvider>
);
});
) export default SageTable;
})
export default SageTable
import React from 'react';
import './style.less';
const GlobalFooter = () => {
return (
<div className="sage-global-footer">
© 2020 江苏圣捷远创科技有限公司版权所有 ⋅ 苏ICP备17030519号
</div>
);
};
export default GlobalFooter;
.sage-global-footer {
position: fixed;
bottom: 0;
width: 100%;
height: 40px;
margin-left: -24px;
padding-left: 10px;
line-height: 40px;
background: #f0f2f5;
border-top: 1px solid #e7eaec;
}
.sage-tabbar { .sage-tabbar {
position: fixed;
z-index: 3;
display: flex; display: flex;
width: calc(100% - 256px);
height: 40px; height: 40px;
margin: -24px -24px -4px; margin: -24px -24px -4px;
background: #fff; background: #fff;
......
...@@ -43,7 +43,28 @@ ol { ...@@ -43,7 +43,28 @@ ol {
} }
.ant-pro-basicLayout-content .ant-pro-page-header-wrap { .ant-pro-basicLayout-content .ant-pro-page-header-wrap {
margin-top: 0px !important; margin-top: 24px !important;
padding-bottom: 40px;
}
.ant-layout-header {
position: fixed;
top: 0;
width: calc(100% - 256px) !important;
}
.ant-pro-basicLayout-content {
position: absolute;
top: 64px;
width: calc(100% - 48px);
}
.ant-layout-footer {
display: none;
}
.ant-table-pagination-right {
margin-right: 10px !important;
} }
// 公共样式 // 公共样式
...@@ -53,8 +74,6 @@ ol { ...@@ -53,8 +74,6 @@ ol {
// 新增组件样式 // 新增组件样式
@media (max-width: @screen-xs) { @media (max-width: @screen-xs) {
.ant-table { .ant-table {
width: 100%; width: 100%;
......
...@@ -11,6 +11,7 @@ import { Result, Button } from 'antd'; ...@@ -11,6 +11,7 @@ import { Result, Button } from 'antd';
import Authorized from '@/utils/Authorized'; import Authorized from '@/utils/Authorized';
import RightContent from '@/components/GlobalHeader/RightContent'; import RightContent from '@/components/GlobalHeader/RightContent';
import TabBar from '@/components/TabBar'; import TabBar from '@/components/TabBar';
import GlobalFooter from '@/components/GlobalFooter';
import { getAuthorityFromRouter } from '@/utils/utils'; import { getAuthorityFromRouter } from '@/utils/utils';
import logo from '../assets/logo.svg'; import logo from '../assets/logo.svg';
...@@ -152,8 +153,11 @@ const BasicLayout = (props) => { ...@@ -152,8 +153,11 @@ const BasicLayout = (props) => {
> >
<TabBar ref={tabBarRef} currentUser={currentUser} /> <TabBar ref={tabBarRef} currentUser={currentUser} />
<Authorized authority={authorized.authority} noMatch={noMatch}> <Authorized authority={authorized.authority} noMatch={noMatch}>
<div style={{ position: 'absolute', top: 0, bottom: 0, left: 0, right: 0 }}>
<KeepAliveLayout {...props}>{children}</KeepAliveLayout> <KeepAliveLayout {...props}>{children}</KeepAliveLayout>
</div>
</Authorized> </Authorized>
<GlobalFooter />
</ProLayout> </ProLayout>
); );
}; };
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论