trithuc-mvc-react 3.1.7 → 3.1.9
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.
|
@@ -79,12 +79,13 @@ export const TableRowRenderSM = ({
|
|
|
79
79
|
)}
|
|
80
80
|
|
|
81
81
|
{/* Các nút thao tác */}
|
|
82
|
-
<Grid container spacing={
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
{
|
|
82
|
+
<Grid container spacing={0.5} sx={{ width: "100%", pt: 2, pb: 2 }}>
|
|
83
|
+
{!disableCellThaoTac && (
|
|
84
|
+
<>
|
|
85
|
+
{!disableEdit && canEdit && (
|
|
86
|
+
<Grid size={4}>
|
|
87
87
|
<Button
|
|
88
|
+
fullWidth
|
|
88
89
|
size="small"
|
|
89
90
|
variant="outlined"
|
|
90
91
|
color="primary"
|
|
@@ -94,9 +95,12 @@ export const TableRowRenderSM = ({
|
|
|
94
95
|
>
|
|
95
96
|
Sửa
|
|
96
97
|
</Button>
|
|
97
|
-
|
|
98
|
-
|
|
98
|
+
</Grid>
|
|
99
|
+
)}
|
|
100
|
+
{canView && !tableActions?.some(({ permissionType }) => permissionType === "view") && (
|
|
101
|
+
<Grid size={4}>
|
|
99
102
|
<Button
|
|
103
|
+
fullWidth
|
|
100
104
|
size="small"
|
|
101
105
|
variant="outlined"
|
|
102
106
|
color="info"
|
|
@@ -106,9 +110,12 @@ export const TableRowRenderSM = ({
|
|
|
106
110
|
>
|
|
107
111
|
Xem
|
|
108
112
|
</Button>
|
|
109
|
-
|
|
110
|
-
|
|
113
|
+
</Grid>
|
|
114
|
+
)}
|
|
115
|
+
{!disableDelete && canDelete && (
|
|
116
|
+
<Grid size={4}>
|
|
111
117
|
<Button
|
|
118
|
+
fullWidth
|
|
112
119
|
size="small"
|
|
113
120
|
variant="outlined"
|
|
114
121
|
color="error"
|
|
@@ -118,11 +125,14 @@ export const TableRowRenderSM = ({
|
|
|
118
125
|
>
|
|
119
126
|
Xóa
|
|
120
127
|
</Button>
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
128
|
+
</Grid>
|
|
129
|
+
)}
|
|
130
|
+
{tableActionsOnTable.map(
|
|
131
|
+
({ title, size, onClick, element, visible = true }, idx) =>
|
|
132
|
+
(typeof visible === "function" ? visible(row) : visible) && (
|
|
133
|
+
<Grid size={4}>
|
|
125
134
|
<Button
|
|
135
|
+
fullWidth
|
|
126
136
|
key={idx}
|
|
127
137
|
size="small"
|
|
128
138
|
variant="outlined"
|
|
@@ -134,12 +144,12 @@ export const TableRowRenderSM = ({
|
|
|
134
144
|
>
|
|
135
145
|
{title === "xem chi tiết" ? "Xem" : title}
|
|
136
146
|
</Button>
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
147
|
+
</Grid>
|
|
148
|
+
)
|
|
149
|
+
)}
|
|
150
|
+
<MoreMenu actions={tableActionsOnMoreMenu} data={row} />
|
|
151
|
+
</>
|
|
152
|
+
)}
|
|
143
153
|
</Grid>
|
|
144
154
|
</TableCell>
|
|
145
155
|
</TableRow>
|
|
@@ -148,13 +158,13 @@ export const TableRowRenderSM = ({
|
|
|
148
158
|
|
|
149
159
|
// Button style dùng chung
|
|
150
160
|
const buttonStyle = {
|
|
151
|
-
marginLeft: 0.3,
|
|
152
|
-
marginRight: 0.3,
|
|
153
|
-
marginBottom:
|
|
154
|
-
borderRadius:
|
|
161
|
+
// marginLeft: 0.3,
|
|
162
|
+
// marginRight: 0.3,
|
|
163
|
+
marginBottom: "10px",
|
|
164
|
+
borderRadius: "10px",
|
|
155
165
|
minWidth: 50,
|
|
156
|
-
padding: "
|
|
157
|
-
height: "
|
|
166
|
+
padding: "4px 8px",
|
|
167
|
+
height: "23px",
|
|
158
168
|
fontSize: "0.6rem",
|
|
159
169
|
whiteSpace: "nowrap",
|
|
160
170
|
overflow: "hidden",
|
|
@@ -3,6 +3,9 @@ import { Box, Button, Card, Grid, IconButton, Stack, Tooltip, Typography, useMed
|
|
|
3
3
|
import { useEffect, useMemo, useState } from "react";
|
|
4
4
|
|
|
5
5
|
import { Add, Refresh } from "@mui/icons-material";
|
|
6
|
+
import BarChartIcon from "@mui/icons-material/BarChart";
|
|
7
|
+
import PieChartIcon from "@mui/icons-material/PieChart";
|
|
8
|
+
import TableChartIcon from "@mui/icons-material/TableChart";
|
|
6
9
|
import PropTypes from "prop-types";
|
|
7
10
|
import { DataTableContext } from "./context";
|
|
8
11
|
import DataTable from "./DataTable";
|
|
@@ -60,7 +63,9 @@ DataManagement.propTypes = {
|
|
|
60
63
|
onAddClick: PropTypes.func,
|
|
61
64
|
onEditClick: PropTypes.func,
|
|
62
65
|
tabPanel: PropTypes.node,
|
|
63
|
-
titleAddButton: PropTypes.string
|
|
66
|
+
titleAddButton: PropTypes.string,
|
|
67
|
+
thongKe: PropTypes.object,
|
|
68
|
+
bieuDo: PropTypes.object
|
|
64
69
|
};
|
|
65
70
|
const getDefaultValues = (filters = []) => {
|
|
66
71
|
const defaultValues = {};
|
|
@@ -101,13 +106,18 @@ function DataManagement({
|
|
|
101
106
|
}
|
|
102
107
|
},
|
|
103
108
|
defaultRowsPerPage = 5,
|
|
104
|
-
titleAddButton = "Thêm"
|
|
109
|
+
titleAddButton = "Thêm",
|
|
110
|
+
thongKe,
|
|
111
|
+
bieuDo
|
|
105
112
|
}) {
|
|
106
113
|
const [openEditorDialog, setOpenEditorDialog] = useState(false);
|
|
107
114
|
const [selectedEditItem, setSelectedEditItem] = useState(null);
|
|
108
115
|
const [openViewDialog, setOpenViewDialog] = useState(false);
|
|
109
116
|
|
|
110
|
-
const { canCreate } = usePermission(apiUrl ? apiUrl : tableName);
|
|
117
|
+
const { canCreate, canThongKe, canBieuDo } = usePermission(apiUrl ? apiUrl : tableName);
|
|
118
|
+
|
|
119
|
+
const [viewMode, setViewMode] = useState("table"); // "table" | "thongke" | "bieudo"
|
|
120
|
+
|
|
111
121
|
const { defaults, filters } = useMemo(() => {
|
|
112
122
|
const filters = tableFilters.filter(({ type }) => type !== "default");
|
|
113
123
|
const defaultFilters = tableFilters.filter(({ type }) => type === "default");
|
|
@@ -165,7 +175,9 @@ function DataManagement({
|
|
|
165
175
|
hasTabpanel,
|
|
166
176
|
backParentNavigator,
|
|
167
177
|
defaultRowsPerPage,
|
|
168
|
-
titleAddButton
|
|
178
|
+
titleAddButton,
|
|
179
|
+
thongKe,
|
|
180
|
+
bieuDo
|
|
169
181
|
};
|
|
170
182
|
}, [
|
|
171
183
|
reserPage,
|
|
@@ -184,7 +196,9 @@ function DataManagement({
|
|
|
184
196
|
setOpenViewDialog,
|
|
185
197
|
onEditClick,
|
|
186
198
|
backParentNavigator,
|
|
187
|
-
defaultRowsPerPage
|
|
199
|
+
defaultRowsPerPage,
|
|
200
|
+
thongKe,
|
|
201
|
+
bieuDo
|
|
188
202
|
]);
|
|
189
203
|
const isSmallScreen = useMediaQuery(theme.breakpoints.down("sm")); // Xác định màn hình nhỏ
|
|
190
204
|
const methods = useForm({ defaultValues: getDefaultValues(filters) });
|
|
@@ -319,6 +333,40 @@ function DataManagement({
|
|
|
319
333
|
width: rightBoxMinWidth ? `${rightBoxMinWidth}px` : "auto" // Sử dụng chiều rộng đo được
|
|
320
334
|
}}
|
|
321
335
|
>
|
|
336
|
+
{(viewMode === "thongke" || viewMode === "bieudo") && (
|
|
337
|
+
<Tooltip title="Danh sách dữ liệu">
|
|
338
|
+
<IconButton size={elementSize} color="primary" onClick={() => setViewMode("table")} sx={{ ml: 0.5, mr: 0.5 }}>
|
|
339
|
+
<TableChartIcon fontSize="inherit" />
|
|
340
|
+
</IconButton>
|
|
341
|
+
</Tooltip>
|
|
342
|
+
)}
|
|
343
|
+
|
|
344
|
+
{canThongKe && (
|
|
345
|
+
<Tooltip title="Thống kê">
|
|
346
|
+
<IconButton
|
|
347
|
+
size={elementSize}
|
|
348
|
+
color={viewMode === "thongke" ? "secondary" : "primary"}
|
|
349
|
+
onClick={() => setViewMode("thongke")}
|
|
350
|
+
sx={{ ml: 0.5, mr: 0.5 }}
|
|
351
|
+
>
|
|
352
|
+
<BarChartIcon fontSize="inherit" />
|
|
353
|
+
</IconButton>
|
|
354
|
+
</Tooltip>
|
|
355
|
+
)}
|
|
356
|
+
|
|
357
|
+
{canBieuDo && (
|
|
358
|
+
<Tooltip title="Biểu đồ">
|
|
359
|
+
<IconButton
|
|
360
|
+
size={elementSize}
|
|
361
|
+
color={viewMode === "bieudo" ? "secondary" : "primary"}
|
|
362
|
+
onClick={() => setViewMode("bieudo")}
|
|
363
|
+
sx={{ ml: 0.5, mr: 0.5 }}
|
|
364
|
+
>
|
|
365
|
+
<PieChartIcon fontSize="inherit" />
|
|
366
|
+
</IconButton>
|
|
367
|
+
</Tooltip>
|
|
368
|
+
)}
|
|
369
|
+
|
|
322
370
|
<HuongDanButton tableName={tableName} size={elementSize} />
|
|
323
371
|
<Tooltip title="Làm mới">
|
|
324
372
|
<IconButton
|
|
@@ -370,25 +418,32 @@ function DataManagement({
|
|
|
370
418
|
|
|
371
419
|
<Card className="custom-card-DataManagement">
|
|
372
420
|
{tabPanel}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
421
|
+
{viewMode === "table" && (
|
|
422
|
+
<>
|
|
423
|
+
<FilterGod tableName={tableName} filters={filters} elementSize={elementSize} setPage={setPage} />
|
|
424
|
+
{backParentNavigator}
|
|
425
|
+
{!isSmallScreen ? (
|
|
426
|
+
<DataTable
|
|
427
|
+
multipleActions={multipleActions}
|
|
428
|
+
page={page}
|
|
429
|
+
setPage={setPage}
|
|
430
|
+
disableEdit={disableEdit}
|
|
431
|
+
disableDelete={disableDelete}
|
|
432
|
+
/>
|
|
433
|
+
) : (
|
|
434
|
+
<DataTableSM
|
|
435
|
+
multipleActions={multipleActions}
|
|
436
|
+
page={page}
|
|
437
|
+
setPage={setPage}
|
|
438
|
+
disableEdit={disableEdit}
|
|
439
|
+
disableDelete={disableDelete}
|
|
440
|
+
/>
|
|
441
|
+
)}
|
|
442
|
+
</>
|
|
391
443
|
)}
|
|
444
|
+
{viewMode === "thongke" && thongKe}
|
|
445
|
+
|
|
446
|
+
{viewMode === "bieudo" && bieuDo}
|
|
392
447
|
</Card>
|
|
393
448
|
</FormProvider>
|
|
394
449
|
|
package/hooks/usePermission.js
CHANGED
|
@@ -11,7 +11,20 @@ const usePermission = (tableName) => {
|
|
|
11
11
|
}
|
|
12
12
|
const { permissionMap, setPermission } = context;
|
|
13
13
|
const permission = permissionMap[tableName];
|
|
14
|
-
const {
|
|
14
|
+
const {
|
|
15
|
+
canEdit,
|
|
16
|
+
canDelete,
|
|
17
|
+
canDeleteMulti,
|
|
18
|
+
canSave,
|
|
19
|
+
canCreate,
|
|
20
|
+
canAction,
|
|
21
|
+
canView,
|
|
22
|
+
canImport,
|
|
23
|
+
canExportWord,
|
|
24
|
+
canPayment,
|
|
25
|
+
canThongKe,
|
|
26
|
+
canBieuDo
|
|
27
|
+
} = useMemo(() => {
|
|
15
28
|
if (permission) {
|
|
16
29
|
if (permission.TrangThaiXuLy !== undefined && permission.ObjTrangThai) {
|
|
17
30
|
const status = permission.ObjTrangThai.find((t) => t.StatusId === permission.TrangThaiXuLy) || {};
|
|
@@ -24,7 +37,10 @@ const usePermission = (tableName) => {
|
|
|
24
37
|
canAction: status.Action ?? false,
|
|
25
38
|
canView: status.View ?? false,
|
|
26
39
|
canImport: status.ImportFile ?? false,
|
|
27
|
-
canExportWord: status.ExportWord ?? false
|
|
40
|
+
canExportWord: status.ExportWord ?? false,
|
|
41
|
+
canPayment: status.Payment ?? false,
|
|
42
|
+
canThongKe: status.ThongKe ?? false,
|
|
43
|
+
canBieuDo: status.BieuDo ?? false
|
|
28
44
|
};
|
|
29
45
|
} else {
|
|
30
46
|
return {
|
|
@@ -36,7 +52,10 @@ const usePermission = (tableName) => {
|
|
|
36
52
|
canAction: permission.Action ?? false,
|
|
37
53
|
canView: permission.View ?? false,
|
|
38
54
|
canImport: permission.ImportFile ?? false,
|
|
39
|
-
canExportWord: permission.ExportWord ?? false
|
|
55
|
+
canExportWord: permission.ExportWord ?? false,
|
|
56
|
+
canPayment: permission.Payment ?? false,
|
|
57
|
+
canThongKe: permission.ThongKe ?? false,
|
|
58
|
+
canBieuDo: permission.BieuDo ?? false
|
|
40
59
|
};
|
|
41
60
|
}
|
|
42
61
|
} else {
|
|
@@ -50,7 +69,10 @@ const usePermission = (tableName) => {
|
|
|
50
69
|
canAction: false,
|
|
51
70
|
canView: false,
|
|
52
71
|
canImport: false,
|
|
53
|
-
canExportWord: false
|
|
72
|
+
canExportWord: false,
|
|
73
|
+
canPayment: false,
|
|
74
|
+
canThongKe: false,
|
|
75
|
+
canBieuDo: false
|
|
54
76
|
};
|
|
55
77
|
}
|
|
56
78
|
}, [permission]);
|
|
@@ -70,7 +92,10 @@ const usePermission = (tableName) => {
|
|
|
70
92
|
canAction,
|
|
71
93
|
canView,
|
|
72
94
|
canImport,
|
|
73
|
-
canExportWord
|
|
95
|
+
canExportWord,
|
|
96
|
+
canPayment,
|
|
97
|
+
canThongKe,
|
|
98
|
+
canBieuDo
|
|
74
99
|
};
|
|
75
100
|
};
|
|
76
101
|
export default usePermission;
|