config.vue 1.77 KB
<template>
  <collapse-item :name="t('information.attribute')" :expanded="true">
    <setting-item-box :name="t('information.uploadImage')" :alone="true">
      <setting-item>
        <TKUpload
          :uploadImageUrl="props.optionData.dataset"
          @sendFile="handleSendFile"
          @removeFile="handleRemoveFile"
        />
      </setting-item>
    </setting-item-box>
    <setting-item-box :name="t('common.styleText')">
      <setting-item :name="t('common.typeText')">
        <n-select v-model:value="optionData.fit" size="small" :options="fitList"></n-select>
      </setting-item>
      <setting-item :name="t('charts.chart.filletText')">
        <n-input-number
          v-model:value="optionData.borderRadius"
          size="small"
          :min="0"
          :placeholder="t('information.fillet')"
        ></n-input-number>
      </setting-item>
    </setting-item-box>
  </collapse-item>
</template>

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

const props = defineProps({
  optionData: {
    type: Object as PropType<typeof option>,
    required: true
  }
})
const  t = window['$t']

const handleSendFile = (file: string) => {
  if (!file) return
  props.optionData.dataset = file
}

const handleRemoveFile = (status: boolean) => (status ? (props.optionData.dataset = '') : null)

// 适应类型
const fitList = [
  {
    value: 'fill',
    label: 'fill'
  },
  {
    value: 'contain',
    label: 'contain'
  },
  {
    value: 'cover',
    label: 'cover'
  },
  {
    value: 'scale-down',
    label: 'scale-down'
  },
  {
    value: 'none',
    label: 'none'
  }
]
</script>