lu-lowcode-package-form 0.11.71 → 0.11.73
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 +72 -72
- package/dist/index.es.js +1624 -1622
- package/package.json +1 -1
- package/src/components/form-container/index.jsx +43 -41
package/package.json
CHANGED
@@ -74,7 +74,7 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
74
74
|
// 当前更新周期的依赖路径
|
75
75
|
updatePath: [],
|
76
76
|
// 最大更新深度限制,避免过深的嵌套引起栈溢出
|
77
|
-
MAX_DEPTH: 30,
|
77
|
+
MAX_DEPTH: 30,
|
78
78
|
// 开始新的更新周期
|
79
79
|
startNewCycle: function () {
|
80
80
|
this.currentCycleId++;
|
@@ -720,71 +720,73 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
720
720
|
const delay = lockStatus.current === 1 ? 500 : 100;
|
721
721
|
|
722
722
|
timeoutRef.current = setTimeout(async () => {
|
723
|
-
console.log("debounceHandleFieldsChange starting",changedFieldsState.current)
|
724
723
|
// 开始新的更新周期
|
725
724
|
dependencyGraphRef.current.startNewCycle();
|
726
725
|
|
726
|
+
// 创建当前变更的快照,避免处理过程中的并发修改
|
727
|
+
const currentChanges = {...changedFieldsState.current};
|
728
|
+
// 立即重置变更状态,为新的变更做准备
|
729
|
+
changedFieldsState.current = {};
|
730
|
+
console.log("debounceHandleFieldsChange starting", currentChanges)
|
731
|
+
|
727
732
|
const fieldValues = form.getFieldsValue();
|
728
733
|
const lockStatus_ = lockStatus.current;
|
729
734
|
lockStatus.current = 0
|
730
735
|
let needRefresh = false;
|
731
736
|
if (!lastFormValues.current) lastFormValues.current = {}
|
732
|
-
console.log("lastFormValues.current",lastFormValues.current)
|
737
|
+
console.log("lastFormValues.current", lastFormValues.current)
|
733
738
|
|
734
739
|
// 创建已处理字段集合,用于避免多次处理同一字段
|
735
740
|
const processedFields = new Set();
|
736
|
-
for (let key in
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
741
|
+
for (let key in currentChanges) {
|
742
|
+
try {
|
743
|
+
let field = currentChanges[key];
|
744
|
+
console.log("debounceHandleFieldsChange field", field)
|
745
|
+
console.log("debounceHandleFieldsChange getLastFieldValue", getLastFieldValue(field.name))
|
746
|
+
if (!isEqual(field.value || "", getLastFieldValue(field.name) || "")) {
|
747
|
+
console.log("debounceHandleFieldsChange lockStatus_", lockStatus_)
|
748
|
+
if (lockStatus_ != 1) {
|
749
|
+
// 获取字段标识符(字符串形式)
|
750
|
+
const fieldId = Array.isArray(field.name)
|
751
|
+
? field.name.map(item => typeof item == "string" ? item : item.toString()).join(".")
|
752
|
+
: field.name;
|
753
|
+
|
754
|
+
// 跳过已处理的字段
|
755
|
+
if (processedFields.has(fieldId)) {
|
756
|
+
console.log("跳过已处理的字段 processedFields", fieldId)
|
757
|
+
continue;
|
758
|
+
}
|
759
|
+
processedFields.add(fieldId);
|
755
760
|
|
756
|
-
|
757
|
-
|
758
|
-
|
761
|
+
// 处理字段依赖关系,传递字段ID和依赖图谱
|
762
|
+
let needRefresh_ = await handleFieldsWith(field.name, fieldValues, false, fieldId);
|
763
|
+
needRefresh = needRefresh || needRefresh_;
|
764
|
+
}
|
765
|
+
lastFormValues.current[field.name] = field.value;
|
759
766
|
}
|
760
|
-
|
767
|
+
} catch (error) {
|
768
|
+
console.log("debounceHandleFieldsChange error", error)
|
761
769
|
}
|
762
|
-
} catch (error) {
|
763
|
-
console.log("debounceHandleFieldsChange error", error)
|
764
|
-
|
765
|
-
}
|
766
770
|
}
|
767
771
|
if (needRefresh) {
|
768
772
|
console.log("needRefresh", needRefresh)
|
769
773
|
updateFormContent();
|
770
774
|
}
|
771
|
-
changedFieldsState.current = {};
|
772
775
|
}, delay);
|
773
776
|
}, []);
|
774
777
|
|
775
778
|
const handleFieldsChange = React.useCallback((changedFields) => {
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
changedFieldsState.current[field.name] = field;
|
779
|
+
changedFields.filter(field => {
|
780
|
+
if (field.name && field.name.length > 0) {
|
781
|
+
// const fieldKey = field.name.filter(item => typeof item == "string").join(".")
|
782
|
+
changedFieldsState.current[field.name] = field;
|
781
783
|
|
782
784
|
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
785
|
+
}
|
786
|
+
})
|
787
|
+
console.log("handleFieldsChange", changedFieldsState.current)
|
788
|
+
debounceHandleFieldsChange();
|
789
|
+
|
788
790
|
}, []);
|
789
791
|
|
790
792
|
const getTableWithIds = (ids) => {
|