fix:数据

This commit is contained in:
Free-sss 2025-09-04 16:42:32 +08:00
parent b61bdc54e3
commit cb721ad2ce
8 changed files with 264 additions and 153 deletions

View File

@ -162,98 +162,98 @@
]
}
]
}
},
"TopAlarmsHaz": {
"a": {
"titleText": "电动自行车停车场景数企业及场景数量",
"source": [
{
"rank": "TOP1",
"name": "株机公司",
"value": 96
},
{
"rank": "TOP2",
"name": "株洲所",
"value": 34
},
{
"rank": "TOP3",
"name": "时代新材",
"value": 19
},
{
"rank": "TOP4",
"name": "产投公司",
"value": 16
},
{
"rank": "TOP5",
"name": "四方股份",
"value": 12
}
]
},
"TopAlarmsHaz": {
"a": {
"titleText": "电动自行车停放区场景数前五的企业及场景数量",
"source": [
{
"rank": "TOP1",
"name": "株机公司",
"value": 96
},
{
"rank": "TOP2",
"name": "株洲所",
"value": 34
},
{
"rank": "TOP3",
"name": "时代新材",
"value": 19
},
{
"rank": "TOP4",
"name": "产投公司",
"value": 16
},
{
"rank": "TOP5",
"name": "四方股份",
"value": 12
}
]
},
"b": {
"titleText": "电动汽车停车场场景数前五的企业及场景数量",
"source": [
{
"rank": "TOP1",
"name": "株机公司",
"value": 18
},
{
"rank": "TOP2",
"name": "株洲所",
"value": 18
},
{
"rank": "TOP3",
"name": "四方股份",
"value": 20
},
{
"rank": "TOP4",
"name": "时代新材",
"value": 12
},
{
"rank": "TOP5",
"name": "长江集团",
"value": 10
}
]
},
"c": {
"titleText": "生产用电动车停放区场景数前五的企业及场景数量",
"source": [
{
"rank": "TOP1",
"name": "株机公司",
"value": 82
},
{
"rank": "TOP2",
"name": "长客股份",
"value": 63
},
{
"rank": "TOP3",
"name": "四方股份",
"value": 32
},
{
"rank": "TOP4",
"name": "株洲所",
"value": 24
},
{
"rank": "TOP5",
"name": "时代新材",
"value": 22
}
]
}
"b": {
"titleText": "电动汽车停车场场景数企业及场景数量",
"source": [
{
"rank": "TOP1",
"name": "株机公司",
"value": 18
},
{
"rank": "TOP2",
"name": "株洲所",
"value": 18
},
{
"rank": "TOP3",
"name": "四方股份",
"value": 20
},
{
"rank": "TOP4",
"name": "时代新材",
"value": 12
},
{
"rank": "TOP5",
"name": "长江集团",
"value": 10
}
]
},
"c": {
"titleText": "生产用电动车停车场景数企业及场景数量",
"source": [
{
"rank": "TOP1",
"name": "株机公司",
"value": 82
},
{
"rank": "TOP2",
"name": "长客股份",
"value": 63
},
{
"rank": "TOP3",
"name": "四方股份",
"value": 32
},
{
"rank": "TOP4",
"name": "株洲所",
"value": 24
},
{
"rank": "TOP5",
"name": "时代新材",
"value": 22
}
]
}
}
},
@ -419,40 +419,36 @@
}
},
"T04": {
"SceneDistribution": {
"WorkshopScene": {
"a": {
"source": [
{
"title": "危化品库",
"label": "场景总数",
"value": 130,
"color": "#00E5FF",
"image": "scene-total.png"
"name": "危化品库",
"icon": "warehouse",
"metrics": [
{
"label": "场景总数",
"value": 130
},
{
"label": "智控场景",
"value": 0
}
]
},
{
"title": "危化品库",
"label": "智控场景",
"value": 0,
"color": "#FFD700",
"image": "scene-control.png"
}
]
},
"b": {
"source": [
{
"title": "危废品库",
"label": "场景总数",
"value": 152,
"color": "#00E5FF",
"image": "scene-total.png"
},
{
"title": "危废品库",
"label": "智控场景",
"value": 0,
"color": "#FFD700",
"image": "scene-control.png"
"name": "危废品库",
"icon": "warehouse",
"metrics": [
{
"label": "智控场景",
"value": 152
},
{
"label": "场景总数",
"value": 0
}
]
}
]
}
@ -462,32 +458,39 @@
"titleText": "危化品库场景数量前五的企业及场景数量",
"source": [
{
"company": "时代新材",
"quantity": 30
"rank": "TOP1",
"name": "时代新材",
"value": 30
},
{
"company": "株洲所",
"quantity": 16
"rank": "TOP2",
"name": "株洲所",
"value": 16
},
{
"company": "四方股份",
"quantity": 15
"rank": "TOP3",
"name": "四方股份",
"value": 15
},
{
"company": "产投公司",
"quantity": 13
"rank": "TOP4",
"name": "产投公司",
"value": 13
},
{
"company": "长江集团",
"quantity": 11
"rank": "TOP5",
"name": "长江集团",
"value": 11
},
{
"company": "长客股份",
"quantity": 11
"rank": "TOP6",
"name": "长客股份",
"value": 11
},
{
"company": "株机公司",
"quantity": 11
"rank": "TOP7",
"name": "株机公司",
"value": 11
}
]
},
@ -495,24 +498,29 @@
"titleText": "危废品库场景数量前五的企业及场景数量",
"source": [
{
"company": "时代新材",
"quantity": 27
"rank": "TOP1",
"name": "时代新材",
"value": 27
},
{
"company": "株机公司",
"quantity": 26
"rank": "TOP2",
"name": "株机公司",
"value": 26
},
{
"company": "株洲所",
"quantity": 20
"rank": "TOP3",
"name": "株洲所",
"value": 20
},
{
"company": "产投公司",
"quantity": 16
"rank": "TOP4",
"name": "产投公司",
"value": 16
},
{
"company": "长客股份",
"quantity": 12
"rank": "TOP5",
"name": "长客股份",
"value": 12
}
]
}

View File

@ -103,6 +103,15 @@ watch(
{ deep: true, immediate: true }
)
const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => {
updateChartData(newData)
})

View File

@ -133,8 +133,24 @@ const fetchCorpsData = async (option: string) => {
// }
// 使
await getStaticData(key, props.chartConfig.option.componentIndexKey, props.chartConfig.option.sceneCode);
displayData.value = response['source']
props.chartConfig.option.titleText = response['titleText']
//
if (response && response['source'] && Array.isArray(response['source']) && response['source'].length > 0) {
//
const isNewDataDifferent =
!displayData.value ||
displayData.value.length !== response['source'].length ||
JSON.stringify(displayData.value) !== JSON.stringify(response['source']);
//
if (isNewDataDifferent) {
displayData.value = response['source'];
}
}
// 使
if (response && response['titleText']) {
props.chartConfig.option.titleText = response['titleText'];
}
} catch (error) {
console.error('获取企业数据失败:', error)
displayData.value = []

View File

@ -287,8 +287,7 @@ const fetchData = async () => {
watch(
() => [
props.chartConfig.option.sceneCode,
props.chartConfig.option.componentIndexKey,
props.chartConfig.option.dataset
props.chartConfig.option.componentIndexKey
],
async () => {
await fetchData();

View File

@ -197,7 +197,7 @@
</svg>
<div class="go-scene-distribution">
<div class="header-title">{{ option.titleText }}</div>
<div class="header-title">场景分布概况</div>
<div class="content">

View File

@ -2,6 +2,7 @@ import { PublicConfigClass } from '@/packages/public'
import { CreateComponentType } from '@/packages/index.d'
import { WorkshopSceneConfig } from './index'
import dataJson from './data.json'
import { cloneDeep } from 'lodash'
export enum FontWeightEnum {
NORMAL = '常规',
BOLD = '加粗',
@ -22,8 +23,10 @@ export const FontStyleObject = {
[FontStyleEnum.ITALIC]: 'italic',
}
export const option = {
sceneCode: 'T06',
componentIndexKey: "a",
dataset: dataJson.source,
title: '场景分布概况',
titleText: '场景分布概况',
titleColor: '#eee',
titleSize: 16,
iconColor: '#00E5FF',
@ -48,5 +51,5 @@ export const option = {
export default class Config extends PublicConfigClass implements CreateComponentType {
public key = WorkshopSceneConfig.key
public chartConfig = WorkshopSceneConfig
public option = option
public option = cloneDeep(option)
}

View File

@ -1,5 +1,15 @@
<template>
<collapse-item name="信息" :expanded="true">
<setting-item-box name="场景 Code " :alone="true">
<setting-item>
<n-input v-model:value="optionData.sceneCode"></n-input>
</setting-item>
</setting-item-box>
<setting-item-box name="组件 key " :alone="true">
<setting-item>
<n-input v-model:value="optionData.componentIndexKey"></n-input>
</setting-item>
</setting-item-box>
<setting-item-box name="标题" :alone="true">
<setting-item>
<n-input v-model:value="optionData.title" type="textarea" size="small"></n-input>

View File

@ -12,7 +12,7 @@
marginLeft: option.paddingX + 'px',
marginTop: option.paddingY + 'px',
letterSpacing: option.letterSpacing + 'px'
}">{{ option.title }}</span>
}">{{ option.titleText }}</span>
</div>
</div>
<a class="link" :style="{ color: option.linkColor }">{{ option.linkText }}</a>
@ -64,11 +64,13 @@
</template>
<script setup lang="ts">
import { PropType, computed } from 'vue'
import { PropType, computed, onMounted, ref, watch } from 'vue'
import { option as configOption } from './config'
import bg1 from './assets/6.png'
import bg2 from './assets/04.png'
import SmallBorder from '../SmallBorder/index.vue'
import { WorkshopSceneConfig } from './index'
import axios from 'axios'
const backgrounds = [bg1, bg2]
@ -79,7 +81,71 @@ const props = defineProps({
}
})
const option = computed(() => props.chartConfig.option)
const isFetching = ref(false) //
const key = WorkshopSceneConfig.key
//
const getStaticData = async (key: string, componentIndexKey: string, sceneCode: string) => {
try {
const response = await axios.get('/staticData/static.json');
if (response.data) {
console.log('静态数据:', response.data);
const dataTemp = response.data[sceneCode]?.[key]?.[componentIndexKey]?.['source'];
if (!dataTemp) {
console.warn(`Data not found for sceneCode: ${sceneCode}, key: ${key}, componentIndexKey: ${componentIndexKey}`);
return props.chartConfig.option.dataset; //
}
return dataTemp;
}
} catch (err) {
console.error('获取static.json失败:', err);
}
return props.chartConfig.option.dataset; //
}
//
const fetchData = async () => {
//
if (isFetching.value) return;
isFetching.value = true;
try {
let data;
//
data = await getStaticData(key, option.value.componentIndexKey, option.value.sceneCode);
props.chartConfig.option.dataset = data;
if (JSON.stringify(data) !== JSON.stringify(option.value.dataset)) {
console.log('更新数据:', data);
}
} finally {
isFetching.value = false;
}
}
watch(
() => [
props.chartConfig.option.sceneCode,
props.chartConfig.option.componentIndexKey,
],
async () => {
await fetchData();
},
{
immediate: true,
deep: true
}
)
//
onMounted(async () => {
await fetchData();
})
</script>
<style lang="scss" scoped>