| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <template>
- <n-progress
- :type="type"
- :height="h"
- :processing="processing"
- :percentage="option.dataset"
- :indicator-placement="indicatorPlacement"
- :color="color"
- :rail-color="railColor"
- :offset-degree="offsetDegree"
- >
- <n-text
- :style="{
- color: indicatorTextColor,
- fontSize: `${indicatorTextSize}px`
- }"
- >
- {{option.dataset}} {{unit}}
- </n-text>
- </n-progress>
- </template>
- <script setup lang="ts">
- import { PropType, toRefs, watch, shallowReactive } from 'vue'
- import { useChartDataFetch } from '@/hooks'
- import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
- import config, { option as configOption } from './config'
- const props = defineProps({
- chartConfig: {
- type: Object as PropType<config>,
- required: true
- }
- })
- // 取配置数据
- const { w, h } = toRefs(props.chartConfig.attr)
- const {
- type,
- unit,
- color,
- fontSize,
- processing,
- railColor,
- indicatorTextColor,
- indicatorPlacement,
- indicatorTextSize,
- offsetDegree,
- dataset
- } = toRefs(props.chartConfig.option)
- const option = shallowReactive({
- dataset: configOption.dataset
- })
- // 手动更新
- watch(
- () => props.chartConfig.option.dataset,
- (newData: any) => {
- option.dataset = newData
- }
- )
- // 预览更新
- useChartDataFetch(props.chartConfig, useChartEditStore, (newData: number) => {
- option.dataset = newData
- })
- </script>
|