@esvndev/es-react-config-setting 1.0.59 → 1.0.64
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/dist/index.js +41 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -22
- package/dist/index.mjs.map +1 -1
- package/dist/request/index.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18804,6 +18804,7 @@ const GetSettingConfigByGroup = (obj, callback) => {
|
|
|
18804
18804
|
const UpdateSettingConfig = (obj, file, callback) => {
|
|
18805
18805
|
const _url = `${BASE_URL}/api/config/update-setting-config`;
|
|
18806
18806
|
const formData = new FormData();
|
|
18807
|
+
formData.append(`GroupId`, obj.GroupId);
|
|
18807
18808
|
obj.Items.forEach((item, index) => {
|
|
18808
18809
|
formData.append(`Items[${index}].Key`, item.Key);
|
|
18809
18810
|
formData.append(`Items[${index}].Value`, item.Value);
|
|
@@ -18843,32 +18844,31 @@ const SettingApp = (props) => {
|
|
|
18843
18844
|
eventClose({ state: 'close' });
|
|
18844
18845
|
};
|
|
18845
18846
|
//Sự kiện sau khi đã mở cài đặt
|
|
18846
|
-
const handleFormOpened = () => {
|
|
18847
|
-
};
|
|
18847
|
+
const handleFormOpened = () => { };
|
|
18848
18848
|
//Sự kiện sau khi đã đóng cài đặt
|
|
18849
|
-
const handleFormClosed = () => {
|
|
18849
|
+
const handleFormClosed = () => { };
|
|
18850
|
+
const DynamicIcon = ({ name, className }) => {
|
|
18851
|
+
const LucideIcon = Icon[name];
|
|
18852
|
+
return LucideIcon ? jsxRuntime.jsx(LucideIcon, { className: className }) : null;
|
|
18850
18853
|
};
|
|
18854
|
+
//#endregion
|
|
18855
|
+
const [settingData, setSettingData] = React.useState({});
|
|
18856
|
+
const [dataSettingGroup, setDataSettingGroup] = React.useState([]);
|
|
18857
|
+
const [formState, setFormState] = React.useState({});
|
|
18851
18858
|
//Sự kiện giá trị thay đổi
|
|
18852
18859
|
const _eventChange = (obj) => {
|
|
18853
18860
|
UpdateSettingConfig({
|
|
18861
|
+
GroupId: obj.groupId,
|
|
18854
18862
|
Items: [{
|
|
18855
18863
|
Key: obj.key,
|
|
18856
|
-
Value: obj.value
|
|
18864
|
+
Value: obj.value,
|
|
18857
18865
|
}]
|
|
18858
|
-
},
|
|
18866
|
+
}, obj.file, (rs) => {
|
|
18859
18867
|
console.log(rs);
|
|
18860
18868
|
});
|
|
18861
18869
|
if (eventChange)
|
|
18862
18870
|
eventChange([{ key: obj.key, value: obj.value, state: "update" }]);
|
|
18863
18871
|
};
|
|
18864
|
-
const DynamicIcon = ({ name, className }) => {
|
|
18865
|
-
const LucideIcon = Icon[name];
|
|
18866
|
-
return LucideIcon ? jsxRuntime.jsx(LucideIcon, { className: className }) : null;
|
|
18867
|
-
};
|
|
18868
|
-
//#endregion
|
|
18869
|
-
const [settingData, setSettingData] = React.useState({});
|
|
18870
|
-
const [dataSettingGroup, setDataSettingGroup] = React.useState([]);
|
|
18871
|
-
const [formState, setFormState] = React.useState({});
|
|
18872
18872
|
//Load data of group config and setting by group
|
|
18873
18873
|
React.useEffect(() => {
|
|
18874
18874
|
if (isOpen) {
|
|
@@ -18925,12 +18925,23 @@ const SettingApp = (props) => {
|
|
|
18925
18925
|
allowed_defects_per_model_day: null
|
|
18926
18926
|
}).current;
|
|
18927
18927
|
//Cấu hình thông số delay tránh gửi liên tục
|
|
18928
|
-
const change_save = (obj, e) => {
|
|
18928
|
+
const change_save = (root, obj, e) => {
|
|
18929
18929
|
const _m = saveSettings;
|
|
18930
18930
|
if (saveSettings && _m[obj.id] !== null) {
|
|
18931
18931
|
clearTimeout(_m[obj.id]);
|
|
18932
18932
|
}
|
|
18933
|
-
|
|
18933
|
+
let value;
|
|
18934
|
+
let value_file;
|
|
18935
|
+
if (e.target.type === "checkbox") {
|
|
18936
|
+
value = e.target.checked;
|
|
18937
|
+
}
|
|
18938
|
+
else if (e.target.type === "file") {
|
|
18939
|
+
value = e.target.value;
|
|
18940
|
+
value_file = e.target.files?.[0] ?? null;
|
|
18941
|
+
}
|
|
18942
|
+
else {
|
|
18943
|
+
value = e.target.value;
|
|
18944
|
+
}
|
|
18934
18945
|
setFormState(prev => ({
|
|
18935
18946
|
...prev,
|
|
18936
18947
|
[obj.id]: value
|
|
@@ -18940,6 +18951,8 @@ const SettingApp = (props) => {
|
|
|
18940
18951
|
obj: obj,
|
|
18941
18952
|
key: obj.id,
|
|
18942
18953
|
value: value,
|
|
18954
|
+
file: value_file,
|
|
18955
|
+
groupId: root.id
|
|
18943
18956
|
};
|
|
18944
18957
|
_m[obj.id] = setTimeout(() => {
|
|
18945
18958
|
_eventChange(_data);
|
|
@@ -18947,16 +18960,22 @@ const SettingApp = (props) => {
|
|
|
18947
18960
|
};
|
|
18948
18961
|
//Hàm sử dụng tạo theo loại giá trị
|
|
18949
18962
|
const _renderInput = (root, data) => {
|
|
18950
|
-
console.log(data);
|
|
18951
18963
|
const value = formState[data.id] ?? data.value ?? "";
|
|
18952
18964
|
switch (data.type) {
|
|
18953
18965
|
case "switch":
|
|
18954
18966
|
case "checkbox":
|
|
18955
|
-
return (jsxRuntime.jsx("div", { className: "checkbox", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "checkbox", checked: !!value, onChange: (e) => change_save(data, e) }) }, data.id));
|
|
18967
|
+
return (jsxRuntime.jsx("div", { className: "checkbox", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "checkbox", checked: !!value, onChange: (e) => change_save(root, data, e) }) }, data.id));
|
|
18956
18968
|
case "radio":
|
|
18957
|
-
return (jsxRuntime.jsx("div", { className: "radio-group", title: data.description, children: data.option?.map((opt, index) => (jsxRuntime.jsxs("label", { children: [jsxRuntime.jsx(Input$1, { type: "radio", name: data.name, value: opt.value, checked: value === opt.value, onChange: (e) => change_save(data, e) }), opt.name] }, index))) }, data.id));
|
|
18969
|
+
return (jsxRuntime.jsx("div", { className: "radio-group", title: data.description, children: data.option?.map((opt, index) => (jsxRuntime.jsxs("label", { children: [jsxRuntime.jsx(Input$1, { type: "radio", name: data.name, value: opt.value, checked: value === opt.value, onChange: (e) => change_save(root, data, e) }), opt.name] }, index))) }, data.id));
|
|
18958
18970
|
case "combobox":
|
|
18959
|
-
|
|
18971
|
+
let _data_option = [];
|
|
18972
|
+
try {
|
|
18973
|
+
_data_option = JSON.parse(data.option ?? []);
|
|
18974
|
+
}
|
|
18975
|
+
catch (ex) {
|
|
18976
|
+
console.log("Error config option setting", data);
|
|
18977
|
+
}
|
|
18978
|
+
return (jsxRuntime.jsx("div", { className: "combobox", title: data.description, children: jsxRuntime.jsxs(Input$1, { type: "select", className: "input-custom", name: data.name, value: value, onChange: (e) => change_save(root, data, e), children: [jsxRuntime.jsx("option", { value: "", children: "Ch\u1ECDn m\u1ED9t gi\u00E1 tr\u1ECB" }), data.option?.map((opt, index) => (jsxRuntime.jsx("option", { value: opt.value, children: opt.name }, index)))] }) }, data.id));
|
|
18960
18979
|
case "slider":
|
|
18961
18980
|
case "text":
|
|
18962
18981
|
case "password":
|
|
@@ -18965,12 +18984,12 @@ const SettingApp = (props) => {
|
|
|
18965
18984
|
case "time":
|
|
18966
18985
|
case "datetime":
|
|
18967
18986
|
case "color":
|
|
18968
|
-
return (jsxRuntime.jsx("div", { className: `${data.type}-input`, title: data.description, children: jsxRuntime.jsx(Input$1, { type: data.type, className: "input-custom", value: value, placeholder: data.name, onChange: (e) => change_save(data, e) }) }, data.id));
|
|
18987
|
+
return (jsxRuntime.jsx("div", { className: `${data.type}-input`, title: data.description, children: jsxRuntime.jsx(Input$1, { type: data.type, className: "input-custom", value: value, placeholder: data.name, onChange: (e) => change_save(root, data, e) }) }, data.id));
|
|
18969
18988
|
case "image":
|
|
18970
18989
|
case "file":
|
|
18971
|
-
return (jsxRuntime.jsx("div", { className: "file-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "file", className: "input-custom", onChange: (e) => change_save(data, e) }) }, data.id));
|
|
18990
|
+
return (jsxRuntime.jsx("div", { className: "file-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "file", className: "input-custom", onChange: (e) => change_save(root, data, e) }) }, data.id));
|
|
18972
18991
|
default:
|
|
18973
|
-
return (jsxRuntime.jsx("div", { className: `${data.type ?? 'normal'}-input`, title: data.description, children: jsxRuntime.jsx(Input$1, { type: data.type ?? "text", value: value, onChange: (e) => change_save(data, e) }) }, data.id));
|
|
18992
|
+
return (jsxRuntime.jsx("div", { className: `${data.type ?? 'normal'}-input`, title: data.description, children: jsxRuntime.jsx(Input$1, { type: data.type ?? "text", value: value, onChange: (e) => change_save(root, data, e) }) }, data.id));
|
|
18974
18993
|
}
|
|
18975
18994
|
};
|
|
18976
18995
|
//hàm tạo các thông số cấu hình và cài đặt
|