|
@@ -124,7 +124,46 @@ function formatAmount(value: number) {
|
|
|
return Number(value || 0).toFixed(2)
|
|
return Number(value || 0).toFixed(2)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function getInventoryChartLayout(chartRef: Ref<HTMLDivElement | undefined>) {
|
|
|
|
|
+ const { clientWidth = 0, clientHeight = 0 } = chartRef.value ?? {}
|
|
|
|
|
+ const compact = clientHeight > 0 && (clientHeight < 210 || clientWidth < 520)
|
|
|
|
|
+
|
|
|
|
|
+ return {
|
|
|
|
|
+ compact,
|
|
|
|
|
+ trendGridTop: compact ? 24 : 32,
|
|
|
|
|
+ trendGridRight: compact ? 12 : THEME.grid.right,
|
|
|
|
|
+ trendGridBottom: compact ? 10 : THEME.grid.bottom,
|
|
|
|
|
+ legendTop: compact ? 0 : 4,
|
|
|
|
|
+ legendRight: compact ? 2 : 6,
|
|
|
|
|
+ legendItemSize: compact ? 9 : 12,
|
|
|
|
|
+ legendGap: compact ? 10 : 16,
|
|
|
|
|
+ legendFontSize: compact ? 11 : 14,
|
|
|
|
|
+ axisFontSize: compact ? 10 : 12,
|
|
|
|
|
+ yAxisLabelWidth: compact ? 96 : 132,
|
|
|
|
|
+ yAxisLabelMargin: compact ? 8 : 12,
|
|
|
|
|
+ distributionTitleTop: compact ? 6 : 18,
|
|
|
|
|
+ distributionTitleFontSize: compact ? 12 : 14,
|
|
|
|
|
+ distributionTitleLineHeight: compact ? 14 : 16,
|
|
|
|
|
+ distributionPieRadius: compact ? ['36%', '54%'] : ['48%', '68%'],
|
|
|
|
|
+ distributionPieCenterY: compact ? '62%' : '57%',
|
|
|
|
|
+ distributionLegendBottom: compact ? 0 : 10,
|
|
|
|
|
+ distributionLegendItemSize: compact ? 9 : 13,
|
|
|
|
|
+ distributionLegendGap: compact ? 8 : 14,
|
|
|
|
|
+ distributionLegendFontSize: compact ? 10 : 14,
|
|
|
|
|
+ pieLabelNameFontSize: compact ? 11 : 13,
|
|
|
|
|
+ pieLabelNameLineHeight: compact ? 18 : 22,
|
|
|
|
|
+ pieLabelValueFontSize: compact ? 16 : 20,
|
|
|
|
|
+ pieLabelValueLineHeight: compact ? 22 : 30,
|
|
|
|
|
+ barWidth: compact ? 8 : 12,
|
|
|
|
|
+ barGap: compact ? '12%' : '5%',
|
|
|
|
|
+ barCategoryGap: compact ? '46%' : '36%',
|
|
|
|
|
+ labelDistance: compact ? 4 : 7,
|
|
|
|
|
+ labelFontSize: compact ? 10 : 12
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function getDistributionOption(data: InventoryItem[]): echarts.EChartsOption {
|
|
function getDistributionOption(data: InventoryItem[]): echarts.EChartsOption {
|
|
|
|
|
+ const layout = getInventoryChartLayout(distributionChartRef)
|
|
|
const inventoryTotal = data.reduce((total, item) => total + item.mayInventoryAmount, 0)
|
|
const inventoryTotal = data.reduce((total, item) => total + item.mayInventoryAmount, 0)
|
|
|
const backlogTotal = data.reduce((total, item) => total + item.mayBacklogAmount, 0)
|
|
const backlogTotal = data.reduce((total, item) => total + item.mayBacklogAmount, 0)
|
|
|
const inventoryPieData = data.map((item) => ({
|
|
const inventoryPieData = data.map((item) => ({
|
|
@@ -146,16 +185,16 @@ function getDistributionOption(data: InventoryItem[]): echarts.EChartsOption {
|
|
|
rich: {
|
|
rich: {
|
|
|
name: {
|
|
name: {
|
|
|
color: THEME.text.regular,
|
|
color: THEME.text.regular,
|
|
|
- fontSize: 13,
|
|
|
|
|
|
|
+ fontSize: layout.pieLabelNameFontSize,
|
|
|
fontWeight: 500,
|
|
fontWeight: 500,
|
|
|
- lineHeight: 22,
|
|
|
|
|
|
|
+ lineHeight: layout.pieLabelNameLineHeight,
|
|
|
fontFamily: FONT_FAMILY
|
|
fontFamily: FONT_FAMILY
|
|
|
},
|
|
},
|
|
|
value: {
|
|
value: {
|
|
|
color: THEME.text.strong,
|
|
color: THEME.text.strong,
|
|
|
- fontSize: 20,
|
|
|
|
|
|
|
+ fontSize: layout.pieLabelValueFontSize,
|
|
|
fontWeight: 700,
|
|
fontWeight: 700,
|
|
|
- lineHeight: 30,
|
|
|
|
|
|
|
+ lineHeight: layout.pieLabelValueLineHeight,
|
|
|
fontFamily: FONT_FAMILY
|
|
fontFamily: FONT_FAMILY
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -185,41 +224,41 @@ function getDistributionOption(data: InventoryItem[]): echarts.EChartsOption {
|
|
|
{
|
|
{
|
|
|
text: `5月底库存金额\n${formatAmount(inventoryTotal)} 万元`,
|
|
text: `5月底库存金额\n${formatAmount(inventoryTotal)} 万元`,
|
|
|
left: '26.5%',
|
|
left: '26.5%',
|
|
|
- top: 18,
|
|
|
|
|
|
|
+ top: layout.distributionTitleTop,
|
|
|
textAlign: 'center',
|
|
textAlign: 'center',
|
|
|
textStyle: {
|
|
textStyle: {
|
|
|
color: THEME.text.strong,
|
|
color: THEME.text.strong,
|
|
|
- fontSize: 14,
|
|
|
|
|
|
|
+ fontSize: layout.distributionTitleFontSize,
|
|
|
fontWeight: 700,
|
|
fontWeight: 700,
|
|
|
- lineHeight: 16,
|
|
|
|
|
|
|
+ lineHeight: layout.distributionTitleLineHeight,
|
|
|
fontFamily: FONT_FAMILY
|
|
fontFamily: FONT_FAMILY
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
text: `5月底积压库存金额\n${formatAmount(backlogTotal)} 万元`,
|
|
text: `5月底积压库存金额\n${formatAmount(backlogTotal)} 万元`,
|
|
|
left: '72.5%',
|
|
left: '72.5%',
|
|
|
- top: 18,
|
|
|
|
|
|
|
+ top: layout.distributionTitleTop,
|
|
|
textAlign: 'center',
|
|
textAlign: 'center',
|
|
|
textStyle: {
|
|
textStyle: {
|
|
|
color: THEME.text.strong,
|
|
color: THEME.text.strong,
|
|
|
- fontSize: 14,
|
|
|
|
|
|
|
+ fontSize: layout.distributionTitleFontSize,
|
|
|
fontWeight: 700,
|
|
fontWeight: 700,
|
|
|
- lineHeight: 16,
|
|
|
|
|
|
|
+ lineHeight: layout.distributionTitleLineHeight,
|
|
|
fontFamily: FONT_FAMILY
|
|
fontFamily: FONT_FAMILY
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
],
|
|
],
|
|
|
legend: createLegend({
|
|
legend: createLegend({
|
|
|
type: 'scroll',
|
|
type: 'scroll',
|
|
|
- bottom: 10,
|
|
|
|
|
|
|
+ bottom: layout.distributionLegendBottom,
|
|
|
left: 10,
|
|
left: 10,
|
|
|
right: 10,
|
|
right: 10,
|
|
|
- itemWidth: 13,
|
|
|
|
|
- itemHeight: 13,
|
|
|
|
|
- itemGap: 14,
|
|
|
|
|
|
|
+ itemWidth: layout.distributionLegendItemSize,
|
|
|
|
|
+ itemHeight: layout.distributionLegendItemSize,
|
|
|
|
|
+ itemGap: layout.distributionLegendGap,
|
|
|
textStyle: {
|
|
textStyle: {
|
|
|
color: THEME.text.regular,
|
|
color: THEME.text.regular,
|
|
|
- fontSize: 14,
|
|
|
|
|
|
|
+ fontSize: layout.distributionLegendFontSize,
|
|
|
fontWeight: 600,
|
|
fontWeight: 600,
|
|
|
fontFamily: FONT_FAMILY
|
|
fontFamily: FONT_FAMILY
|
|
|
}
|
|
}
|
|
@@ -228,8 +267,8 @@ function getDistributionOption(data: InventoryItem[]): echarts.EChartsOption {
|
|
|
{
|
|
{
|
|
|
name: '5月底库存金额',
|
|
name: '5月底库存金额',
|
|
|
type: 'pie',
|
|
type: 'pie',
|
|
|
- radius: ['48%', '68%'],
|
|
|
|
|
- center: ['27%', '57%'],
|
|
|
|
|
|
|
+ radius: layout.distributionPieRadius,
|
|
|
|
|
+ center: ['27%', layout.distributionPieCenterY],
|
|
|
minAngle: 5,
|
|
minAngle: 5,
|
|
|
avoidLabelOverlap: true,
|
|
avoidLabelOverlap: true,
|
|
|
label: pieLabel,
|
|
label: pieLabel,
|
|
@@ -247,8 +286,8 @@ function getDistributionOption(data: InventoryItem[]): echarts.EChartsOption {
|
|
|
{
|
|
{
|
|
|
name: '5月底积压库存金额',
|
|
name: '5月底积压库存金额',
|
|
|
type: 'pie',
|
|
type: 'pie',
|
|
|
- radius: ['48%', '68%'],
|
|
|
|
|
- center: ['73%', '57%'],
|
|
|
|
|
|
|
+ radius: layout.distributionPieRadius,
|
|
|
|
|
+ center: ['73%', layout.distributionPieCenterY],
|
|
|
minAngle: 5,
|
|
minAngle: 5,
|
|
|
avoidLabelOverlap: true,
|
|
avoidLabelOverlap: true,
|
|
|
label: pieLabel,
|
|
label: pieLabel,
|
|
@@ -274,12 +313,13 @@ function getTrendOption(data: InventoryItem[]): echarts.EChartsOption {
|
|
|
1
|
|
1
|
|
|
)
|
|
)
|
|
|
const backlogAxisMax = Math.ceil((maxBacklog * 1.15) / 50) * 50
|
|
const backlogAxisMax = Math.ceil((maxBacklog * 1.15) / 50) * 50
|
|
|
|
|
+ const layout = getInventoryChartLayout(trendChartRef)
|
|
|
const barLabel = {
|
|
const barLabel = {
|
|
|
show: true,
|
|
show: true,
|
|
|
position: 'right' as any,
|
|
position: 'right' as any,
|
|
|
- distance: 7,
|
|
|
|
|
|
|
+ distance: layout.labelDistance,
|
|
|
color: THEME.text.strong,
|
|
color: THEME.text.strong,
|
|
|
- fontSize: 12,
|
|
|
|
|
|
|
+ fontSize: layout.labelFontSize,
|
|
|
fontWeight: 700,
|
|
fontWeight: 700,
|
|
|
fontFamily: FONT_FAMILY,
|
|
fontFamily: FONT_FAMILY,
|
|
|
formatter(params: any) {
|
|
formatter(params: any) {
|
|
@@ -293,19 +333,21 @@ function getTrendOption(data: InventoryItem[]): echarts.EChartsOption {
|
|
|
...ANIMATION,
|
|
...ANIMATION,
|
|
|
grid: {
|
|
grid: {
|
|
|
...THEME.grid,
|
|
...THEME.grid,
|
|
|
- top: 32
|
|
|
|
|
|
|
+ top: layout.trendGridTop,
|
|
|
|
|
+ right: layout.trendGridRight,
|
|
|
|
|
+ bottom: layout.trendGridBottom
|
|
|
},
|
|
},
|
|
|
color: [THEME.color.blue.line, THEME.color.orange.line],
|
|
color: [THEME.color.blue.line, THEME.color.orange.line],
|
|
|
legend: createLegend(
|
|
legend: createLegend(
|
|
|
{
|
|
{
|
|
|
- top: 4,
|
|
|
|
|
- right: 6,
|
|
|
|
|
- itemWidth: 12,
|
|
|
|
|
- itemHeight: 12,
|
|
|
|
|
- itemGap: 16,
|
|
|
|
|
|
|
+ top: layout.legendTop,
|
|
|
|
|
+ right: layout.legendRight,
|
|
|
|
|
+ itemWidth: layout.legendItemSize,
|
|
|
|
|
+ itemHeight: layout.legendItemSize,
|
|
|
|
|
+ itemGap: layout.legendGap,
|
|
|
textStyle: {
|
|
textStyle: {
|
|
|
color: THEME.text.regular,
|
|
color: THEME.text.regular,
|
|
|
- fontSize: 14,
|
|
|
|
|
|
|
+ fontSize: layout.legendFontSize,
|
|
|
fontWeight: 600,
|
|
fontWeight: 600,
|
|
|
fontFamily: FONT_FAMILY
|
|
fontFamily: FONT_FAMILY
|
|
|
}
|
|
}
|
|
@@ -336,7 +378,7 @@ function getTrendOption(data: InventoryItem[]): echarts.EChartsOption {
|
|
|
},
|
|
},
|
|
|
axisLabel: {
|
|
axisLabel: {
|
|
|
color: THEME.text.regular,
|
|
color: THEME.text.regular,
|
|
|
- fontSize: 12,
|
|
|
|
|
|
|
+ fontSize: layout.axisFontSize,
|
|
|
fontFamily: FONT_FAMILY,
|
|
fontFamily: FONT_FAMILY,
|
|
|
formatter(value: number) {
|
|
formatter(value: number) {
|
|
|
return `${value}`
|
|
return `${value}`
|
|
@@ -361,11 +403,11 @@ function getTrendOption(data: InventoryItem[]): echarts.EChartsOption {
|
|
|
},
|
|
},
|
|
|
axisLabel: {
|
|
axisLabel: {
|
|
|
color: THEME.text.regular,
|
|
color: THEME.text.regular,
|
|
|
- fontSize: 12,
|
|
|
|
|
|
|
+ fontSize: layout.axisFontSize,
|
|
|
fontWeight: 600,
|
|
fontWeight: 600,
|
|
|
fontFamily: FONT_FAMILY,
|
|
fontFamily: FONT_FAMILY,
|
|
|
- margin: 12,
|
|
|
|
|
- width: 132,
|
|
|
|
|
|
|
+ margin: layout.yAxisLabelMargin,
|
|
|
|
|
+ width: layout.yAxisLabelWidth,
|
|
|
overflow: 'break',
|
|
overflow: 'break',
|
|
|
align: 'right'
|
|
align: 'right'
|
|
|
}
|
|
}
|
|
@@ -375,9 +417,9 @@ function getTrendOption(data: InventoryItem[]): echarts.EChartsOption {
|
|
|
name: '年初积压库存',
|
|
name: '年初积压库存',
|
|
|
type: 'bar',
|
|
type: 'bar',
|
|
|
data: data.map((item) => item.yearBeginningBacklog),
|
|
data: data.map((item) => item.yearBeginningBacklog),
|
|
|
- barWidth: 12,
|
|
|
|
|
- barGap: '5%',
|
|
|
|
|
- barCategoryGap: '36%',
|
|
|
|
|
|
|
+ barWidth: layout.barWidth,
|
|
|
|
|
+ barGap: layout.barGap,
|
|
|
|
|
+ barCategoryGap: layout.barCategoryGap,
|
|
|
barMinHeight: 0,
|
|
barMinHeight: 0,
|
|
|
showBackground: false,
|
|
showBackground: false,
|
|
|
backgroundStyle: {
|
|
backgroundStyle: {
|
|
@@ -386,7 +428,7 @@ function getTrendOption(data: InventoryItem[]): echarts.EChartsOption {
|
|
|
},
|
|
},
|
|
|
label: barLabel,
|
|
label: barLabel,
|
|
|
labelLayout: {
|
|
labelLayout: {
|
|
|
- hideOverlap: true
|
|
|
|
|
|
|
+ hideOverlap: false
|
|
|
},
|
|
},
|
|
|
itemStyle: {
|
|
itemStyle: {
|
|
|
shadowBlur: 10,
|
|
shadowBlur: 10,
|
|
@@ -402,10 +444,10 @@ function getTrendOption(data: InventoryItem[]): echarts.EChartsOption {
|
|
|
name: '5月底积压库存',
|
|
name: '5月底积压库存',
|
|
|
type: 'bar',
|
|
type: 'bar',
|
|
|
data: data.map((item) => item.mayBacklogAmount),
|
|
data: data.map((item) => item.mayBacklogAmount),
|
|
|
- barWidth: 12,
|
|
|
|
|
|
|
+ barWidth: layout.barWidth,
|
|
|
barMinHeight: 0,
|
|
barMinHeight: 0,
|
|
|
- barGap: '5%',
|
|
|
|
|
- barCategoryGap: '36%',
|
|
|
|
|
|
|
+ barGap: layout.barGap,
|
|
|
|
|
+ barCategoryGap: layout.barCategoryGap,
|
|
|
showBackground: false,
|
|
showBackground: false,
|
|
|
backgroundStyle: {
|
|
backgroundStyle: {
|
|
|
color: THEME.split,
|
|
color: THEME.split,
|
|
@@ -413,7 +455,7 @@ function getTrendOption(data: InventoryItem[]): echarts.EChartsOption {
|
|
|
},
|
|
},
|
|
|
label: barLabel,
|
|
label: barLabel,
|
|
|
labelLayout: {
|
|
labelLayout: {
|
|
|
- hideOverlap: true
|
|
|
|
|
|
|
+ hideOverlap: false
|
|
|
},
|
|
},
|
|
|
itemStyle: {
|
|
itemStyle: {
|
|
|
shadowBlur: 10,
|
|
shadowBlur: 10,
|
|
@@ -468,6 +510,8 @@ function initTrendChart() {
|
|
|
function resizeCharts() {
|
|
function resizeCharts() {
|
|
|
distributionChart?.resize()
|
|
distributionChart?.resize()
|
|
|
trendChart?.resize()
|
|
trendChart?.resize()
|
|
|
|
|
+ renderDistributionChart()
|
|
|
|
|
+ renderTrendChart()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function destroyCharts() {
|
|
function destroyCharts() {
|