<!--
 * @Author: walker.liu
 * @Date: 2022-05-30 18:18:10
 * @Copyright（C）:  2019-2020 ZP Inc.   All rights reserved.
-->
<template>
  <div class="dimension-wrapper">
    <t-radio-group
      class="dimension-group"
      v-model="radioCurrent"
      @change="changeDimension"
    >
      <t-radio-button
        v-for="item of radioOptions"
        :value="item.value"
        :key="item.value"
        >{{ item.label }}</t-radio-button
      >
    </t-radio-group>
  </div>
</template>
<script setup lang="tsx">
const props = defineProps({
  current: [String, Number],
  type: String,
  options: {
    type: Array,
    default: () => [],
  },
});
const radioCurrent = ref(props.current);
const radioOptions: any = computed(() => {
  if (props.type === 'analysisDate') {
    return [
      { label: '5M', value: '5m' },
      { label: '30M', value: '30m' },
      { label: '1H', value: '1h' },
      { label: '6H', value: '6h' },
      { label: '1D', value: '1d' },
    ];
  } else if (props.options.length > 0) {
    return props.options;
  } else {
    return [];
  }
});
const emit = defineEmits(['update:current', 'change']);
const changeDimension = (v) => {
  radioCurrent.value = v;
  emit('update:current', v);
  emit('change', v);
};
</script>
