JinZHouXiYiJi_DaPin2/resource/Text/SubText/SubText.vue

64 lines
1.4 KiB
Vue

<template>
<span v-resize="resizeHandler">
{{ propValue.base.label ? `${propValue.base.label}:` : '' }}
{{ customeText }}
{{ propValue.base.unit }}
</span>
</template>
<script setup lang="ts">
import { useData, useEventBus, useProp } from 'open-data-v/base'
import { onMounted, ref } from 'vue'
import { http } from '@/utils/http'
import type SubTextComponent from './config'
import type { SubTextType } from './type'
const props = defineProps<{
component: SubTextComponent
}>()
const { propValue } = useProp<SubTextType>(props.component)
const customeText = ref<string>('0')
const lineHeight = ref<string>('20px')
const resizeHandler = (entry: ResizeObserverEntry) => {
const { height } = entry.contentRect
lineHeight.value = `${height}px`
}
const dataHandler = (event) => {
console.log(event)
customeText.value=event
}
onMounted(async () => {
})
const dataChange = (resp: any, _?: string) => {
console.log(resp)
if (!resp || !resp.data) {
console.log("数据失败-----")
return
}
if (resp.status === 'SUCCESS') {
console.log(resp.data.data)
dataHandler(resp.data.data)
}
}
useData(props.component, dataChange)
useEventBus('globalData', dataHandler)
</script>
<style lang="less" scoped>
span {
pointer-events: none;
display: inline-block;
width: 100%;
text-align: center;
line-height: v-bind(lineHeight);
}
</style>