trithuc-mvc-react 3.2.3 → 3.2.5
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.
|
@@ -244,6 +244,8 @@ const DataTable = ({ multipleActions = [], page, setPage = () => {}, disableEdit
|
|
|
244
244
|
const newRowsPerPage = parseInt(event.target.value, 10); // Chuyển đổi giá trị thành số nguyên
|
|
245
245
|
// Lưu giá trị mới vào localStorage với khóa tùy chỉnh theo tableName
|
|
246
246
|
localStorage.setItem(`${tableName}rowsPerPage`, newRowsPerPage);
|
|
247
|
+
localStorage.setItem(`BoxThongKe${tableName}_RowsPerPage`, newRowsPerPage);
|
|
248
|
+
localStorage.setItem(`${tableName}_RowsPerPage`, newRowsPerPage);
|
|
247
249
|
setRowsPerPage(newRowsPerPage);
|
|
248
250
|
setPage(0);
|
|
249
251
|
};
|
|
@@ -288,6 +290,15 @@ const DataTable = ({ multipleActions = [], page, setPage = () => {}, disableEdit
|
|
|
288
290
|
|
|
289
291
|
return (
|
|
290
292
|
<>
|
|
293
|
+
<Grid container>
|
|
294
|
+
{!hasTabpanel && (
|
|
295
|
+
<Grid alignSelf={"center"} sx={{ pl: 2 }}>
|
|
296
|
+
<Typography variant="body1">
|
|
297
|
+
Tổng số lượng: <span>{total}</span>
|
|
298
|
+
</Typography>
|
|
299
|
+
</Grid>
|
|
300
|
+
)}
|
|
301
|
+
</Grid>
|
|
291
302
|
<TableContainer sx={{ position: "relative" }}>
|
|
292
303
|
<TableToolbar
|
|
293
304
|
onSelectAllClick={handleSelectAllClick}
|
|
@@ -342,14 +353,6 @@ const DataTable = ({ multipleActions = [], page, setPage = () => {}, disableEdit
|
|
|
342
353
|
</TableContainer>
|
|
343
354
|
|
|
344
355
|
<Grid container>
|
|
345
|
-
{!hasTabpanel && (
|
|
346
|
-
<Grid alignSelf={"center"} sx={{ pl: 2 }}>
|
|
347
|
-
<Typography variant="body1">
|
|
348
|
-
Tổng số lượng: <span>{total}</span>
|
|
349
|
-
</Typography>
|
|
350
|
-
</Grid>
|
|
351
|
-
)}
|
|
352
|
-
|
|
353
356
|
<Grid size={12}>
|
|
354
357
|
<TablePaginationCustom
|
|
355
358
|
count={total}
|
|
@@ -298,6 +298,15 @@ const DataTableSM = ({ multipleActions = [], page, setPage = () => {}, disableEd
|
|
|
298
298
|
|
|
299
299
|
return (
|
|
300
300
|
<>
|
|
301
|
+
<Grid container>
|
|
302
|
+
{!hasTabpanel && (
|
|
303
|
+
<Grid alignSelf={"center"} sx={{ pl: 2 }}>
|
|
304
|
+
<Typography variant="body1">
|
|
305
|
+
Tổng số lượng: <span>{total}</span>
|
|
306
|
+
</Typography>
|
|
307
|
+
</Grid>
|
|
308
|
+
)}
|
|
309
|
+
</Grid>
|
|
301
310
|
<TableContainer sx={{ position: "relative" }}>
|
|
302
311
|
<TableToolbar
|
|
303
312
|
onSelectAllClick={handleSelectAllClick}
|
|
@@ -352,14 +361,6 @@ const DataTableSM = ({ multipleActions = [], page, setPage = () => {}, disableEd
|
|
|
352
361
|
</TableContainer>
|
|
353
362
|
|
|
354
363
|
<Grid container>
|
|
355
|
-
{!hasTabpanel && (
|
|
356
|
-
<Grid alignSelf={"center"} sx={{ pl: 2 }}>
|
|
357
|
-
<Typography variant="body1" sx={{ fontSize: "0.7rem" }}>
|
|
358
|
-
Tổng số lượng: <span>{total}</span>
|
|
359
|
-
</Typography>
|
|
360
|
-
</Grid>
|
|
361
|
-
)}
|
|
362
|
-
|
|
363
364
|
<Grid size={12}>
|
|
364
365
|
<TablePaginationCustom
|
|
365
366
|
count={total}
|
|
@@ -14,6 +14,7 @@ export function FilterElement({
|
|
|
14
14
|
keyLabel,
|
|
15
15
|
childrenFields,
|
|
16
16
|
datas,
|
|
17
|
+
multiple = false,
|
|
17
18
|
loading = false,
|
|
18
19
|
onChange = () => {},
|
|
19
20
|
size = "small",
|
|
@@ -74,35 +75,83 @@ export function FilterElement({
|
|
|
74
75
|
);
|
|
75
76
|
|
|
76
77
|
case "autocomplete": {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
<Autocomplete
|
|
82
|
-
key={name}
|
|
83
|
-
name={name}
|
|
84
|
-
disablePortal
|
|
85
|
-
loading={loading}
|
|
86
|
-
noOptionsText="Không có dữ liệu"
|
|
87
|
-
fullWidth
|
|
88
|
-
options={datas ?? []}
|
|
89
|
-
onChange={(event, newValue) => {
|
|
90
|
-
let updateObject = { [name]: newValue?.[keyValue] };
|
|
91
|
-
onFieldChange(newValue?.[keyValue]);
|
|
92
|
-
onChange(newValue);
|
|
93
|
-
setPage(0);
|
|
94
|
-
childrenFields?.forEach((childrenField) => {
|
|
95
|
-
setValue(childrenField, null, { shouldTouch: true });
|
|
96
|
-
updateObject[childrenField] = null;
|
|
97
|
-
});
|
|
78
|
+
if (multiple) {
|
|
79
|
+
const autocompleteValue = multiple
|
|
80
|
+
? datas.filter((item) => (value || []).includes(item[keyValue]))
|
|
81
|
+
: datas.find((item) => item[keyValue] === value) ?? null;
|
|
98
82
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
83
|
+
const parsedValue = multiple ? autocompleteValue : autocompleteValue;
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<Autocomplete
|
|
87
|
+
key={name}
|
|
88
|
+
name={name}
|
|
89
|
+
disablePortal
|
|
90
|
+
multiple={multiple}
|
|
91
|
+
loading={loading}
|
|
92
|
+
noOptionsText="Không có dữ liệu"
|
|
93
|
+
fullWidth
|
|
94
|
+
options={datas}
|
|
95
|
+
value={parsedValue}
|
|
96
|
+
onChange={(event, newValue) => {
|
|
97
|
+
// ✅ Khai báo biến trước khi sử dụng
|
|
98
|
+
const updateObject = {
|
|
99
|
+
[name]: multiple ? JSON.stringify(newValue.map((item) => item[keyValue])) : newValue?.[keyValue]
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
if (multiple) {
|
|
103
|
+
onFieldChange(newValue.map((item) => item[keyValue]));
|
|
104
|
+
} else {
|
|
105
|
+
onFieldChange(newValue?.[keyValue]);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
onChange(newValue);
|
|
109
|
+
setPage(0);
|
|
110
|
+
|
|
111
|
+
// ✅ Xử lý các trường con (nếu có)
|
|
112
|
+
childrenFields?.forEach((childrenField) => {
|
|
113
|
+
setValue(childrenField, null, { shouldTouch: true });
|
|
114
|
+
updateObject[childrenField] = null;
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// ✅ Cập nhật state tìm kiếm
|
|
118
|
+
setDataSearch({ ...dataSearch, ...updateObject });
|
|
119
|
+
}}
|
|
120
|
+
getOptionLabel={(option) => option?.[keyLabel] || ""}
|
|
121
|
+
renderInput={(params) => <TextField {...params} label={label} placeholder={placeholder} />}
|
|
122
|
+
/>
|
|
123
|
+
);
|
|
124
|
+
} else {
|
|
125
|
+
//Bùa bởi vì không hiện giá trị đầu tiên
|
|
126
|
+
let autocompleteValue = datas?.find((item) => item[keyValue] == dataSearch[name]);
|
|
127
|
+
autocompleteValue = autocompleteValue ? { ...autocompleteValue } : { [keyLabel]: "" };
|
|
128
|
+
return (
|
|
129
|
+
<Autocomplete
|
|
130
|
+
key={name}
|
|
131
|
+
name={name}
|
|
132
|
+
disablePortal
|
|
133
|
+
loading={loading}
|
|
134
|
+
noOptionsText="Không có dữ liệu"
|
|
135
|
+
fullWidth
|
|
136
|
+
options={datas ?? []}
|
|
137
|
+
onChange={(event, newValue) => {
|
|
138
|
+
let updateObject = { [name]: newValue?.[keyValue] };
|
|
139
|
+
onFieldChange(newValue?.[keyValue]);
|
|
140
|
+
onChange(newValue);
|
|
141
|
+
setPage(0);
|
|
142
|
+
childrenFields?.forEach((childrenField) => {
|
|
143
|
+
setValue(childrenField, null, { shouldTouch: true });
|
|
144
|
+
updateObject[childrenField] = null;
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
setDataSearch({ ...dataSearch, ...updateObject });
|
|
148
|
+
}}
|
|
149
|
+
value={autocompleteValue}
|
|
150
|
+
getOptionLabel={(option) => option?.[keyLabel]}
|
|
151
|
+
renderInput={(params) => <TextField {...params} label={label} placeholder={placeholder} />}
|
|
152
|
+
/>
|
|
153
|
+
);
|
|
154
|
+
}
|
|
106
155
|
}
|
|
107
156
|
case "select":
|
|
108
157
|
return (
|