大屏页面初始化

This commit is contained in:
2026-02-27 13:59:38 +08:00
parent 381b5c6460
commit 368127ae19
11 changed files with 55 additions and 1525 deletions

View File

@@ -51,12 +51,12 @@ router.beforeEach((to, from, next) => {
try {
const token = localStorage.getItem('token')
if (token && token.trim() !== '') {
next()
next();
} else {
next({ path: '/login', query: { redirect: to.fullPath } })
next({ path: '/login', query: { redirect: to.fullPath } });
}
} catch (error) {
next('/login')
next('/login');
}
})

View File

@@ -12,11 +12,11 @@ const service = axios.create({
service.interceptors.request.use(
(config) => {
// 登录接口不添加token
if (!config.url?.includes('/userLogin')) {
const excludePaths = ['/userLogin', '/register'];
if (!excludePaths.some(path => config.url?.includes(path))) {
const token = localStorage.getItem('token');
if (token) {
config.headers.Authorization = token;
config.headers.Authorization = `Bearer ${token}`;
}
}
return config
@@ -33,8 +33,7 @@ service.interceptors.response.use(
if (res.code !== 200) {
ElMessage.error(res.msg || '接口请求失败');
if (res.code === 401) {
localStorage.removeItem('token');
router.push('/login').catch(err => console.warn('路由跳转失败', err));
handleLoginExpired();
}
return Promise.reject(res);
}
@@ -42,8 +41,55 @@ service.interceptors.response.use(
},
(error) => {
console.error('【响应拦截器错误】', error);
if (isLoginExpiredError(error)) {
handleLoginExpired();
return Promise.reject(new Error('登录状态已失效,请重新登录'));
}
if (!error.response) {
if (error.message.includes('Network Error') || error.message.includes('timeout')) {
ElMessage.error('网络异常,请检查网络连接或稍后重试');
} else {
ElMessage.error('请求失败,请稍后重试');
}
return Promise.reject(error);
}
ElMessage.error(error.response.data?.msg || error.message || '接口请求失败');
return Promise.reject(error);
}
)
function isLoginExpiredError(error) {
if (error.response && error.response.status === 401) {
return true;
}
const errorMsg = error.message.toLowerCase();
const expiredKeywords = [
'token expired', 'invalid token', '未授权',
'登录失效', '认证失败', '401'
];
const networkKeywords = ['network error', 'timeout', '网络'];
return (
expiredKeywords.some(keyword => errorMsg.includes(keyword.toLowerCase())) &&
!networkKeywords.some(keyword => errorMsg.includes(keyword.toLowerCase()))
);
}
function handleLoginExpired() {
localStorage.removeItem('token');
if (router.currentRoute.path !== '/login') {
const redirect = encodeURIComponent(router.currentRoute.fullPath);
router.push(`/login?redirect=${redirect}`).catch(err => {
console.warn('路由跳转失败', err);
});
ElMessage.error('登录状态已失效,请重新登录');
}
}
export default service

View File

@@ -35,9 +35,6 @@
<div v-else-if="activeTab === 'work'" class="screen-page">
<WorkIndex :formParams="FormValues" />
</div>
<div v-else-if="activeTab === 'test'" class="screen-page">
<TestIndex :formParams="FormValues" />
</div>
<div v-else-if="activeTab === 'erp'" class="screen-page">
<ErpIndex :formParams="FormValues" />
</div>
@@ -50,9 +47,8 @@ import { ref, onMounted } from 'vue';
import HomeIndex from './screen/Home/index.vue';
import ErpIndex from './screen/Erp/index.vue';
import WorkIndex from './screen/Work/index.vue';
import TestIndex from './screen/Test/index.vue';
const screenTitle = ref('数字化可视化');
const screenTitle = ref('数字化可视化看板');
const currentYear = new Date().getFullYear().toString();
const FormValues = ref({
@@ -62,7 +58,6 @@ const FormValues = ref({
const allTabs = [
{ key: 'home', name: '首页' },
{ key: 'work', name: '工作' },
{ key: 'test', name: '测试' },
{ key: 'erp', name: '财务' },
]

View File

@@ -1,148 +0,0 @@
<template>
<div class="chart-card">
<div class="chart-card-header">
<span class="chart-card-title">产品销售额排名分析</span>
</div>
<div class="rank-chart-container" ref="chartRef"></div>
</div>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'
const chartRef = ref(null)
let chartInstance = null
const initRankChart = () => {
const el = chartRef.value
if (!el) return
chartInstance = echarts.init(el)
const salesData = [980, 1250, 1420, 1580, 1650, 1820, 2150, 2580]
const totalSales = salesData.reduce((sum, val) => sum + val, 0)
const percentData = salesData.map(val => ((val / totalSales) * 100).toFixed(1))
const option = {
tooltip: {
trigger: 'axis',
axisPointer: { type: 'shadow' },
backgroundColor: 'rgba(145, 200, 255, 0.9)',
borderColor: '#409EFF',
borderWidth: 1,
textStyle: { color: '#0a3b70' },
padding: [8, 12],
borderRadius: 6,
formatter: function(params) {
const index = params[0].dataIndex
return `产品:${params[0].name}<br/>销售额:${params[0].value}万元<br/>占比:${percentData[index]}%`
}
},
legend: {
show: false
},
grid: {
left: '5%',
right: '5%',
bottom: '10%',
top: '15%',
containLabel: true
},
xAxis: [
{
type: 'value',
axisLabel: {
fontSize: 11,
color: '#b4c7e7'
},
axisLine: { lineStyle: { color: '#1a508b' } },
splitLine: { lineStyle: { color: 'rgba(26, 80, 139, 0.3)' } }
}
],
yAxis: [
{
type: 'category',
data: ['产品H', '产品G', '产品F', '产品E', '产品D', '产品C', '产品B', '产品A'],
axisLabel: {
fontSize: 11,
color: '#b4c7e7'
},
axisLine: { lineStyle: { color: '#1a508b' } },
inverse: false // 核心修改:关闭反转,第一名显示在底部
}
],
series: [
{
name: '销售额',
type: 'bar',
barWidth: '15%',
data: salesData,
itemStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [
{ offset: 0, color: '#409EFF' },
{ offset: 1, color: '#1890FF' }
])
},
label: {
show: true,
position: 'right',
fontSize: 10,
color: '#e0e6ff',
formatter: function(params) {
const index = params.dataIndex
return `${params.value}万元 (${percentData[index]}%)`
}
}
}
]
}
chartInstance.setOption(option)
window.addEventListener('resize', () => chartInstance.resize())
}
onMounted(() => initRankChart())
</script>
<style scoped>
.chart-card {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
overflow: hidden;
}
.chart-card-header {
height: 40px;
line-height: 40px;
padding: 0 16px;
background-color: rgba(26, 80, 139, 0.5);
border-bottom: 1px solid #1a508b;
display: flex;
align-items: center;
}
.chart-card-title {
font-size: 16px;
font-weight: 600;
color: #409EFF;
letter-spacing: 0.5px;
}
.rank-chart-container {
flex: 1;
width: 100%;
height: calc(100% - 40px);
margin: 0;
padding: 0;
}
:deep(.echarts-tooltip) {
background-color: rgba(145, 200, 255, 0.9) !important;
border-color: #409EFF !important;
color: #0a3b70 !important;
border-radius: 6px !important;
}
</style>

View File

@@ -1,156 +0,0 @@
<template>
<div class="chart-card">
<div class="chart-card-header">
<span class="chart-card-title">各产品线月度销售额构成</span>
</div>
<div class="stack-bar-chart-container" ref="chartRef"></div>
</div>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'
const chartRef = ref(null)
let chartInstance = null
const initStackBarChart = () => {
const el = chartRef.value
if (!el) return
chartInstance = echarts.init(el)
const productAData = [320, 302, 301, 334, 390, 330, 310, 350, 340, 320, 380, 360]
const productBData = [120, 132, 101, 134, 90, 230, 180, 150, 170, 190, 210, 200]
const productCData = [220, 182, 191, 234, 290, 330, 280, 260, 290, 270, 250, 280]
const totalData = productAData.map((val, index) => {
return val + productBData[index] + productCData[index]
})
const option = {
tooltip: {
trigger: 'axis',
axisPointer: { type: 'shadow' },
backgroundColor: 'rgba(145, 200, 255, 0.9)',
borderColor: '#409EFF',
borderWidth: 1,
textStyle: { color: '#0a3b70', fontSize: 11 },
padding: [8, 12],
borderRadius: 6
},
legend: {
top: '10',
left: 'center',
textStyle: { fontSize: 12, color: '#e0e6ff' }
},
grid: {
left: '5%',
right: '5%',
bottom: '10%',
top: '15%',
containLabel: true
},
xAxis: [
{
type: 'category',
data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
axisLabel: { fontSize: 11, color: '#b4c7e7' },
axisLine: { lineStyle: { color: '#1a508b' } }
}
],
yAxis: [
{
type: 'value',
name: '销售额 (万元)',
nameTextStyle: { fontSize: 12, color: '#b4c7e7' },
axisLabel: { color: '#b4c7e7' },
axisLine: { lineStyle: { color: '#1a508b' } },
splitLine: { lineStyle: { color: 'rgba(26, 80, 139, 0.3)' } }
}
],
series: [
{
name: '产品A',
type: 'bar',
stack: 'total',
barWidth: '12%',
data: productAData,
itemStyle: { color: '#409EFF' }
},
{
name: '产品B',
type: 'bar',
stack: 'total',
barWidth: '12%',
data: productBData,
itemStyle: { color: '#36CFc9' }
},
{
name: '产品C',
type: 'bar',
stack: 'total',
barWidth: '12%',
data: productCData,
itemStyle: { color: '#67C23A' },
label: {
show: true,
position: 'top',
fontSize: 10,
color: '#e0e6ff',
formatter: function(params) {
return totalData[params.dataIndex] + '万元'
}
}
}
]
}
chartInstance.setOption(option)
window.addEventListener('resize', () => chartInstance.resize())
}
onMounted(() => initStackBarChart())
</script>
<style scoped>
.chart-card {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
overflow: hidden;
}
.chart-card-header {
height: 40px;
line-height: 40px;
padding: 0 16px;
background-color: rgba(26, 80, 139, 0.5);
border-bottom: 1px solid #1a508b;
display: flex;
align-items: center;
}
.chart-card-title {
font-size: 16px;
font-weight: 600;
color: #409EFF;
letter-spacing: 0.5px;
}
.stack-bar-chart-container {
flex: 1;
width: 100%;
height: calc(100% - 40px);
margin: 0;
padding: 0;
}
:deep(.echarts-tooltip) {
background-color: rgba(145, 200, 255, 0.9) !important;
border-color: #409EFF !important;
color: #0a3b70 !important;
border-radius: 6px !important;
}
</style>

View File

@@ -1,225 +0,0 @@
<template>
<div class="chart-card">
<div class="chart-card-header">
<span class="chart-card-title">多产品线月度趋势分析</span>
</div>
<div class="multi-line-chart-container" ref="chartRef"></div>
</div>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'
const chartRef = ref(null)
let chartInstance = null
const initMultiLineChart = () => {
const el = chartRef.value
if (!el) return
chartInstance = echarts.init(el)
const option = {
tooltip: {
trigger: 'axis',
backgroundColor: 'rgba(145, 200, 255, 0.9)',
borderColor: '#409EFF',
borderWidth: 1,
textStyle: { color: '#0a3b70' },
padding: [8, 12],
borderRadius: 6
},
legend: {
top: '10',
left: 'center',
textStyle: { fontSize: 12, color: '#e0e6ff' }
},
grid: {
left: '5%',
right: '5%',
bottom: '10%',
top: '15%',
containLabel: true
},
xAxis: [
{
type: 'category',
boundaryGap: false,
data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
axisLabel: { fontSize: 11, color: '#b4c7e7' },
axisLine: { lineStyle: { color: '#1a508b' } }
}
],
yAxis: [
{
type: 'value',
name: '销售额 (万元)',
nameTextStyle: { fontSize: 12, color: '#b4c7e7' },
axisLabel: { color: '#b4c7e7' },
axisLine: { lineStyle: { color: '#1a508b' } },
splitLine: { lineStyle: { color: 'rgba(26, 80, 139, 0.3)' } }
}
],
series: [
{
name: '产品线A',
type: 'line',
smooth: true,
symbol: 'circle',
symbolSize: 4,
data: [320, 450, 380, 520, 480, 610, 550, 720, 680, 850, 790, 920],
lineStyle: { width: 2, color: '#409EFF' },
areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: 'rgba(64, 158, 255, 0.3)' },
{ offset: 1, color: 'rgba(64, 158, 255, 0)' }
])
},
label: {
show: true,
position: 'top',
fontSize: 9,
color: '#409EFF',
formatter: '{c}'
}
},
{
name: '产品线B',
type: 'line',
smooth: true,
symbol: 'circle',
symbolSize: 4,
data: [210, 280, 240, 350, 310, 420, 380, 490, 450, 580, 520, 650],
lineStyle: { width: 2, color: '#36CFC9' },
areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: 'rgba(54, 207, 201, 0.3)' },
{ offset: 1, color: 'rgba(54, 207, 201, 0)' }
])
},
label: {
show: true,
position: 'top',
fontSize: 9,
color: '#36CFC9',
formatter: '{c}'
}
},
{
name: '产品线C',
type: 'line',
smooth: true,
symbol: 'circle',
symbolSize: 4,
data: [150, 220, 180, 290, 250, 360, 320, 430, 390, 500, 460, 570],
lineStyle: { width: 2, color: '#67C23A' },
areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: 'rgba(103, 194, 58, 0.3)' },
{ offset: 1, color: 'rgba(103, 194, 58, 0)' }
])
},
label: {
show: true,
position: 'top',
fontSize: 9,
color: '#67C23A',
formatter: '{c}'
}
},
{
name: '产品线D',
type: 'line',
smooth: true,
symbol: 'circle',
symbolSize: 4,
data: [90, 160, 120, 210, 180, 270, 230, 320, 290, 380, 340, 430],
lineStyle: { width: 2, color: '#E6A23C' },
areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: 'rgba(230, 162, 60, 0.3)' },
{ offset: 1, color: 'rgba(230, 162, 60, 0)' }
])
},
label: {
show: true,
position: 'top',
fontSize: 9,
color: '#E6A23C',
formatter: '{c}'
}
},
{
name: '产品线E',
type: 'line',
smooth: true,
symbol: 'circle',
symbolSize: 4,
data: [50, 110, 80, 150, 120, 190, 160, 230, 200, 270, 240, 310],
lineStyle: { width: 2, color: '#F56C6C' },
areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: 'rgba(245, 108, 108, 0.3)' },
{ offset: 1, color: 'rgba(245, 108, 108, 0)' }
])
},
label: {
show: true,
position: 'top',
fontSize: 9,
color: '#F56C6C',
formatter: '{c}'
}
}
]
}
chartInstance.setOption(option)
window.addEventListener('resize', () => chartInstance.resize())
}
onMounted(() => initMultiLineChart())
</script>
<style scoped>
.chart-card {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
overflow: hidden;
}
.chart-card-header {
height: 40px;
line-height: 40px;
padding: 0 16px;
background-color: rgba(26, 80, 139, 0.5);
border-bottom: 1px solid #1a508b;
display: flex;
align-items: center;
}
.chart-card-title {
font-size: 16px;
font-weight: 600;
color: #409EFF;
letter-spacing: 0.5px;
}
.multi-line-chart-container {
flex: 1;
width: 100%;
height: calc(100% - 40px);
margin: 0;
padding: 0;
}
:deep(.echarts-tooltip) {
background-color: rgba(145, 200, 255, 0.9) !important;
border-color: #409EFF !important;
color: #0a3b70 !important;
border-radius: 6px !important;
}
</style>

View File

@@ -1,181 +0,0 @@
<template>
<div class="chart-card">
<div class="chart-card-header">
<span class="chart-card-title">月度销售额与增长率分析</span>
</div>
<div class="bar-line-chart-container" ref="chartRef"></div>
</div>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'
const chartRef = ref(null)
let chartInstance = null
const initBarLineChart = () => {
const el = chartRef.value
if (!el) return
chartInstance = echarts.init(el)
const option = {
tooltip: {
trigger: 'axis',
axisPointer: { type: 'cross' },
backgroundColor: 'rgba(145, 200, 255, 0.9)',
borderColor: '#409EFF',
borderWidth: 1,
textStyle: { color: '#0a3b70' },
padding: [8, 12],
borderRadius: 6,
formatter: function(params) {
let res = `<b>${params[0].axisValue}</b>`
params.forEach(item => {
res += `<br/>${item.seriesName}${item.value}${item.seriesName === '增长率' ? '%' : '万元'}`
})
return res
}
},
legend: {
top: '10',
left: 'center',
textStyle: { fontSize: 12, color: '#e0e6ff' }
},
grid: {
left: '5%',
right: '5%',
bottom: '10%',
top: '15%',
containLabel: true
},
xAxis: [
{
type: 'category',
data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
axisLabel: {
fontSize: 11,
interval: 0,
color: '#b4c7e7'
},
axisLine: { lineStyle: { color: '#1a508b' } },
boundaryGap: true
}
],
yAxis: [
{
type: 'value',
name: '销售额 (万元)',
nameTextStyle: { fontSize: 12, color: '#b4c7e7' },
axisLabel: { formatter: '{value}', color: '#b4c7e7' },
axisLine: { lineStyle: { color: '#1a508b' } },
splitLine: { lineStyle: { color: 'rgba(26, 80, 139, 0.3)' } },
nameLocation: 'end',
nameGap: 10,
nameRotate: 0
},
{
type: 'value',
name: '增长率 (%)',
nameTextStyle: { fontSize: 12, color: '#b4c7e7' },
axisLabel: { formatter: '{value} %', color: '#b4c7e7' },
axisLine: { lineStyle: { color: '#1a508b' } },
splitLine: { lineStyle: { color: 'rgba(26, 80, 139, 0.3)' } },
nameLocation: 'end',
nameGap: 10,
nameRotate: 0
}
],
series: [
{
name: '销售额',
type: 'bar',
yAxisIndex: 0,
data: [120, 200, 150, 80, 70, 110, 130, 180, 160, 90, 100, 140],
itemStyle: { color: '#409EFF' },
barWidth: '15%',
// 柱子顶部标签
label: {
show: true,
position: 'top',
fontSize: 10,
color: '#fff'
}
},
{
name: '增长率',
type: 'line',
yAxisIndex: 1,
data: [12, 20, 15, 8, 7, 11, 13, 18, 16, 9, 10, 14],
smooth: true,
lineStyle: { width: 1.5 },
symbol: 'circle',
symbolSize: 5,
emphasis: { symbolSize: 7 },
// 折线标签
label: {
show: true,
position: 'top',
fontSize: 10,
color: '#E6A23C',
formatter: '{c}%'
},
areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: 'rgba(230, 162, 60, 0.3)' },
{ offset: 1, color: 'rgba(230, 162, 60, 0.0)' }
])
}
}
]
}
chartInstance.setOption(option)
window.addEventListener('resize', () => chartInstance.resize())
}
onMounted(() => initBarLineChart())
</script>
<style scoped>
.chart-card {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
overflow: hidden;
}
.chart-card-header {
height: 40px;
line-height: 40px;
padding: 0 16px;
background-color: rgba(26, 80, 139, 0.5);
border-bottom: 1px solid #1a508b;
display: flex;
align-items: center;
}
.chart-card-title {
font-size: 16px;
font-weight: 600;
color: #409EFF;
letter-spacing: 0.5px;
}
.bar-line-chart-container {
flex: 1;
width: 100%;
height: calc(100% - 40px);
margin: 0;
padding: 0;
}
:deep(.echarts-tooltip) {
background-color: rgba(145, 200, 255, 0.9) !important;
border-color: #409EFF !important;
color: #0a3b70 !important;
border-radius: 6px !important;
}
</style>

View File

@@ -1,175 +0,0 @@
<template>
<div class="chart-card">
<div class="chart-card-header">
<span class="chart-card-title">年度销售额占比分析</span>
</div>
<div class="pie-chart-container" ref="chartRef"></div>
</div>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'
const chartRef = ref(null)
let chartInstance = null
const initPieChart = () => {
const el = chartRef.value
if (!el) return
chartInstance = echarts.init(el)
const pieData = [
{ value: 85, name: 'A-华东' },
{ value: 78, name: 'A-华南' },
{ value: 92, name: 'A-华北' },
{ value: 65, name: 'B-华东' },
{ value: 72, name: 'B-华南' },
{ value: 88, name: 'B-华北' },
{ value: 58, name: 'C-华东' }
]
const colorList = [
'#409EFF', '#36CFc9', '#67C23A', '#E6A23C', '#F56C6C',
'#909399', '#722ED1', '#EB2F96', '#1890FF', '#52C41A',
'#FAAD14', '#F5222D', '#8C8C8C', '#A062D4', '#F7BA1E'
]
const option = {
tooltip: {
trigger: 'item',
backgroundColor: 'rgba(145, 200, 255, 0.9)',
borderColor: '#409EFF',
borderWidth: 1,
textStyle: { color: '#0a3b70', fontSize: 12 },
padding: [10, 15],
borderRadius: 6,
formatter: function(params) {
return `分类:${params.name}<br/>销售额:${params.value}万元<br/>占比:${params.percent.toFixed(1)}%`
}
},
legend: {
orient: 'horizontal',
top: '10%',
left: 'center',
textStyle: { fontSize: 11, color: '#e0e6ff' },
itemWidth: 12,
itemHeight: 12,
itemGap: 10,
pageIconColor: '#409EFF',
pageTextStyle: { color: '#e0e6ff', fontSize: 10 },
pageButtonItemGap: 6,
pageButtonGap: 10,
type: 'scroll'
},
series: [
{
name: '销售额',
type: 'pie',
radius: ['30%', '55%'],
center: ['50%', '65%'],
avoidLabelOverlap: true,
itemStyle: {
borderRadius: 4,
borderColor: 'rgba(15, 52, 96, 0.9)',
borderWidth: 1
},
label: {
show: true,
position: 'outside',
fontSize: 10,
color: '#e0e6ff',
formatter: '{b} {d}%',
overflow: 'truncate',
ellipsis: '...',
distance: 8
},
labelLine: {
show: true,
length: 12,
length2: 8,
lineStyle: { color: '#e0e6ff', width: 1 },
smooth: 0.2,
minTurnAngle: 45
},
data: pieData,
color: colorList
}
]
}
chartInstance.setOption(option)
window.addEventListener('resize', () => chartInstance.resize())
}
onMounted(() => initPieChart())
</script>
<style scoped>
.chart-card {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
overflow: hidden;
}
.chart-card-header {
height: 40px;
line-height: 40px;
padding: 0 16px;
background-color: rgba(26, 80, 139, 0.5);
border-bottom: 1px solid #1a508b;
display: flex;
align-items: center;
}
.chart-card-title {
font-size: 16px;
font-weight: 600;
color: #409EFF;
letter-spacing: 0.5px;
}
.pie-chart-container {
flex: 1;
width: 100%;
height: calc(100% - 40px);
margin: 0;
padding: 0;
}
:deep(.echarts-tooltip) {
background-color: rgba(145, 200, 255, 0.9) !important;
border-color: #409EFF !important;
color: #0a3b70 !important;
border-radius: 6px !important;
}
:deep(.echarts-legend-scroll) {
background-color: transparent !important;
}
:deep(.echarts-legend-scroll-text) {
color: #e0e6ff !important;
font-size: 11px !important;
}
:deep(.echarts-legend-scroll-button) {
border-color: #1a508b !important;
}
:deep(.echarts-legend-scroll-button-icon) {
color: #409EFF !important;
}
:deep(.ec-label) {
z-index: 9999 !important;
white-space: nowrap !important;
font-size: 10px !important;
color: #e0e6ff !important;
}
:deep(.ec-label-line) {
stroke: #e0e6ff !important;
stroke-width: 1px !important;
}
</style>

View File

@@ -1,234 +0,0 @@
<template>
<div class="chart-card">
<div class="chart-card-header">
<span class="chart-card-title">月度收支与占比分析</span>
</div>
<div class="bar-line-chart-container" ref="chartRef"></div>
</div>
</template>
<script setup>
import { ref, onMounted, nextTick, watch } from 'vue'
import * as echarts from 'echarts'
import { getItemInfoList } from '@/api/itemInfo'
const vList = ref([])
const chartRef = ref(null)
let chartInstance = null
async function getList() {
try {
const params = {
itemCode: 'ERP_YEARPSAV_M001',
reqParam: '2025'
}
const res = await getItemInfoList(params)
vList.value = res || []
} catch (error) {
console.error(error)
}
}
function initChart() {
const el = chartRef.value
if (!el || vList.value.length === 0) return
if (chartInstance) {
chartInstance.dispose()
}
chartInstance = echarts.init(el)
const xData = vList.value.map(item => {
const xaxis = item.xaxis || ''
return xaxis.includes('月') ? xaxis : `${xaxis}`
})
const index01Yuan = vList.value.map(item => item.index01 || 0)
const index02Yuan = vList.value.map(item => item.index02 || 0)
const index03 = vList.value.map(item => item.index03 || 0)
const index01Wan = index01Yuan.map(val => (val / 10000).toFixed(2))
const index02Wan = index02Yuan.map(val => (val / 10000).toFixed(2))
const option = {
tooltip: {
trigger: 'axis',
axisPointer: { type: 'cross' },
backgroundColor: 'rgba(145, 200, 255, 0.9)',
borderColor: '#409EFF',
borderWidth: 1,
textStyle: { color: '#0a3b70' },
padding: [8, 12],
borderRadius: 6,
formatter: function (params) {
const title = params[0].axisValue
const idx = params[0].dataIndex
const incomeVal = index01Yuan[idx]
const expenseVal = index02Yuan[idx]
const rateVal = index03[idx]
return `
<div style="text-align:center; font-weight:bold; margin-bottom:6px">${title}</div>
<table style="width:100%; border-collapse:collapse; text-align:center">
<tr>
<td style="border:1px solid #409EFF; padding:4px; font-weight:bold">收入(元)</td>
<td style="border:1px solid #409EFF; padding:4px; font-weight:bold">支出(元)</td>
<td style="border:1px solid #409EFF; padding:4px; font-weight:bold">存储率(%)</td>
</tr>
<tr>
<td style="border:1px solid #409EFF; padding:4px">${incomeVal}</td>
<td style="border:1px solid #409EFF; padding:4px">${expenseVal}</td>
<td style="border:1px solid #409EFF; padding:4px">${rateVal}</td>
</tr>
</table>
`
}
},
legend: {
top: '10',
left: 'center',
textStyle: { fontSize: 12, color: '#e0e6ff' }
},
grid: {
left: '5%',
right: '5%',
bottom: '10%',
top: '15%',
containLabel: true
},
xAxis: [
{
type: 'category',
data: xData,
axisLabel: {
fontSize: 11,
interval: 0,
color: '#b4c7e7'
},
axisLine: { lineStyle: { color: '#1a508b' } },
boundaryGap: true
}
],
yAxis: [
{
type: 'value',
name: '金额 (万元)',
nameTextStyle: { fontSize: 12, color: '#b4c7e7' },
axisLabel: { formatter: '{value}', color: '#b4c7e7' },
axisLine: { lineStyle: { color: '#1a508b' } },
splitLine: { lineStyle: { color: 'rgba(26, 80, 139, 0.3)' } }
},
{
type: 'value',
name: '占比 (%)',
nameTextStyle: { fontSize: 12, color: '#b4c7e7' },
axisLabel: { formatter: '{value} %', color: '#b4c7e7' },
axisLine: { lineStyle: { color: '#1a508b' } },
splitLine: { show: false },
min: 0,
max: 100
}
],
series: [
{
name: '收入',
type: 'bar',
yAxisIndex: 0,
data: index01Wan,
itemStyle: { color: '#67C23A' },
barWidth: '12%',
label: {
show: true,
position: 'top',
fontSize: 10,
color: '#fff',
formatter: '{c}' // 移除万元单位,只显示数值
}
},
{
name: '支出',
type: 'bar',
yAxisIndex: 0,
data: index02Wan,
itemStyle: { color: '#F56C6C' },
barWidth: '12%',
label: {
show: true,
position: 'top',
fontSize: 10,
color: '#fff',
formatter: '{c}' // 移除万元单位,只显示数值
}
},
{
name: '存储率',
type: 'line',
yAxisIndex: 1,
data: index03,
smooth: true,
lineStyle: { width: 1.5, color: '#409EFF' },
symbol: 'circle',
symbolSize: 5,
label: {
show: true,
position: 'top',
fontSize: 10,
color: '#409EFF',
formatter: '{c}' // 移除%单位,只显示数值
},
areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: 'rgba(64, 158, 255, 0.3)' },
{ offset: 1, color: 'rgba(64, 158, 255, 0.0)' }
])
}
}
]
}
chartInstance.setOption(option)
window.addEventListener('resize', () => chartInstance?.resize())
}
watch(vList, () => {
nextTick(() => initChart())
}, { deep: true })
onMounted(() => {
getList()
})
</script>
<style scoped>
.chart-card {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
overflow: hidden;
}
.chart-card-header {
height: 40px;
line-height: 40px;
padding: 0 16px;
background-color: rgba(26, 80, 139, 0.5);
border-bottom: 1px solid #1a508b;
display: flex;
align-items: center;
}
.chart-card-title {
font-size: 16px;
font-weight: 600;
color: #409EFF;
letter-spacing: 0.5px;
}
.bar-line-chart-container {
flex: 1;
width: 100%;
height: calc(100% - 40px);
}
</style>

View File

@@ -1,146 +0,0 @@
<template>
<div class="chart-card">
<div class="chart-card-header">
<span class="chart-card-title">年度销售额完成率</span>
</div>
<div class="gauge-chart-container" ref="chartRef"></div>
</div>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'
const chartRef = ref(null)
let chartInstance = null
const initGaugeChart = () => {
const el = chartRef.value
if (!el) return
chartInstance = echarts.init(el)
const option = {
tooltip: {
trigger: 'item',
backgroundColor: 'rgba(145, 200, 255, 0.9)',
borderColor: '#409EFF',
borderWidth: 1,
textStyle: { color: '#0a3b70', fontSize: 11 },
padding: [8, 12],
borderRadius: 6,
formatter: '完成率:{c}%<br/>目标1500万元<br/>已完成1275万元'
},
series: [
{
name: '完成率',
type: 'gauge',
startAngle: 180,
endAngle: 0,
min: 0,
max: 100,
splitNumber: 10,
radius: '80%',
center: ['50%', '70%'],
axisLine: {
lineStyle: {
width: 15,
color: [
[0.3, '#F56C6C'],
[0.7, '#E6A23C'],
[1, '#409EFF']
]
}
},
splitLine: {
length: 15,
lineStyle: {
color: '#b4c7e7',
width: 2
}
},
axisTick: {
length: 8,
lineStyle: {
color: '#b4c7e7',
width: 1
}
},
axisLabel: {
color: '#e0e6ff',
fontSize: 10,
distance: 20
},
pointer: {
icon: 'path://M12.8,0.7l12,40.1H0.7L12.8,0.7z',
length: '85%',
width: 8,
color: '#fff',
shadowColor: 'rgba(0, 0, 0, 0.3)',
shadowBlur: 5
},
title: {
fontSize: 14,
color: '#e0e6ff',
offsetCenter: [0, '50%']
},
detail: {
fontSize: 16,
color: '#409EFF',
fontWeight: 600,
offsetCenter: [0, '20%'],
formatter: '{value}%'
},
data: [{ value: 85, name: '销售额完成率' }]
}
]
}
chartInstance.setOption(option)
window.addEventListener('resize', () => chartInstance.resize())
}
onMounted(() => initGaugeChart())
</script>
<style scoped>
.chart-card {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
overflow: hidden;
}
.chart-card-header {
height: 40px;
line-height: 40px;
padding: 0 16px;
background-color: rgba(26, 80, 139, 0.5);
border-bottom: 1px solid #1a508b;
display: flex;
align-items: center;
}
.chart-card-title {
font-size: 16px;
font-weight: 600;
color: #409EFF;
letter-spacing: 0.5px;
}
.gauge-chart-container {
flex: 1;
width: 100%;
height: calc(100% - 40px);
margin: 0;
padding: 0;
}
:deep(.echarts-tooltip) {
background-color: rgba(145, 200, 255, 0.9) !important;
border-color: #409EFF !important;
color: #0a3b70 !important;
border-radius: 6px !important;
}
</style>

View File

@@ -1,246 +0,0 @@
<template>
<div class="work-layout-container">
<div class="work-section work-top-header">
<div class="work-card full-card">
<h3>Work页面顶部区域 (10%)</h3>
<p>可放置工作概览筛选条件操作按钮等</p>
</div>
</div>
<div class="work-main-container">
<div class="work-col">
<div class="work-inner-section work-inner-one-third">
<div class="work-card">
<CahrtLine />
</div>
</div>
<div class="work-inner-section work-inner-one-third">
<div class="work-card">
<ChartPic />
</div>
</div>
<div class="work-inner-section work-inner-one-third">
<div class="work-card">
<ChartBar />
</div>
</div>
</div>
<div class="work-col">
<div class="work-inner-section work-inner-two-third">
<div class="work-card">
<h3>中间上部 (60%)</h3>
<p>核心工作内容/进度展示</p>
</div>
</div>
<div class="work-inner-section work-inner-one-third">
<div class="work-card">
<ChartYbp />
</div>
</div>
</div>
<div class="work-col">
<div class="work-inner-section work-inner-one-third">
<div class="work-card">
<ChartDjt />
</div>
</div>
<div class="work-inner-section work-inner-one-third">
<div class="work-card">
<ChartTwo />
</div>
</div>
<div class="work-inner-section work-inner-one-third">
<div class="work-card">
<ChartDuo />
</div>
</div>
</div>
</div>
</div>
</template>
<script setup>
import CahrtLine from './components/ChartLine.vue';
import ChartPic from './components/ChartPic.vue';
import ChartBar from './components/ChartBar.vue';
import ChartYbp from './components/ChartYbp.vue';
import ChartDjt from './components/ChartDjt.vue';
import ChartTwo from './components/ChartTwo.vue';
import ChartDuo from './components/ChartDuo.vue';
</script>
<style scoped>
.work-layout-container {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
gap: 6px;
padding: 8px;
margin: 0 !important;
box-sizing: border-box;
background-color: transparent;
overflow: hidden;
}
.work-top-header {
width: 100%;
height: 10%;
display: flex;
box-sizing: border-box;
overflow: hidden;
}
.work-main-container {
width: 100%;
height: 90%;
display: flex;
gap: 6px;
box-sizing: border-box;
overflow: hidden;
}
.work-col {
flex: 1;
height: 100%;
display: flex;
flex-direction: column;
gap: 6px;
box-sizing: border-box;
overflow: hidden;
}
.work-inner-one-third {
flex: 1;
box-sizing: border-box;
overflow: hidden;
}
.work-inner-two-third {
flex: 2;
box-sizing: border-box;
overflow: hidden;
}
.work-card {
width: 100%;
height: 100%;
background-color: rgba(15, 52, 96, 0.9);
border: 1px solid #1a508b;
border-radius: 8px;
padding: 2px;
box-sizing: border-box;
display: block;
flex-direction: column;
justify-content: center;
align-items: center;
color: #e0e6ff;
backdrop-filter: blur(4px);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
min-height: 0;
}
.full-card {
width: 100%;
}
.work-card:hover {
box-shadow: 0 4px 12px rgba(60, 156, 255, 0.3);
border-color: #3c9cff;
transition: all 0.3s ease;
}
.work-card h3 {
font-size: 16px;
margin-bottom: 8px;
letter-spacing: 1px;
background: #3c9cff;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
font-weight: 600;
}
.work-card p {
font-size: 13px;
opacity: 0.75;
color: #b4c7e7;
text-align: center;
line-height: 1.5;
}
@media (max-width: 1600px) {
.work-layout-container {
padding: 6px;
gap: 4px;
}
.work-main-container {
gap: 4px;
}
.work-col {
gap: 4px;
}
.work-card {
padding: 10px;
}
.work-card h3 {
font-size: 14px;
}
.work-card p {
font-size: 12px;
}
}
@media (max-width: 768px) {
.work-layout-container {
flex-direction: column;
height: auto;
min-height: 100%;
padding: 6px;
gap: 6px;
overflow-y: auto;
}
.work-top-header {
height: auto;
min-height: 80px;
}
.work-main-container {
flex-direction: column;
height: auto;
min-height: calc(100% - 80px);
gap: 6px;
}
.work-col {
width: 100%;
height: 33%;
gap: 6px;
}
.work-card {
padding: 8px;
}
}
@media (max-height: 900px) {
.work-layout-container {
padding: 6px;
gap: 4px;
}
.work-main-container {
gap: 4px;
}
.work-col {
gap: 4px;
}
.work-card {
padding: 8px;
}
.work-card h3 {
font-size: 14px;
margin-bottom: 6px;
}
.work-card p {
font-size: 12px;
}
}
</style>