Commit 0b21afc0a28f3336bd424f318397c63dc6f8f16f

Authored by xp.Huang
2 parents 593d18a5 11cc50c1

Merge branch 'fix/DEFECT-1302' into 'main_dev'

fix: DEFECT-1302修复组件复制功能,复制的组件布局信息为初始化布局信息

See merge request yunteng/thingskit-front!632
... ... @@ -12,10 +12,11 @@
12 12 import { addDataComponent, deleteDataComponent } from '/@/api/dataBoard';
13 13 import { useBoardId } from '../../hooks/useBoardId';
14 14 import { unref, toRaw } from 'vue';
15   - import { ApiDataBoardDataType } from '../../types';
  15 + import { ApiDataBoardDataType, ComponentLayoutType } from '../../types';
16 16 import { useCalcNewWidgetPosition } from '../../hooks/useCalcNewWidgetPosition';
17 17 import { Layout } from 'vue3-grid-layout';
18 18 import { DataComponentRecord } from '/@/api/dataBoard/model';
  19 + import { computed } from 'vue';
19 20
20 21 const props = defineProps<{
21 22 sourceInfo: WidgetDataType;
... ... @@ -72,11 +73,16 @@
72 73 } catch (error) {}
73 74 }
74 75
  76 + const getLayout = computed(() => {
  77 + const { sourceInfo } = props;
  78 + const { id, w, h, x, y } = sourceInfo;
  79 + return { id, w, h, x, y } as ComponentLayoutType;
  80 + });
  81 +
75 82 async function handleCopy() {
76 83 const id = props.sourceInfo.id;
77 84 const copyRecord = props.rawDataSource.componentData.find((item) => item.id === id);
78   - const copyLayout = props.rawDataSource.componentLayout.find((item) => item.id === id);
79   -
  85 + const copyLayout = unref(getLayout);
80 86 const raw = toRaw(copyRecord) as unknown as DataComponentRecord;
81 87
82 88 const layout = useCalcNewWidgetPosition(
... ...
... ... @@ -104,9 +104,10 @@ export const useDataSource = (propsRef: ComputedRef<Recordable>) => {
104 104 */
105 105 const setLayoutInfo = async () => {
106 106 try {
  107 + const layout = getLayoutInfo();
107 108 await updateDataBoardLayout({
108 109 boardId: unref(getBoardId),
109   - layout: getLayoutInfo(),
  110 + layout,
110 111 });
111 112 } catch (error) {}
112 113 };
... ...