trithuc-mvc-react 2.4.8 → 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.
|
@@ -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 = [],page, setPage = () => { } }) => {
|
|
16
|
+
const DataTable = ({ multipleActions = [],page, setPage = () => { }, disableEdit }) => {
|
|
17
17
|
const {
|
|
18
18
|
tableName,
|
|
19
19
|
selectedField,
|
|
@@ -209,6 +209,7 @@ const DataTable = ({ multipleActions = [],page, setPage = () => { } }) => {
|
|
|
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}
|
|
@@ -35,7 +35,7 @@ export const FilterGod = ({ filters, elementSize = "small",setPage=()=>{} }) =>
|
|
|
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;
|
|
@@ -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" />
|
|
@@ -210,7 +210,7 @@ function DataManagement({
|
|
|
210
210
|
{tabPanel}
|
|
211
211
|
<FilterGod filters={filters} elementSize={elementSize} setPage={setPage} />
|
|
212
212
|
{backParentNavigator}
|
|
213
|
-
<DataTable multipleActions={multipleActions} page={page} setPage={setPage}/>
|
|
213
|
+
<DataTable multipleActions={multipleActions} page={page} setPage={setPage} disableEdit={disableEditor}/>
|
|
214
214
|
</Card>
|
|
215
215
|
</FormProvider>
|
|
216
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}
|