项目初始化

This commit is contained in:
2026-03-24 11:40:47 +08:00
parent 61d3520d11
commit fc00fb634c
4 changed files with 923 additions and 990 deletions

View File

@@ -7,17 +7,9 @@
</div>
<div class="erp-section erp-upper-section">
<div
v-for="item in getComponentsBySortRange(1, 3)"
:key="item.sort"
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">
<component
:is="componentMap[item.vueName]"
:formParams="FormValues"
v-if="componentMap[item.vueName]"
/>
<component :is="componentMap[item.vueName]" :formParams="FormValues" v-if="componentMap[item.vueName]" />
</div>
</div>
</div>
@@ -25,17 +17,9 @@
<div class="erp-section erp-middle-section">
<div class="erp-col erp-col-1-2">
<div class="erp-inner-layout">
<div
v-for="item in getComponentsBySortRange(4, 5)"
:key="item.sort"
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">
<component
:is="componentMap[item.vueName]"
:formParams="FormValues"
v-if="componentMap[item.vueName]"
/>
<component :is="componentMap[item.vueName]" :formParams="FormValues" v-if="componentMap[item.vueName]" />
</div>
</div>
</div>
@@ -54,17 +38,9 @@
<div class="erp-section erp-lower-section">
<div class="erp-col erp-col-1-2">
<div class="erp-inner-layout">
<div
v-for="item in getComponentsBySortRange(7, 8)"
:key="item.sort"
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">
<component
:is="componentMap[item.vueName]"
:formParams="FormValues"
v-if="componentMap[item.vueName]"
/>
<component :is="componentMap[item.vueName]" :formParams="FormValues" v-if="componentMap[item.vueName]" />
</div>
</div>
</div>
@@ -83,285 +59,279 @@
</template>
<script lang="ts" setup>
import { ref, watch, onMounted, defineAsyncComponent } from 'vue';
import { useRoute } from 'vue-router';
import type { Component } from 'vue';
import ChartTop from './components/ChartTop.vue';
import { MyChartInfo, myChartInfoListAll } from '@jeesite/biz/api/biz/myChartInfo';
import { ref, watch, onMounted, defineAsyncComponent } from 'vue';
import { useRoute } from 'vue-router';
import type { Component } from 'vue';
import ChartTop from './components/ChartTop.vue';
import { MyChartInfo, myChartInfoListAll } from '@jeesite/biz/api/biz/myChartInfo';
const route = useRoute();
const route = useRoute();
// 1. 完善类型定义,避免 any 类型
const FormValues = ref({
yearDate: route.query.yearDate || ''
});
// 2. 定义组件映射的类型
interface ComponentMap {
[key: string]: Component;
}
// 3. 初始化时赋空数组,避免 undefined 问题
const componentMap = ref<ComponentMap>({});
const chartData = ref<MyChartInfo[]>([]);
// 4. 优化空值处理
const getComponentBySort = (sort: number): MyChartInfo | undefined => {
if (!chartData.value.length) return undefined;
return chartData.value.find(item => item.sort === sort);
};
const getComponentsBySortRange = (start: number, end: number): MyChartInfo[] => {
if (!chartData.value.length) return [];
return chartData.value.filter(item => item.sort >= start && item.sort <= end);
};
// 5. 优化组件加载函数
const loadComponent = (vueName: string) => {
return defineAsyncComponent({
loader: () => import(`./components/${vueName}.vue`),
delay: 200,
timeout: 5000
const FormValues = ref({
yearDate: route.query.yearDate || '',
});
};
// 6. 封装数据获取逻辑
async function getChartList() {
try {
const reqParams = {
chartCode: 'erp'
};
const res = await myChartInfoListAll(reqParams);
chartData.value = res || [];
// 排序确保顺序正确
chartData.value.sort((a, b) => a.sort - b.sort);
} catch (error) {
console.error('获取数据失败:', error);
chartData.value = [];
interface ComponentMap {
[key: string]: Component;
}
}
// 7. 监听路由参数变化
watch(
() => route.query.yearDate,
(newVal) => {
FormValues.value.yearDate = newVal || '';
},
{
deep: true,
immediate: true
}
);
const componentMap = ref<ComponentMap>({});
const chartData = ref<MyChartInfo[]>([]);
onMounted(async () => {
try {
await getChartList();
const newComponentMap: ComponentMap = {};
// 获取唯一的组件名称
const uniqueComponents = [...new Set(chartData.value.map(item => item.vueName))];
// 加载所有需要的组件
for (const vueName of uniqueComponents) {
if (vueName) {
newComponentMap[vueName] = loadComponent(vueName);
}
const getSortValue = (item: MyChartInfo) => Number(item.sort ?? 0);
const getComponentBySort = (sort: number): MyChartInfo | undefined => {
if (!chartData.value.length) return undefined;
return chartData.value.find((item) => getSortValue(item) === sort);
};
const getComponentsBySortRange = (start: number, end: number): MyChartInfo[] => {
if (!chartData.value.length) return [];
return chartData.value.filter((item) => {
const sort = getSortValue(item);
return sort >= start && sort <= end;
});
};
const loadComponent = (vueName: string) => {
return defineAsyncComponent({
loader: () => import(`./components/${vueName}.vue`),
delay: 200,
timeout: 5000,
});
};
async function getChartList() {
try {
const reqParams = {
chartCode: 'erp',
};
const res = await myChartInfoListAll(reqParams);
chartData.value = res || [];
chartData.value.sort((a, b) => getSortValue(a) - getSortValue(b));
} catch (error) {
console.error('获取数据失败:', error);
chartData.value = [];
}
componentMap.value = newComponentMap;
} catch (error) {
console.error('加载图表数据失败:', error);
}
});
watch(
() => route.query.yearDate,
(newVal) => {
FormValues.value.yearDate = newVal || '';
},
{
deep: true,
immediate: true,
},
);
onMounted(async () => {
try {
await getChartList();
const newComponentMap: ComponentMap = {};
const uniqueComponents = [...new Set(chartData.value.map((item) => item.vueName))];
for (const vueName of uniqueComponents) {
if (vueName) {
newComponentMap[vueName] = loadComponent(vueName);
}
}
componentMap.value = newComponentMap;
} catch (error) {
console.error('加载图表数据失败:', error);
}
});
</script>
<style scoped>
.erp-layout-container {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
gap: 2px;
padding: 2px;
margin: 0 !important;
box-sizing: border-box;
background-color: transparent;
overflow: hidden;
}
.erp-section {
width: 100%;
display: flex;
gap: 2px;
box-sizing: border-box;
overflow: hidden;
}
.erp-top-header {
height: 10%;
}
.erp-upper-section,
.erp-middle-section,
.erp-lower-section {
height: 30%;
}
.erp-col {
height: 100%;
box-sizing: border-box;
overflow: hidden;
}
.erp-col-1-3 {
width: calc((100% - 4px) / 3);
}
.erp-col-1-2 {
width: calc((100% - 2px) / 2);
}
.erp-inner-layout {
width: 100%;
height: 100%;
display: flex;
gap: 2px;
box-sizing: border-box;
}
.erp-card {
width: 100%;
height: 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%;
}
.erp-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;
}
.erp-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;
}
.erp-card p {
font-size: 13px;
opacity: 0.75;
color: #b4c7e7;
text-align: center;
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 {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
gap: 2px;
padding: 2px;
gap: 2px;
margin: 0 !important;
box-sizing: border-box;
background-color: transparent;
overflow: hidden;
}
.erp-section {
width: 100%;
display: flex;
gap: 2px;
box-sizing: border-box;
overflow: hidden;
}
.erp-top-header {
height: 10%;
}
.erp-upper-section,
.erp-middle-section,
.erp-lower-section {
height: 30%;
}
.erp-col {
height: 100%;
box-sizing: border-box;
overflow: hidden;
}
.erp-col-1-3 {
width: calc((100% - 4px) / 3);
}
.erp-col-1-2 {
width: calc((100% - 2px) / 2);
}
.erp-inner-layout {
gap: 2px;
}
.erp-card {
padding: 2px;
}
.erp-card h3 {
font-size: 14px;
}
.erp-card p {
font-size: 12px;
}
}
@media (max-width: 768px) {
.erp-layout-container {
flex-direction: column;
height: auto;
min-height: 100vh;
padding: 2px;
gap: 2px;
overflow-y: auto;
}
.erp-section {
flex-direction: column;
height: auto !important;
min-height: 120px;
gap: 2px;
margin-bottom: 8px;
}
.erp-col-1-3,
.erp-col-1-2 {
.erp-inner-layout {
width: 100%;
height: 120px; /* 固定高度,避免计算错误 */
margin-bottom: 2px;
}
.erp-inner-layout {
flex-direction: column;
height: 100%;
display: flex;
gap: 2px;
box-sizing: border-box;
}
.erp-card {
padding: 8px; /* 增加移动端内边距,提升体验 */
}
}
@media (max-height: 900px) {
.erp-layout-container {
padding: 2px;
gap: 2px;
}
.erp-section {
gap: 2px;
}
.erp-card {
width: 100%;
height: 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%;
}
.erp-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;
}
.erp-card h3 {
font-size: 14px;
margin-bottom: 6px;
font-size: 16px;
margin-bottom: 8px;
letter-spacing: 1px;
background: #3c9cff;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
font-weight: 600;
}
.erp-card p {
font-size: 12px;
font-size: 13px;
opacity: 0.75;
color: #b4c7e7;
text-align: center;
line-height: 1.5;
}
}
</style>
.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: 2px;
gap: 2px;
}
.erp-section {
gap: 2px;
}
.erp-col-1-3 {
width: calc((100% - 4px) / 3);
}
.erp-col-1-2 {
width: calc((100% - 2px) / 2);
}
.erp-inner-layout {
gap: 2px;
}
.erp-card {
padding: 2px;
}
.erp-card h3 {
font-size: 14px;
}
.erp-card p {
font-size: 12px;
}
}
@media (max-width: 768px) {
.erp-layout-container {
flex-direction: column;
height: auto;
min-height: 100vh;
padding: 2px;
gap: 2px;
overflow-y: auto;
}
.erp-section {
flex-direction: column;
height: auto !important;
min-height: 120px;
gap: 2px;
margin-bottom: 8px;
}
.erp-col-1-3,
.erp-col-1-2 {
width: 100%;
height: 120px; /* 固定高度,避免计算错误 */
margin-bottom: 2px;
}
.erp-inner-layout {
flex-direction: column;
height: 100%;
gap: 2px;
}
.erp-card {
padding: 8px; /* 增加移动端内边距,提升体验 */
}
}
@media (max-height: 900px) {
.erp-layout-container {
padding: 2px;
gap: 2px;
}
.erp-section {
gap: 2px;
}
.erp-card {
padding: 2px;
}
.erp-card h3 {
font-size: 14px;
margin-bottom: 6px;
}
.erp-card p {
font-size: 12px;
}
}
</style>

View File

@@ -8,44 +8,20 @@
<div class="work-section work-main-section">
<div class="work-row work-row-1-3">
<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 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-row work-row-1-3">
<div
v-for="item in getComponentsBySortRange(4, 5)"
:key="item.sort"
class="work-card work-card-1-2"
>
<component
:is="componentMap[item.vueName]"
:formParams="FormValues"
v-if="componentMap[item.vueName]"
/>
<div v-for="item in getComponentsBySortRange(4, 5)" :key="item.sort" class="work-card work-card-1-2">
<component :is="componentMap[item.vueName]" :formParams="FormValues" v-if="componentMap[item.vueName]" />
</div>
</div>
<div class="work-row work-row-1-3">
<div
v-for="item in getComponentsBySortRange(6, 7)"
:key="item.sort"
class="work-card work-card-1-2"
>
<component
:is="componentMap[item.vueName]"
:formParams="FormValues"
v-if="componentMap[item.vueName]"
/>
<div v-for="item in getComponentsBySortRange(6, 7)" :key="item.sort" class="work-card work-card-1-2">
<component :is="componentMap[item.vueName]" :formParams="FormValues" v-if="componentMap[item.vueName]" />
</div>
</div>
</div>
@@ -53,229 +29,239 @@
</template>
<script lang="ts" setup>
import { ref, watch, onMounted } from 'vue';
import { useRoute } from 'vue-router';
import ChartTop from './components/ChartTop.vue';
import { MyChartInfo, myChartInfoListAll } from '@jeesite/biz/api/biz/myChartInfo';
import { ref, watch, onMounted } from 'vue';
import type { Component } from 'vue';
import { useRoute } from 'vue-router';
import ChartTop from './components/ChartTop.vue';
import { MyChartInfo, myChartInfoListAll } from '@jeesite/biz/api/biz/myChartInfo';
const route = useRoute();
const route = useRoute();
const FormValues = ref({
yearDate: route.query.yearDate
});
const FormValues = ref({
yearDate: route.query.yearDate || '',
});
watch(
() => route.query.yearDate,
(newVal) => {
FormValues.value.yearDate = newVal;
},
{
deep: true,
immediate: true
watch(
() => route.query.yearDate,
(newVal) => {
FormValues.value.yearDate = newVal || '';
},
{
deep: true,
immediate: true,
},
);
interface ComponentMap {
[key: string]: Component;
}
);
const componentMap = ref({});
const chartData = ref([]);
const componentMap = ref<ComponentMap>({});
const chartData = ref<MyChartInfo[]>([]);
const getComponentsBySortRange = (start, end) => {
return chartData.value.filter(item => item.sort >= start && item.sort <= end);
};
const getSortValue = (item: MyChartInfo) => Number(item.sort ?? 0);
const loadComponent = async (vueName) => {
try {
const module = await import(`./components/${vueName}.vue`);
return module.default;
} catch (error) {
console.error('加载组件失败', error);
return null;
}
};
const getComponentsBySortRange = (start: number, end: number): MyChartInfo[] => {
return chartData.value.filter((item) => {
const sort = getSortValue(item);
return sort >= start && sort <= end;
});
};
async function getChartList(){
try {
const reqParams = {
chartCode: 'home'
const loadComponent = async (vueName: string): Promise<Component | null> => {
try {
const module = await import(`./components/${vueName}.vue`);
return module.default;
} catch (error) {
console.error('加载组件失败', error);
return null;
}
const res = await myChartInfoListAll(reqParams)
chartData.value = res || []
} catch (error) {
console.error('获取数据失败:', error);
chartData.value = []
}
}
};
onMounted(async () => {
try {
await getChartList();
chartData.value = chartData.value.sort((a, b) => a.sort - b.sort);
const newComponentMap = {};
const uniqueComponents = [...new Set(chartData.value.map(item => item.vueName))];
for (const vueName of uniqueComponents) {
const component = await loadComponent(vueName);
if (component) {
newComponentMap[vueName] = component;
async function getChartList() {
try {
const reqParams = {
chartCode: 'home',
};
const res = await myChartInfoListAll(reqParams);
chartData.value = res || [];
} catch (error) {
console.error('获取数据失败:', error);
chartData.value = [];
}
}
onMounted(async () => {
try {
await getChartList();
const newComponentMap: ComponentMap = {};
const uniqueComponents = [...new Set(chartData.value.map((item) => item.vueName))];
for (const vueName of uniqueComponents) {
if (vueName) {
newComponentMap[vueName] = loadComponent(vueName);
}
}
componentMap.value = newComponentMap;
} catch (error) {
console.error('加载图表数据失败:', error);
}
componentMap.value = newComponentMap;
} catch (error) {
console.error('加载图表数据失败:', error);
}
});
});
</script>
<style scoped>
.work-layout-container {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
gap: 2px;
padding: 2px;
margin: 0 !important;
box-sizing: border-box;
background-color: transparent;
overflow: hidden;
}
.work-section {
width: 100%;
display: flex;
gap: 2px;
box-sizing: border-box;
overflow: hidden;
}
.work-top-header {
height: 10%;
}
.work-main-section {
height: 90%;
flex-direction: column;
}
/* 行样式 */
.work-row {
width: 100%;
display: flex;
gap: 2px;
box-sizing: border-box;
overflow: hidden;
}
.work-row-1-3 {
height: calc((100% - 4px) / 3);
}
/* 一行 3 个时的卡片宽度 */
.work-card-1-3 {
width: calc((100% - 4px) / 3);
height: 100%;
}
/* 一行 2 个时的卡片宽度 */
.work-card-1-2 {
width: calc((100% - 2px) / 2);
height: 100%;
}
.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;
margin: 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;
}
.empty-card {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
color: #88a0c2;
font-size: 14px;
}
@media (max-width: 1600px) {
.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%;
overflow-y: auto;
}
.work-section {
flex-direction: column;
height: auto !important;
min-height: 120px;
}
.work-row-1-3 {
height: auto;
flex-direction: column;
}
.work-card-1-3,
.work-card-1-2 {
width: 100%;
height: 120px;
margin-bottom: 2px;
height: 100%;
display: flex;
flex-direction: column;
gap: 2px;
padding: 2px;
margin: 0 !important;
box-sizing: border-box;
background-color: transparent;
overflow: hidden;
}
.work-section {
width: 100%;
display: flex;
gap: 2px;
box-sizing: border-box;
overflow: hidden;
}
.work-top-header {
height: 10%;
}
.work-main-section {
height: 90%;
flex-direction: column;
}
/* 行样式 */
.work-row {
width: 100%;
display: flex;
gap: 2px;
box-sizing: border-box;
overflow: hidden;
}
.work-row-1-3 {
height: calc((100% - 4px) / 3);
}
/* 一行 3 个时的卡片宽度 */
.work-card-1-3 {
width: calc((100% - 4px) / 3);
height: 100%;
}
/* 一行 2 个时的卡片宽度 */
.work-card-1-2 {
width: calc((100% - 2px) / 2);
height: 100%;
}
.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;
margin: 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;
}
}
@media (max-height: 900px) {
.work-card h3 {
font-size: 14px;
margin-bottom: 6px;
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: 12px;
font-size: 13px;
opacity: 0.75;
color: #b4c7e7;
text-align: center;
line-height: 1.5;
}
}
</style>
.empty-card {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
color: #88a0c2;
font-size: 14px;
}
@media (max-width: 1600px) {
.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%;
overflow-y: auto;
}
.work-section {
flex-direction: column;
height: auto !important;
min-height: 120px;
}
.work-row-1-3 {
height: auto;
flex-direction: column;
}
.work-card-1-3,
.work-card-1-2 {
width: 100%;
height: 120px;
margin-bottom: 2px;
}
}
@media (max-height: 900px) {
.work-card h3 {
font-size: 14px;
margin-bottom: 6px;
}
.work-card p {
font-size: 12px;
}
}
</style>

View File

@@ -8,44 +8,20 @@
<div class="work-section work-main-section">
<div class="work-row work-row-1-3">
<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 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-row work-row-1-3">
<div
v-for="item in getComponentsBySortRange(4, 6)"
:key="item.sort"
class="work-card work-card-1-3"
>
<component
:is="componentMap[item.vueName]"
:formParams="FormValues"
v-if="componentMap[item.vueName]"
/>
<div v-for="item in getComponentsBySortRange(4, 6)" :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-row work-row-1-3">
<div
v-for="item in getComponentsBySortRange(7, 9)"
:key="item.sort"
class="work-card work-card-1-3"
>
<component
:is="componentMap[item.vueName]"
:formParams="FormValues"
v-if="componentMap[item.vueName]"
/>
<div v-for="item in getComponentsBySortRange(7, 9)" :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>
@@ -53,220 +29,230 @@
</template>
<script lang="ts" setup>
import { ref, watch, onMounted } from 'vue';
import { useRoute } from 'vue-router';
import ChartTop from './components/ChartTop.vue';
import { MyChartInfo, myChartInfoListAll } from '@jeesite/biz/api/biz/myChartInfo';
import { ref, watch, onMounted } from 'vue';
import type { Component } from 'vue';
import { useRoute } from 'vue-router';
import ChartTop from './components/ChartTop.vue';
import { MyChartInfo, myChartInfoListAll } from '@jeesite/biz/api/biz/myChartInfo';
const route = useRoute();
const route = useRoute();
const FormValues = ref({
yearDate: route.query.year
});
const FormValues = ref({
yearDate: route.query.yearDate || '',
});
watch(
() => route.query.yearDate,
(newVal) => {
FormValues.value.yearDate = newVal;
},
{
deep: true,
immediate: true
watch(
() => route.query.yearDate,
(newVal) => {
FormValues.value.yearDate = newVal || '';
},
{
deep: true,
immediate: true,
},
);
interface ComponentMap {
[key: string]: Component;
}
);
const componentMap = ref({});
const chartData = ref([]);
const componentMap = ref<ComponentMap>({});
const chartData = ref<MyChartInfo[]>([]);
const getComponentsBySortRange = (start, end) => {
return chartData.value.filter(item => item.sort >= start && item.sort <= end);
};
const getSortValue = (item: MyChartInfo) => Number(item.sort ?? 0);
const loadComponent = async (vueName) => {
try {
const module = await import(`./components/${vueName}.vue`);
return module.default;
} catch (error) {
console.error('加载组件失败', error);
return null;
}
};
const getComponentsBySortRange = (start: number, end: number): MyChartInfo[] => {
return chartData.value.filter((item) => {
const sort = getSortValue(item);
return sort >= start && sort <= end;
});
};
async function getChartList(){
try {
const reqParams = {
chartCode: 'sys'
}
const res = await myChartInfoListAll(reqParams)
chartData.value = res || []
} catch (error) {
console.error('获取数据失败:', error);
chartData.value = []
}
}
onMounted(async () => {
try {
await getChartList();
chartData.value = chartData.value.sort((a, b) => a.sort - b.sort);
const newComponentMap = {};
const uniqueComponents = [...new Set(chartData.value.map(item => item.vueName))];
for (const vueName of uniqueComponents) {
const component = await loadComponent(vueName);
if (component) {
newComponentMap[vueName] = component;
}
const loadComponent = async (vueName: string): Promise<Component | null> => {
try {
const module = await import(`./components/${vueName}.vue`);
return module.default;
} catch (error) {
console.error('加载组件失败', error);
return null;
}
};
async function getChartList() {
try {
const reqParams = {
chartCode: 'sys',
};
const res = await myChartInfoListAll(reqParams);
chartData.value = res || [];
} catch (error) {
console.error('获取数据失败:', error);
chartData.value = [];
}
componentMap.value = newComponentMap;
} catch (error) {
console.error('加载图表数据失败:', error);
}
});
onMounted(async () => {
try {
await getChartList();
const newComponentMap: ComponentMap = {};
const uniqueComponents = [...new Set(chartData.value.map((item) => item.vueName))];
for (const vueName of uniqueComponents) {
if (vueName) {
newComponentMap[vueName] = loadComponent(vueName);
}
}
componentMap.value = newComponentMap;
} catch (error) {
console.error('加载图表数据失败:', error);
}
});
</script>
<style scoped>
.work-layout-container {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
gap: 2px;
padding: 2px;
margin: 0 !important;
box-sizing: border-box;
background-color: transparent;
overflow: hidden;
}
.work-section {
width: 100%;
display: flex;
gap: 2px;
box-sizing: border-box;
overflow: hidden;
}
.work-top-header {
height: 10%;
}
.work-main-section {
height: 90%;
flex-direction: column;
}
.work-row {
width: 100%;
display: flex;
gap: 2px;
box-sizing: border-box;
overflow: hidden;
}
.work-row-1-3 {
height: calc((100% - 4px) / 3);
}
.work-card-1-3 {
width: calc((100% - 4px) / 3);
height: 100%;
}
.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;
margin: 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;
}
.empty-card {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
color: #88a0c2;
font-size: 14px;
}
@media (max-width: 1600px) {
.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%;
overflow-y: auto;
}
.work-section {
flex-direction: column;
height: auto !important;
min-height: 120px;
}
.work-row-1-3 {
height: auto;
flex-direction: column;
}
.work-card-1-3 {
width: 100%;
height: 120px;
margin-bottom: 2px;
height: 100%;
display: flex;
flex-direction: column;
gap: 2px;
padding: 2px;
margin: 0 !important;
box-sizing: border-box;
background-color: transparent;
overflow: hidden;
}
.work-section {
width: 100%;
display: flex;
gap: 2px;
box-sizing: border-box;
overflow: hidden;
}
.work-top-header {
height: 10%;
}
.work-main-section {
height: 90%;
flex-direction: column;
}
.work-row {
width: 100%;
display: flex;
gap: 2px;
box-sizing: border-box;
overflow: hidden;
}
.work-row-1-3 {
height: calc((100% - 4px) / 3);
}
.work-card-1-3 {
width: calc((100% - 4px) / 3);
height: 100%;
}
.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;
margin: 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;
}
}
@media (max-height: 900px) {
.work-card h3 {
font-size: 14px;
margin-bottom: 6px;
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: 12px;
font-size: 13px;
opacity: 0.75;
color: #b4c7e7;
text-align: center;
line-height: 1.5;
}
}
</style>
.empty-card {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
color: #88a0c2;
font-size: 14px;
}
@media (max-width: 1600px) {
.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%;
overflow-y: auto;
}
.work-section {
flex-direction: column;
height: auto !important;
min-height: 120px;
}
.work-row-1-3 {
height: auto;
flex-direction: column;
}
.work-card-1-3 {
width: 100%;
height: 120px;
margin-bottom: 2px;
}
}
@media (max-height: 900px) {
.work-card h3 {
font-size: 14px;
margin-bottom: 6px;
}
.work-card p {
font-size: 12px;
}
}
</style>

View File

@@ -7,35 +7,19 @@
</div>
<div class="work-section work-main-section">
<div class="work-col work-col-1-3 work-left-col">
<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 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
:key="getComponentBySort(4)?.sort"
class="work-card work-card-2-3"
v-if="getComponentBySort(4)"
>
<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)"
>
<div :key="getComponentBySort(5)?.sort" class="work-card work-card-1-3" v-if="getComponentBySort(5)">
<component
:is="componentMap[getComponentBySort(5).vueName]"
:formParams="FormValues"
@@ -44,16 +28,8 @@
</div>
</div>
<div class="work-col work-col-1-3 work-right-col">
<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 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>
@@ -61,269 +37,284 @@
</template>
<script lang="ts" setup>
import { ref, watch, onMounted } from 'vue';
import { useRoute } from 'vue-router';
import ChartTop from './components/ChartTop.vue';
import { MyChartInfo, myChartInfoListAll } from '@jeesite/biz/api/biz/myChartInfo';
import { ref, watch, onMounted } from 'vue';
import type { Component } from 'vue';
import { useRoute } from 'vue-router';
import ChartTop from './components/ChartTop.vue';
import { MyChartInfo, myChartInfoListAll } from '@jeesite/biz/api/biz/myChartInfo';
const route = useRoute();
const route = useRoute();
const FormValues = ref({
yearDate: route.query.yearDate
});
const FormValues = ref({
yearDate: route.query.yearDate || '',
});
watch(
() => route.query.yearDate,
(newVal) => {
FormValues.value.yearDate = newVal;
},
{
deep: true,
immediate: true
watch(
() => route.query.yearDate,
(newVal) => {
FormValues.value.yearDate = newVal || '';
},
{
deep: true,
immediate: true,
},
);
interface ComponentMap {
[key: string]: Component;
}
);
const componentMap = ref({});
const chartData = ref([]);
const componentMap = ref<ComponentMap>({});
const chartData = ref<MyChartInfo[]>([]);
const getComponentBySort = (sort) => {
return chartData.value.find(item => item.sort === sort);
};
const getSortValue = (item: MyChartInfo) => Number(item.sort ?? 0);
const getComponentsBySortRange = (start, end) => {
return chartData.value.filter(item => item.sort >= start && item.sort <= end);
};
const getComponentBySort = (sort: number): MyChartInfo | undefined => {
return chartData.value.find((item) => getSortValue(item) === sort);
};
const loadComponent = async (vueName) => {
try {
const module = await import(`./components/${vueName}.vue`);
return module.default;
} catch (error) {
console.error('加载组件失败', error);
return null;
}
};
const getComponentsBySortRange = (start: number, end: number): MyChartInfo[] => {
return chartData.value.filter((item) => {
const sort = getSortValue(item);
return sort >= start && sort <= end;
});
};
async function getChartList(){
try {
const reqParams = {
chartCode: 'work'
}
const res = await myChartInfoListAll(reqParams)
chartData.value = res || []
} catch (error) {
console.error('获取数据失败:', error);
chartData.value = []
}
}
onMounted(async () => {
try {
await getChartList();
chartData.value = chartData.value.sort((a, b) => a.sort - b.sort);
const newComponentMap = {};
const uniqueComponents = [...new Set(chartData.value.map(item => item.vueName))];
for (const vueName of uniqueComponents) {
const component = await loadComponent(vueName);
if (component) {
newComponentMap[vueName] = component;
}
const loadComponent = async (vueName: string): Promise<Component | null> => {
try {
const module = await import(`./components/${vueName}.vue`);
return module.default;
} catch (error) {
console.error('加载组件失败', error);
return null;
}
};
async function getChartList() {
try {
const reqParams = {
chartCode: 'work',
};
const res = await myChartInfoListAll(reqParams);
chartData.value = res || [];
} catch (error) {
console.error('获取数据失败:', error);
chartData.value = [];
}
componentMap.value = newComponentMap;
} catch (error) {
console.error('加载图表数据失败:', error);
}
});
onMounted(async () => {
try {
await getChartList();
const newComponentMap: ComponentMap = {};
const uniqueComponents = [...new Set(chartData.value.map((item) => item.vueName))];
for (const vueName of uniqueComponents) {
if (vueName) {
newComponentMap[vueName] = loadComponent(vueName);
}
}
componentMap.value = newComponentMap;
} catch (error) {
console.error('加载图表数据失败:', error);
}
});
</script>
<style scoped>
.work-layout-container {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
gap: 2px;
padding: 2px;
margin: 0 !important;
box-sizing: border-box;
background-color: transparent;
overflow: hidden;
}
.work-section {
width: 100%;
display: flex;
gap: 2px;
box-sizing: border-box;
overflow: hidden;
}
.work-top-header {
height: 10%;
}
.work-main-section {
height: 90%;
}
.work-col {
height: 100%;
box-sizing: border-box;
overflow: hidden;
}
.work-col-1-3 {
width: calc((100% - 4px) / 3);
}
.work-left-col, .work-middle-col, .work-right-col {
display: flex;
flex-direction: column;
gap: 2px;
}
.work-card-1-3 {
height: calc((100% - 4px) / 3);
}
.work-card-2-3 {
height: calc(2 * ((100% - 4px) / 3) + 2px);
}
.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;
margin: 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;
}
.empty-card {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
color: #88a0c2;
font-size: 14px;
}
@media (max-width: 1600px) {
.work-layout-container {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
gap: 2px;
padding: 2px;
gap: 2px;
margin: 0 !important;
box-sizing: border-box;
background-color: transparent;
overflow: hidden;
}
.work-section {
width: 100%;
display: flex;
gap: 2px;
box-sizing: border-box;
overflow: hidden;
}
.work-top-header {
height: 10%;
}
.work-main-section {
height: 90%;
}
.work-col {
height: 100%;
box-sizing: border-box;
overflow: hidden;
}
.work-col-1-3 {
width: calc((100% - 4px) / 3);
}
.work-left-col,
.work-middle-col,
.work-right-col {
display: flex;
flex-direction: column;
gap: 2px;
}
.work-card-1-3 {
height: calc((100% - 4px) / 3);
}
.work-card-2-3 {
height: calc(2 * ((100% - 4px) / 3) + 2px);
}
.work-card {
padding: 2px;
}
.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: 2px;
gap: 2px;
overflow-y: auto;
}
.work-section {
flex-direction: column;
height: auto !important;
min-height: 120px;
gap: 2px;
}
.work-col-1-3 {
.work-card {
width: 100%;
height: auto;
}
.work-left-col, .work-middle-col, .work-right-col {
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;
height: auto;
gap: 2px;
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;
margin: 0;
}
.work-card-1-3, .work-card-2-3 {
height: 120px;
margin-bottom: 2px;
}
.work-card {
padding: 2px;
}
}
@media (max-height: 900px) {
.work-layout-container {
padding: 2px;
gap: 2px;
.full-card {
width: 100%;
height: 100%;
}
.work-section {
gap: 2px;
}
.work-card {
padding: 2px;
.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: 14px;
margin-bottom: 6px;
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: 12px;
font-size: 13px;
opacity: 0.75;
color: #b4c7e7;
text-align: center;
line-height: 1.5;
}
}
</style>
.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: 2px;
gap: 2px;
}
.work-section {
gap: 2px;
}
.work-col-1-3 {
width: calc((100% - 4px) / 3);
}
.work-card-1-3 {
height: calc((100% - 4px) / 3);
}
.work-card-2-3 {
height: calc(2 * ((100% - 4px) / 3) + 2px);
}
.work-card {
padding: 2px;
}
.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: 2px;
gap: 2px;
overflow-y: auto;
}
.work-section {
flex-direction: column;
height: auto !important;
min-height: 120px;
gap: 2px;
}
.work-col-1-3 {
width: 100%;
height: auto;
}
.work-left-col,
.work-middle-col,
.work-right-col {
flex-direction: column;
height: auto;
gap: 2px;
}
.work-card-1-3,
.work-card-2-3 {
height: 120px;
margin-bottom: 2px;
}
.work-card {
padding: 2px;
}
}
@media (max-height: 900px) {
.work-layout-container {
padding: 2px;
gap: 2px;
}
.work-section {
gap: 2px;
}
.work-card {
padding: 2px;
}
.work-card h3 {
font-size: 14px;
margin-bottom: 6px;
}
.work-card p {
font-size: 12px;
}
}
</style>