trithuc-mvc-react 3.0.0 → 3.0.1
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.
- package/components/DataManagement/DataTableSM.jsx +1 -1
- package/components/DataManagement/ExportExcelButton.jsx +12 -13
- package/components/DataManagement/FilterGod.jsx +1 -1
- package/components/DataManagement/TableRowRenderSM.jsx +105 -113
- package/components/DataManagement/index.jsx +57 -54
- package/package.json +1 -1
|
@@ -246,7 +246,7 @@ const DataTableSM = ({ multipleActions = [], page, setPage = () => {}, disableEd
|
|
|
246
246
|
multipleActions={multipleActions}
|
|
247
247
|
/>
|
|
248
248
|
|
|
249
|
-
<Table
|
|
249
|
+
<Table size={downXL ? "small" : "medium"}>
|
|
250
250
|
{/* <TableHead
|
|
251
251
|
headLabel={columns}
|
|
252
252
|
onSelectAllClick={handleSelectAllClick}
|
|
@@ -27,23 +27,22 @@ const ExportExcelButton = ({ tableName, data, size = "small" }) => {
|
|
|
27
27
|
onClick={() => {
|
|
28
28
|
handleExportExcel(tableName, data);
|
|
29
29
|
}}
|
|
30
|
+
sx={{ ml: 0.5, mr: 0.5 }}
|
|
30
31
|
>
|
|
31
32
|
Excel
|
|
32
33
|
</Button>
|
|
33
34
|
) : (
|
|
34
|
-
<
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
</IconButton>
|
|
46
|
-
</Tooltip>
|
|
35
|
+
<Button
|
|
36
|
+
size={size}
|
|
37
|
+
variant="outlined"
|
|
38
|
+
startIcon={<Download />}
|
|
39
|
+
onClick={() => {
|
|
40
|
+
handleExportExcel(tableName, data);
|
|
41
|
+
}}
|
|
42
|
+
sx={{ ml: 0.5, mr: 0.5 }}
|
|
43
|
+
>
|
|
44
|
+
Excel
|
|
45
|
+
</Button>
|
|
47
46
|
);
|
|
48
47
|
};
|
|
49
48
|
export default ExportExcelButton;
|
|
@@ -16,7 +16,7 @@ export const FilterGod = ({ tableName, filters, elementSize = "small", setPage =
|
|
|
16
16
|
const { setDataSearch, dataSearch } = useDataTable();
|
|
17
17
|
// Lấy trạng thái từ localStorage hoặc mặc định là true
|
|
18
18
|
const [isFilterVisible, setFilterVisible] = useState(
|
|
19
|
-
() => JSON.parse(localStorage.getItem(`${tableName}-isFilterVisible`)) ??
|
|
19
|
+
() => JSON.parse(localStorage.getItem(`${tableName}-isFilterVisible`)) ?? false
|
|
20
20
|
);
|
|
21
21
|
|
|
22
22
|
// Lưu trạng thái vào localStorage mỗi khi thay đổi
|
|
@@ -47,8 +47,8 @@ export const TableRowRenderSM = ({
|
|
|
47
47
|
const downXl = useMediaQuery(theme.breakpoints.down("xl"));
|
|
48
48
|
|
|
49
49
|
return (
|
|
50
|
-
<TableRow hover key={row[selectedField]} selected={selected}>
|
|
51
|
-
<TableCell colSpan={columns.length} align="left">
|
|
50
|
+
<TableRow hover key={row[selectedField]} selected={selected} sx={{ width: "100%" }}>
|
|
51
|
+
<TableCell colSpan={columns.length} align="left" sx={{ width: "100%" }}>
|
|
52
52
|
{columns.map(({ field, label, type = "text", valueGetter = (row) => row[field], renderCell, valueFormat = (e) => e }) => {
|
|
53
53
|
const value = renderCell ? renderCell(row) : valueFormat(valueGetter(row));
|
|
54
54
|
return (
|
|
@@ -67,117 +67,109 @@ export const TableRowRenderSM = ({
|
|
|
67
67
|
inputProps={{ "aria-label": "controlled" }}
|
|
68
68
|
/>
|
|
69
69
|
)}
|
|
70
|
-
<Grid
|
|
71
|
-
{
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
<
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
</Button>
|
|
174
|
-
</Tooltip>
|
|
175
|
-
))}
|
|
176
|
-
<MoreMenu actions={tableActionsOnMoreMenu} data={row} />
|
|
177
|
-
</Box>
|
|
178
|
-
</Box>
|
|
179
|
-
</Box>
|
|
180
|
-
)}
|
|
70
|
+
<Grid container spacing={{ xs: 2, xl: 2 }} sx={{ width: "100%", pt: 2, pb: 2 }}>
|
|
71
|
+
<Grid item xs={12} sx={{ display: "flex", justifyContent: "flex-end", alignItems: "center", width: "100%" }}>
|
|
72
|
+
{!disableCellThaoTac && (
|
|
73
|
+
<>
|
|
74
|
+
{!disableEdit && canEdit && (
|
|
75
|
+
<Button
|
|
76
|
+
size="small"
|
|
77
|
+
variant="outlined"
|
|
78
|
+
color="primary"
|
|
79
|
+
onClick={() => onEdit(row)}
|
|
80
|
+
startIcon={<EditOutlined fontSize="inherit" />}
|
|
81
|
+
sx={{
|
|
82
|
+
marginLeft: 0.5,
|
|
83
|
+
marginRight: 0.5,
|
|
84
|
+
borderRadius: 14,
|
|
85
|
+
minWidth: 60,
|
|
86
|
+
padding: "2px 8px",
|
|
87
|
+
height: "20px",
|
|
88
|
+
fontSize: "0.6rem",
|
|
89
|
+
whiteSpace: "nowrap",
|
|
90
|
+
overflow: "hidden",
|
|
91
|
+
textOverflow: "ellipsis"
|
|
92
|
+
}}
|
|
93
|
+
>
|
|
94
|
+
Sửa
|
|
95
|
+
</Button>
|
|
96
|
+
)}
|
|
97
|
+
{canView && !tableActions?.some(({ permissionType }) => permissionType === "view") && (
|
|
98
|
+
<Button
|
|
99
|
+
size="small"
|
|
100
|
+
variant="outlined"
|
|
101
|
+
color="info"
|
|
102
|
+
onClick={() => onView(row)}
|
|
103
|
+
startIcon={<RemoveRedEyeOutlinedIcon />}
|
|
104
|
+
sx={{
|
|
105
|
+
marginLeft: 0.5,
|
|
106
|
+
marginRight: 0.5,
|
|
107
|
+
borderRadius: 14,
|
|
108
|
+
minWidth: 60,
|
|
109
|
+
padding: "2px 8px",
|
|
110
|
+
height: "20px",
|
|
111
|
+
fontSize: "0.6rem",
|
|
112
|
+
whiteSpace: "nowrap",
|
|
113
|
+
overflow: "hidden",
|
|
114
|
+
textOverflow: "ellipsis"
|
|
115
|
+
}}
|
|
116
|
+
>
|
|
117
|
+
Xem
|
|
118
|
+
</Button>
|
|
119
|
+
)}
|
|
120
|
+
{!disableDelete && canDelete && (
|
|
121
|
+
<Button
|
|
122
|
+
size="small"
|
|
123
|
+
variant="outlined"
|
|
124
|
+
color="error"
|
|
125
|
+
onClick={() => {
|
|
126
|
+
onDelete(row[selectedField]);
|
|
127
|
+
}}
|
|
128
|
+
startIcon={<DeleteOutlineIcon fontSize="inherit" />}
|
|
129
|
+
sx={{
|
|
130
|
+
marginLeft: 0.5,
|
|
131
|
+
marginRight: 0.5,
|
|
132
|
+
borderRadius: 14,
|
|
133
|
+
minWidth: 60,
|
|
134
|
+
padding: "2px 8px",
|
|
135
|
+
height: "20px",
|
|
136
|
+
fontSize: "0.6rem",
|
|
137
|
+
whiteSpace: "nowrap",
|
|
138
|
+
overflow: "hidden",
|
|
139
|
+
textOverflow: "ellipsis"
|
|
140
|
+
}}
|
|
141
|
+
>
|
|
142
|
+
Xóa
|
|
143
|
+
</Button>
|
|
144
|
+
)}
|
|
145
|
+
{tableActionsOnTable.map(({ title, onClick, element }) => (
|
|
146
|
+
<Button
|
|
147
|
+
size="small"
|
|
148
|
+
variant="outlined"
|
|
149
|
+
onClick={() => {
|
|
150
|
+
onClick(row);
|
|
151
|
+
}}
|
|
152
|
+
startIcon={element}
|
|
153
|
+
sx={{
|
|
154
|
+
marginLeft: 0.5,
|
|
155
|
+
marginRight: 0.5,
|
|
156
|
+
borderRadius: 14,
|
|
157
|
+
minWidth: 60,
|
|
158
|
+
padding: "2px 8px",
|
|
159
|
+
height: "20px",
|
|
160
|
+
fontSize: "0.6rem",
|
|
161
|
+
whiteSpace: "nowrap",
|
|
162
|
+
overflow: "hidden",
|
|
163
|
+
textOverflow: "ellipsis"
|
|
164
|
+
}}
|
|
165
|
+
>
|
|
166
|
+
{title.toLowerCase() === "xem chi tiết" ? "Xem" : title}
|
|
167
|
+
</Button>
|
|
168
|
+
))}
|
|
169
|
+
<MoreMenu actions={tableActionsOnMoreMenu} data={row} />
|
|
170
|
+
</>
|
|
171
|
+
)}
|
|
172
|
+
</Grid>
|
|
181
173
|
</Grid>
|
|
182
174
|
</TableCell>
|
|
183
175
|
</TableRow>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Button, Card, IconButton, Stack, Tooltip, Typography, useMediaQuery, useTheme } from "@mui/material";
|
|
1
|
+
import { Button, Card, Grid, IconButton, Stack, Tooltip, Typography, useMediaQuery, useTheme } from "@mui/material";
|
|
2
2
|
|
|
3
3
|
import { useEffect, useMemo, useState } from "react";
|
|
4
4
|
|
|
@@ -189,57 +189,44 @@ function DataManagement({
|
|
|
189
189
|
<DataTableContext.Provider value={values}>
|
|
190
190
|
<FormProvider {...methods}>
|
|
191
191
|
<Stack direction="row" justifyContent={"space-between"} sx={{ mb: upXL ? 2 : 1, ...slotProps?.header?.sx }}>
|
|
192
|
-
<
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
[...filters].forEach((filter) => {
|
|
203
|
-
filter?.onChange?.();
|
|
204
|
-
});
|
|
205
|
-
reset();
|
|
206
|
-
setValue("Search");
|
|
207
|
-
}}
|
|
208
|
-
>
|
|
209
|
-
<Refresh fontSize="inherit" />
|
|
210
|
-
</IconButton>
|
|
211
|
-
</Tooltip>
|
|
212
|
-
|
|
213
|
-
{titleButtons?.map((button, index) => (
|
|
214
|
-
<div key={index}>
|
|
215
|
-
{button}
|
|
216
|
-
{/* Các phần tử khác có thể được thêm ở đây nếu cần */}
|
|
217
|
-
</div>
|
|
218
|
-
))}
|
|
219
|
-
<ExportExcelButton tableName={tableName} data={dataSearch} size={elementSize} />
|
|
220
|
-
{canCreate &&
|
|
221
|
-
!disableAdd &&
|
|
222
|
-
(!isSmallScreen ? (
|
|
223
|
-
<Button
|
|
192
|
+
<Grid container spacing={{ xs: 1, xl: 1 }}>
|
|
193
|
+
<Grid item md={9} xs={12}>
|
|
194
|
+
<Typography variant="h4">{title}</Typography>
|
|
195
|
+
</Grid>
|
|
196
|
+
<Grid item md={3} xs={12} sx={{ display: "flex", justifyContent: "flex-end", alignItems: "center" }}>
|
|
197
|
+
<HuongDanButton tableName={tableName} size={elementSize} />
|
|
198
|
+
<Tooltip title="Làm mới">
|
|
199
|
+
<IconButton
|
|
200
|
+
variant="outlined"
|
|
201
|
+
color="primary"
|
|
224
202
|
size={elementSize}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
onAddClick(e);
|
|
203
|
+
onClick={() => {
|
|
204
|
+
setDataSearch({ ...defaults });
|
|
205
|
+
[...filters].forEach((filter) => {
|
|
206
|
+
filter?.onChange?.();
|
|
207
|
+
});
|
|
208
|
+
reset();
|
|
209
|
+
setValue("Search");
|
|
233
210
|
}}
|
|
234
211
|
>
|
|
235
|
-
|
|
236
|
-
</
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
212
|
+
<Refresh fontSize="inherit" />
|
|
213
|
+
</IconButton>
|
|
214
|
+
</Tooltip>
|
|
215
|
+
|
|
216
|
+
{titleButtons?.map((button, index) => (
|
|
217
|
+
<div key={index}>
|
|
218
|
+
{button}
|
|
219
|
+
{/* Các phần tử khác có thể được thêm ở đây nếu cần */}
|
|
220
|
+
</div>
|
|
221
|
+
))}
|
|
222
|
+
<ExportExcelButton tableName={tableName} data={dataSearch} size={elementSize} />
|
|
223
|
+
{canCreate &&
|
|
224
|
+
!disableAdd &&
|
|
225
|
+
(!isSmallScreen ? (
|
|
226
|
+
<Button
|
|
242
227
|
size={elementSize}
|
|
228
|
+
variant="contained"
|
|
229
|
+
startIcon={<Add fontSize="inherit" />}
|
|
243
230
|
onClick={(e) => {
|
|
244
231
|
if (!disableEditor) {
|
|
245
232
|
setOpenEditorDialog(true);
|
|
@@ -247,13 +234,29 @@ function DataManagement({
|
|
|
247
234
|
}
|
|
248
235
|
onAddClick(e);
|
|
249
236
|
}}
|
|
250
|
-
sx={{
|
|
237
|
+
sx={{ ml: 0.5, mr: 0.5 }}
|
|
251
238
|
>
|
|
252
|
-
|
|
253
|
-
</
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
239
|
+
Thêm
|
|
240
|
+
</Button>
|
|
241
|
+
) : (
|
|
242
|
+
<Button
|
|
243
|
+
size={elementSize}
|
|
244
|
+
variant="contained"
|
|
245
|
+
startIcon={<Add fontSize="inherit" />}
|
|
246
|
+
onClick={(e) => {
|
|
247
|
+
if (!disableEditor) {
|
|
248
|
+
setOpenEditorDialog(true);
|
|
249
|
+
setSelectedEditItem(null);
|
|
250
|
+
}
|
|
251
|
+
onAddClick(e);
|
|
252
|
+
}}
|
|
253
|
+
sx={{ ml: 0.5, mr: 0.5 }}
|
|
254
|
+
>
|
|
255
|
+
Thêm
|
|
256
|
+
</Button>
|
|
257
|
+
))}
|
|
258
|
+
</Grid>
|
|
259
|
+
</Grid>
|
|
257
260
|
</Stack>
|
|
258
261
|
|
|
259
262
|
<Card>
|