trithuc-mvc-react 1.5.1 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Table, TableBody, TableCell, TableContainer, TableRow } from "@mui/material";
|
|
1
|
+
import { Table, TableBody, TableCell, TableContainer, TableRow, useMediaQuery, useTheme } from "@mui/material";
|
|
2
2
|
import TablePaginationCustom from "../table/TablePagination";
|
|
3
3
|
import { useMemo, useState } from "react";
|
|
4
4
|
|
|
@@ -142,6 +142,9 @@ const DataTable = () => {
|
|
|
142
142
|
})
|
|
143
143
|
.catch(() => {});
|
|
144
144
|
};
|
|
145
|
+
const theme = useTheme();
|
|
146
|
+
const downXL = useMediaQuery(theme.breakpoints.down("xl"));
|
|
147
|
+
console.log("downXL", downXL);
|
|
145
148
|
return (
|
|
146
149
|
<>
|
|
147
150
|
<TableContainer sx={{ position: "relative" }}>
|
|
@@ -151,8 +154,13 @@ const DataTable = () => {
|
|
|
151
154
|
rowCount={rows.length}
|
|
152
155
|
onDeleteMultiple={handleDeleteMultiple}
|
|
153
156
|
/>
|
|
154
|
-
<Table className="border">
|
|
155
|
-
<TableHead
|
|
157
|
+
<Table className="border" size={downXL ? "small" : "medium"}>
|
|
158
|
+
<TableHead
|
|
159
|
+
headLabel={columns}
|
|
160
|
+
onSelectAllClick={handleSelectAllClick}
|
|
161
|
+
numSelected={selected?.length}
|
|
162
|
+
rowCount={rows.length}
|
|
163
|
+
/>
|
|
156
164
|
{isLoading ? (
|
|
157
165
|
<TableRowsLoader rowsNum={5} colsNum={columns.length + 4} />
|
|
158
166
|
) : (
|
|
@@ -169,10 +177,12 @@ const DataTable = () => {
|
|
|
169
177
|
onDelete={handleDelete}
|
|
170
178
|
/>
|
|
171
179
|
))}
|
|
172
|
-
|
|
180
|
+
|
|
173
181
|
{rows?.length == 0 && (
|
|
174
182
|
<TableRow>
|
|
175
|
-
<TableCell colSpan={columns.length + 4} align="center">
|
|
183
|
+
<TableCell colSpan={columns.length + 4} align="center">
|
|
184
|
+
Không có dữ liệu
|
|
185
|
+
</TableCell>
|
|
176
186
|
</TableRow>
|
|
177
187
|
)}
|
|
178
188
|
</TableBody>
|
|
@@ -13,14 +13,18 @@ export function TableHead({ numSelected, rowCount, onSelectAllClick, headLabel }
|
|
|
13
13
|
onChange={onSelectAllClick}
|
|
14
14
|
/>
|
|
15
15
|
</TableCell>
|
|
16
|
-
<TableCell sx={{
|
|
16
|
+
<TableCell sx={{ textAlign: "center" }}>STT</TableCell>
|
|
17
17
|
{headLabel.map((headCell) => (
|
|
18
|
-
<TableCell
|
|
18
|
+
<TableCell
|
|
19
|
+
key={headCell.field}
|
|
20
|
+
align={headCell.alignRight ? "right" : "left"}
|
|
21
|
+
sx={{ textAlign: "center" }}
|
|
22
|
+
>
|
|
19
23
|
{headCell.label}
|
|
20
24
|
</TableCell>
|
|
21
25
|
))}
|
|
22
|
-
{!disableStatus && canEdit && <TableCell>Kích hoạt</TableCell>}
|
|
23
|
-
<TableCell sx={{minWidth:
|
|
26
|
+
{!disableStatus && canEdit && <TableCell sx={{ textAlign: "center"} }>Kích hoạt</TableCell>}
|
|
27
|
+
<TableCell sx={{ minWidth: "136px", textAlign: "center" }} >Thao tác</TableCell>
|
|
24
28
|
</TableRow>
|
|
25
29
|
</MuiTableHead>
|
|
26
30
|
);
|
|
@@ -32,19 +32,20 @@ export const TableRowRender = ({ index, row, selected, onSelect, onChangeStatus,
|
|
|
32
32
|
<TableCell padding="checkbox">
|
|
33
33
|
<Checkbox checked={selected} onChange={(event) => onSelect(event, row[selectedField])} />
|
|
34
34
|
</TableCell>
|
|
35
|
-
<TableCell>{index + 1}</TableCell>
|
|
35
|
+
<TableCell align="center">{index + 1}</TableCell>
|
|
36
36
|
{columns.map(
|
|
37
37
|
({
|
|
38
38
|
field,
|
|
39
|
-
|
|
39
|
+
type="text",
|
|
40
40
|
valueGetter = (row) => {
|
|
41
41
|
return row[field];
|
|
42
42
|
},
|
|
43
43
|
renderCell,
|
|
44
44
|
valueFormat = (e) => e
|
|
45
45
|
}) => {
|
|
46
|
+
let align = ( type=="image" || type == "number" || type =="date"|| type == "datetime") ? "right" : "left";
|
|
46
47
|
return (
|
|
47
|
-
<TableCell key={`${row[selectedField]}-${field}`} align={
|
|
48
|
+
<TableCell key={`${row[selectedField]}-${field}`} align={align}>
|
|
48
49
|
{renderCell ? renderCell(row) : valueFormat(valueGetter(row))}
|
|
49
50
|
</TableCell>
|
|
50
51
|
);
|
|
@@ -40,7 +40,6 @@ DataManagement.propTypes = {
|
|
|
40
40
|
tabPanel: PropTypes.node
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
|
|
44
43
|
function DataManagement({
|
|
45
44
|
columns = [],
|
|
46
45
|
title,
|
|
@@ -58,9 +57,7 @@ function DataManagement({
|
|
|
58
57
|
tabPanel,
|
|
59
58
|
slotProps = {
|
|
60
59
|
header: {
|
|
61
|
-
sx: {
|
|
62
|
-
|
|
63
|
-
}
|
|
60
|
+
sx: {}
|
|
64
61
|
}
|
|
65
62
|
}
|
|
66
63
|
}) {
|
|
@@ -128,7 +125,7 @@ function DataManagement({
|
|
|
128
125
|
<DataTableContext.Provider value={values}>
|
|
129
126
|
<PermissionContext.Provider value={permissionValues}>
|
|
130
127
|
<FormProvider {...methods}>
|
|
131
|
-
<Stack direction="row" justifyContent={"space-between"} sx={{ mb:
|
|
128
|
+
<Stack direction="row" justifyContent={"space-between"} sx={{ mb: upXL ? 2 : 1, ...slotProps?.header?.sx }}>
|
|
132
129
|
<Typography variant="h4">{title}</Typography>
|
|
133
130
|
<Stack direction="row" spacing={1}>
|
|
134
131
|
<Tooltip title="Làm mới">
|