Commit 61f1f49746e6b9c6b102d5e340f8b8a886d50d4f

Authored by ww
1 parent f4833661

fix: 修复首次创建组件后再次创建组件为清除表单实例

... ... @@ -40,7 +40,7 @@
40 40
41 41 const [registerModal, { openModal }] = useModal();
42 42
43   - const { trackUpdate, triggerUpdate } = useUpdateQueue(props);
  43 + const { trackUpdate, triggerUpdate, clear } = useUpdateQueue(props);
44 44
45 45 const spinning = ref(false);
46 46
... ... @@ -156,6 +156,9 @@
156 156 if (value && value.length) {
157 157 nextTick();
158 158 setFormValues(value);
  159 + } else {
  160 + dataSourceFormsEl.value = [];
  161 + clear();
159 162 }
160 163 }
161 164 );
... ...
... ... @@ -19,5 +19,9 @@ export const useUpdateQueue = (props: { dataSource: DataSourceType[] }) => {
19 19 return uuid;
20 20 };
21 21
22   - return { trackUpdate, triggerUpdate };
  22 + const clear = () => {
  23 + needUpdateQueue.length = 0;
  24 + };
  25 +
  26 + return { trackUpdate, triggerUpdate, clear };
23 27 };
... ...
... ... @@ -133,7 +133,6 @@
133 133 [oldCategory, category].some((item) => item === PackagesCategoryEnum.CONTROL) &&
134 134 oldCategory !== category &&
135 135 firstEnter;
136   -
137 136 dataSource.value = unref(dataSource).map((item) => ({
138 137 ...item,
139 138 ...(needReset ? { attribute: null } : {}),
... ... @@ -248,6 +247,7 @@
248 247 componentKey: TextComponent1Config.key,
249 248 categoryKey: PackagesCategoryEnum.TEXT,
250 249 };
  250 + dataSource.value = [];
251 251 loading.value = false;
252 252 }
253 253 };
... ...