2022-01-14 16:17:14 +08:00
|
|
|
<template>
|
2022-04-06 21:53:00 +08:00
|
|
|
<div class="go-text-box">
|
|
|
|
<div
|
|
|
|
:style="`
|
|
|
|
color: ${fontColor};
|
2022-04-24 20:02:22 +08:00
|
|
|
padding: ${paddingY}px ${paddingX}px;
|
2022-04-06 21:53:00 +08:00
|
|
|
font-size: ${fontSize}px;
|
|
|
|
letter-spacing: ${letterSpacing}px;
|
|
|
|
writing-mode: ${writingMode};
|
2022-05-01 17:36:23 +08:00
|
|
|
|
|
|
|
border-style: solid;
|
|
|
|
border-width: ${borderWidth}px;
|
|
|
|
border-radius: ${borderRadius}px;
|
|
|
|
border-color: ${borderColor};
|
|
|
|
|
2022-04-06 21:53:00 +08:00
|
|
|
background-color:${backgroundColor}`"
|
2022-04-24 20:02:22 +08:00
|
|
|
>
|
2022-06-25 17:03:03 +08:00
|
|
|
{{ option.dataset }}
|
2022-04-24 20:02:22 +08:00
|
|
|
</div>
|
2022-01-14 16:17:14 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
2022-06-25 17:03:03 +08:00
|
|
|
import { PropType, toRefs, shallowReactive, watch } from 'vue'
|
2022-04-06 21:53:00 +08:00
|
|
|
import { CreateComponentType } from '@/packages/index.d'
|
2022-06-25 17:03:03 +08:00
|
|
|
import { useChartDataFetch } from '@/hooks'
|
|
|
|
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
2022-06-27 20:26:24 +08:00
|
|
|
import { option as configOption } from './config'
|
2022-04-06 21:53:00 +08:00
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
chartConfig: {
|
|
|
|
type: Object as PropType<CreateComponentType>,
|
2022-06-25 17:03:03 +08:00
|
|
|
required: true
|
|
|
|
}
|
2022-04-06 21:53:00 +08:00
|
|
|
})
|
2022-01-14 16:17:14 +08:00
|
|
|
|
2022-04-06 21:53:00 +08:00
|
|
|
const { w, h } = toRefs(props.chartConfig.attr)
|
2022-04-24 20:02:22 +08:00
|
|
|
const {
|
|
|
|
dataset,
|
|
|
|
fontColor,
|
|
|
|
fontSize,
|
|
|
|
letterSpacing,
|
|
|
|
paddingY,
|
|
|
|
paddingX,
|
2022-05-01 17:36:23 +08:00
|
|
|
borderWidth,
|
|
|
|
borderColor,
|
2022-04-24 20:02:22 +08:00
|
|
|
borderRadius,
|
|
|
|
writingMode,
|
2022-06-25 17:03:03 +08:00
|
|
|
backgroundColor
|
2022-04-24 20:02:22 +08:00
|
|
|
} = toRefs(props.chartConfig.option)
|
2022-06-25 17:03:03 +08:00
|
|
|
|
|
|
|
const option = shallowReactive({
|
2022-06-27 20:26:24 +08:00
|
|
|
dataset: configOption.dataset
|
2022-06-25 17:03:03 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
// 手动更新
|
|
|
|
watch(
|
|
|
|
() => props.chartConfig.option.dataset,
|
|
|
|
(newData: any) => {
|
|
|
|
option.dataset = newData
|
|
|
|
}, {
|
|
|
|
immediate: true
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
// 预览更新
|
2022-06-27 20:26:24 +08:00
|
|
|
useChartDataFetch(props.chartConfig, useChartEditStore, (newData: string) => {
|
2022-06-25 17:03:03 +08:00
|
|
|
option.dataset = newData
|
|
|
|
})
|
2022-01-14 16:17:14 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2022-04-24 20:02:22 +08:00
|
|
|
@include go('text-box') {
|
2022-04-06 21:53:00 +08:00
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
}
|
|
|
|
</style>
|