项目初始化
This commit is contained in:
@@ -5,4 +5,4 @@
|
||||
</script>
|
||||
|
||||
<style>
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,697 @@
|
||||
<template>
|
||||
<div class="work-layout-container">
|
||||
<div class="main-wrapper">
|
||||
<div class="left-area">
|
||||
<div class="work-section work-top-header">
|
||||
<div class="work-card full-card">
|
||||
<div class="chart-top-inner">
|
||||
<h2>财务可视化大屏指标配置</h2>
|
||||
<div class="btn-group">
|
||||
<el-button type="primary" size="default" @click="handleSave"
|
||||
:loading="saveLoading" :disabled="saveLoading">保存</el-button>
|
||||
<el-button type="warning" size="default" @click="handleReset">重置</el-button>
|
||||
<el-button type="danger" size="default" @click="handleClearAll">清空</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="work-section work-main-section">
|
||||
<div class="layout-row top-row">
|
||||
<div class="work-col work-col-1-3">
|
||||
<div class="work-card full-height-card">
|
||||
<span v-if="metric1.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(1)">×</span>
|
||||
<div
|
||||
class="grid-content"
|
||||
@drop="(e) => handleDrop(e, 1)"
|
||||
@dragover="(e) => e.preventDefault()"
|
||||
>
|
||||
<div v-if="metric1.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{1}}</span>
|
||||
{{ metric1[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric1[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{1}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-col work-col-1-3">
|
||||
<div class="work-card full-height-card">
|
||||
<span v-if="metric2.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(2)">×</span>
|
||||
<div
|
||||
class="grid-content"
|
||||
@drop="(e) => handleDrop(e, 2)"
|
||||
@dragover="(e) => e.preventDefault()"
|
||||
>
|
||||
<div v-if="metric2.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{2}}</span>
|
||||
{{ metric2[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric2[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{2}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-col work-col-1-3">
|
||||
<div class="work-card full-height-card">
|
||||
<span v-if="metric3.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(3)">×</span>
|
||||
<div
|
||||
class="grid-content"
|
||||
@drop="(e) => handleDrop(e, 3)"
|
||||
@dragover="(e) => e.preventDefault()"
|
||||
>
|
||||
<div v-if="metric3.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{3}}</span>
|
||||
{{ metric3[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric3[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{3}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout-row middle-row">
|
||||
<div class="work-col work-col-1-2">
|
||||
<div class="inner-layout double-col-horizontal">
|
||||
<div class="work-col work-col-1-2">
|
||||
<div class="work-card full-height-card">
|
||||
<span v-if="metric4.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(4)">×</span>
|
||||
<div
|
||||
class="grid-content"
|
||||
@drop="(e) => handleDrop(e, 4)"
|
||||
@dragover="(e) => e.preventDefault()"
|
||||
>
|
||||
<div v-if="metric4.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{4}}</span>
|
||||
{{ metric4[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric4[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{4}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-col work-col-1-2">
|
||||
<div class="work-card full-height-card">
|
||||
<span v-if="metric5.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(5)">×</span>
|
||||
<div
|
||||
class="grid-content"
|
||||
@drop="(e) => handleDrop(e, 5)"
|
||||
@dragover="(e) => e.preventDefault()"
|
||||
>
|
||||
<div v-if="metric5.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{5}}</span>
|
||||
{{ metric5[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric5[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{5}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-col work-col-1-2">
|
||||
<div class="work-card full-height-card">
|
||||
<span v-if="metric6.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(6)">×</span>
|
||||
<div
|
||||
class="grid-content"
|
||||
@drop="(e) => handleDrop(e, 6)"
|
||||
@dragover="(e) => e.preventDefault()"
|
||||
>
|
||||
<div v-if="metric6.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{6}}</span>
|
||||
{{ metric6[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric6[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{6}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layout-row bottom-row">
|
||||
<div class="work-col work-col-1-2">
|
||||
<div class="inner-layout double-col-horizontal">
|
||||
<div class="work-col work-col-1-2">
|
||||
<div class="work-card full-height-card">
|
||||
<span v-if="metric7.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(7)">×</span>
|
||||
<div
|
||||
class="grid-content"
|
||||
@drop="(e) => handleDrop(e, 7)"
|
||||
@dragover="(e) => e.preventDefault()"
|
||||
>
|
||||
<div v-if="metric7.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{7}}</span>
|
||||
{{ metric7[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric7[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{7}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-col work-col-1-2">
|
||||
<div class="work-card full-height-card">
|
||||
<span v-if="metric8.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(8)">×</span>
|
||||
<div
|
||||
class="grid-content"
|
||||
@drop="(e) => handleDrop(e, 8)"
|
||||
@dragover="(e) => e.preventDefault()"
|
||||
>
|
||||
<div v-if="metric8.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{8}}</span>
|
||||
{{ metric8[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric8[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{8}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-col work-col-1-2">
|
||||
<div class="work-card full-height-card">
|
||||
<span v-if="metric9.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(9)">×</span>
|
||||
<div
|
||||
class="grid-content"
|
||||
@drop="(e) => handleDrop(e, 9)"
|
||||
@dragover="(e) => e.preventDefault()"
|
||||
>
|
||||
<div v-if="metric9.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{9}}</span>
|
||||
{{ metric9[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric9[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{9}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="right-area">
|
||||
<div class="search-box">
|
||||
<el-input v-model="searchKey" placeholder="搜索指标项..." size="default"></el-input>
|
||||
</div>
|
||||
<div class="metric-list">
|
||||
<div
|
||||
v-for="item in allMetricList"
|
||||
:key="item.chartId"
|
||||
class="metric-item"
|
||||
:class="{ active: isMetricUsed(item.chartId) }"
|
||||
draggable="true"
|
||||
@dragstart="(e) => handleDragStart(e, item)"
|
||||
@dragend="handleDragEnd"
|
||||
>
|
||||
<span>{{ item.chartName }}</span>
|
||||
<span class="color-dot" :style="{ backgroundColor: item.color || getRandomColor() }"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { ElMessage, ElButton, ElInput } from 'element-plus';
|
||||
// import { getChartListAll, getChartSetting } from '@/api/bizChart'
|
||||
|
||||
const metric1 = ref([]);
|
||||
const metric2 = ref([]);
|
||||
const metric3 = ref([]);
|
||||
const metric4 = ref([]);
|
||||
const metric5 = ref([]);
|
||||
const metric6 = ref([]);
|
||||
const metric7 = ref([]);
|
||||
const metric8 = ref([]);
|
||||
const metric9 = ref([]);
|
||||
|
||||
const gridOriginalChartId = ref({
|
||||
1: null, 2: null, 3: null, 4: null,
|
||||
5: null, 6: null, 7: null, 8: null, 9: null
|
||||
});
|
||||
const metricHistory = ref({});
|
||||
|
||||
const saveLoading = ref(false);
|
||||
const rawChartData = ref([]);
|
||||
const searchKey = ref('');
|
||||
const dragItem = ref(null);
|
||||
|
||||
const allMetricList = computed({
|
||||
get() {
|
||||
if (!rawChartData.value || !Array.isArray(rawChartData.value)) return [];
|
||||
return rawChartData.value.filter(item => {
|
||||
if (!item || !item.chartName) return false;
|
||||
const searchVal = searchKey.value ? searchKey.value.toLowerCase() : '';
|
||||
const nameVal = item.chartName ? item.chartName.toLowerCase() : '';
|
||||
return nameVal.includes(searchVal);
|
||||
});
|
||||
},
|
||||
set(val) {
|
||||
rawChartData.value = val;
|
||||
}
|
||||
});
|
||||
|
||||
const getAllMetricArrays = () => ([
|
||||
metric1, metric2, metric3, metric4,
|
||||
metric5, metric6, metric7, metric8, metric9
|
||||
]);
|
||||
|
||||
const getMetricArrByGridNum = (gridNum) => {
|
||||
return getAllMetricArrays()[gridNum - 1];
|
||||
};
|
||||
|
||||
const isMetricUsed = (metricId) => {
|
||||
if (!metricId) return false;
|
||||
return getAllMetricArrays().some(
|
||||
metricArr => metricArr.value.some(m => m && m.chartId === metricId)
|
||||
);
|
||||
};
|
||||
|
||||
const findGridNumByChartId = (chartId) => {
|
||||
const arr = getAllMetricArrays();
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
if (arr[i].value.length && arr[i].value[0].chartId === chartId) {
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const handleDragStart = (e, item) => {
|
||||
dragItem.value = item;
|
||||
e.dataTransfer.setData('text/plain', JSON.stringify(item));
|
||||
e.target.style.opacity = '0.6';
|
||||
};
|
||||
|
||||
const handleDragEnd = (e) => {
|
||||
e.target.style.opacity = '1';
|
||||
};
|
||||
|
||||
const handleDrop = (e, gridNum) => {
|
||||
e.preventDefault();
|
||||
if (!dragItem.value) return;
|
||||
const targetArr = getMetricArrByGridNum(gridNum);
|
||||
if (!targetArr) return;
|
||||
const currentChartId = dragItem.value.chartId;
|
||||
|
||||
const sourceGrid = findGridNumByChartId(currentChartId);
|
||||
const targetOldItem = targetArr.value[0] || null;
|
||||
|
||||
getAllMetricArrays().forEach((arr, index) => {
|
||||
const pos = index + 1;
|
||||
if (pos !== gridNum && arr.value.some(item => item.chartId === currentChartId)) {
|
||||
arr.value = [];
|
||||
}
|
||||
});
|
||||
|
||||
const oldSort = sourceGrid || metricHistory.value[currentChartId] || 0;
|
||||
const oldChartId = gridOriginalChartId.value[gridNum] || targetOldItem?.chartId || currentChartId;
|
||||
|
||||
const newItem = {
|
||||
...dragItem.value,
|
||||
sort: gridNum,
|
||||
oldSort: oldSort,
|
||||
fixedOldChartId: oldChartId,
|
||||
oldChartId: oldChartId
|
||||
};
|
||||
|
||||
targetArr.value = [newItem];
|
||||
metricHistory.value[currentChartId] = gridNum;
|
||||
dragItem.value = null;
|
||||
};
|
||||
|
||||
const handleDeleteMetric = (gridNum) => {
|
||||
const targetArr = getMetricArrByGridNum(gridNum);
|
||||
if (targetArr) {
|
||||
targetArr.value = [];
|
||||
}
|
||||
};
|
||||
|
||||
const handleReset = () => {
|
||||
getAllMetricArrays().forEach(arr => arr.value = []);
|
||||
searchKey.value = '';
|
||||
getChartList();
|
||||
ElMessage.info('已重置所有指标');
|
||||
};
|
||||
|
||||
const handleClearAll = () => {
|
||||
getAllMetricArrays().forEach(arr => arr.value = []);
|
||||
ElMessage.info('已清空所有格子');
|
||||
};
|
||||
|
||||
const handleSave = async () => {
|
||||
saveLoading.value = true;
|
||||
const saveData = getAllMetricArrays().map((arr, index) => {
|
||||
const gridNum = index + 1;
|
||||
const currentItem = arr.value[0];
|
||||
return {
|
||||
sort: gridNum,
|
||||
chartId: currentItem?.chartId || null,
|
||||
oldChartId: currentItem?.fixedOldChartId || null,
|
||||
chartName: currentItem?.chartName || '',
|
||||
chartCode: 'erp',
|
||||
oldSort: currentItem?.oldSort || gridNum,
|
||||
color: currentItem?.color || ''
|
||||
};
|
||||
}).filter(item => item.chartId);
|
||||
|
||||
try {
|
||||
const res = await getChartSetting(saveData);
|
||||
ElMessage.success(res?.msg);
|
||||
return saveData;
|
||||
} catch (error) {
|
||||
console.error('保存失败:', error);
|
||||
} finally {
|
||||
getChartList();
|
||||
saveLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const getRandomColor = () => {
|
||||
const colors = ['#3c9cff', '#5ac8fa', '#9254de', '#f7ba2a', '#ff7d00', '#23c8c8', '#ff6b6b', '#86909c', '#7b68ee'];
|
||||
return colors[Math.floor(Math.random() * colors.length)];
|
||||
};
|
||||
|
||||
async function getChartList() {
|
||||
try {
|
||||
const reqParams = { chartCode: 'erp' };
|
||||
const res = await getChartListAll(reqParams);
|
||||
rawChartData.value = res || [];
|
||||
|
||||
metricHistory.value = {};
|
||||
Object.keys(gridOriginalChartId.value).forEach(key => {
|
||||
gridOriginalChartId.value[key] = null;
|
||||
});
|
||||
|
||||
rawChartData.value.forEach(item => {
|
||||
const sortNum = item.sort || 0;
|
||||
if (sortNum >= 1 && sortNum <= 9) {
|
||||
const targetArr = getMetricArrByGridNum(sortNum);
|
||||
if (targetArr) {
|
||||
gridOriginalChartId.value[sortNum] = item.chartId;
|
||||
targetArr.value = [{
|
||||
...item,
|
||||
sort: sortNum,
|
||||
oldSort: 0,
|
||||
fixedOldChartId: item.chartId,
|
||||
oldChartId: item.chartId
|
||||
}];
|
||||
metricHistory.value[item.chartId] = sortNum;
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('获取数据失败:', error);
|
||||
rawChartData.value = [];
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await getChartList();
|
||||
});
|
||||
</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: #0a1a33;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.main-wrapper {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
gap: 2px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.left-area {
|
||||
width: calc(85% - 1px);
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.right-area {
|
||||
width: calc(15% - 1px);
|
||||
height: 100%;
|
||||
background-color: rgba(15, 52, 96, 0.5);
|
||||
border: 1px solid #1a508b;
|
||||
border-radius: 8px;
|
||||
padding: 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.work-top-header {
|
||||
height: calc(6% - 1px);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.work-main-section {
|
||||
height: calc(94% - 1px);
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.layout-row {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
gap: 2px;
|
||||
box-sizing: border-box;
|
||||
height: calc(100% / 3);
|
||||
}
|
||||
|
||||
.work-col-1-3 {
|
||||
width: calc(100% / 3);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.work-col-1-2 {
|
||||
width: calc(100% / 2);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.inner-layout.double-col-horizontal {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
gap: 2px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.full-height-card {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(15, 52, 96, 0.3);
|
||||
border: 1px solid #1a508b;
|
||||
border-radius: 8px;
|
||||
padding: 8px;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
color: #e0e6ff;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.work-section {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
gap: 2px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.chart-top-inner {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0 16px;
|
||||
color: #e0e6ff;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.chart-top-inner h2 {
|
||||
font-size: 16px;
|
||||
margin: 0;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.btn-group {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.work-col {
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.work-card {
|
||||
width: 100%;
|
||||
background-color: rgba(15, 52, 96, 0.3);
|
||||
border: 1px solid #1a508b;
|
||||
border-radius: 8px;
|
||||
padding: 8px;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
color: #e0e6ff;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.full-card {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.delete-icon {
|
||||
position: absolute;
|
||||
top: 6px;
|
||||
right: 6px;
|
||||
color: #ff6b6b;
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-radius: 50%;
|
||||
background-color: rgba(255, 107, 107, 0.1);
|
||||
z-index: 10;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.delete-icon:hover {
|
||||
background-color: rgba(255, 107, 107, 0.3);
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
.grid-content {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 8px;
|
||||
box-sizing: border-box;
|
||||
cursor: drop;
|
||||
}
|
||||
|
||||
.metric-tag {
|
||||
padding: 0;
|
||||
background: none;
|
||||
color: #e0e6ff;
|
||||
font-size: 18px;
|
||||
white-space: nowrap;
|
||||
text-align: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.sort-num {
|
||||
font-size: 14px;
|
||||
color: #88a0c2;
|
||||
margin-bottom: 4px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.empty-tip {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
color: #88a0c2;
|
||||
font-size: 14px;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.search-box {
|
||||
padding: 4px 0;
|
||||
margin-bottom: 8px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.metric-list {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 4px;
|
||||
box-sizing: border-box;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: rgba(60, 156, 255, 0.2) transparent;
|
||||
}
|
||||
|
||||
.metric-list::-webkit-scrollbar {
|
||||
width: 1px;
|
||||
}
|
||||
|
||||
.metric-list::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.metric-list::-webkit-scrollbar-thumb {
|
||||
background: rgba(60, 156, 255, 0.2);
|
||||
border-radius: 0.5px;
|
||||
}
|
||||
|
||||
.metric-list::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(60, 156, 255, 0.4);
|
||||
}
|
||||
|
||||
.metric-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 8px 6px;
|
||||
margin-bottom: 6px;
|
||||
border-radius: 6px;
|
||||
color: #e0e6ff;
|
||||
cursor: grab;
|
||||
font-size: 14px;
|
||||
box-sizing: border-box;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.metric-item.active {
|
||||
background-color: rgba(60, 156, 255, 0.3);
|
||||
border: 1px solid #3c9cff;
|
||||
}
|
||||
|
||||
.metric-item:hover {
|
||||
background-color: rgba(60, 156, 255, 0.15);
|
||||
}
|
||||
|
||||
.color-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
margin-left: 6px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,608 @@
|
||||
<template>
|
||||
<div class="work-layout-container">
|
||||
<div class="main-wrapper">
|
||||
<div class="left-area">
|
||||
<div class="work-section work-top-header">
|
||||
<div class="work-card full-card">
|
||||
<div class="chart-top-inner">
|
||||
<h2>首页可视化大屏指标配置</h2>
|
||||
<div class="btn-group">
|
||||
<el-button type="primary" size="default" @click="handleSave"
|
||||
:loading="saveLoading" :disabled="saveLoading">保存</el-button>
|
||||
<el-button type="warning" size="default" @click="handleReset">重置</el-button>
|
||||
<el-button type="danger" size="default" @click="handleClearAll">清空</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="work-section work-main-section">
|
||||
<div class="layout-row top-row">
|
||||
<div class="work-col work-col-1-3">
|
||||
<div class="work-card full-height-card">
|
||||
<span v-if="metric1.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(1)">×</span>
|
||||
<div class="grid-content" @drop="(e) => handleDrop(e, 1)" @dragover="(e) => e.preventDefault()">
|
||||
<div v-if="metric1.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{1}}</span>
|
||||
{{ metric1[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric1[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{1}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-col work-col-1-3">
|
||||
<div class="work-card full-height-card">
|
||||
<span v-if="metric2.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(2)">×</span>
|
||||
<div class="grid-content" @drop="(e) => handleDrop(e, 2)" @dragover="(e) => e.preventDefault()">
|
||||
<div v-if="metric2.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{2}}</span>
|
||||
{{ metric2[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric2[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{2}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-col work-col-1-3">
|
||||
<div class="work-card full-height-card">
|
||||
<span v-if="metric3.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(3)">×</span>
|
||||
<div class="grid-content" @drop="(e) => handleDrop(e, 3)" @dragover="(e) => e.preventDefault()">
|
||||
<div v-if="metric3.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{3}}</span>
|
||||
{{ metric3[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric3[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{3}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layout-row middle-row">
|
||||
<div class="work-col work-col-1-2">
|
||||
<div class="work-card full-height-card">
|
||||
<span v-if="metric4.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(4)">×</span>
|
||||
<div class="grid-content" @drop="(e) => handleDrop(e, 4)" @dragover="(e) => e.preventDefault()">
|
||||
<div v-if="metric4.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{4}}</span>
|
||||
{{ metric4[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric4[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{4}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-col work-col-1-2">
|
||||
<div class="work-card full-height-card">
|
||||
<span v-if="metric5.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(5)">×</span>
|
||||
<div class="grid-content" @drop="(e) => handleDrop(e, 5)" @dragover="(e) => e.preventDefault()">
|
||||
<div v-if="metric5.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{5}}</span>
|
||||
{{ metric5[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric5[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{5}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layout-row bottom-row">
|
||||
<div class="work-col work-col-1-2">
|
||||
<div class="work-card full-height-card">
|
||||
<span v-if="metric6.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(6)">×</span>
|
||||
<div class="grid-content" @drop="(e) => handleDrop(e, 6)" @dragover="(e) => e.preventDefault()">
|
||||
<div v-if="metric6.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{6}}</span>
|
||||
{{ metric6[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric6[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{6}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-col work-col-1-2">
|
||||
<div class="work-card full-height-card">
|
||||
<span v-if="metric7.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(7)">×</span>
|
||||
<div class="grid-content" @drop="(e) => handleDrop(e, 7)" @dragover="(e) => e.preventDefault()">
|
||||
<div v-if="metric7.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{7}}</span>
|
||||
{{ metric7[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric7[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{7}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="right-area">
|
||||
<div class="search-box">
|
||||
<el-input v-model="searchKey" placeholder="搜索指标项..." size="default"></el-input>
|
||||
</div>
|
||||
<div class="metric-list">
|
||||
<div v-for="item in allMetricList" :key="item.chartId" class="metric-item" :class="{ active: isMetricUsed(item.chartId) }" draggable="true" @dragstart="(e) => handleDragStart(e, item)" @dragend="handleDragEnd">
|
||||
<span>{{ item.chartName }}</span>
|
||||
<span class="color-dot" :style="{ backgroundColor: item.color || getRandomColor() }"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { ElMessage, ElButton, ElInput } from 'element-plus';
|
||||
// import { getChartListAll, getChartSetting } from '@/api/bizChart'
|
||||
|
||||
const metric1 = ref([]);
|
||||
const metric2 = ref([]);
|
||||
const metric3 = ref([]);
|
||||
const metric4 = ref([]);
|
||||
const metric5 = ref([]);
|
||||
const metric6 = ref([]);
|
||||
const metric7 = ref([]);
|
||||
|
||||
const gridOriginalChartId = ref({
|
||||
1: null, 2: null, 3: null,
|
||||
4: null, 5: null, 6: null, 7: null
|
||||
});
|
||||
const metricHistory = ref({});
|
||||
|
||||
const saveLoading = ref(false);
|
||||
const rawChartData = ref([]);
|
||||
const searchKey = ref('');
|
||||
const dragItem = ref(null);
|
||||
|
||||
const allMetricList = computed({
|
||||
get() {
|
||||
if (!rawChartData.value || !Array.isArray(rawChartData.value)) return [];
|
||||
return rawChartData.value.filter(item => {
|
||||
if (!item || !item.chartName) return false;
|
||||
const searchVal = searchKey.value ? searchKey.value.toLowerCase() : '';
|
||||
const nameVal = item.chartName ? item.chartName.toLowerCase() : '';
|
||||
return nameVal.includes(searchVal);
|
||||
});
|
||||
},
|
||||
set(val) {
|
||||
rawChartData.value = val;
|
||||
}
|
||||
});
|
||||
|
||||
const getAllMetricArrays = () => ([
|
||||
metric1, metric2, metric3,
|
||||
metric4, metric5, metric6, metric7
|
||||
]);
|
||||
|
||||
const getMetricArrByGridNum = (gridNum) => {
|
||||
return getAllMetricArrays()[gridNum - 1];
|
||||
};
|
||||
|
||||
const isMetricUsed = (metricId) => {
|
||||
if (!metricId) return false;
|
||||
return getAllMetricArrays().some(
|
||||
metricArr => metricArr.value.some(m => m && m.chartId === metricId)
|
||||
);
|
||||
};
|
||||
|
||||
const findGridNumByChartId = (chartId) => {
|
||||
const arr = getAllMetricArrays();
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
if (arr[i].value.length && arr[i].value[0].chartId === chartId) {
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const handleDragStart = (e, item) => {
|
||||
dragItem.value = item;
|
||||
e.dataTransfer.setData('text/plain', JSON.stringify(item));
|
||||
e.target.style.opacity = '0.6';
|
||||
};
|
||||
|
||||
const handleDragEnd = (e) => {
|
||||
e.target.style.opacity = '1';
|
||||
};
|
||||
|
||||
const handleDrop = (e, targetGrid) => {
|
||||
e.preventDefault();
|
||||
if (!dragItem.value) return;
|
||||
|
||||
const dragChartId = dragItem.value.chartId;
|
||||
const sourceGrid = findGridNumByChartId(dragChartId);
|
||||
const targetArr = getMetricArrByGridNum(targetGrid);
|
||||
const targetOldItem = targetArr.value[0] || null;
|
||||
const oldSort = sourceGrid || metricHistory.value[dragChartId] || 0;
|
||||
|
||||
getAllMetricArrays().forEach((arr, index) => {
|
||||
const gridNum = index + 1;
|
||||
if (gridNum !== targetGrid) {
|
||||
arr.value = arr.value.filter(i => i.chartId !== dragChartId);
|
||||
}
|
||||
});
|
||||
|
||||
const newItem = {
|
||||
...dragItem.value,
|
||||
sort: targetGrid,
|
||||
oldSort: oldSort,
|
||||
chartId: dragChartId,
|
||||
oldChartId: gridOriginalChartId.value[targetGrid] || targetOldItem?.chartId || null,
|
||||
};
|
||||
targetArr.value = [newItem];
|
||||
metricHistory.value[dragChartId] = targetGrid;
|
||||
if (sourceGrid && sourceGrid !== targetGrid) {
|
||||
const sourceArr = getMetricArrByGridNum(sourceGrid);
|
||||
sourceArr.value = [];
|
||||
}
|
||||
dragItem.value = null;
|
||||
};
|
||||
|
||||
const handleDeleteMetric = (gridNum) => {
|
||||
const targetArr = getMetricArrByGridNum(gridNum);
|
||||
if (targetArr) {
|
||||
targetArr.value = [];
|
||||
}
|
||||
};
|
||||
|
||||
const handleReset = () => {
|
||||
getAllMetricArrays().forEach(arr => arr.value = []);
|
||||
searchKey.value = '';
|
||||
getChartList();
|
||||
ElMessage.info('已重置所有指标');
|
||||
};
|
||||
|
||||
const handleClearAll = () => {
|
||||
getAllMetricArrays().forEach(arr => arr.value = []);
|
||||
ElMessage.info('已清空所有格子');
|
||||
};
|
||||
|
||||
const handleSave = async () => {
|
||||
saveLoading.value = true;
|
||||
const saveData = getAllMetricArrays().map((arr, index) => {
|
||||
const gridNum = index + 1;
|
||||
const currentItem = arr.value[0];
|
||||
return {
|
||||
sort: gridNum,
|
||||
chartId: currentItem?.chartId || null,
|
||||
oldChartId: currentItem?.oldChartId || null,
|
||||
chartName: currentItem?.chartName || '',
|
||||
chartCode: 'home',
|
||||
oldSort: currentItem?.oldSort || gridNum,
|
||||
color: currentItem?.color || ''
|
||||
};
|
||||
}).filter(item => item.chartId);
|
||||
|
||||
try {
|
||||
const res = await getChartSetting(saveData);
|
||||
ElMessage.success(res?.msg);
|
||||
return saveData;
|
||||
} catch (error) {
|
||||
console.error('保存失败:', error);
|
||||
} finally {
|
||||
getChartList();
|
||||
saveLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const getRandomColor = () => {
|
||||
const colors = ['#3c9cff', '#5ac8fa', '#9254de', '#f7ba2a', '#ff7d00', '#23c8c8', '#ff6b6b'];
|
||||
return colors[Math.floor(Math.random() * colors.length)];
|
||||
};
|
||||
|
||||
async function getChartList() {
|
||||
try {
|
||||
const reqParams = { chartCode: 'home' };
|
||||
const res = await getChartListAll(reqParams);
|
||||
rawChartData.value = res || [];
|
||||
metricHistory.value = {};
|
||||
Object.keys(gridOriginalChartId.value).forEach(key => {
|
||||
gridOriginalChartId.value[key] = null;
|
||||
});
|
||||
rawChartData.value.forEach(item => {
|
||||
const sortNum = item.sort || 0;
|
||||
if (sortNum >= 1 && sortNum <= 7) {
|
||||
const targetArr = getMetricArrByGridNum(sortNum);
|
||||
if (targetArr) {
|
||||
gridOriginalChartId.value[sortNum] = item.chartId;
|
||||
targetArr.value = [{
|
||||
...item,
|
||||
sort: sortNum,
|
||||
oldSort: 0,
|
||||
chartId: item.chartId,
|
||||
oldChartId: item.chartId
|
||||
}];
|
||||
metricHistory.value[item.chartId] = sortNum;
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('获取数据失败:', error);
|
||||
rawChartData.value = [];
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await getChartList();
|
||||
});
|
||||
</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: #0a1a33;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.main-wrapper {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
gap: 2px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.left-area {
|
||||
width: calc(85% - 1px);
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.right-area {
|
||||
width: calc(15% - 1px);
|
||||
height: 100%;
|
||||
background-color: rgba(15, 52, 96, 0.5);
|
||||
border: 1px solid #1a508b;
|
||||
border-radius: 8px;
|
||||
padding: 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.work-top-header {
|
||||
height: calc(6% - 1px);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.work-main-section {
|
||||
height: calc(94% - 1px);
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.layout-row {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
gap: 2px;
|
||||
box-sizing: border-box;
|
||||
height: calc(100% / 3);
|
||||
}
|
||||
|
||||
.work-col-1-3 {
|
||||
width: calc((100% - 4px) / 3);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.work-col-1-2 {
|
||||
width: calc((100% - 2px) / 2);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.full-height-card {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(15, 52, 96, 0.3);
|
||||
border: 1px solid #1a508b;
|
||||
border-radius: 8px;
|
||||
padding: 8px;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
color: #e0e6ff;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.work-section {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
gap: 2px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.chart-top-inner {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0 16px;
|
||||
color: #e0e6ff;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.chart-top-inner h2 {
|
||||
font-size: 16px;
|
||||
margin: 0;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.btn-group {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.work-col {
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.work-card {
|
||||
width: 100%;
|
||||
background-color: rgba(15, 52, 96, 0.3);
|
||||
border: 1px solid #1a508b;
|
||||
border-radius: 8px;
|
||||
padding: 8px;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
color: #e0e6ff;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.full-card {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.delete-icon {
|
||||
position: absolute;
|
||||
top: 6px;
|
||||
right: 6px;
|
||||
color: #ff6b6b;
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-radius: 50%;
|
||||
background-color: rgba(255, 107, 107, 0.1);
|
||||
z-index: 10;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.delete-icon:hover {
|
||||
background-color: rgba(255, 107, 107, 0.3);
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
.grid-content {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 8px;
|
||||
box-sizing: border-box;
|
||||
cursor: drop;
|
||||
}
|
||||
|
||||
.metric-tag {
|
||||
padding: 0;
|
||||
background: none;
|
||||
color: #e0e6ff;
|
||||
font-size: 18px;
|
||||
white-space: nowrap;
|
||||
text-align: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.sort-num {
|
||||
font-size: 14px;
|
||||
color: #88a0c2;
|
||||
margin-bottom: 4px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.empty-tip {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
color: #88a0c2;
|
||||
font-size: 14px;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.search-box {
|
||||
padding: 4px 0;
|
||||
margin-bottom: 8px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.metric-list {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 4px;
|
||||
box-sizing: border-box;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: rgba(60, 156, 255, 0.2) transparent;
|
||||
}
|
||||
|
||||
.metric-list::-webkit-scrollbar {
|
||||
width: 1px;
|
||||
}
|
||||
|
||||
.metric-list::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.metric-list::-webkit-scrollbar-thumb {
|
||||
background: rgba(60, 156, 255, 0.2);
|
||||
border-radius: 0.5px;
|
||||
}
|
||||
|
||||
.metric-list::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(60, 156, 255, 0.4);
|
||||
}
|
||||
|
||||
.metric-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 8px 6px;
|
||||
margin-bottom: 6px;
|
||||
border-radius: 6px;
|
||||
color: #e0e6ff;
|
||||
cursor: grab;
|
||||
font-size: 14px;
|
||||
box-sizing: border-box;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.metric-item.active {
|
||||
background-color: rgba(60, 156, 255, 0.3);
|
||||
border: 1px solid #3c9cff;
|
||||
}
|
||||
|
||||
.metric-item:hover {
|
||||
background-color: rgba(60, 156, 255, 0.15);
|
||||
}
|
||||
|
||||
.color-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
margin-left: 6px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,630 @@
|
||||
<template>
|
||||
<div class="work-layout-container">
|
||||
<div class="main-wrapper">
|
||||
<div class="left-area">
|
||||
<div class="work-section work-top-header">
|
||||
<div class="work-card full-card">
|
||||
<div class="chart-top-inner">
|
||||
<h2>系统可视化大屏指标配置</h2>
|
||||
<div class="btn-group">
|
||||
<el-button type="primary" size="default" @click="handleSave"
|
||||
:loading="saveLoading" :disabled="saveLoading">保存</el-button>
|
||||
<el-button type="warning" size="default" @click="handleReset">重置</el-button>
|
||||
<el-button type="danger" size="default" @click="handleClearAll">清空</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="work-section work-main-section">
|
||||
<div class="layout-row top-row">
|
||||
<div class="work-col work-col-1-3">
|
||||
<div class="work-card full-height-card">
|
||||
<span v-if="metric1.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(1)">×</span>
|
||||
<div class="grid-content" @drop="(e) => handleDrop(e, 1)" @dragover="(e) => e.preventDefault()">
|
||||
<div v-if="metric1.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{1}}</span>
|
||||
{{ metric1[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric1[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{1}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-col work-col-1-3">
|
||||
<div class="work-card full-height-card">
|
||||
<span v-if="metric2.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(2)">×</span>
|
||||
<div class="grid-content" @drop="(e) => handleDrop(e, 2)" @dragover="(e) => e.preventDefault()">
|
||||
<div v-if="metric2.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{2}}</span>
|
||||
{{ metric2[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric2[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{2}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-col work-col-1-3">
|
||||
<div class="work-card full-height-card">
|
||||
<span v-if="metric3.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(3)">×</span>
|
||||
<div class="grid-content" @drop="(e) => handleDrop(e, 3)" @dragover="(e) => e.preventDefault()">
|
||||
<div v-if="metric3.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{3}}</span>
|
||||
{{ metric3[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric3[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{3}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout-row middle-row">
|
||||
<div class="work-col work-col-1-3">
|
||||
<div class="work-card full-height-card">
|
||||
<span v-if="metric4.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(4)">×</span>
|
||||
<div class="grid-content" @drop="(e) => handleDrop(e, 4)" @dragover="(e) => e.preventDefault()">
|
||||
<div v-if="metric4.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{4}}</span>
|
||||
{{ metric4[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric4[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{4}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-col work-col-1-3">
|
||||
<div class="work-card full-height-card">
|
||||
<span v-if="metric5.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(5)">×</span>
|
||||
<div class="grid-content" @drop="(e) => handleDrop(e, 5)" @dragover="(e) => e.preventDefault()">
|
||||
<div v-if="metric5.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{5}}</span>
|
||||
{{ metric5[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric5[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{5}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-col work-col-1-3">
|
||||
<div class="work-card full-height-card">
|
||||
<span v-if="metric6.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(6)">×</span>
|
||||
<div class="grid-content" @drop="(e) => handleDrop(e, 6)" @dragover="(e) => e.preventDefault()">
|
||||
<div v-if="metric6.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{6}}</span>
|
||||
{{ metric6[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric6[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{6}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout-row bottom-row">
|
||||
<div class="work-col work-col-1-3">
|
||||
<div class="work-card full-height-card">
|
||||
<span v-if="metric7.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(7)">×</span>
|
||||
<div class="grid-content" @drop="(e) => handleDrop(e, 7)" @dragover="(e) => e.preventDefault()">
|
||||
<div v-if="metric7.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{7}}</span>
|
||||
{{ metric7[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric7[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{7}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-col work-col-1-3">
|
||||
<div class="work-card full-height-card">
|
||||
<span v-if="metric8.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(8)">×</span>
|
||||
<div class="grid-content" @drop="(e) => handleDrop(e, 8)" @dragover="(e) => e.preventDefault()">
|
||||
<div v-if="metric8.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{8}}</span>
|
||||
{{ metric8[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric8[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{8}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-col work-col-1-3">
|
||||
<div class="work-card full-height-card">
|
||||
<span v-if="metric9.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(9)">×</span>
|
||||
<div class="grid-content" @drop="(e) => handleDrop(e, 9)" @dragover="(e) => e.preventDefault()">
|
||||
<div v-if="metric9.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{9}}</span>
|
||||
{{ metric9[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric9[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{9}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right-area">
|
||||
<div class="search-box">
|
||||
<el-input v-model="searchKey" placeholder="搜索指标项..." size="default"></el-input>
|
||||
</div>
|
||||
<div class="metric-list">
|
||||
<div v-for="item in allMetricList" :key="item.chartId" class="metric-item" :class="{ active: isMetricUsed(item.chartId) }" draggable="true" @dragstart="(e) => handleDragStart(e, item)" @dragend="handleDragEnd">
|
||||
<span>{{ item.chartName }}</span>
|
||||
<span class="color-dot" :style="{ backgroundColor: item.color || getRandomColor() }"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { ElMessage, ElButton, ElInput } from 'element-plus';
|
||||
// import { getChartListAll, getChartSetting } from '@/api/bizChart'
|
||||
|
||||
const metric1 = ref([]);
|
||||
const metric2 = ref([]);
|
||||
const metric3 = ref([]);
|
||||
const metric4 = ref([]);
|
||||
const metric5 = ref([]);
|
||||
const metric6 = ref([]);
|
||||
const metric7 = ref([]);
|
||||
const metric8 = ref([]);
|
||||
const metric9 = ref([]);
|
||||
|
||||
const gridOriginalChartId = ref({
|
||||
1: null, 2: null, 3: null, 4: null,
|
||||
5: null, 6: null, 7: null, 8: null, 9: null
|
||||
});
|
||||
const metricHistory = ref({});
|
||||
|
||||
const saveLoading = ref(false);
|
||||
const rawChartData = ref([]);
|
||||
const searchKey = ref('');
|
||||
const dragItem = ref(null);
|
||||
|
||||
const allMetricList = computed({
|
||||
get() {
|
||||
if (!rawChartData.value || !Array.isArray(rawChartData.value)) return [];
|
||||
return rawChartData.value.filter(item => {
|
||||
if (!item || !item.chartName) return false;
|
||||
const searchVal = searchKey.value ? searchKey.value.toLowerCase() : '';
|
||||
const nameVal = item.chartName ? item.chartName.toLowerCase() : '';
|
||||
return nameVal.includes(searchVal);
|
||||
});
|
||||
},
|
||||
set(val) {
|
||||
rawChartData.value = val;
|
||||
}
|
||||
});
|
||||
|
||||
const getAllMetricArrays = () => ([
|
||||
metric1, metric2, metric3, metric4,
|
||||
metric5, metric6, metric7, metric8, metric9
|
||||
]);
|
||||
|
||||
const getMetricArrByGridNum = (gridNum) => {
|
||||
return getAllMetricArrays()[gridNum - 1];
|
||||
};
|
||||
|
||||
const isMetricUsed = (metricId) => {
|
||||
if (!metricId) return false;
|
||||
return getAllMetricArrays().some(
|
||||
metricArr => metricArr.value.some(m => m && m.chartId === metricId)
|
||||
);
|
||||
};
|
||||
|
||||
const findGridNumByChartId = (chartId) => {
|
||||
const arr = getAllMetricArrays();
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
if (arr[i].value.length && arr[i].value[0].chartId === chartId) {
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const handleDragStart = (e, item) => {
|
||||
dragItem.value = item;
|
||||
e.dataTransfer.setData('text/plain', JSON.stringify(item));
|
||||
e.target.style.opacity = '0.6';
|
||||
};
|
||||
|
||||
const handleDragEnd = (e) => {
|
||||
e.target.style.opacity = '1';
|
||||
};
|
||||
|
||||
const handleDrop = (e, targetGrid) => {
|
||||
e.preventDefault();
|
||||
if (!dragItem.value) return;
|
||||
|
||||
const dragChartId = dragItem.value.chartId;
|
||||
const sourceGrid = findGridNumByChartId(dragChartId);
|
||||
const targetArr = getMetricArrByGridNum(targetGrid);
|
||||
const targetOldItem = targetArr.value[0] || null;
|
||||
const oldSort = sourceGrid || metricHistory.value[dragChartId] || 0;
|
||||
|
||||
getAllMetricArrays().forEach((arr, index) => {
|
||||
const gridNum = index + 1;
|
||||
if (gridNum !== targetGrid) {
|
||||
arr.value = arr.value.filter(i => i.chartId !== dragChartId);
|
||||
}
|
||||
});
|
||||
|
||||
const newItem = {
|
||||
...dragItem.value,
|
||||
sort: targetGrid,
|
||||
oldSort: oldSort,
|
||||
chartId: dragChartId,
|
||||
oldChartId: gridOriginalChartId.value[targetGrid] || targetOldItem?.chartId || null,
|
||||
};
|
||||
targetArr.value = [newItem];
|
||||
metricHistory.value[dragChartId] = targetGrid;
|
||||
if (sourceGrid && sourceGrid !== targetGrid) {
|
||||
const sourceArr = getMetricArrByGridNum(sourceGrid);
|
||||
sourceArr.value = [];
|
||||
}
|
||||
|
||||
dragItem.value = null;
|
||||
};
|
||||
|
||||
const handleDeleteMetric = (gridNum) => {
|
||||
const targetArr = getMetricArrByGridNum(gridNum);
|
||||
if (targetArr) {
|
||||
targetArr.value = [];
|
||||
}
|
||||
};
|
||||
|
||||
const handleReset = () => {
|
||||
getAllMetricArrays().forEach(arr => arr.value = []);
|
||||
searchKey.value = '';
|
||||
getChartList();
|
||||
ElMessage.info('已重置所有指标');
|
||||
};
|
||||
|
||||
const handleClearAll = () => {
|
||||
getAllMetricArrays().forEach(arr => arr.value = []);
|
||||
ElMessage.info('已清空所有格子');
|
||||
};
|
||||
|
||||
const handleSave = async () => {
|
||||
saveLoading.value = true;
|
||||
const saveData = getAllMetricArrays().map((arr, index) => {
|
||||
const gridNum = index + 1;
|
||||
const currentItem = arr.value[0];
|
||||
return {
|
||||
sort: gridNum,
|
||||
chartId: currentItem?.chartId || null,
|
||||
oldChartId: currentItem?.oldChartId || null,
|
||||
chartName: currentItem?.chartName || '',
|
||||
chartCode: 'sys',
|
||||
oldSort: currentItem?.oldSort || gridNum,
|
||||
color: currentItem?.color || ''
|
||||
};
|
||||
}).filter(item => item.chartId);
|
||||
|
||||
try {
|
||||
const res = await getChartSetting(saveData);
|
||||
ElMessage.success(res?.msg);
|
||||
return saveData;
|
||||
} catch (error) {
|
||||
console.error('保存失败:', error);
|
||||
} finally {
|
||||
getChartList();
|
||||
saveLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const getRandomColor = () => {
|
||||
const colors = ['#3c9cff', '#5ac8fa', '#9254de', '#f7ba2a', '#ff7d00', '#23c8c8', '#ff6b6b', '#86909c', '#7b68ee'];
|
||||
return colors[Math.floor(Math.random() * colors.length)];
|
||||
};
|
||||
|
||||
async function getChartList() {
|
||||
try {
|
||||
const reqParams = { chartCode: 'sys' };
|
||||
const res = await getChartListAll(reqParams);
|
||||
rawChartData.value = res || [];
|
||||
metricHistory.value = {};
|
||||
Object.keys(gridOriginalChartId.value).forEach(key => {
|
||||
gridOriginalChartId.value[key] = null;
|
||||
});
|
||||
rawChartData.value.forEach(item => {
|
||||
const sortNum = item.sort || 0;
|
||||
if (sortNum >= 1 && sortNum <= 9) {
|
||||
const targetArr = getMetricArrByGridNum(sortNum);
|
||||
if (targetArr) {
|
||||
gridOriginalChartId.value[sortNum] = item.chartId;
|
||||
targetArr.value = [{
|
||||
...item,
|
||||
sort: sortNum,
|
||||
oldSort: 0,
|
||||
chartId: item.chartId,
|
||||
oldChartId: item.chartId
|
||||
}];
|
||||
metricHistory.value[item.chartId] = sortNum;
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('获取数据失败:', error);
|
||||
rawChartData.value = [];
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化加载数据
|
||||
onMounted(async () => {
|
||||
await getChartList();
|
||||
});
|
||||
</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: #0a1a33;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.main-wrapper {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
gap: 2px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.left-area {
|
||||
width: calc(85% - 1px);
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.right-area {
|
||||
width: calc(15% - 1px);
|
||||
height: 100%;
|
||||
background-color: rgba(15, 52, 96, 0.5);
|
||||
border: 1px solid #1a508b;
|
||||
border-radius: 8px;
|
||||
padding: 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.work-top-header {
|
||||
height: calc(6% - 1px);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.work-main-section {
|
||||
height: calc(94% - 1px);
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.layout-row {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
gap: 2px;
|
||||
box-sizing: border-box;
|
||||
height: calc(100% / 3);
|
||||
}
|
||||
|
||||
.work-col-1-3 {
|
||||
width: calc(100% / 3);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.full-height-card {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(15, 52, 96, 0.3);
|
||||
border: 1px solid #1a508b;
|
||||
border-radius: 8px;
|
||||
padding: 8px;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
color: #e0e6ff;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.work-section {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
gap: 2px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.chart-top-inner {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0 16px;
|
||||
color: #e0e6ff;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.chart-top-inner h2 {
|
||||
font-size: 16px;
|
||||
margin: 0;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.btn-group {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.work-col {
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.work-card {
|
||||
width: 100%;
|
||||
background-color: rgba(15, 52, 96, 0.3);
|
||||
border: 1px solid #1a508b;
|
||||
border-radius: 8px;
|
||||
padding: 8px;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
color: #e0e6ff;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.full-card {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.delete-icon {
|
||||
position: absolute;
|
||||
top: 6px;
|
||||
right: 6px;
|
||||
color: #ff6b6b;
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-radius: 50%;
|
||||
background-color: rgba(255, 107, 107, 0.1);
|
||||
z-index: 10;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.delete-icon:hover {
|
||||
background-color: rgba(255, 107, 107, 0.3);
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
.grid-content {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 8px;
|
||||
box-sizing: border-box;
|
||||
cursor: drop;
|
||||
}
|
||||
|
||||
.metric-tag {
|
||||
padding: 0;
|
||||
background: none;
|
||||
color: #e0e6ff;
|
||||
font-size: 18px;
|
||||
white-space: nowrap;
|
||||
text-align: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.sort-num {
|
||||
font-size: 14px;
|
||||
color: #88a0c2;
|
||||
margin-bottom: 4px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.empty-tip {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
color: #88a0c2;
|
||||
font-size: 14px;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.search-box {
|
||||
padding: 4px 0;
|
||||
margin-bottom: 8px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.metric-list {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 4px;
|
||||
box-sizing: border-box;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: rgba(60, 156, 255, 0.2) transparent;
|
||||
}
|
||||
|
||||
.metric-list::-webkit-scrollbar {
|
||||
width: 1px;
|
||||
}
|
||||
|
||||
.metric-list::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.metric-list::-webkit-scrollbar-thumb {
|
||||
background: rgba(60, 156, 255, 0.2);
|
||||
border-radius: 0.5px;
|
||||
}
|
||||
|
||||
.metric-list::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(60, 156, 255, 0.4);
|
||||
}
|
||||
|
||||
.metric-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 8px 6px;
|
||||
margin-bottom: 6px;
|
||||
border-radius: 6px;
|
||||
color: #e0e6ff;
|
||||
cursor: grab;
|
||||
font-size: 14px;
|
||||
box-sizing: border-box;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.metric-item.active {
|
||||
background-color: rgba(60, 156, 255, 0.3);
|
||||
border: 1px solid #3c9cff;
|
||||
}
|
||||
|
||||
.metric-item:hover {
|
||||
background-color: rgba(60, 156, 255, 0.15);
|
||||
}
|
||||
|
||||
.color-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
margin-left: 6px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,578 @@
|
||||
<template>
|
||||
<div class="work-layout-container">
|
||||
<div class="main-wrapper">
|
||||
<div class="left-area">
|
||||
<div class="work-section work-top-header">
|
||||
<div class="work-card full-card">
|
||||
<div class="chart-top-inner">
|
||||
<h2>工作可视化大屏指标配置</h2>
|
||||
<div class="btn-group">
|
||||
<el-button type="primary" size="default" @click="handleSave" :loading="saveLoading" :disabled="saveLoading">保存</el-button>
|
||||
<el-button type="warning" size="default" @click="handleReset">重置</el-button>
|
||||
<el-button type="danger" size="default" @click="handleClearAll">清空</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</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">
|
||||
<span v-if="metric1.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(1)">×</span>
|
||||
<div class="grid-content" @drop="(e) => handleDrop(e, 1)" @dragover="(e) => e.preventDefault()">
|
||||
<div v-if="metric1.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{1}}</span>
|
||||
{{ metric1[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric1[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{1}})</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-card work-card-1-3">
|
||||
<span v-if="metric2.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(2)">×</span>
|
||||
<div class="grid-content" @drop="(e) => handleDrop(e, 2)" @dragover="(e) => e.preventDefault()">
|
||||
<div v-if="metric2.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{2}}</span>
|
||||
{{ metric2[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric2[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{2}})</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-card work-card-1-3">
|
||||
<span v-if="metric3.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(3)">×</span>
|
||||
<div class="grid-content" @drop="(e) => handleDrop(e, 3)" @dragover="(e) => e.preventDefault()">
|
||||
<div v-if="metric3.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{3}}</span>
|
||||
{{ metric3[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric3[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{3}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-col work-col-1-3 work-middle-col">
|
||||
<div class="work-card work-card-2-3">
|
||||
<span v-if="metric4.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(4)">×</span>
|
||||
<div class="grid-content" @drop="(e) => handleDrop(e, 4)" @dragover="(e) => e.preventDefault()">
|
||||
<div v-if="metric4.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{4}}</span>
|
||||
{{ metric4[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric4[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{4}})</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-card work-card-1-3">
|
||||
<span v-if="metric5.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(5)">×</span>
|
||||
<div class="grid-content" @drop="(e) => handleDrop(e, 5)" @dragover="(e) => e.preventDefault()">
|
||||
<div v-if="metric5.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{5}}</span>
|
||||
{{ metric5[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric5[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{5}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-col work-col-1-3 work-right-col">
|
||||
<div class="work-card work-card-1-3">
|
||||
<span v-if="metric6.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(6)">×</span>
|
||||
<div class="grid-content" @drop="(e) => handleDrop(e, 6)" @dragover="(e) => e.preventDefault()">
|
||||
<div v-if="metric6.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{6}}</span>
|
||||
{{ metric6[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric6[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{6}})</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-card work-card-1-3">
|
||||
<span v-if="metric7.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(7)">×</span>
|
||||
<div class="grid-content" @drop="(e) => handleDrop(e, 7)" @dragover="(e) => e.preventDefault()">
|
||||
<div v-if="metric7.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{7}}</span>
|
||||
{{ metric7[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric7[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{7}})</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-card work-card-1-3">
|
||||
<span v-if="metric8.length > 0" class="delete-icon" @click.stop="handleDeleteMetric(8)">×</span>
|
||||
<div class="grid-content" @drop="(e) => handleDrop(e, 8)" @dragover="(e) => e.preventDefault()">
|
||||
<div v-if="metric8.length > 0" class="metric-tag">
|
||||
<span class="sort-num">指标{{8}}</span>
|
||||
{{ metric8[0].chartName }}
|
||||
<small style="font-size:12px; color:#88a0c2;">ID: {{ metric8[0].chartId }}</small>
|
||||
</div>
|
||||
<div v-else class="empty-tip">拖拽指标到此处(指标{{8}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right-area">
|
||||
<div class="search-box">
|
||||
<el-input v-model="searchKey" placeholder="搜索指标项..." size="small"></el-input>
|
||||
</div>
|
||||
<div class="metric-list">
|
||||
<div v-for="item in allMetricList" :key="item.chartId" class="metric-item" :class="{ active: isMetricUsed(item.chartId) }" draggable="true" @dragstart="(e) => handleDragStart(e, item)" @dragend="handleDragEnd">
|
||||
<span>{{ item.chartName }}</span>
|
||||
<span class="color-dot" :style="{ backgroundColor: item.color || getRandomColor() }"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
// import { getChartListAll, getChartSetting } from '@/api/bizChart'
|
||||
|
||||
const metric1 = ref([]);
|
||||
const metric2 = ref([]);
|
||||
const metric3 = ref([]);
|
||||
const metric4 = ref([]);
|
||||
const metric5 = ref([]);
|
||||
const metric6 = ref([]);
|
||||
const metric7 = ref([]);
|
||||
const metric8 = ref([]);
|
||||
|
||||
const gridOriginalChartId = ref({
|
||||
1: null, 2: null, 3: null, 4: null,
|
||||
5: null, 6: null, 7: null, 8: null
|
||||
});
|
||||
const metricHistory = ref({});
|
||||
|
||||
const saveLoading = ref(false);
|
||||
const rawChartData = ref([]);
|
||||
const searchKey = ref('');
|
||||
const dragItem = ref(null);
|
||||
|
||||
const allMetricList = computed({
|
||||
get() {
|
||||
if (!rawChartData.value || !Array.isArray(rawChartData.value)) return [];
|
||||
return rawChartData.value.filter(item => {
|
||||
if (!item || !item.chartName) return false;
|
||||
const searchVal = searchKey.value ? searchKey.value.toLowerCase() : '';
|
||||
const nameVal = item.chartName ? item.chartName.toLowerCase() : '';
|
||||
return nameVal.includes(searchVal);
|
||||
});
|
||||
},
|
||||
set(val) {
|
||||
rawChartData.value = val;
|
||||
}
|
||||
});
|
||||
|
||||
const getAllMetricArrays = () => ([
|
||||
metric1, metric2, metric3, metric4,
|
||||
metric5, metric6, metric7, metric8
|
||||
]);
|
||||
|
||||
const getMetricArrByGridNum = (gridNum) => {
|
||||
return getAllMetricArrays()[gridNum - 1];
|
||||
};
|
||||
|
||||
const isMetricUsed = (metricId) => {
|
||||
if (!metricId) return false;
|
||||
return getAllMetricArrays().some(
|
||||
metricArr => metricArr.value.some(m => m && m.chartId === metricId)
|
||||
);
|
||||
};
|
||||
|
||||
const findGridNumByChartId = (chartId) => {
|
||||
const arr = getAllMetricArrays();
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
if (arr[i].value.length && arr[i].value[0].chartId === chartId) {
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const handleDragStart = (e, item) => {
|
||||
dragItem.value = item;
|
||||
e.dataTransfer.setData('text/plain', JSON.stringify(item));
|
||||
e.target.style.opacity = '0.6';
|
||||
};
|
||||
|
||||
const handleDragEnd = (e) => {
|
||||
e.target.style.opacity = '1';
|
||||
};
|
||||
|
||||
const handleDrop = (e, targetGrid) => {
|
||||
e.preventDefault();
|
||||
if (!dragItem.value) return;
|
||||
const dragChartId = dragItem.value.chartId;
|
||||
const sourceGrid = findGridNumByChartId(dragChartId);
|
||||
const targetArr = getMetricArrByGridNum(targetGrid);
|
||||
const targetOldItem = targetArr.value[0] || null;
|
||||
const oldSort = sourceGrid || metricHistory.value[dragChartId] || 0;
|
||||
getAllMetricArrays().forEach((arr, index) => {
|
||||
const gridNum = index + 1;
|
||||
if (gridNum !== targetGrid) {
|
||||
arr.value = arr.value.filter(i => i.chartId !== dragChartId);
|
||||
}
|
||||
});
|
||||
|
||||
const newItem = {
|
||||
...dragItem.value,
|
||||
sort: targetGrid,
|
||||
oldSort: oldSort,
|
||||
chartId: dragChartId,
|
||||
oldChartId: gridOriginalChartId.value[targetGrid] || targetOldItem?.chartId || null,
|
||||
};
|
||||
|
||||
targetArr.value = [newItem];
|
||||
metricHistory.value[dragChartId] = targetGrid;
|
||||
|
||||
if (sourceGrid && sourceGrid !== targetGrid) {
|
||||
const sourceArr = getMetricArrByGridNum(sourceGrid);
|
||||
sourceArr.value = [];
|
||||
}
|
||||
|
||||
dragItem.value = null;
|
||||
};
|
||||
|
||||
const handleDeleteMetric = (gridNum) => {
|
||||
const targetArr = getMetricArrByGridNum(gridNum);
|
||||
if (targetArr) {
|
||||
targetArr.value = [];
|
||||
}
|
||||
};
|
||||
|
||||
const handleReset = () => {
|
||||
getAllMetricArrays().forEach(arr => arr.value = []);
|
||||
searchKey.value = '';
|
||||
getChartList();
|
||||
ElMessage.info('已重置所有指标');
|
||||
};
|
||||
|
||||
const handleClearAll = () => {
|
||||
getAllMetricArrays().forEach(arr => arr.value = []);
|
||||
ElMessage.info('已清空所有格子');
|
||||
};
|
||||
|
||||
const handleSave = async () => {
|
||||
saveLoading.value = true;
|
||||
const saveData = getAllMetricArrays().map((arr, index) => {
|
||||
const gridNum = index + 1;
|
||||
const currentItem = arr.value[0];
|
||||
return {
|
||||
sort: gridNum,
|
||||
chartId: currentItem?.chartId || null,
|
||||
oldChartId: currentItem?.oldChartId || null,
|
||||
chartName: currentItem?.chartName || '',
|
||||
chartCode: 'work',
|
||||
oldSort: currentItem?.oldSort || gridNum,
|
||||
color: currentItem?.color || ''
|
||||
};
|
||||
}).filter(item => item.chartId);
|
||||
|
||||
try {
|
||||
const res = await getChartSetting(saveData);
|
||||
ElMessage.success(res?.msg);
|
||||
return saveData;
|
||||
} catch (error) {
|
||||
console.error('保存失败:', error);
|
||||
} finally {
|
||||
getChartList()
|
||||
saveLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const getRandomColor = () => {
|
||||
const colors = ['#3c9cff', '#5ac8fa', '#9254de', '#f7ba2a', '#ff7d00', '#23c8c8', '#ff6b6b', '#86909c'];
|
||||
return colors[Math.floor(Math.random() * colors.length)];
|
||||
};
|
||||
|
||||
async function getChartList() {
|
||||
try {
|
||||
const reqParams = { chartCode: 'work' };
|
||||
const res = await getChartListAll(reqParams);
|
||||
rawChartData.value = res || [];
|
||||
metricHistory.value = {};
|
||||
Object.keys(gridOriginalChartId.value).forEach(key => {
|
||||
gridOriginalChartId.value[key] = null;
|
||||
});
|
||||
|
||||
rawChartData.value.forEach(item => {
|
||||
const sortNum = item.sort || 0;
|
||||
if (sortNum >= 1 && sortNum <= 8) {
|
||||
const targetArr = getMetricArrByGridNum(sortNum);
|
||||
if (targetArr) {
|
||||
gridOriginalChartId.value[sortNum] = item.chartId;
|
||||
targetArr.value = [{
|
||||
...item,
|
||||
sort: sortNum,
|
||||
oldSort: 0,
|
||||
chartId: item.chartId,
|
||||
oldChartId: item.chartId
|
||||
}];
|
||||
metricHistory.value[item.chartId] = sortNum;
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('获取数据失败:', error);
|
||||
rawChartData.value = [];
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await getChartList();
|
||||
});
|
||||
</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: #0a1a33;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.main-wrapper {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
gap: 2px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.left-area {
|
||||
width: calc(85% - 1px);
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.right-area {
|
||||
width: calc(15% - 1px);
|
||||
height: 100%;
|
||||
background-color: rgba(15, 52, 96, 0.5);
|
||||
border: 1px solid #1a508b;
|
||||
border-radius: 8px;
|
||||
padding: 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.work-top-header {
|
||||
height: calc(6% - 1px);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.work-main-section {
|
||||
height: calc(94% - 1px);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.work-section {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
gap: 2px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.chart-top-inner {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0 16px;
|
||||
color: #e0e6ff;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.chart-top-inner h2 {
|
||||
font-size: 16px;
|
||||
margin: 0;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.btn-group {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.work-col {
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.work-col-1-3 {
|
||||
width: calc(100% / 3 - 2px);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.work-card {
|
||||
width: 100%;
|
||||
background-color: rgba(15, 52, 96, 0.3);
|
||||
border: 1px solid #1a508b;
|
||||
border-radius: 8px;
|
||||
padding: 8px;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
color: #e0e6ff;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.work-card-1-3 {
|
||||
height: calc(100% / 3 - 2px);
|
||||
}
|
||||
|
||||
.work-card-2-3 {
|
||||
height: calc(200% / 3 - 2px);
|
||||
}
|
||||
|
||||
.full-card {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.delete-icon {
|
||||
position: absolute;
|
||||
top: 6px;
|
||||
right: 6px;
|
||||
color: #ff6b6b;
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-radius: 50%;
|
||||
background-color: rgba(255, 107, 107, 0.1);
|
||||
z-index: 10;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.delete-icon:hover {
|
||||
background-color: rgba(255, 107, 107, 0.3);
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
.grid-content {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 8px;
|
||||
box-sizing: border-box;
|
||||
cursor: drop;
|
||||
}
|
||||
|
||||
.metric-tag {
|
||||
padding: 0;
|
||||
background: none;
|
||||
color: #e0e6ff;
|
||||
font-size: 18px;
|
||||
white-space: nowrap;
|
||||
text-align: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.sort-num {
|
||||
font-size: 14px;
|
||||
color: #88a0c2;
|
||||
margin-bottom: 4px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.empty-tip {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
color: #88a0c2;
|
||||
font-size: 14px;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.search-box {
|
||||
padding: 4px 0;
|
||||
margin-bottom: 8px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.metric-list {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 4px;
|
||||
box-sizing: border-box;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: rgba(60, 156, 255, 0.2) transparent;
|
||||
}
|
||||
|
||||
.metric-list::-webkit-scrollbar {
|
||||
width: 1px;
|
||||
}
|
||||
|
||||
.metric-list::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.metric-list::-webkit-scrollbar-thumb {
|
||||
background: rgba(60, 156, 255, 0.2);
|
||||
border-radius: 0.5px;
|
||||
}
|
||||
|
||||
.metric-list::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(60, 156, 255, 0.4);
|
||||
}
|
||||
|
||||
.metric-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 8px 6px;
|
||||
margin-bottom: 6px;
|
||||
border-radius: 6px;
|
||||
color: #e0e6ff;
|
||||
cursor: grab;
|
||||
font-size: 14px;
|
||||
box-sizing: border-box;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.metric-item.active {
|
||||
background-color: rgba(60, 156, 255, 0.3);
|
||||
border: 1px solid #3c9cff;
|
||||
}
|
||||
|
||||
.metric-item:hover {
|
||||
background-color: rgba(60, 156, 255, 0.15);
|
||||
}
|
||||
|
||||
.color-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
margin-left: 6px;
|
||||
}
|
||||
</style>
|
||||
192
web-vue/packages/core/layouts/views/screen/setting/index.vue
Normal file
192
web-vue/packages/core/layouts/views/screen/setting/index.vue
Normal file
@@ -0,0 +1,192 @@
|
||||
<template>
|
||||
<div class="work-layout-container">
|
||||
<div class="work-left-sidebar">
|
||||
<div class="menu-title">
|
||||
<h3>指标配置</h3>
|
||||
</div>
|
||||
<div class="menu-list">
|
||||
<div
|
||||
class="menu-item"
|
||||
:class="{ active: activeMenu === item.key }"
|
||||
v-for="item in menuList"
|
||||
:key="item.key"
|
||||
@click="activeMenu = item.key"
|
||||
>
|
||||
{{ item.label }}
|
||||
</div>
|
||||
</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 } 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: '系统' },
|
||||
])
|
||||
const activeMenu = ref(1)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.work-layout-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 6px;
|
||||
padding: 8px;
|
||||
margin: 0 !important;
|
||||
box-sizing: border-box;
|
||||
background-color: transparent;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.work-left-sidebar {
|
||||
width: 15%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
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 {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 10;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.menu-title h3 {
|
||||
margin: 0;
|
||||
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 {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
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 {
|
||||
height: 36px;
|
||||
line-height: 36px;
|
||||
padding: 0 16px;
|
||||
border-radius: 8px;
|
||||
font-size: 16px;
|
||||
cursor: pointer;
|
||||
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 {
|
||||
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);
|
||||
}
|
||||
|
||||
.work-main-section {
|
||||
height: 100%;
|
||||
width: 85%;
|
||||
background: transparent;
|
||||
border: 1px solid rgba(26, 80, 139, 0.3);
|
||||
border-radius: 12px;
|
||||
backdrop-filter: blur(2px);
|
||||
overflow: auto;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.menu-content {
|
||||
padding: 0 4px;
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
color: #e0e6ff;
|
||||
}
|
||||
|
||||
.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>
|
||||
Reference in New Issue
Block a user