全工厂统计概览页面完成

This commit is contained in:
2026-09-30 14:49:22 +08:00
parent 8206121d46
commit 071d751f79
10 changed files with 522 additions and 300 deletions
+31 -5
View File
@@ -6,7 +6,8 @@ defineOptions({
name: 'RingChart'
});
const props = defineProps<{ data?: { name: string; value: number }[]; colors?: string[] }>();
const props = defineProps<{ data?: { name: string; value: number }[] }>();
const chartData = ref<{ name: string; value: number; }[]>([]);
const { domRef, updateOptions } = useEcharts(() => ({
tooltip: {
@@ -22,9 +23,28 @@ const { domRef, updateOptions } = useEcharts(() => ({
itemStyle: {
borderWidth: 0
},
textStyle: {
rich: {
name: {
padding: [0, 0, 0, 0],
},
count: {
padding: [0, 0, 0, 5],
fontWeight: 600,
},
}
},
formatter: function (name: string) {
var info = chartData.value?.find((item: { name: string }) => item.name === name);
if(info){
return '{name|'+name+'} {count|'+(info.value)+'}';
}else{
return name;
}
}
},
title: {
text: `{a|39}\n{b|本专业变更}`,
text: '',
textStyle: {
rich: {
a: {
@@ -50,7 +70,7 @@ const { domRef, updateOptions } = useEcharts(() => ({
series: [
{
type: 'pie',
color: ['#5da8ff', '#8e9dff', '#fedc69', '#26deca'],
color: ["#2080f0", "#7CC242", "#F5A623"],
radius: ['45%', '65%'],
center: ['50%', '45%'],
avoidLabelOverlap: false,
@@ -72,8 +92,14 @@ const { domRef, updateOptions } = useEcharts(() => ({
function init() {
updateOptions(opts => {
opts.series[0].data = props.data || [];
opts.series[0].color = props.colors || [];
const total = props.data?.reduce((sum:number, item:any) => sum + item.count, 0);
const result:any = props.data?.map((item:any) => ({
name: item.label,
value: item.count,
}));
chartData.value = result || [];
opts.title.text = `{a|${total}}\n{b|本专业变更}`;
opts.series[0].data = result || [];
return opts;
});
}