feat:标签选择器增加默认值选项

This commit is contained in:
lyx 2023-06-02 17:29:18 +08:00
parent 2f43ddd59b
commit 84f6bfcb8a
2 changed files with 9 additions and 2 deletions

View File

@ -1,8 +1,11 @@
<template>
<collapse-item name="标签页配置" :expanded="true">
<setting-item-box name="默认值" :alone="true">
<setting-item-box name="标签类型" :alone="true">
<n-select size="small" v-model:value="optionData.tabType" :options="tabTypeOptions" />
</setting-item-box>
<setting-item-box name="默认值" :alone="true">
<n-select size="small" v-model:value="optionData.tabLabel" value-field="label" :options="optionData.dataset" />
</setting-item-box>
</collapse-item>
</template>

View File

@ -1,5 +1,5 @@
<template>
<n-tabs :type="option.value.tabType" @update:value="onChange">
<n-tabs :type="option.value.tabType" @update:value="onChange" :default-value="option.value.tabLabel">
<n-tab v-for="(item, index) in option.value.dataset" :name="item.label" :key="index"> {{ item.label }} </n-tab>
</n-tabs>
</template>
@ -12,6 +12,7 @@ import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore
import { useChartInteract } from '@/hooks'
import { InteractEventOn } from '@/enums/eventEnum'
import { ComponentInteractParamsEnum } from './interact'
import { changeURLStatic } from '@/utils/changeURLParam'
const props = defineProps({
chartConfig: {
@ -29,6 +30,9 @@ const option = shallowReactive({
const onChange = (v: string) => {
if (v === undefined) return
const selectItem = option.value.dataset.find((item: { label: string; value: any }) => item.label === v)
const { chartConfig } = props
const key = chartConfig.chartConfig.title || chartConfig.id;
changeURLStatic(key, selectItem.value)
//
useChartInteract(
props.chartConfig,