lu-lowcode-package-form 0.11.83 → 0.11.84
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.cjs.js +287 -287
- package/dist/index.es.js +23848 -23847
- package/package.json +1 -1
- package/src/components/form-container/index.jsx +28 -17
package/package.json
CHANGED
@@ -162,8 +162,15 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
162
162
|
}
|
163
163
|
|
164
164
|
const lastFormValues = React.useRef(null);
|
165
|
+
// 统一使用点分隔的字符串格式
|
166
|
+
const normalizeFieldPath = (fieldPath) => {
|
167
|
+
if (Array.isArray(fieldPath)) {
|
168
|
+
return fieldPath.map(item => typeof item === "string" ? item : item.toString()).join(".");
|
169
|
+
}
|
170
|
+
return fieldPath;
|
171
|
+
};
|
165
172
|
const getLastFieldValue = (path) => {
|
166
|
-
return lastFormValues.current?.[path]
|
173
|
+
return lastFormValues.current?.[normalizeFieldPath(path)]
|
167
174
|
// let current = lastFormValues.current;
|
168
175
|
// for (let i = 0; i < path.length; i++) {
|
169
176
|
// if (current == null) {
|
@@ -310,11 +317,11 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
310
317
|
for (let index = 0; index < lastFormValuesKeys.length; index++) {
|
311
318
|
const key = lastFormValuesKeys[index];
|
312
319
|
if (key.includes(`${name},`)) {
|
313
|
-
delete lastFormValues.current[key]
|
320
|
+
delete lastFormValues.current[normalizeFieldPath(key)]
|
314
321
|
}
|
315
322
|
}
|
316
323
|
}
|
317
|
-
else delete lastFormValues.current[name]
|
324
|
+
else delete lastFormValues.current[normalizeFieldPath(name)]
|
318
325
|
}
|
319
326
|
|
320
327
|
const recordFieldChange = (fieldName, fieldValue) => {
|
@@ -421,8 +428,12 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
421
428
|
changedFields[target] = { name: Array.isArray(target) ? target : [target], value: setValue };
|
422
429
|
}
|
423
430
|
if (rule?.type == 1) {
|
431
|
+
console.log("rule?.type == 1", target)
|
432
|
+
console.log("rule?.type == 1", setValue)
|
433
|
+
console.log("rule?.type == 1 current_identifier", current_identifier)
|
424
434
|
form.setFieldValue(target, undefined);
|
425
435
|
}
|
436
|
+
console.log("form.setFieldValue(target, setValue) " +target, setValue)
|
426
437
|
form.setFieldValue(target, setValue)
|
427
438
|
|
428
439
|
// 处理完当前字段后从依赖路径中移除
|
@@ -725,10 +736,10 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
725
736
|
dependencyGraphRef.current.startNewCycle();
|
726
737
|
|
727
738
|
// 创建当前变更的快照,避免处理过程中的并发修改
|
728
|
-
const currentChanges = {...changedFieldsState.current};
|
739
|
+
const currentChanges = { ...changedFieldsState.current };
|
729
740
|
// 立即重置变更状态,为新的变更做准备
|
730
741
|
changedFieldsState.current = {};
|
731
|
-
|
742
|
+
|
732
743
|
const fieldValues = form.getFieldsValue();
|
733
744
|
const lockStatus_ = lockStatus.current;
|
734
745
|
lockStatus.current = 0
|
@@ -758,7 +769,7 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
758
769
|
let needRefresh_ = await handleFieldsWith(field.name, fieldValues, false, fieldId);
|
759
770
|
needRefresh = needRefresh || needRefresh_;
|
760
771
|
}
|
761
|
-
lastFormValues.current[field.name] = field.value;
|
772
|
+
lastFormValues.current[normalizeFieldPath(field.name)] = field.value;
|
762
773
|
}
|
763
774
|
} catch (error) {
|
764
775
|
console.log("debounceHandleFieldsChange error", error)
|
@@ -772,22 +783,22 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
772
783
|
}, []);
|
773
784
|
|
774
785
|
const handleFieldsChange = React.useCallback((changedFields) => {
|
775
|
-
console.log("handleFieldsChange (disabled, using handleValuesChange instead)", JSON.stringify(changedFields))
|
786
|
+
// console.log("handleFieldsChange (disabled, using handleValuesChange instead)", JSON.stringify(changedFields))
|
776
787
|
// 已禁用,改为使用 handleValuesChange 来处理字段变更
|
777
788
|
// 这样可以避免重复处理和多余的触发
|
778
789
|
}, []);
|
779
790
|
const handleValuesChange = React.useCallback((changedValues, allValues) => {
|
780
791
|
console.log("handleValuesChange changedValues", JSON.stringify(changedValues))
|
781
|
-
console.log("handleValuesChange allValues", JSON.stringify(allValues))
|
782
|
-
|
792
|
+
// console.log("handleValuesChange allValues", JSON.stringify(allValues))
|
793
|
+
|
783
794
|
// 将 changedValues 转换为类似 handleFieldsChange 的格式
|
784
795
|
const convertToFieldsFormat = (values, parentPath = []) => {
|
785
796
|
const fieldsArray = [];
|
786
|
-
|
797
|
+
|
787
798
|
for (let fieldName in values) {
|
788
799
|
const fieldValue = values[fieldName];
|
789
800
|
const currentPath = [...parentPath, fieldName];
|
790
|
-
|
801
|
+
|
791
802
|
// 处理数组类型(如table字段)
|
792
803
|
if (Array.isArray(fieldValue)) {
|
793
804
|
fieldValue.forEach((item, index) => {
|
@@ -822,14 +833,14 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
822
833
|
});
|
823
834
|
}
|
824
835
|
}
|
825
|
-
|
836
|
+
|
826
837
|
return fieldsArray;
|
827
838
|
};
|
828
|
-
|
839
|
+
|
829
840
|
// 转换为类似 handleFieldsChange 的格式
|
830
841
|
const convertedFields = convertToFieldsFormat(changedValues);
|
831
842
|
console.log("handleValuesChange converted to fields format", JSON.stringify(convertedFields));
|
832
|
-
|
843
|
+
|
833
844
|
// 使用转换后的数据,复用原有的处理逻辑
|
834
845
|
if (convertedFields.length > 0) {
|
835
846
|
convertedFields.forEach(field => {
|
@@ -837,12 +848,12 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
837
848
|
changedFieldsState.current[field.name] = field;
|
838
849
|
}
|
839
850
|
});
|
840
|
-
|
841
|
-
console.log("handleValuesChange changedFieldsState",JSON.parse(JSON.stringify(changedFieldsState.current)));
|
851
|
+
|
852
|
+
console.log("handleValuesChange changedFieldsState", JSON.parse(JSON.stringify(changedFieldsState.current)));
|
842
853
|
debounceHandleFieldsChange();
|
843
854
|
}
|
844
855
|
}, []);
|
845
|
-
|
856
|
+
|
846
857
|
const getTableWithIds = (ids) => {
|
847
858
|
let withAllIds = []
|
848
859
|
ids.forEach(id => {
|