Skip to content

Commit b28be3b

Browse files
committed
fix: tab add component
1 parent a64119e commit b28be3b

File tree

1 file changed

+8
-9
lines changed
  • frontend/src/views/dashboard/components/sq-tab

1 file changed

+8
-9
lines changed

frontend/src/views/dashboard/components/sq-tab/index.vue

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import DragHandle from '@/views/dashboard/canvas/DragHandle.vue'
1515
import { ArrowDown } from '@element-plus/icons-vue'
1616
import DashboardEditor from '@/views/dashboard/editor/DashboardEditor.vue'
1717
18-
const editableTabsValue = ref(null)
1918
const showTabTitleFlag = ref(true)
2019
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
2120
let currentInstance
@@ -54,7 +53,6 @@ const props = defineProps({
5453
const { configItem } = toRefs(props)
5554
5655
const state = reactive({
57-
activeTabName: '',
5856
curItem: { title: '' },
5957
textarea: '',
6058
dialogVisible: false,
@@ -75,7 +73,7 @@ function addTab() {
7573
}
7674
configItem.value.propValue.push(newTab)
7775
configItem.value.activeSubTabIndex = configItem.value.propValue.length - 1
78-
editableTabsValue.value = newTab.name
76+
configItem.value.activeTabName = newTab.name
7977
}
8078
8179
function deleteCur(param: any) {
@@ -86,7 +84,7 @@ function deleteCur(param: any) {
8684
configItem.value.propValue.splice(len, 1)
8785
const activeIndex =
8886
(len - 1 + configItem.value.propValue.length) % configItem.value.propValue.length
89-
editableTabsValue.value = configItem.value.propValue[activeIndex].name
87+
configItem.value.activeTabName = configItem.value.propValue[activeIndex].name
9088
configItem.value.activeSubTabIndex = configItem.value.propValue.length - 1
9189
state.tabShow = false
9290
nextTick(() => {
@@ -97,7 +95,7 @@ function deleteCur(param: any) {
9795
}
9896
9997
function editCurTitle(param: any) {
100-
state.activeTabName = param.name
98+
configItem.value.activeTabName = param.name
10199
state.curItem = param
102100
state.textarea = param.title
103101
state.dialogVisible = true
@@ -149,7 +147,7 @@ const titleValid = computed(() => {
149147
150148
const titleStyle = (itemName: string) => {
151149
let style = {}
152-
if (editableTabsValue.value === itemName) {
150+
if (configItem.value.activeTabName === itemName) {
153151
style = {
154152
fontSize: '16px',
155153
}
@@ -164,7 +162,8 @@ const titleStyle = (itemName: string) => {
164162
onMounted(() => {
165163
currentInstance = getCurrentInstance()
166164
if (configItem.value.propValue.length > 0) {
167-
editableTabsValue.value = configItem.value.propValue[0].name
165+
configItem.value.activeTabName = configItem.value.propValue[0].name
166+
console.log('test1')
168167
}
169168
})
170169
@@ -177,7 +176,7 @@ defineExpose({
177176
<div :class="{ 'tab-moveout': configItem.moveOutActive }">
178177
<drag-handle></drag-handle>
179178
<custom-tab
180-
v-model="editableTabsValue"
179+
v-model="configItem.activeTabName"
181180
:addable="isEditMode"
182181
:font-color="state.headFontColor"
183182
:active-color="state.headFontActiveColor"
@@ -230,7 +229,7 @@ defineExpose({
230229
v-for="(tabItem, index) in configItem.propValue"
231230
:key="tabItem.name + '-content'"
232231
class="tab-content-custom"
233-
:class="{ 'switch-hidden': editableTabsValue !== tabItem.name }"
232+
:class="{ 'switch-hidden': configItem.activeTabName !== tabItem.name }"
234233
>
235234
<SQPreview
236235
v-if="showPosition === 'preview'"

0 commit comments

Comments
 (0)