|
|
@@ -1,29 +1,28 @@
|
|
|
<template>
|
|
|
- <div class="go-decorates-more-countdown">
|
|
|
- <!-- <n-countdown :duration="50000" :active="true" /> -->
|
|
|
- <n-space :gap="10">
|
|
|
- <flipper
|
|
|
- flip-type="down"
|
|
|
- :count="item"
|
|
|
- :width="flipperWidth"
|
|
|
- :height="flipperHeight"
|
|
|
- :front-color="flipperTextColor"
|
|
|
- :back-color="flipperBgColor"
|
|
|
- :radius="flipperRadius"
|
|
|
- :duration="flipperSpeed"
|
|
|
- v-for="(item, index) in flipperData"
|
|
|
- :key="index"
|
|
|
- />
|
|
|
- </n-space>
|
|
|
- </div>
|
|
|
+ <!-- <n-countdown :duration="50000" :active="true" /> -->
|
|
|
+ <n-space class="go-decorates-more-countdown" :size="flipperGap" align="center" justify="center">
|
|
|
+ <flipper
|
|
|
+ :count="item"
|
|
|
+ :width="flipperWidth"
|
|
|
+ :height="flipperHeight"
|
|
|
+ :front-color="flipperTextColor"
|
|
|
+ :back-color="flipperBgColor"
|
|
|
+ :radius="flipperRadius"
|
|
|
+ :flip-type="flipperType"
|
|
|
+ :duration="flipperSpeed"
|
|
|
+ v-for="(item, index) in flipperData"
|
|
|
+ :key="index"
|
|
|
+ />
|
|
|
+ </n-space>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { PropType, toRefs, watch, computed } from 'vue'
|
|
|
+import { PropType, toRefs, watch, ref } from 'vue'
|
|
|
import { CreateComponentType } from '@/packages/index.d'
|
|
|
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
|
|
import { useChartDataFetch } from '@/hooks'
|
|
|
-import { Flipper } from '@/components/Flipper/index'
|
|
|
+import { Flipper } from '@/components/Flipper'
|
|
|
+import { OptionType } from './config'
|
|
|
|
|
|
const props = defineProps({
|
|
|
chartConfig: {
|
|
|
@@ -35,41 +34,41 @@ const props = defineProps({
|
|
|
const { w, h } = toRefs(props.chartConfig.attr)
|
|
|
|
|
|
const {
|
|
|
- dataset,
|
|
|
flipperLength,
|
|
|
flipperBgColor,
|
|
|
flipperTextColor,
|
|
|
flipperWidth,
|
|
|
flipperHeight,
|
|
|
flipperRadius,
|
|
|
+ flipperGap,
|
|
|
+ flipperType,
|
|
|
flipperSpeed
|
|
|
-} = toRefs(props.chartConfig.option)
|
|
|
+} = toRefs(props.chartConfig.option as OptionType)
|
|
|
|
|
|
-const updateDatasetHandler = (newVal: number) => {
|
|
|
- let datasetVal = dataset?.value as Number
|
|
|
- datasetVal !== undefined && (datasetVal = newVal)
|
|
|
+const flipperData = ref<string[] | number[]>([])
|
|
|
+const getFlipperData = (val: string | number) => {
|
|
|
+ return val
|
|
|
+ .toString()
|
|
|
+ .padStart(flipperLength.value, '0') // 左侧填充|右对齐
|
|
|
+ .split('') // 转数组
|
|
|
+ .slice(flipperLength.value * -1) // 从右向左取
|
|
|
+}
|
|
|
+const updateDatasetHandler = (newVal: string | number) => {
|
|
|
+ flipperData.value = getFlipperData(newVal)
|
|
|
}
|
|
|
|
|
|
watch(
|
|
|
- props.chartConfig.option.dataset,
|
|
|
- (newVal: number) => {
|
|
|
- updateDatasetHandler(newVal)
|
|
|
+ () => props.chartConfig.option,
|
|
|
+ newVal => {
|
|
|
+ updateDatasetHandler((newVal as OptionType).dataset)
|
|
|
},
|
|
|
{
|
|
|
- immediate: true
|
|
|
+ immediate: true,
|
|
|
+ deep: true
|
|
|
}
|
|
|
)
|
|
|
|
|
|
-const flipperData = computed(() => {
|
|
|
- const datasetVal: Number = dataset?.value || 0
|
|
|
- return datasetVal
|
|
|
- .toString()
|
|
|
- .padStart(flipperLength.value, '0')
|
|
|
- .split('')
|
|
|
- .slice(flipperLength.value * -1)
|
|
|
-})
|
|
|
-
|
|
|
-useChartDataFetch(props.chartConfig, useChartEditStore, (newVal: number) => {
|
|
|
+useChartDataFetch(props.chartConfig, useChartEditStore, (newVal: string | number) => {
|
|
|
updateDatasetHandler(newVal)
|
|
|
})
|
|
|
</script>
|
|
|
@@ -78,8 +77,5 @@ useChartDataFetch(props.chartConfig, useChartEditStore, (newVal: number) => {
|
|
|
@include go('decorates-more-countdown') {
|
|
|
width: v-bind('`${w}px`');
|
|
|
height: v-bind('`${h}px`');
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- justify-content: center;
|
|
|
}
|
|
|
</style>
|