trithuc-mvc-react 1.8.10 → 1.8.11
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Autocomplete, FormControl, InputAdornment, InputLabel, MenuItem, OutlinedInput, Select, TextField } from "@mui/material";
|
|
2
|
-
import { useCallback } from "react";
|
|
2
|
+
import { useCallback, useMemo } from "react";
|
|
3
3
|
import { SearchOutlined } from "@mui/icons-material";
|
|
4
4
|
import { useController, useFormContext } from "react-hook-form";
|
|
5
5
|
import { debounce } from "lodash";
|
|
@@ -55,31 +55,38 @@ export function FilterElement({
|
|
|
55
55
|
/>
|
|
56
56
|
);
|
|
57
57
|
|
|
58
|
-
case "autocomplete":
|
|
58
|
+
case "autocomplete": {
|
|
59
|
+
//Bùa bởi vì không hiện giá trị đầu tiên
|
|
60
|
+
let autocompleteValue = datas?.find((item) => item[keyValue] == dataSearch[name]);
|
|
61
|
+
autocompleteValue = autocompleteValue ? { ...autocompleteValue } : { [keyLabel]: "" };
|
|
59
62
|
return (
|
|
60
63
|
<Autocomplete
|
|
61
|
-
{
|
|
64
|
+
key={name}
|
|
65
|
+
name={name}
|
|
62
66
|
disablePortal
|
|
63
67
|
loading={loading}
|
|
64
68
|
noOptionsText="Không có dữ liệu"
|
|
65
69
|
fullWidth
|
|
66
70
|
options={datas ?? []}
|
|
67
|
-
onChange={(event, newValue) => {
|
|
71
|
+
onChange={(event, newValue, reason) => {
|
|
68
72
|
let updateObject = { [name]: newValue?.[keyValue] };
|
|
69
73
|
onFieldChange(newValue?.[keyValue]);
|
|
74
|
+
|
|
70
75
|
onChange(newValue);
|
|
76
|
+
|
|
71
77
|
childrenFields?.forEach((childrenField) => {
|
|
72
78
|
setValue(childrenField, null, { shouldTouch: true });
|
|
73
79
|
updateObject[childrenField] = null;
|
|
74
80
|
});
|
|
81
|
+
|
|
75
82
|
setDataSearch({ ...dataSearch, ...updateObject });
|
|
76
83
|
}}
|
|
77
|
-
value={
|
|
84
|
+
value={autocompleteValue}
|
|
78
85
|
getOptionLabel={(option) => option?.[keyLabel]}
|
|
79
86
|
renderInput={(params) => <TextField {...params} label={label} />}
|
|
80
87
|
/>
|
|
81
88
|
);
|
|
82
|
-
|
|
89
|
+
}
|
|
83
90
|
case "select":
|
|
84
91
|
return (
|
|
85
92
|
<FormControl sx={{ minWidth: 160 }} size="small" fullWidth>
|
|
@@ -44,8 +44,8 @@ DataManagement.propTypes = {
|
|
|
44
44
|
};
|
|
45
45
|
const getDefaultValues = (filters = []) => {
|
|
46
46
|
const defaultValues = {};
|
|
47
|
-
filters.forEach((
|
|
48
|
-
defaultValues[
|
|
47
|
+
filters.forEach(({ defaultValue, field }) => {
|
|
48
|
+
defaultValues[field] = defaultValue;
|
|
49
49
|
});
|
|
50
50
|
return defaultValues;
|
|
51
51
|
};
|