fix: update layout config

This commit is contained in:
Qiuxia Fan 2022-03-03 19:19:37 +08:00
parent c7c6fd18fd
commit f904792eca
3 changed files with 24 additions and 3 deletions

View File

@ -56,7 +56,9 @@ limitations under the License. -->
:row-height="10" :row-height="10"
:is-draggable="true" :is-draggable="true"
:is-resizable="true" :is-resizable="true"
@layout-updated="layoutUpdatedEvent" :vertical-compact="true"
:use-css-transforms="true"
:responsive="true"
> >
<grid-item <grid-item
v-for="item in dashboardStore.currentTabItems" v-for="item in dashboardStore.currentTabItems"
@ -80,7 +82,7 @@ limitations under the License. -->
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { ref, watch, reactive, defineComponent, toRefs } from "vue"; import { ref, watch, defineComponent, toRefs } from "vue";
import type { PropType } from "vue"; import type { PropType } from "vue";
import { LayoutConfig } from "@/types/dashboard"; import { LayoutConfig } from "@/types/dashboard";
import { useDashboardStore } from "@/store/modules/dashboard"; import { useDashboardStore } from "@/store/modules/dashboard";
@ -116,7 +118,13 @@ export default defineComponent({
function clickTabs(e: Event, idx: number) { function clickTabs(e: Event, idx: number) {
e.stopPropagation(); e.stopPropagation();
activeTabIndex.value = idx; activeTabIndex.value = idx;
dashboardStore.activeGridItem(idx); dashboardStore.activeGridItem(
`${props.data.i}-${activeTabIndex.value}-0`
);
dashboardStore.setCurrentTabItems(
dashboardStore.layout[props.data.i].children[activeTabIndex.value]
.children
);
} }
function removeTab(e: Event) { function removeTab(e: Event) {
e.stopPropagation(); e.stopPropagation();
@ -146,6 +154,14 @@ export default defineComponent({
`${props.data.i}-${activeTabIndex.value}-${item.i}` `${props.data.i}-${activeTabIndex.value}-${item.i}`
); );
} }
function breakpointChangedEvent(newBreakpoint: any, newLayout: any) {
console.log(
"BREAKPOINT CHANGED breakpoint=",
newBreakpoint,
", layout: ",
newLayout
);
}
document.body.addEventListener("click", handleClick, false); document.body.addEventListener("click", handleClick, false);
watch( watch(
() => dashboardStore.activedGridItem, () => dashboardStore.activedGridItem,
@ -170,6 +186,7 @@ export default defineComponent({
removeTab, removeTab,
clickTabs, clickTabs,
layoutUpdatedEvent, layoutUpdatedEvent,
breakpointChangedEvent,
...toRefs(props), ...toRefs(props),
activeTabWidget, activeTabWidget,
dashboardStore, dashboardStore,

View File

@ -128,6 +128,9 @@ export default defineComponent({
watch( watch(
() => [props.data.metricTypes, props.data.metrics], () => [props.data.metricTypes, props.data.metrics],
() => { () => {
if (!dashboardStore.selectedGrid) {
return;
}
if (props.data.i !== dashboardStore.selectedGrid.i) { if (props.data.i !== dashboardStore.selectedGrid.i) {
return; return;
} }

View File

@ -19,6 +19,7 @@ limitations under the License. -->
:row-height="10" :row-height="10"
:is-draggable="true" :is-draggable="true"
:is-resizable="true" :is-resizable="true"
:responsive="true"
@layout-updated="layoutUpdatedEvent" @layout-updated="layoutUpdatedEvent"
> >
<grid-item <grid-item