fix: active widgets

This commit is contained in:
Qiuxia Fan 2022-01-13 14:17:31 +08:00
parent 4efbe48664
commit a467269a67
2 changed files with 11 additions and 2 deletions

View File

@ -74,7 +74,10 @@ limitations under the License. -->
@click="clickTabGrid($event, item)"
:class="{ active: activeTabWidget === item.i }"
>
<Widget :data="item" :active="activeTabWidget === item.i" />
<Widget
:data="item"
:activeIndex="`${data.i}-${activeTabIndex}-${item.i}`"
/>
</grid-item>
</grid-layout>
<div class="no-data-tips" v-else>Please add widgets.</div>

View File

@ -69,7 +69,7 @@ const props = {
type: Object as PropType<LayoutConfig>,
default: () => ({ widget: {} }),
},
active: { type: Boolean, default: false },
activeIndex: { type: String, default: "" },
};
export default defineComponent({
name: "Widget",
@ -112,8 +112,14 @@ export default defineComponent({
dashboardStore.removeControls(props.data);
}
function editConfig() {
console.log(props.data);
dashboardStore.setConfigPanel(true);
dashboardStore.selectWidget(props.data);
if (props.activeIndex) {
dashboardStore.activeGridItem(props.activeIndex);
} else {
dashboardStore.activeGridItem(props.data.i);
}
}
watch(
() => [props.data.queryMetricType, props.data.metrics],