fix:修复数据源
This commit is contained in:
parent
30d47df4bd
commit
b61bdc54e3
@ -18,9 +18,22 @@
|
|||||||
<n-dropdown v-if='option.isShowButton' trigger="hover" :options="dropdownOptions" @select="handleSelect">
|
<n-dropdown v-if='option.isShowButton' trigger="hover" :options="dropdownOptions" @select="handleSelect">
|
||||||
<div class="dropdown-button">
|
<div class="dropdown-button">
|
||||||
{{ selectedOption }}
|
{{ selectedOption }}
|
||||||
<svg-icon icon-class="arrow-down" class="arrow-down-icon" />
|
<div class="arrow-down-icon">
|
||||||
|
<svg viewBox="0 0 1024 1024" width="14" height="14">
|
||||||
|
<path
|
||||||
|
d="M512 768c-6.3 0-12.6-2.4-17.4-7.3L285.3 551.4c-9.8-9.8-9.8-25.6 0-35.4s25.6-9.8 35.4 0L512 707.3l191.3-191.3c9.8-9.8 25.6-9.8 35.4 0s9.8 25.6 0 35.4L529.4 760.7c-4.8 4.9-11.1 7.3-17.4 7.3z"
|
||||||
|
fill="currentColor"></path>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</n-dropdown>
|
</n-dropdown>
|
||||||
|
<!-- <n-dropdown v-if='option.isShowButton' trigger="hover" :options="dropdownOptions" @select="handleSelect">
|
||||||
|
<div class="dropdown-button">
|
||||||
|
{{ selectedOption }}
|
||||||
|
<svg-icon icon-class="arrow-down" class="arrow-down-icon" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</n-dropdown> -->
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<ul>
|
<ul>
|
||||||
@ -51,7 +64,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, PropType, onMounted } from 'vue'
|
import { ref, computed, PropType, onMounted, watch } from 'vue'
|
||||||
import { option as configOption } from './config'
|
import { option as configOption } from './config'
|
||||||
import SmallBorder from '../SmallBorder/index.vue'
|
import SmallBorder from '../SmallBorder/index.vue'
|
||||||
import CustomSelect from './select.vue'
|
import CustomSelect from './select.vue'
|
||||||
@ -80,11 +93,11 @@ const dropdownOptions = computed(() => {
|
|||||||
|
|
||||||
// 修改:基于API数据计算进度条宽度
|
// 修改:基于API数据计算进度条宽度
|
||||||
const calculateWidth = (value: number) => {
|
const calculateWidth = (value: number) => {
|
||||||
if (displayData.value.length === 0 || displayData.value[0].alarmCount === 0) {
|
if (displayData.value.length === 0 || displayData.value[0].value === 0) {
|
||||||
return '0%'
|
return '0%'
|
||||||
}
|
}
|
||||||
const firstRowValue = displayData.value[0].alarmCount
|
const firstRowValue = displayData.value[0].value
|
||||||
return `${(value / firstRowValue) * 100}%` // 当前行的alarmCount/第一行的alarmCount值
|
return `${(value / firstRowValue) * 100}%` // 当前行的value/第一行的value值
|
||||||
}
|
}
|
||||||
const key = TopAlarmsConfig.key;
|
const key = TopAlarmsConfig.key;
|
||||||
const getStaticData = async (key: string, componentIndexKey: string, sceneCode: string) => {
|
const getStaticData = async (key: string, componentIndexKey: string, sceneCode: string) => {
|
||||||
@ -138,7 +151,20 @@ const handleSelectChange = async (value: any) => {
|
|||||||
await fetchCorpsData(value)
|
await fetchCorpsData(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => [
|
||||||
|
props.chartConfig.option.sceneCode,
|
||||||
|
props.chartConfig.option.componentIndexKey,
|
||||||
|
props.chartConfig.option.dataset
|
||||||
|
],
|
||||||
|
async () => {
|
||||||
|
await fetchCorpsData('day');
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true,
|
||||||
|
deep: true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
// 新增:组件挂载时初始化数据
|
// 新增:组件挂载时初始化数据
|
||||||
|
Loading…
Reference in New Issue
Block a user