Commit 60192cc766a9e0dedc58d80fefa0455eb340164b

Authored by xp.Huang
2 parents 1644ffa8 61f1f497

Merge branch 'fix/data-board-create-component' into 'main_dev'

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

See merge request yunteng/thingskit-front!707
@@ -40,7 +40,7 @@ @@ -40,7 +40,7 @@
40 40
41 const [registerModal, { openModal }] = useModal(); 41 const [registerModal, { openModal }] = useModal();
42 42
43 - const { trackUpdate, triggerUpdate } = useUpdateQueue(props); 43 + const { trackUpdate, triggerUpdate, clear } = useUpdateQueue(props);
44 44
45 const spinning = ref(false); 45 const spinning = ref(false);
46 46
@@ -156,6 +156,9 @@ @@ -156,6 +156,9 @@
156 if (value && value.length) { 156 if (value && value.length) {
157 nextTick(); 157 nextTick();
158 setFormValues(value); 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,5 +19,9 @@ export const useUpdateQueue = (props: { dataSource: DataSourceType[] }) => {
19 return uuid; 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,7 +133,6 @@
133 [oldCategory, category].some((item) => item === PackagesCategoryEnum.CONTROL) && 133 [oldCategory, category].some((item) => item === PackagesCategoryEnum.CONTROL) &&
134 oldCategory !== category && 134 oldCategory !== category &&
135 firstEnter; 135 firstEnter;
136 -  
137 dataSource.value = unref(dataSource).map((item) => ({ 136 dataSource.value = unref(dataSource).map((item) => ({
138 ...item, 137 ...item,
139 ...(needReset ? { attribute: null } : {}), 138 ...(needReset ? { attribute: null } : {}),
@@ -248,6 +247,7 @@ @@ -248,6 +247,7 @@
248 componentKey: TextComponent1Config.key, 247 componentKey: TextComponent1Config.key,
249 categoryKey: PackagesCategoryEnum.TEXT, 248 categoryKey: PackagesCategoryEnum.TEXT,
250 }; 249 };
  250 + dataSource.value = [];
251 loading.value = false; 251 loading.value = false;
252 } 252 }
253 }; 253 };