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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lu-lowcode-package-form",
3
- "version": "0.11.71",
3
+ "version": "0.11.73",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^4.8.1",
6
6
  "@dnd-kit/core": "^6.1.0",
@@ -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 changedFieldsState.current) {
737
- try {
738
- let field = changedFieldsState.current[key];
739
- console.log("debounceHandleFieldsChange field", field)
740
- console.log("debounceHandleFieldsChange getLastFieldValue", getLastFieldValue(field.name))
741
- if (!isEqual(field.value || "", getLastFieldValue(field.name) || "")) {
742
- console.log("debounceHandleFieldsChange lockStatus_", lockStatus_)
743
- if (lockStatus_ != 1) {
744
- // 获取字段标识符(字符串形式)
745
- const fieldId = Array.isArray(field.name)
746
- ? field.name.map(item => typeof item == "string" ? item : item.toString()).join(".")
747
- : field.name;
748
-
749
- // 跳过已处理的字段
750
- if (processedFields.has(fieldId)){
751
- console.log("跳过已处理的字段 processedFields", fieldId)
752
- continue;
753
- }
754
- processedFields.add(fieldId);
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
- // 处理字段依赖关系,传递字段ID和依赖图谱
757
- let needRefresh_ = await handleFieldsWith(field.name, fieldValues, false, fieldId);
758
- needRefresh = needRefresh || needRefresh_;
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
- lastFormValues.current[field.name] = field.value;
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
- setTimeout(() => {
777
- changedFields.filter(field => {
778
- if (field.name && field.name.length > 0) {
779
- // const fieldKey = field.name.filter(item => typeof item == "string").join(".")
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
- console.log("handleFieldsChange", changedFieldsState.current)
786
- debounceHandleFieldsChange();
787
- }, 0);
785
+ }
786
+ })
787
+ console.log("handleFieldsChange", changedFieldsState.current)
788
+ debounceHandleFieldsChange();
789
+
788
790
  }, []);
789
791
 
790
792
  const getTableWithIds = (ids) => {