Commit 83f39218 authored by chenshouchao's avatar chenshouchao

feat: 新增多选 分页组件

parent 9c8fe2c6
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
left: 0; left: 0;
background-color: #fff; background-color: #fff;
border-radius: 16px 0 0 0; border-radius: 16px 0 0 0;
padding: 24px 32px; /* padding: 24px 32px; */
box-sizing: border-box; box-sizing: border-box;
overflow: scroll; overflow: scroll;
animation: showDrawer 1s ease; animation: showDrawer 1s ease;
......
...@@ -5,6 +5,8 @@ import Menu from "@mui/material/Menu"; ...@@ -5,6 +5,8 @@ import Menu from "@mui/material/Menu";
import MenuItem from "@mui/material/MenuItem"; import MenuItem from "@mui/material/MenuItem";
import Checkbox from "@mui/material/Checkbox"; import Checkbox from "@mui/material/Checkbox";
import { ThemeProvider, createTheme } from "@mui/material/styles"; import { ThemeProvider, createTheme } from "@mui/material/styles";
import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown";
import ArrowDropUpIcon from "@mui/icons-material/ArrowDropUp";
import _ from "lodash"; import _ from "lodash";
const theme = createTheme({ const theme = createTheme({
...@@ -79,6 +81,7 @@ type IMyMultipleMenuProps = { ...@@ -79,6 +81,7 @@ type IMyMultipleMenuProps = {
setValue?: any; // 设置选中的项values setValue?: any; // 设置选中的项values
showSelectAll?: boolean; // 是否显示全选 showSelectAll?: boolean; // 是否显示全选
selectAllText?: string; // 全选的文字 selectAllText?: string; // 全选的文字
showHiddenIcon?: boolean; // 是否显示 展开收起箭头
}; };
const MyMultipleMenu = (props: IMyMultipleMenuProps) => { const MyMultipleMenu = (props: IMyMultipleMenuProps) => {
...@@ -89,6 +92,7 @@ const MyMultipleMenu = (props: IMyMultipleMenuProps) => { ...@@ -89,6 +92,7 @@ const MyMultipleMenu = (props: IMyMultipleMenuProps) => {
setValue, setValue,
showSelectAll = false, showSelectAll = false,
selectAllText = "全部", selectAllText = "全部",
showHiddenIcon = true,
} = props; } = props;
// 下拉框展示的相对位置参考元素 // 下拉框展示的相对位置参考元素
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null); const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
...@@ -132,10 +136,28 @@ const MyMultipleMenu = (props: IMyMultipleMenuProps) => { ...@@ -132,10 +136,28 @@ const MyMultipleMenu = (props: IMyMultipleMenuProps) => {
return result === -1 ? false : true; return result === -1 ? false : true;
}; };
const randerShowHiddenIcon = () => {
if (Boolean(anchorEl)) {
return <ArrowDropUpIcon sx={{ color: "rgba(19, 112, 255, 1)" }} />;
} else {
return <ArrowDropDownIcon sx={{ color: "rgba(19, 112, 255, 1)" }} />;
}
};
return ( return (
<ThemeProvider theme={theme}> <ThemeProvider theme={theme}>
<div> <div>
<div onClick={handleClick}>{children}</div> <div
onClick={handleClick}
style={{
display: "flex",
justifyContent: "flex-start",
alignItems: "center",
}}
>
{children}
{showHiddenIcon && randerShowHiddenIcon()}
</div>
<Menu <Menu
id="basic-menu" id="basic-menu"
anchorEl={anchorEl} anchorEl={anchorEl}
......
// 分页组件
import Pagination from "@mui/material/Pagination";
import { ThemeProvider, createTheme } from "@mui/material/styles";
const theme = createTheme({
components: {
MuiPaginationItem: {
styleOverrides: {
root: {
"&.Mui-selected": {
background: "rgba(19, 112, 255, 1)",
color: "#fff",
":hover": {
background: "rgba(19, 112, 255, 1)",
color: "#fff",
},
},
},
},
},
},
});
type IMyPaginationProps = {
page: number;
pageChange: any;
count: number;
};
const MyPagination = (props: IMyPaginationProps) => {
const { page, pageChange, count } = props;
const handlePageChange = (e: any, value: number) => {
pageChange && pageChange(value);
};
return (
<ThemeProvider theme={theme}>
<Pagination
page={page}
count={count}
shape="rounded"
onChange={handlePageChange}
/>
</ThemeProvider>
);
};
export default MyPagination;
.datasetBox {
padding: 24px 32px 0;
box-sizing: border-box;
position: relative;
display: flex;
flex-direction: column;
justify-content: flex-start;
height: 100%;
}
.top {
margin-bottom: 20px;
}
.title {
line-height: 22px;
color: rgba(30, 38, 51, 1);
font-size: 18px;
font-weight: 600;
margin-bottom: 20px;
}
.screens {
display: flex;
justify-content: space-between;
align-items: center;
}
.screensLeft {
display: flex;
justify-content: flex-start;
align-items: center;
}
.screensRight {
display: flex;
justify-content: flex-end;
align-items: center;
}
.selectShowData {
margin-left: 24px;
font-size: 14px;
color: rgba(19, 112, 255, 1);
}
.table {
flex: 1;
overflow: auto;
display: flex;
flex-direction: column;
}
.list {
flex: 1;
display: flex;
justify-content: space-between;
flex-wrap: wrap;
}
.datasetLi {
flex: 1;
min-width: 20%;
margin: 0 16px 16px 0;
border: 1px solid rgba(235, 237, 240, 1);
border-radius: 4px;
min-height: 275px;
box-sizing: border-box;
}
.datasetLi:nth-child(4n) {
margin-right: 0;
}
.datasetLi:nth-last-child(1) {
margin-bottom: 0;
}
.datasetLi:nth-last-child(2) {
margin-bottom: 0;
}
.datasetLi:nth-last-child(3) {
margin-bottom: 0;
}
.datasetLi:nth-last-child(4) {
margin-bottom: 0;
}
.pagination {
height: 76px;
min-height: 76px;
display: flex;
justify-content: center;
align-items: center;
}
.foot {
position: absolute;
bottom: 0;
background-color: #fff;
width: 100%;
box-sizing: border-box;
height: 64px;
padding: 0 32px;
display: flex;
justify-content: flex-end;
align-items: center;
box-shadow: 0px -3px 10px 0px rgba(0, 24, 57, 0.04);
}
...@@ -2,6 +2,11 @@ import FullScreenDrawer from "@/components/CommonComponents/FullScreenDrawer"; ...@@ -2,6 +2,11 @@ import FullScreenDrawer from "@/components/CommonComponents/FullScreenDrawer";
import { useState } from "react"; import { useState } from "react";
import RadioGroupOfButtonStyle from "@/components/CommonComponents/RadioGroupOfButtonStyle"; import RadioGroupOfButtonStyle from "@/components/CommonComponents/RadioGroupOfButtonStyle";
import MyMultipleMenu, { IOption } from "@/components/mui/MyMultipleMenu"; import MyMultipleMenu, { IOption } from "@/components/mui/MyMultipleMenu";
import MySelect from "../../ProjectSubmitWork/components/MySelect";
import MyInput from "@/components/mui/MyInput";
import ButtonComponent from "@/components/mui/MyButton";
import SearchIcon from "@mui/icons-material/Search";
import MyPagination from "@/components/mui/MyPagination";
import style from "./index.module.css"; import style from "./index.module.css";
type ISeeDatasetProps = { type ISeeDatasetProps = {
...@@ -27,9 +32,31 @@ const SeeDataset = (props: ISeeDatasetProps) => { ...@@ -27,9 +32,31 @@ const SeeDataset = (props: ISeeDatasetProps) => {
const [graphicDimension, setGraphicDimension] = useState("2D"); // 分子结构图是2D还是3D const [graphicDimension, setGraphicDimension] = useState("2D"); // 分子结构图是2D还是3D
const [showDataTypes, setShowDataTypes] = useState<Array<string>>([]); //显示的数据类型 const [showDataTypes, setShowDataTypes] = useState<Array<string>>([]); //显示的数据类型
const [dataTypes, setdataTypes] = useState<Array<IOption>>(dataTypesMock); // 可选的数据类型 const [dataTypes, setdataTypes] = useState<Array<IOption>>(dataTypesMock); // 可选的数据类型
const [sort, setSort] = useState("null"); // 排序方式
const [keyword, setKeyword] = useState(""); // 关键字
const [searchDataType, setSearchDataType] = useState<string>(""); //显示的数据类型
const [page, setPage] = useState(1); // 当前页码
const [count, setCount] = useState(1); // 总页数
const handleSearchDataTypeChange = (e: any) => {
setSearchDataType(e.target.value);
};
const handleSortChange = (e: any) => {
console.log(e);
setSort(e.target.value);
};
const handleKeywordChange = (e: any) => {
console.log(e);
setKeyword(e.target.value);
};
const list = [1, 2, 3, 2, 1, 45, 6, 7];
const pageChange = (value: number) => {
setPage(value);
};
return ( return (
<FullScreenDrawer handleClose={props.handleClose}> <FullScreenDrawer handleClose={props.handleClose}>
<h2>数据集title</h2> <div className={style.datasetBox}>
<div className={style.top}>
<div className={style.title}>数据集title</div>
<div className={style.screens}> <div className={style.screens}>
<div className={style.screensLeft}> <div className={style.screensLeft}>
<RadioGroupOfButtonStyle <RadioGroupOfButtonStyle
...@@ -53,12 +80,96 @@ const SeeDataset = (props: ISeeDatasetProps) => { ...@@ -53,12 +80,96 @@ const SeeDataset = (props: ISeeDatasetProps) => {
setValue={setShowDataTypes} setValue={setShowDataTypes}
showSelectAll={true} showSelectAll={true}
> >
<span className={style.selectShowData}>
选择显示数据({showDataTypes.length}) 选择显示数据({showDataTypes.length})
</span>
</MyMultipleMenu> </MyMultipleMenu>
</div> </div>
<div className={style.screensRight}></div> <div className={style.screensRight}>
<MySelect
options={dataTypes}
placeholder="选择属性"
value={searchDataType}
onChange={handleSearchDataTypeChange}
fullWidth={false}
sx={{
width: "160px",
marginRight: "16px",
}}
></MySelect>
<MySelect
options={[
{
label: "无",
value: "null",
},
{
label: "正序",
value: "1",
},
{
label: "倒序",
value: "2",
},
]}
title="排序方式"
value={sort}
onChange={handleSortChange}
isTitle={true}
fullWidth={false}
sx={{
width: "160px",
marginRight: "16px",
}}
></MySelect>
<MyInput
value={keyword}
onChange={handleKeywordChange}
placeholder="请输入关键词搜索"
fullWidth={false}
InputProps={{
endAdornment: <SearchIcon style={{ color: "#8A9099" }} />,
}}
inputSx={{
width: "340px",
marginRight: "16px",
}}
// sx={{
// width: "340px",
// marginRight: "16px",
// }}
></MyInput>
<ButtonComponent
text="确认"
style={{ width: "68px" }}
></ButtonComponent>
</div>
</div>
</div>
<div className={style.table}>
<div className={style.list}>
{list.map((item) => {
return (
<div className={style.datasetLi}>
{/* <div className={datasetLiTop}></div>
<div className={datasetLiTop}></div> */}
</div>
);
})}
</div>
<div className={style.pagination}>
<MyPagination page={page} pageChange={pageChange} count={count} />
</div>
</div>
</div> </div>
SeeDataset {/* <div className={style.foot}>
<ButtonComponent
variant="outlined"
text="下载"
style={{ marginRight: "12px" }}
></ButtonComponent>
<ButtonComponent text="另存为"></ButtonComponent>
</div> */}
</FullScreenDrawer> </FullScreenDrawer>
); );
}; };
......
...@@ -41,6 +41,7 @@ interface IProps ...@@ -41,6 +41,7 @@ interface IProps
multiple?: boolean; // 多选 multiple?: boolean; // 多选
error?: boolean; error?: boolean;
helpertext?: string; helpertext?: string;
fullWidth?: boolean;
} }
export default function MySelect(props: IProps) { export default function MySelect(props: IProps) {
const { const {
...@@ -54,10 +55,11 @@ export default function MySelect(props: IProps) { ...@@ -54,10 +55,11 @@ export default function MySelect(props: IProps) {
multiple = false, multiple = false,
error = false, error = false,
helpertext, helpertext,
fullWidth = true,
} = props; } = props;
return ( return (
<FormControl fullWidth variant={variant} error={error}> <FormControl fullWidth={fullWidth} variant={variant} error={error}>
{isTitle ? ( {isTitle ? (
<InputLabel id="demo-simple-select-label"> <InputLabel id="demo-simple-select-label">
{title || "请选择"} {title || "请选择"}
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
border-radius: 16px 0 0 0; border-radius: 16px 0 0 0;
padding: 24px 32px; padding: 24px 32px;
box-sizing: border-box; box-sizing: border-box;
overflow: scroll; overflow: auto;
} }
.templateList { .templateList {
/* height: 2000px; */ /* height: 2000px; */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment