大屏项目初始化
This commit is contained in:
@@ -7,19 +7,17 @@
|
||||
</div>
|
||||
|
||||
<div class="erp-section erp-upper-section">
|
||||
<div class="erp-col erp-col-1-3">
|
||||
<div
|
||||
v-for="item in getComponentsBySortRange(1, 3)"
|
||||
:key="item.sort"
|
||||
class="erp-col erp-col-1-3"
|
||||
>
|
||||
<div class="erp-card">
|
||||
<ChartV01 :formParams="FormValues" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="erp-col erp-col-1-3">
|
||||
<div class="erp-card">
|
||||
<ChartV02 :formParams="FormValues" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="erp-col erp-col-1-3">
|
||||
<div class="erp-card">
|
||||
<ChartV03 :formParams="FormValues" />
|
||||
<component
|
||||
:is="componentMap[item.vueName]"
|
||||
:formParams="FormValues"
|
||||
v-if="componentMap[item.vueName]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -27,21 +25,28 @@
|
||||
<div class="erp-section erp-middle-section">
|
||||
<div class="erp-col erp-col-1-2">
|
||||
<div class="erp-inner-layout">
|
||||
<div class="erp-col erp-col-1-2">
|
||||
<div
|
||||
v-for="item in getComponentsBySortRange(4, 5)"
|
||||
:key="item.sort"
|
||||
class="erp-col erp-col-1-2"
|
||||
>
|
||||
<div class="erp-card">
|
||||
<ChartV04 :formParams="FormValues" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="erp-col erp-col-1-2">
|
||||
<div class="erp-card">
|
||||
<ChartV05 :formParams="FormValues" />
|
||||
<component
|
||||
:is="componentMap[item.vueName]"
|
||||
:formParams="FormValues"
|
||||
v-if="componentMap[item.vueName]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="erp-col erp-col-1-2">
|
||||
<div class="erp-card">
|
||||
<ChartV06 :formParams="FormValues" />
|
||||
<component
|
||||
:is="componentMap[getComponentBySort(6)?.vueName]"
|
||||
:formParams="FormValues"
|
||||
v-if="getComponentBySort(6) && componentMap[getComponentBySort(6).vueName]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -49,21 +54,28 @@
|
||||
<div class="erp-section erp-lower-section">
|
||||
<div class="erp-col erp-col-1-2">
|
||||
<div class="erp-inner-layout">
|
||||
<div class="erp-col erp-col-1-2">
|
||||
<div
|
||||
v-for="item in getComponentsBySortRange(7, 8)"
|
||||
:key="item.sort"
|
||||
class="erp-col erp-col-1-2"
|
||||
>
|
||||
<div class="erp-card">
|
||||
<ChartV07 :formParams="FormValues" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="erp-col erp-col-1-2">
|
||||
<div class="erp-card">
|
||||
<ChartV08 :formParams="FormValues" />
|
||||
<component
|
||||
:is="componentMap[item.vueName]"
|
||||
:formParams="FormValues"
|
||||
v-if="componentMap[item.vueName]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="erp-col erp-col-1-2">
|
||||
<div class="erp-card">
|
||||
<ChartV09 :formParams="FormValues" />
|
||||
<component
|
||||
:is="componentMap[getComponentBySort(9)?.vueName]"
|
||||
:formParams="FormValues"
|
||||
v-if="getComponentBySort(9) && componentMap[getComponentBySort(9).vueName]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -71,18 +83,9 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { ref, watch, onMounted, computed } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import ChartTop from './components/ChartTop.vue'
|
||||
import ChartV01 from './components/ChartV01.vue';
|
||||
import ChartV02 from './components/ChartV02.vue';
|
||||
import ChartV03 from './components/ChartV03.vue';
|
||||
import ChartV04 from './components/ChartV04.vue';
|
||||
import ChartV05 from './components/ChartV05.vue';
|
||||
import ChartV06 from './components/ChartV06.vue';
|
||||
import ChartV07 from './components/ChartV07.vue';
|
||||
import ChartV08 from './components/ChartV08.vue';
|
||||
import ChartV09 from './components/ChartV09.vue';
|
||||
import ChartTop from './components/ChartTop.vue';
|
||||
|
||||
const route = useRoute();
|
||||
|
||||
@@ -93,13 +96,71 @@ const FormValues = ref({
|
||||
watch(
|
||||
() => route.query.year,
|
||||
(newVal) => {
|
||||
FormValues.value.reqParam = newVal;
|
||||
FormValues.value.reqParam = newVal;
|
||||
},
|
||||
{
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
);
|
||||
|
||||
const componentMap = ref({});
|
||||
const chartData = ref([]);
|
||||
|
||||
const getComponentBySort = (sort) => {
|
||||
return chartData.value.find(item => item.sort === sort);
|
||||
};
|
||||
|
||||
const getComponentsBySortRange = (start, end) => {
|
||||
return chartData.value.filter(item => item.sort >= start && item.sort <= end);
|
||||
};
|
||||
|
||||
const loadComponent = async (vueName) => {
|
||||
try {
|
||||
const module = await import(`./components/${vueName}.vue`);
|
||||
return module.default;
|
||||
} catch (error) {
|
||||
console.error('加载组件失败', error);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const fetchChartData = async () => {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
const apiData = [
|
||||
{ sort: 1, vueName: 'ChartV01' },
|
||||
{ sort: 2, vueName: 'ChartV02' },
|
||||
{ sort: 3, vueName: 'ChartV03' },
|
||||
{ sort: 4, vueName: 'ChartV04' },
|
||||
{ sort: 5, vueName: 'ChartV05' },
|
||||
{ sort: 6, vueName: 'ChartV06' },
|
||||
{ sort: 7, vueName: 'ChartV07' },
|
||||
{ sort: 8, vueName: 'ChartV08' },
|
||||
{ sort: 9, vueName: 'ChartV09' },
|
||||
];
|
||||
resolve(apiData);
|
||||
}, 300);
|
||||
});
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const data = await fetchChartData();
|
||||
chartData.value = data.sort((a, b) => a.sort - b.sort);
|
||||
const newComponentMap = {};
|
||||
const uniqueComponents = [...new Set(data.map(item => item.vueName))];
|
||||
for (const vueName of uniqueComponents) {
|
||||
const component = await loadComponent(vueName);
|
||||
if (component) {
|
||||
newComponentMap[vueName] = component;
|
||||
}
|
||||
}
|
||||
componentMap.value = newComponentMap;
|
||||
} catch (error) {
|
||||
console.error('加载图表数据失败:', error);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@@ -176,7 +237,6 @@ watch(
|
||||
|
||||
.full-card {
|
||||
width: 100%;
|
||||
|
||||
}
|
||||
|
||||
.erp-card:hover {
|
||||
@@ -203,6 +263,15 @@ watch(
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.empty-card {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
color: #88a0c2;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
@media (max-width: 1600px) {
|
||||
.erp-layout-container {
|
||||
padding: 6px;
|
||||
|
||||
@@ -17,30 +17,45 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-section work-main-section">
|
||||
|
||||
<div v-if="activeMenu === 1" class="menu-content">
|
||||
<HomeIndex />
|
||||
</div>
|
||||
<div v-else-if="activeMenu === 2" class="menu-content">
|
||||
<WorkIndex />
|
||||
</div>
|
||||
<div v-else-if="activeMenu === 3" class="menu-content">
|
||||
<ErpIndex />
|
||||
</div>
|
||||
<div v-else-if="activeMenu === 4" class="menu-content">
|
||||
<SysIndex />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
|
||||
import HomeIndex from './components/Home.vue'
|
||||
import WorkIndex from './components/Work.vue'
|
||||
import ErpIndex from './components/Erp.vue'
|
||||
import SysIndex from './components/Sys.vue'
|
||||
|
||||
const menuList = ref([
|
||||
{ key: 1, label: '指标一' },
|
||||
{ key: 2, label: '指标二' },
|
||||
{ key: 3, label: '指标三' },
|
||||
{ key: 4, label: '指标四' },
|
||||
{ key: 1, label: '首页' },
|
||||
{ key: 2, label: '工作' },
|
||||
{ key: 3, label: '财务' },
|
||||
{ key: 4, label: '系统' },
|
||||
])
|
||||
const activeMenu = ref(1)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 你原来的全部样式 100% 保留,我只加左侧样式 */
|
||||
.work-layout-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: row; /* 只改这一个字:column → row */
|
||||
flex-direction: row;
|
||||
gap: 6px;
|
||||
padding: 8px;
|
||||
margin: 0 !important;
|
||||
@@ -49,93 +64,6 @@ const activeMenu = ref(1)
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.work-section {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.work-top-header {
|
||||
height: 10%;
|
||||
}
|
||||
|
||||
.work-main-section {
|
||||
height: 100%;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.work-col {
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.work-col-1-3 {
|
||||
width: calc((100% - 12px) / 3);
|
||||
}
|
||||
|
||||
.work-left-col, .work-middle-col, .work-right-col {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.work-card-1-3 {
|
||||
height: calc((100% - 12px) / 3);
|
||||
}
|
||||
|
||||
.work-card-2-3 {
|
||||
height: calc(2 * ((100% - 12px) / 3) + 6px);
|
||||
}
|
||||
|
||||
.work-card {
|
||||
width: 100%;
|
||||
background-color: rgba(15, 52, 96, 0.1);
|
||||
border: 1px solid rgba(26, 80, 139, 0.3);
|
||||
border-radius: 8px;
|
||||
padding: 2px;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
color: #e0e6ff;
|
||||
backdrop-filter: blur(2px);
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.full-card {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.work-card:hover {
|
||||
box-shadow: 0 4px 12px rgba(60, 156, 255, 0.2);
|
||||
border-color: rgba(60, 156, 255, 0.6);
|
||||
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;
|
||||
}
|
||||
|
||||
.work-left-sidebar {
|
||||
width: 15%;
|
||||
height: 100%;
|
||||
@@ -143,135 +71,124 @@ const activeMenu = ref(1)
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
background: transparent;
|
||||
border: 1px solid rgba(26, 80, 139, 0.3);
|
||||
border-radius: 12px;
|
||||
padding: 16px;
|
||||
backdrop-filter: blur(2px);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.menu-title {
|
||||
height: 10%;
|
||||
background: rgba(15, 52, 96, 0.1);
|
||||
border: 1px solid rgba(26, 80, 139, 0.3);
|
||||
border-radius: 8px;
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #e0e6ff;
|
||||
backdrop-filter: blur(2px);
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 10;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.menu-title h3 {
|
||||
margin: 0;
|
||||
font-size: 16px;
|
||||
letter-spacing: 1px;
|
||||
background: #3c9cff;
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
font-weight: 600;
|
||||
padding: 0 4px 8px 4px;
|
||||
color: #e0e6ff;
|
||||
font-size: 20px;
|
||||
border-bottom: 1px solid rgba(26, 80, 139, 0.5);
|
||||
line-height: 1;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.menu-list {
|
||||
height: 90%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
gap: 8px;
|
||||
padding: 4px 0;
|
||||
margin-top: 0;
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding-right: 4px;
|
||||
}
|
||||
|
||||
.menu-list::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.menu-list::-webkit-scrollbar-track {
|
||||
background: rgba(26, 80, 139, 0.1);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.menu-list::-webkit-scrollbar-thumb {
|
||||
background: rgba(26, 80, 139, 0.5);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.menu-list::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(26, 80, 139, 0.7);
|
||||
}
|
||||
|
||||
.menu-item {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgba(15, 52, 96, 0.1);
|
||||
border: 1px solid rgba(26, 80, 139, 0.3);
|
||||
height: 36px;
|
||||
line-height: 36px;
|
||||
padding: 0 16px;
|
||||
border-radius: 8px;
|
||||
color: #e0e6ff;
|
||||
font-size: 16px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
transition: all 0.3s ease;
|
||||
background: rgba(26, 80, 139, 0.2);
|
||||
color: #e0e6ff;
|
||||
text-align: center;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.menu-item:hover {
|
||||
background: rgba(26, 80, 139, 0.3);
|
||||
color: #fff;
|
||||
box-shadow: 0 2px 8px rgba(60, 156, 255, 0.2);
|
||||
}
|
||||
|
||||
.menu-item.active {
|
||||
border-color: rgba(60, 156, 255, 0.6);
|
||||
box-shadow: 0 4px 12px rgba(60, 156, 255, 0.2);
|
||||
background: rgba(60, 156, 255, 0.1);
|
||||
background: linear-gradient(90deg, rgba(26, 80, 139, 0.8), rgba(60, 156, 255, 0.8));
|
||||
color: #fff;
|
||||
font-weight: 500;
|
||||
box-shadow: 0 2px 8px rgba(60, 156, 255, 0.4);
|
||||
}
|
||||
|
||||
/* 你原来的媒体查询我完全不动 */
|
||||
@media (max-width: 1600px) {
|
||||
.work-layout-container {
|
||||
padding: 6px;
|
||||
gap: 4px;
|
||||
}
|
||||
.work-section {
|
||||
gap: 4px;
|
||||
}
|
||||
.work-col-1-3 {
|
||||
width: calc((100% - 8px) / 3);
|
||||
}
|
||||
.work-card-1-3 {
|
||||
height: calc((100% - 8px) / 3);
|
||||
}
|
||||
.work-card-2-3 {
|
||||
height: calc(2 * ((100% - 8px) / 3) + 4px);
|
||||
}
|
||||
.work-card {
|
||||
padding: 10px;
|
||||
}
|
||||
.work-card h3 {
|
||||
font-size: 14px;
|
||||
}
|
||||
.work-card p {
|
||||
font-size: 12px;
|
||||
}
|
||||
.work-main-section {
|
||||
height: 100%;
|
||||
width: 85%;
|
||||
background: transparent;
|
||||
border: 1px solid rgba(26, 80, 139, 0.3);
|
||||
border-radius: 12px;
|
||||
padding: 16px;
|
||||
backdrop-filter: blur(2px);
|
||||
overflow: auto;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.work-layout-container {
|
||||
flex-direction: column;
|
||||
height: auto;
|
||||
min-height: 100%;
|
||||
padding: 6px;
|
||||
gap: 6px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.work-section {
|
||||
flex-direction: column;
|
||||
height: auto !important;
|
||||
min-height: 120px;
|
||||
gap: 6px;
|
||||
}
|
||||
.work-col-1-3 {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
.work-left-col, .work-middle-col, .work-right-col {
|
||||
flex-direction: column;
|
||||
height: auto;
|
||||
}
|
||||
.work-card-1-3, .work-card-2-3 {
|
||||
height: 120px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.work-card {
|
||||
padding: 8px;
|
||||
}
|
||||
.menu-content {
|
||||
padding: 0 4px;
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
color: #e0e6ff;
|
||||
}
|
||||
|
||||
@media (max-height: 900px) {
|
||||
.work-layout-container {
|
||||
padding: 6px;
|
||||
gap: 4px;
|
||||
}
|
||||
.work-section {
|
||||
gap: 4px;
|
||||
}
|
||||
.work-card {
|
||||
padding: 8px;
|
||||
}
|
||||
.work-card h3 {
|
||||
font-size: 14px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.work-card p {
|
||||
font-size: 12px;
|
||||
}
|
||||
.menu-content h4 {
|
||||
margin: 0 0 16px 0;
|
||||
color: #fff;
|
||||
font-size: 20px;
|
||||
border-bottom: 1px solid rgba(26, 80, 139, 0.5);
|
||||
padding-bottom: 8px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.menu-content p {
|
||||
margin: 0;
|
||||
color: #e0e6ff;
|
||||
line-height: 1.6;
|
||||
font-size: 14px;
|
||||
}
|
||||
</style>
|
||||
@@ -5,56 +5,65 @@
|
||||
<ChartTop />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="work-section work-main-section">
|
||||
<div class="work-col work-col-1-3 work-left-col">
|
||||
<div class="work-card work-card-1-3">
|
||||
<ChartV01 :formParams="FormValues" />
|
||||
</div>
|
||||
<div class="work-card work-card-1-3">
|
||||
<ChartV02 :formParams="FormValues" />
|
||||
</div>
|
||||
<div class="work-card work-card-1-3">
|
||||
<ChartV03 :formParams="FormValues" />
|
||||
</div>
|
||||
<div
|
||||
v-for="item in getComponentsBySortRange(1, 3)"
|
||||
:key="item.sort"
|
||||
class="work-card work-card-1-3"
|
||||
>
|
||||
<component
|
||||
:is="componentMap[item.vueName]"
|
||||
:formParams="FormValues"
|
||||
v-if="componentMap[item.vueName]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="work-col work-col-1-3 work-middle-col">
|
||||
<div class="work-card work-card-2-3">
|
||||
<ChartV04 :formParams="FormValues" />
|
||||
</div>
|
||||
<div class="work-card work-card-1-3">
|
||||
<ChartV05 :formParams="FormValues" />
|
||||
</div>
|
||||
<div
|
||||
:key="getComponentBySort(4)?.sort"
|
||||
class="work-card work-card-2-3"
|
||||
v-if="getComponentBySort(4)"
|
||||
>
|
||||
<component
|
||||
:is="componentMap[getComponentBySort(4).vueName]"
|
||||
:formParams="FormValues"
|
||||
v-if="componentMap[getComponentBySort(4).vueName]"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
:key="getComponentBySort(5)?.sort"
|
||||
class="work-card work-card-1-3"
|
||||
v-if="getComponentBySort(5)"
|
||||
>
|
||||
<component
|
||||
:is="componentMap[getComponentBySort(5).vueName]"
|
||||
:formParams="FormValues"
|
||||
v-if="componentMap[getComponentBySort(5).vueName]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="work-col work-col-1-3 work-right-col">
|
||||
<div class="work-card work-card-1-3">
|
||||
<ChartV06 :formParams="FormValues" />
|
||||
</div>
|
||||
<div class="work-card work-card-1-3">
|
||||
<ChartV07 :formParams="FormValues" />
|
||||
</div>
|
||||
<div class="work-card work-card-1-3">
|
||||
<ChartV08 :formParams="FormValues" />
|
||||
</div>
|
||||
<div
|
||||
v-for="item in getComponentsBySortRange(6, 8)"
|
||||
:key="item.sort"
|
||||
class="work-card work-card-1-3"
|
||||
>
|
||||
<component
|
||||
:is="componentMap[item.vueName]"
|
||||
:formParams="FormValues"
|
||||
v-if="componentMap[item.vueName]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { ref, watch, onMounted } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import ChartTop from './components/ChartTop.vue'
|
||||
import ChartV01 from './components/ChartV01.vue';
|
||||
import ChartV02 from './components/ChartV02.vue';
|
||||
import ChartV03 from './components/ChartV03.vue';
|
||||
import ChartV04 from './components/ChartV04.vue';
|
||||
import ChartV05 from './components/ChartV05.vue';
|
||||
import ChartV06 from './components/ChartV06.vue';
|
||||
import ChartV07 from './components/ChartV07.vue';
|
||||
import ChartV08 from './components/ChartV08.vue';
|
||||
import ChartTop from './components/ChartTop.vue';
|
||||
|
||||
const route = useRoute();
|
||||
|
||||
@@ -65,13 +74,70 @@ const FormValues = ref({
|
||||
watch(
|
||||
() => route.query.year,
|
||||
(newVal) => {
|
||||
FormValues.value.reqParam = newVal;
|
||||
FormValues.value.reqParam = newVal;
|
||||
},
|
||||
{
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
);
|
||||
|
||||
const componentMap = ref({});
|
||||
const chartData = ref([]);
|
||||
|
||||
const getComponentBySort = (sort) => {
|
||||
return chartData.value.find(item => item.sort === sort);
|
||||
};
|
||||
|
||||
const getComponentsBySortRange = (start, end) => {
|
||||
return chartData.value.filter(item => item.sort >= start && item.sort <= end);
|
||||
};
|
||||
|
||||
const loadComponent = async (vueName) => {
|
||||
try {
|
||||
const module = await import(`./components/${vueName}.vue`);
|
||||
return module.default;
|
||||
} catch (error) {
|
||||
console.error('加载组件失败', error);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const fetchChartData = async () => {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
const apiData = [
|
||||
{ sort: 1, vueName: 'ChartV01' },
|
||||
{ sort: 2, vueName: 'ChartV02' },
|
||||
{ sort: 3, vueName: 'ChartV03' },
|
||||
{ sort: 4, vueName: 'ChartV04' },
|
||||
{ sort: 5, vueName: 'ChartV05' },
|
||||
{ sort: 6, vueName: 'ChartV06' },
|
||||
{ sort: 7, vueName: 'ChartV07' },
|
||||
{ sort: 8, vueName: 'ChartV08' },
|
||||
];
|
||||
resolve(apiData);
|
||||
}, 300);
|
||||
});
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const data = await fetchChartData();
|
||||
chartData.value = data.sort((a, b) => a.sort - b.sort);
|
||||
const newComponentMap = {};
|
||||
const uniqueComponents = [...new Set(data.map(item => item.vueName))];
|
||||
for (const vueName of uniqueComponents) {
|
||||
const component = await loadComponent(vueName);
|
||||
if (component) {
|
||||
newComponentMap[vueName] = component;
|
||||
}
|
||||
}
|
||||
componentMap.value = newComponentMap;
|
||||
} catch (error) {
|
||||
console.error('加载图表数据失败:', error);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@@ -174,6 +240,15 @@ watch(
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.empty-card {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
color: #88a0c2;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
@media (max-width: 1600px) {
|
||||
.work-layout-container {
|
||||
padding: 6px;
|
||||
|
||||
Reference in New Issue
Block a user