config.vue 5.82 KB
<template>
  <collapse-item name="展示方式" :expanded="true">
    <setting-item-box name="选择方式">
      <n-select v-model:value="optionData.isPanel" size="small" :options="panelOptions" />
    </setting-item-box>
  </collapse-item>
  <collapse-item name="时间配置" :expanded="true">
    <setting-item-box name="快捷选择">
      <setting-item name="日期">
        <n-select @change="shortCutSelect" v-model:value="optionData.shortcut" size="small" :options="intervalOption" />
      </setting-item>
    </setting-item-box>
    <setting-item-box name="基础">
      <setting-item name="类型">
        <n-select v-model:value="optionData.componentInteractEventKey" size="small" :options="datePickerTypeOptions" />
      </setting-item>
    </setting-item-box>
    <setting-item-box name="默认值" :alone="true">
      <n-date-picker size="small" v-model:value="optionData.dataset" :type="optionData.componentInteractEventKey" />
    </setting-item-box>
    <setting-item-box :alone="true">
      <template #name>
        <n-text>动态</n-text>
        <n-tooltip trigger="hover">
          <template #trigger>
            <n-icon size="21" :depth="3">
              <help-outline-icon></help-outline-icon>
            </n-icon>
          </template>
          <n-text>动态值不为0时,默认值:取当天时间相加当前值</n-text>
        </n-tooltip>
      </template>
      <n-input-number v-model:value="optionData.differValue" class="input-num-width" size="small" :min="-40" :max="40">
        <template #suffix> 天 </template>
      </n-input-number>
    </setting-item-box>
    <setting-item-box name="文字颜色" :alone="true">
      <SettingItem name="颜色">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.selectStyleOptions.textColor"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button size="small" @click="optionData.selectStyleOptions.textColor = '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.selectStyleOptions.textBackgroundColor"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button size="small" @click="optionData.selectStyleOptions.textBackgroundColor = 'white'">
          恢复默认
        </n-button>
      </SettingItem>
    </setting-item-box>
    <setting-item-box name="透明度" :alone="true">
      <SettingItem name="透明度">
        <n-input-number
          :min="0"
          :max="1"
          v-model:value="optionData.selectStyleOptions.textBackgroundColorAlpha"
          clearable
        />
      </SettingItem>
    </setting-item-box>
    <setting-item-box name="弹出框背景色" :alone="true">
      <SettingItem name="背景色">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.selectStyleOptions.textSelectModalBackgroundColor"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button size="small" @click="optionData.selectStyleOptions.textSelectModalBackgroundColor = 'white'">
          恢复默认
        </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.selectStyleOptions.textSelectModalTextColor"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button size="small" @click="optionData.selectStyleOptions.textSelectModalTextColor = '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.selectStyleOptions.iconColor"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button size="small" @click="optionData.selectStyleOptions.iconColor = 'black'"> 恢复默认 </n-button>
      </SettingItem>
    </setting-item-box>
  </collapse-item>
</template>

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

const { HelpOutlineIcon } = icon.ionicons5

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

const panelOptions = [
  {
    label: '下拉展示',
    value: 0
  },
  {
    label: '面板展示',
    value: 1
  }
]

const datePickerTypeOptions = [
  {
    label: '日期',
    value: ComponentInteractEventEnum.DATE
  },
  {
    label: '日期时间',
    value: ComponentInteractEventEnum.DATE_TIME
  },
  {
    label: '日期范围',
    value: ComponentInteractEventEnum.DATE_RANGE
  },
  {
    label: '月份',
    value: ComponentInteractEventEnum.MONTH
  },
  {
    label: '月份范围',
    value: ComponentInteractEventEnum.MONTH_RANGE
  },
  {
    label: '年份',
    value: ComponentInteractEventEnum.YEAR
  },
  {
    label: '年份范围',
    value: ComponentInteractEventEnum.YEAR_RANGE
  },
  {
    label: '季度',
    value: ComponentInteractEventEnum.QUARTER
  },
  {
    label: '季度范围',
    value: ComponentInteractEventEnum.QUARTER_RANGE
  }
]

const shortCutSelect = (value: number) => {
  const startTs = Date.now() - value
  const endTs = Date.now()
  props.optionData.dataset = [startTs, endTs] as any
}
</script>