tabs组件优化
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<template>
|
||||
<avue-draggable
|
||||
:data-widget-index="index"
|
||||
:step="step"
|
||||
:width="widgetsWidth"
|
||||
:height="widgetsHeight"
|
||||
@@ -12,7 +13,15 @@
|
||||
@blur="handleBlur"
|
||||
>
|
||||
<!-- :z-index="-1" -->
|
||||
<component :is="type" :widget-index="index" :value="value"/>
|
||||
<component
|
||||
:is="type"
|
||||
:widget-index="index"
|
||||
:value="value"
|
||||
@childActivated="handleChildActivated"
|
||||
@innerDragStart="handleInnerDragStart"
|
||||
@innerDragEnd="handleInnerDragEnd"
|
||||
@tabsHeaderMouseDown="handleTabsHeaderMouseDown"
|
||||
/>
|
||||
</avue-draggable>
|
||||
</template>
|
||||
|
||||
@@ -148,6 +157,8 @@ export default {
|
||||
/* leftMargin: null,
|
||||
topMargin: null*/
|
||||
},
|
||||
// 当 Tabs 内部拖拽子组件时,暂时禁用外层 avue-draggable,防止整个 Tabs 被拖动
|
||||
innerDragging: false,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -167,7 +178,11 @@ export default {
|
||||
return this.value.position.zIndex || 1;
|
||||
},
|
||||
widgetDisabled() {
|
||||
return this.value.position.disabled || false;
|
||||
// Tabs 必须禁用外层拖拽,内部子组件才能选中;Tabs 整体拖动改由标题栏单独处理
|
||||
if (this.type === 'widget-tabs') {
|
||||
return true;
|
||||
}
|
||||
return this.value.position.disabled || this.innerDragging || false;
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
@@ -220,6 +235,26 @@ export default {
|
||||
});
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 接收 Tabs 内部子组件发出的激活事件,并转发给设计器主页面
|
||||
*/
|
||||
handleChildActivated(payload) {
|
||||
const info = Object.assign({}, payload || {});
|
||||
if (info.rootWidgetIndex === undefined || info.rootWidgetIndex === null) {
|
||||
info.rootWidgetIndex = this.index;
|
||||
}
|
||||
this.$emit("onChildActivated", info);
|
||||
},
|
||||
// Tabs 内部开始拖拽/点击子组件时,暂时禁用外层拖拽
|
||||
handleInnerDragStart() {
|
||||
this.innerDragging = true;
|
||||
},
|
||||
handleInnerDragEnd() {
|
||||
this.innerDragging = false;
|
||||
},
|
||||
handleTabsHeaderMouseDown(evt) {
|
||||
this.$emit('onTabsHeaderMouseDown', { event: evt, rootWidgetIndex: this.index });
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user