trithuc-mvc-react 2.4.7 → 2.5.0
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/DataTable.jsx +3 -2
- package/components/DataManagement/FilterElement.jsx +6 -4
- package/components/DataManagement/FilterGod.jsx +6 -4
- package/components/DataManagement/TableRowRender.jsx +4 -3
- package/components/DataManagement/index.jsx +4 -2
- package/components/date/DateRangePicker.jsx +37 -43
- package/package.json +1 -1
|
@@ -13,7 +13,7 @@ import { TableRowRender } from "./TableRowRender";
|
|
|
13
13
|
import TableToolbar from "./TableToolbar";
|
|
14
14
|
import { useDataTable } from "./hooks";
|
|
15
15
|
import { usePermission } from "../../hooks";
|
|
16
|
-
const DataTable = ({ multipleActions = [] }) => {
|
|
16
|
+
const DataTable = ({ multipleActions = [],page, setPage = () => { }, disableEdit }) => {
|
|
17
17
|
const {
|
|
18
18
|
tableName,
|
|
19
19
|
selectedField,
|
|
@@ -31,7 +31,7 @@ const DataTable = ({ multipleActions = [] }) => {
|
|
|
31
31
|
const queryClient = useQueryClient();
|
|
32
32
|
const confirm = useConfirm();
|
|
33
33
|
const [selectedItems, setSelectedItems] = useState([]);
|
|
34
|
-
const [page, setPage] = useState(0);
|
|
34
|
+
// const [page, setPage] = useState(0);
|
|
35
35
|
const [rowsPerPage, setRowsPerPage] = useState(defaultRowsPerPage);
|
|
36
36
|
|
|
37
37
|
const { data, isLoading } = useQuery({
|
|
@@ -209,6 +209,7 @@ const DataTable = ({ multipleActions = [] }) => {
|
|
|
209
209
|
selected={isSelected(row[selectedField])}
|
|
210
210
|
onSelect={handleSelect}
|
|
211
211
|
onEdit={handlEdit}
|
|
212
|
+
disableEdit={disableEdit}
|
|
212
213
|
onView={handlViewDetail}
|
|
213
214
|
onChangeStatus={handleChangeStatus}
|
|
214
215
|
onDelete={handleDelete}
|
|
@@ -14,9 +14,10 @@ export function FilterElement({
|
|
|
14
14
|
childrenFields,
|
|
15
15
|
datas,
|
|
16
16
|
loading = false,
|
|
17
|
-
onChange = () => {},
|
|
17
|
+
onChange = () => { },
|
|
18
18
|
size = "small",
|
|
19
|
-
handleChange = () => {},
|
|
19
|
+
handleChange = () => { },
|
|
20
|
+
setPage = () => { },
|
|
20
21
|
}) {
|
|
21
22
|
const { control, setValue } = useFormContext();
|
|
22
23
|
|
|
@@ -43,6 +44,7 @@ export function FilterElement({
|
|
|
43
44
|
onChange={(e) => {
|
|
44
45
|
onFieldChange(e);
|
|
45
46
|
handleFilterChangeDebounce(name, e.target.value);
|
|
47
|
+
setPage(0);
|
|
46
48
|
}}
|
|
47
49
|
placeholder={label}
|
|
48
50
|
variant="outlined"
|
|
@@ -72,9 +74,8 @@ export function FilterElement({
|
|
|
72
74
|
onChange={(event, newValue, reason) => {
|
|
73
75
|
let updateObject = { [name]: newValue?.[keyValue] };
|
|
74
76
|
onFieldChange(newValue?.[keyValue]);
|
|
75
|
-
|
|
76
77
|
onChange(newValue);
|
|
77
|
-
|
|
78
|
+
setPage(0);
|
|
78
79
|
childrenFields?.forEach((childrenField) => {
|
|
79
80
|
setValue(childrenField, null, { shouldTouch: true });
|
|
80
81
|
updateObject[childrenField] = null;
|
|
@@ -103,6 +104,7 @@ export function FilterElement({
|
|
|
103
104
|
onChange={(e) => {
|
|
104
105
|
handleChange(e);
|
|
105
106
|
onFieldChange(e);
|
|
107
|
+
setPage(0);
|
|
106
108
|
setDataSearch({ ...dataSearch, [name]: e.target.value });
|
|
107
109
|
}}
|
|
108
110
|
>
|
|
@@ -10,7 +10,7 @@ import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
|
|
10
10
|
import { DateRangePicker } from "../date";
|
|
11
11
|
import { ArraySchema } from "yup";
|
|
12
12
|
|
|
13
|
-
export const FilterGod = ({ filters, elementSize = "small" }) => {
|
|
13
|
+
export const FilterGod = ({ filters, elementSize = "small",setPage=()=>{} }) => {
|
|
14
14
|
const { handleSubmit } = useFormContext();
|
|
15
15
|
const onSubmit = (data) => console.log(data);
|
|
16
16
|
const { setDataSearch, dataSearch } = useDataTable();
|
|
@@ -35,7 +35,7 @@ export const FilterGod = ({ filters, elementSize = "small" }) => {
|
|
|
35
35
|
<Grid container spacing={1}>
|
|
36
36
|
{filters.map(({ field, size, ...rest }) => {
|
|
37
37
|
if (rest.type === "date-range") {
|
|
38
|
-
let label = ["
|
|
38
|
+
let label = ["Từ ngày", "Đến ngày"];
|
|
39
39
|
|
|
40
40
|
if (Array.isArray(field.label)) {
|
|
41
41
|
label = field.label;
|
|
@@ -50,7 +50,8 @@ export const FilterGod = ({ filters, elementSize = "small" }) => {
|
|
|
50
50
|
[field[0]]: value[0],
|
|
51
51
|
[field[1]]: value[1]
|
|
52
52
|
});
|
|
53
|
-
|
|
53
|
+
setPage(0)
|
|
54
|
+
}}
|
|
54
55
|
size={elementSize}
|
|
55
56
|
value={[dataSearch?.[field[0]], dataSearch?.[field[1]]]}
|
|
56
57
|
/>
|
|
@@ -68,6 +69,7 @@ export const FilterGod = ({ filters, elementSize = "small" }) => {
|
|
|
68
69
|
[field[0]]: value[0],
|
|
69
70
|
[field[1]]: value[1]
|
|
70
71
|
});
|
|
72
|
+
setPage(0)
|
|
71
73
|
}}
|
|
72
74
|
size={elementSize}
|
|
73
75
|
marks={rest.marks}
|
|
@@ -81,7 +83,7 @@ export const FilterGod = ({ filters, elementSize = "small" }) => {
|
|
|
81
83
|
}
|
|
82
84
|
return (
|
|
83
85
|
<Grid key={field} md={size?.md} xs={size?.xs} sm={size?.sm}>
|
|
84
|
-
<FilterElement name={field} {...rest} />
|
|
86
|
+
<FilterElement name={field} {...rest} setPage={setPage}/>
|
|
85
87
|
</Grid>
|
|
86
88
|
);
|
|
87
89
|
})}
|
|
@@ -21,12 +21,13 @@ export const TableRowRender = ({
|
|
|
21
21
|
onChangeStatus,
|
|
22
22
|
onDelete,
|
|
23
23
|
onEdit,
|
|
24
|
-
onView
|
|
24
|
+
onView,
|
|
25
|
+
disableEdit,
|
|
25
26
|
}) => {
|
|
26
27
|
const { selectedField, columns, statusKey, disableStatus, tableActions, disableCellThaoTac, tableName, sttLuyKe } =
|
|
27
28
|
useDataTable();
|
|
28
29
|
const { canEdit, canDelete, canView, canAction } = usePermission(tableName);
|
|
29
|
-
|
|
30
|
+
|
|
30
31
|
const { tableActionsOnTable, tableActionsOnMoreMenu } = useMemo(() => {
|
|
31
32
|
const tableActionsAfterFilter = [...tableActions]
|
|
32
33
|
.filter((x) => x)
|
|
@@ -96,7 +97,7 @@ export const TableRowRender = ({
|
|
|
96
97
|
|
|
97
98
|
{!disableCellThaoTac && (
|
|
98
99
|
<TableCell align="center">
|
|
99
|
-
{
|
|
100
|
+
{!disableEdit && (
|
|
100
101
|
<Tooltip title="Chỉnh sửa">
|
|
101
102
|
<IconButton size={downXl ? "small" : "medium"} onClick={() => onEdit(row)}>
|
|
102
103
|
<EditOutlined fontSize="inherit" color="primary" />
|
|
@@ -108,6 +108,8 @@ function DataManagement({
|
|
|
108
108
|
}, [filters]);
|
|
109
109
|
|
|
110
110
|
const [dataSearch, setDataSearch] = useState({ ...defaults, ...getDefaultValues(filters) });
|
|
111
|
+
const [page, setPage] = useState(0);
|
|
112
|
+
|
|
111
113
|
const values = useMemo(() => {
|
|
112
114
|
const hasTabpanel = !!tabPanel;
|
|
113
115
|
return {
|
|
@@ -206,9 +208,9 @@ function DataManagement({
|
|
|
206
208
|
|
|
207
209
|
<Card>
|
|
208
210
|
{tabPanel}
|
|
209
|
-
<FilterGod filters={filters} elementSize={elementSize} />
|
|
211
|
+
<FilterGod filters={filters} elementSize={elementSize} setPage={setPage} />
|
|
210
212
|
{backParentNavigator}
|
|
211
|
-
<DataTable multipleActions={multipleActions} />
|
|
213
|
+
<DataTable multipleActions={multipleActions} page={page} setPage={setPage} disableEdit={disableEditor}/>
|
|
212
214
|
</Card>
|
|
213
215
|
</FormProvider>
|
|
214
216
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { DateField } from "@mui/x-date-pickers";
|
|
2
2
|
import { DEFAULT_DATE_FORMAT } from "../../constants";
|
|
3
|
-
import { ClickAwayListener, Popover, Popper, Stack, Typography } from "@mui/material";
|
|
3
|
+
import { ClickAwayListener, Popover, Popper, Stack, Typography, IconButton } from "@mui/material";
|
|
4
|
+
import ClearIcon from "@mui/icons-material/Clear";
|
|
5
|
+
import InputAdornment from "@mui/material/InputAdornment";
|
|
4
6
|
import StaticDateRangePicker from "./StaticDateRangePicker";
|
|
5
7
|
import moment from "moment";
|
|
6
8
|
import { memo, useEffect, useRef, useState } from "react";
|
|
@@ -77,25 +79,6 @@ const DateRangePicker = ({ label = ["Từ ngày", "Đến ngày"] }) => {
|
|
|
77
79
|
useEffect(() => {
|
|
78
80
|
setAnchorEl(containerRef.current);
|
|
79
81
|
}, []);
|
|
80
|
-
// useEffect(() => {
|
|
81
|
-
// console.log("CHANGEEEE");
|
|
82
|
-
// }, [isFocusStart, isFocusEnd]);
|
|
83
|
-
// useEffect(() => {
|
|
84
|
-
// if (dateFns.isBefore(dateRange.startDate, dateRange.endDate) || dateFns.isSameDay(dateRange.startDate, dateRange.endDate)) {
|
|
85
|
-
// onChange([dateRange.startDate, dateRange.endDate]);
|
|
86
|
-
// }
|
|
87
|
-
// }, [dateRange]);
|
|
88
|
-
|
|
89
|
-
// useEffect(() => {
|
|
90
|
-
// if (!value) return;
|
|
91
|
-
// if (dateFns.isSameDay(dateRange.startDate, value[0]) && dateFns.isSameDay(dateRange.endDate, value[1])) {
|
|
92
|
-
// return;
|
|
93
|
-
// }
|
|
94
|
-
// setDateRange({
|
|
95
|
-
// startDate: value?.[0],
|
|
96
|
-
// endDate: value?.[1]
|
|
97
|
-
// });
|
|
98
|
-
// }, [value]);
|
|
99
82
|
|
|
100
83
|
return (
|
|
101
84
|
<>
|
|
@@ -114,6 +97,23 @@ const DateRangePicker = ({ label = ["Từ ngày", "Đến ngày"] }) => {
|
|
|
114
97
|
}}
|
|
115
98
|
value={dateRange.startDate && moment(dateRange.startDate)}
|
|
116
99
|
maxDate={dateRange.endDate ?? moment(dateRange.endDate)}
|
|
100
|
+
InputProps={{
|
|
101
|
+
endAdornment: (
|
|
102
|
+
<InputAdornment position="end">
|
|
103
|
+
<IconButton
|
|
104
|
+
onClick={() => {
|
|
105
|
+
setDateRange((d) => ({
|
|
106
|
+
...d,
|
|
107
|
+
startDate: null
|
|
108
|
+
}));
|
|
109
|
+
}}
|
|
110
|
+
edge="end"
|
|
111
|
+
>
|
|
112
|
+
<ClearIcon />
|
|
113
|
+
</IconButton>
|
|
114
|
+
</InputAdornment>
|
|
115
|
+
)
|
|
116
|
+
}}
|
|
117
117
|
/>
|
|
118
118
|
<Typography variant="body1" sx={{ height: "24px", alignSelf: "center" }}>
|
|
119
119
|
–
|
|
@@ -132,6 +132,23 @@ const DateRangePicker = ({ label = ["Từ ngày", "Đến ngày"] }) => {
|
|
|
132
132
|
}}
|
|
133
133
|
value={dateRange.endDate && moment(dateRange.endDate)}
|
|
134
134
|
minDate={dateRange.startDate ?? moment(dateRange.startDate)}
|
|
135
|
+
InputProps={{
|
|
136
|
+
endAdornment: (
|
|
137
|
+
<InputAdornment position="end">
|
|
138
|
+
<IconButton
|
|
139
|
+
onClick={() => {
|
|
140
|
+
setDateRange((d) => ({
|
|
141
|
+
...d,
|
|
142
|
+
endDate: null
|
|
143
|
+
}));
|
|
144
|
+
}}
|
|
145
|
+
edge="end"
|
|
146
|
+
>
|
|
147
|
+
<ClearIcon />
|
|
148
|
+
</IconButton>
|
|
149
|
+
</InputAdornment>
|
|
150
|
+
)
|
|
151
|
+
}}
|
|
135
152
|
/>
|
|
136
153
|
</Stack>
|
|
137
154
|
<ClickAwayListener onClickAway={handleClickAway}>
|
|
@@ -145,29 +162,6 @@ const DateRangePicker = ({ label = ["Từ ngày", "Đến ngày"] }) => {
|
|
|
145
162
|
anchorEl={anchorEl}
|
|
146
163
|
onClose={handleClose}
|
|
147
164
|
onClick={handleClickPopper}
|
|
148
|
-
|
|
149
|
-
// modifiers={[
|
|
150
|
-
// {
|
|
151
|
-
// name: "flip",
|
|
152
|
-
// enabled: true,
|
|
153
|
-
// options: {
|
|
154
|
-
// altBoundary: true,
|
|
155
|
-
// rootBoundary: "viewport",
|
|
156
|
-
// padding: 8
|
|
157
|
-
// }
|
|
158
|
-
// },
|
|
159
|
-
// {
|
|
160
|
-
// name: "preventOverflow",
|
|
161
|
-
// enabled: true,
|
|
162
|
-
// options: {
|
|
163
|
-
// altAxis: true,
|
|
164
|
-
// altBoundary: true,
|
|
165
|
-
// tether: true,
|
|
166
|
-
// rootBoundary: "document",
|
|
167
|
-
// padding: 8
|
|
168
|
-
// }
|
|
169
|
-
// }
|
|
170
|
-
// ]}
|
|
171
165
|
>
|
|
172
166
|
<StaticDateRangePicker
|
|
173
167
|
value={dateRange}
|