config.vue 3.43 KB
<template>
  <collapse-item name="标签页配置" :expanded="true">
    <setting-item-box name="默认值" :alone="true">
      <n-select size="small" v-model:value="optionData.tabType" :options="tabTypeOptions" @change="onHandleSelect" />
    </setting-item-box>
    <setting-item-box name="默认文字" :alone="true">
      <SettingItem name="大小">
        <n-input v-model:value="optionData.customTabCss.labelTextSize" />
      </SettingItem>
      <SettingItem name="颜色">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.customTabCss.labelDefaultColor"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button size="small" @click="optionData.customTabCss.labelDefaultColor = 'black'"> 恢复默认 </n-button>
      </SettingItem>
    </setting-item-box>
    <setting-item-box name="激活文字" :alone="true">
      <SettingItem name="颜色">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.customTabCss.labelActiveColor"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button size="small" @click="optionData.customTabCss.labelActiveColor = 'green'"> 恢复默认 </n-button>
      </SettingItem>
    </setting-item-box>
    <setting-item-box name="底部条颜色" :alone="true">
      <SettingItem name="颜色">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.customTabCss.tabBottomBarColor"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button size="small" @click="optionData.customTabCss.tabBottomBarColor = 'green'"> 恢复默认 </n-button>
      </SettingItem>
    </setting-item-box>
    <setting-item-box v-if="optionData.tabType === 'segment'" name="分段背景色" :alone="true">
      <SettingItem name="颜色">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.customTabCss.segmentationBgColor"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button size="small" @click="optionData.customTabCss.segmentationBgColor = 'white'"> 恢复默认 </n-button>
      </SettingItem>
    </setting-item-box>
    <setting-item-box v-if="optionData.tabType === 'segment'" name="分段激活色" :alone="true">
      <SettingItem name="颜色">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.customTabCss.segmentationActiveBgColor"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button size="small" @click="optionData.customTabCss.segmentationActiveBgColor = '#C0C0C0'">
          恢复默认
        </n-button>
      </SettingItem>
    </setting-item-box>
  </collapse-item>
</template>

<script lang="ts" setup>
import { PropType } from 'vue'
import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
import { option } from './config'

const props = defineProps({
  optionData: {
    type: Object as PropType<typeof option>,
    required: true
  }
})

const tabTypeOptions = [
  {
    label: '线条',
    value: 'bar'
  },
  {
    label: '分段',
    value: 'segment'
  }
]
const onHandleSelect = (value: string) => {
  if (value === 'bar') {
    props.optionData.customTabCss.segmentationBgColor = ''
    props.optionData.customTabCss.segmentationActiveBgColor = ''

  }
}
</script>