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

View File

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

View File

@ -133,8 +133,24 @@ const fetchCorpsData = async (option: string) => {
// } // }
// 使 // 使
await getStaticData(key, props.chartConfig.option.componentIndexKey, props.chartConfig.option.sceneCode); 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) { } catch (error) {
console.error('获取企业数据失败:', error) console.error('获取企业数据失败:', error)
displayData.value = [] displayData.value = []

View File

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

View File

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

View File

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

View File

@ -1,5 +1,15 @@
<template> <template>
<collapse-item name="信息" :expanded="true"> <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-box name="标题" :alone="true">
<setting-item> <setting-item>
<n-input v-model:value="optionData.title" type="textarea" size="small"></n-input> <n-input v-model:value="optionData.title" type="textarea" size="small"></n-input>

View File

@ -12,7 +12,7 @@
marginLeft: option.paddingX + 'px', marginLeft: option.paddingX + 'px',
marginTop: option.paddingY + 'px', marginTop: option.paddingY + 'px',
letterSpacing: option.letterSpacing + 'px' letterSpacing: option.letterSpacing + 'px'
}">{{ option.title }}</span> }">{{ option.titleText }}</span>
</div> </div>
</div> </div>
<a class="link" :style="{ color: option.linkColor }">{{ option.linkText }}</a> <a class="link" :style="{ color: option.linkColor }">{{ option.linkText }}</a>
@ -64,11 +64,13 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { PropType, computed } from 'vue' import { PropType, computed, onMounted, ref, watch } from 'vue'
import { option as configOption } from './config' import { option as configOption } from './config'
import bg1 from './assets/6.png' import bg1 from './assets/6.png'
import bg2 from './assets/04.png' import bg2 from './assets/04.png'
import SmallBorder from '../SmallBorder/index.vue' import SmallBorder from '../SmallBorder/index.vue'
import { WorkshopSceneConfig } from './index'
import axios from 'axios'
const backgrounds = [bg1, bg2] const backgrounds = [bg1, bg2]
@ -79,7 +81,71 @@ const props = defineProps({
} }
}) })
const option = computed(() => props.chartConfig.option) 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> </script>
<style lang="scss" scoped> <style lang="scss" scoped>