FPSMS-frontend
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

248 行
6.3 KiB

  1. import * as React from "react";
  2. import {
  3. Card,
  4. CardHeader,
  5. CardContent,
  6. SxProps,
  7. Theme,
  8. Tabs,
  9. Tab,
  10. Box,
  11. Typography,
  12. Grid,
  13. Link,
  14. } from "@mui/material";
  15. import { DataGrid, GridColDef } from "@mui/x-data-grid";
  16. import { darken, lighten, styled } from "@mui/material/styles";
  17. import { ThemeProvider } from "@emotion/react";
  18. import { TAB_THEME } from "@/theme/colorConst";
  19. import AllProjectGrid from "../UserWorkspacePage/ProjectGrid";
  20. interface AssignedProjectGridProps {
  21. Title?: string;
  22. // rows: any[];
  23. // columns: any[];
  24. columnWidth?: number;
  25. Style?: boolean;
  26. sx?: SxProps<Theme>;
  27. height?: number;
  28. [key: string]: any;
  29. }
  30. interface TabPanelProps {
  31. children?: React.ReactNode;
  32. index: number;
  33. value: number;
  34. }
  35. function CustomTabPanel(props: TabPanelProps) {
  36. const { children, value, index, ...other } = props;
  37. return (
  38. <div
  39. role="tabpanel"
  40. hidden={value !== index}
  41. id={`simple-tabpanel-${index}`}
  42. aria-labelledby={`simple-tab-${index}`}
  43. {...other}
  44. >
  45. {value === index && (
  46. <Box sx={{ p: 3 }}>
  47. <Typography>{children}</Typography>
  48. </Box>
  49. )}
  50. </div>
  51. );
  52. }
  53. function a11yProps(index: number) {
  54. return {
  55. id: `simple-tab-${index}`,
  56. "aria-controls": `simple-tabpanel-${index}`,
  57. };
  58. }
  59. const AssignedProjectGrid: React.FC<AssignedProjectGridProps> = ({
  60. Title,
  61. rows,
  62. columns,
  63. columnWidth,
  64. Style = true,
  65. sx,
  66. height,
  67. ...props
  68. }) => {
  69. // const modifiedColumns = columns.map((column) => {
  70. // return {
  71. // ...column,
  72. // width: columnWidth ?? 150,
  73. // };
  74. // });
  75. // const rowsWithDefaultValues = rows.map((row) => {
  76. // return { ...row };
  77. // });
  78. const getBackgroundColor = (color: string, mode: "light" | "dark") =>
  79. mode === "dark" ? darken(color, 0.7) : lighten(color, 0.7);
  80. const getHoverBackgroundColor = (color: string, mode: "light" | "dark") =>
  81. mode === "dark" ? darken(color, 0.6) : lighten(color, 0.6);
  82. const getSelectedBackgroundColor = (color: string, mode: "light" | "dark") =>
  83. mode === "dark" ? darken(color, 0.5) : lighten(color, 0.5);
  84. const getSelectedHoverBackgroundColor = (
  85. color: string,
  86. mode: "light" | "dark",
  87. ) => (mode === "dark" ? darken(color, 0.4) : lighten(color, 0.4));
  88. const StyledDataGrid = styled(DataGrid)(({ theme }) => ({
  89. "& .super-app-theme--Open": {
  90. backgroundColor: getBackgroundColor(
  91. theme.palette.info.main,
  92. theme.palette.mode,
  93. ),
  94. "&:hover": {
  95. backgroundColor: getHoverBackgroundColor(
  96. theme.palette.info.main,
  97. theme.palette.mode,
  98. ),
  99. },
  100. "&.Mui-selected": {
  101. backgroundColor: getSelectedBackgroundColor(
  102. theme.palette.info.main,
  103. theme.palette.mode,
  104. ),
  105. "&:hover": {
  106. backgroundColor: getSelectedHoverBackgroundColor(
  107. theme.palette.info.main,
  108. theme.palette.mode,
  109. ),
  110. },
  111. },
  112. },
  113. "& .super-app-theme--finish": {
  114. backgroundColor: getBackgroundColor(
  115. theme.palette.success.main,
  116. theme.palette.mode,
  117. ),
  118. "&:hover": {
  119. backgroundColor: getHoverBackgroundColor(
  120. theme.palette.success.main,
  121. theme.palette.mode,
  122. ),
  123. },
  124. "&.Mui-selected": {
  125. backgroundColor: getSelectedBackgroundColor(
  126. theme.palette.success.main,
  127. theme.palette.mode,
  128. ),
  129. "&:hover": {
  130. backgroundColor: getSelectedHoverBackgroundColor(
  131. theme.palette.success.main,
  132. theme.palette.mode,
  133. ),
  134. },
  135. },
  136. },
  137. "& .super-app-theme--danger": {
  138. backgroundColor: getBackgroundColor(
  139. theme.palette.warning.main,
  140. theme.palette.mode,
  141. ),
  142. "&:hover": {
  143. backgroundColor: getHoverBackgroundColor(
  144. theme.palette.warning.main,
  145. theme.palette.mode,
  146. ),
  147. },
  148. "&.Mui-selected": {
  149. backgroundColor: getSelectedBackgroundColor(
  150. theme.palette.warning.main,
  151. theme.palette.mode,
  152. ),
  153. "&:hover": {
  154. backgroundColor: getSelectedHoverBackgroundColor(
  155. theme.palette.warning.main,
  156. theme.palette.mode,
  157. ),
  158. },
  159. },
  160. },
  161. "& .super-app-theme--warning": {
  162. backgroundColor: getBackgroundColor(
  163. theme.palette.error.main,
  164. theme.palette.mode,
  165. ),
  166. "&:hover": {
  167. backgroundColor: getHoverBackgroundColor(
  168. theme.palette.error.main,
  169. theme.palette.mode,
  170. ),
  171. },
  172. "&.Mui-selected": {
  173. backgroundColor: getSelectedBackgroundColor(
  174. theme.palette.error.main,
  175. theme.palette.mode,
  176. ),
  177. "&:hover": {
  178. backgroundColor: getSelectedHoverBackgroundColor(
  179. theme.palette.error.main,
  180. theme.palette.mode,
  181. ),
  182. },
  183. },
  184. },
  185. }));
  186. const [value, setValue] = React.useState(0);
  187. const handleChange = (event: React.SyntheticEvent, newValue: number) => {
  188. setValue(newValue);
  189. };
  190. return (
  191. <div style={{ height: height ?? 400, width: "100%" }}>
  192. <Card style={{ margin: "auto 20px auto 20px" }}>
  193. {Title && <CardHeader title={Title} />}
  194. <CardContent
  195. style={{
  196. padding: "0px 24px 24px 24px",
  197. display: "flex",
  198. alignItems: "center",
  199. }}
  200. >
  201. <div>
  202. <ThemeProvider theme={TAB_THEME}>
  203. <Box sx={{ borderBottom: 4, borderColor: "divider" }}>
  204. <Tabs
  205. value={value}
  206. onChange={handleChange}
  207. aria-label="Manage assigned project"
  208. >
  209. <Tab label="All Projects" {...a11yProps(0)} />
  210. <Tab label="On Track" {...a11yProps(1)} />
  211. <Tab label="Potential Delay" {...a11yProps(2)} />
  212. </Tabs>
  213. </Box>
  214. {/* <CustomTabPanel value={value} index={0}>
  215. Item {value}
  216. </CustomTabPanel>
  217. <CustomTabPanel value={value} index={1}>
  218. Item {value}
  219. </CustomTabPanel>
  220. <CustomTabPanel value={value} index={2}>
  221. Item {value}
  222. </CustomTabPanel> */}
  223. </ThemeProvider>
  224. </div>
  225. </CardContent>
  226. <AllProjectGrid tab={value} />
  227. </Card>
  228. </div>
  229. );
  230. };
  231. export default AssignedProjectGrid;