perf: 优化无数据源数据展示
This commit is contained in:
parent
530bb98782
commit
88764d77a8
@ -4,7 +4,6 @@ import { Decorates03Config } from './index'
|
|||||||
import cloneDeep from 'lodash/cloneDeep'
|
import cloneDeep from 'lodash/cloneDeep'
|
||||||
|
|
||||||
export const option = {
|
export const option = {
|
||||||
dataset: '装饰-03',
|
|
||||||
textColor: '#fff',
|
textColor: '#fff',
|
||||||
textSize: 24,
|
textSize: 24,
|
||||||
colors: ['#1dc1f5', '#1dc1f5'],
|
colors: ['#1dc1f5', '#1dc1f5'],
|
||||||
|
@ -164,21 +164,23 @@ const dimensionsAndSourceHandle = () => {
|
|||||||
watch(
|
watch(
|
||||||
() => targetData.value?.option?.dataset,
|
() => targetData.value?.option?.dataset,
|
||||||
(
|
(
|
||||||
newData: {
|
newData?: {
|
||||||
source: any
|
source: any
|
||||||
dimensions: any
|
dimensions: any
|
||||||
} | null
|
} | null
|
||||||
) => {
|
) => {
|
||||||
if (newData && isObject(newData)) {
|
if (newData && targetData?.value?.chartConfig?.chartFrame === ChartFrameEnum.ECHARTS) {
|
||||||
// 只有 Echarts 数据才有对应的格式
|
// 只有 DataSet 数据才有对应的格式
|
||||||
source.value = newData
|
source.value = newData
|
||||||
if (isCharts.value) {
|
if (isCharts.value) {
|
||||||
dimensions.value = newData.dimensions
|
dimensions.value = newData.dimensions
|
||||||
dimensionsAndSource.value = dimensionsAndSourceHandle()
|
dimensionsAndSource.value = dimensionsAndSourceHandle()
|
||||||
}
|
}
|
||||||
} else {
|
} else if (newData !== undefined && newData !== null) {
|
||||||
dimensionsAndSource.value = null
|
dimensionsAndSource.value = null
|
||||||
source.value = newData
|
source.value = newData
|
||||||
|
} else {
|
||||||
|
source.value = '此组件无数据源'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="go-chart-configurations-data" v-if="targetData">
|
<div class="go-chart-configurations-data" v-if="targetData">
|
||||||
<setting-item-box name="请求方式" :alone="true">
|
<setting-item-box name="请求方式" :alone="true">
|
||||||
<n-select
|
<n-select v-model:value="targetData.request.requestDataType" :disabled="isNotData" :options="selectOptions" />
|
||||||
v-model:value="targetData.request.requestDataType"
|
|
||||||
:options="selectOptions"
|
|
||||||
/>
|
|
||||||
</setting-item-box>
|
</setting-item-box>
|
||||||
|
|
||||||
<!-- 静态 -->
|
<!-- 静态 -->
|
||||||
<chart-data-static
|
<chart-data-static v-if="targetData.request.requestDataType === RequestDataTypeEnum.STATIC"></chart-data-static>
|
||||||
v-if="targetData.request.requestDataType === RequestDataTypeEnum.STATIC"
|
|
||||||
></chart-data-static>
|
|
||||||
|
|
||||||
<!-- 动态 -->
|
<!-- 动态 -->
|
||||||
<chart-data-ajax v-else></chart-data-ajax>
|
<chart-data-ajax v-else></chart-data-ajax>
|
||||||
@ -18,6 +13,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue'
|
||||||
import { SettingItemBox } from '@/components/Pages/ChartItemSetting'
|
import { SettingItemBox } from '@/components/Pages/ChartItemSetting'
|
||||||
import { useTargetData } from '../hooks/useTargetData.hook'
|
import { useTargetData } from '../hooks/useTargetData.hook'
|
||||||
import { ChartDataStatic } from './components/ChartDataStatic/index'
|
import { ChartDataStatic } from './components/ChartDataStatic/index'
|
||||||
@ -38,4 +34,9 @@ const selectOptions: SelectCreateDataType[] = [
|
|||||||
value: RequestDataTypeEnum.AJAX
|
value: RequestDataTypeEnum.AJAX
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
</script>
|
|
||||||
|
// 无数据源
|
||||||
|
const isNotData = computed(() => {
|
||||||
|
return typeof targetData.value?.option?.dataset === 'undefined'
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user