大屏页面初始化

This commit is contained in:
2026-03-11 18:20:02 +08:00
parent 786217af69
commit 8069e437dc
2 changed files with 29 additions and 25 deletions

View File

@@ -5,7 +5,7 @@
<div class="work-section work-top-header"> <div class="work-section work-top-header">
<div class="work-card full-card"> <div class="work-card full-card">
<div class="chart-top-inner"> <div class="chart-top-inner">
<h2>财务可视化大屏指标配置</h2> <h2>系统可视化大屏指标配置</h2>
<div class="btn-group"> <div class="btn-group">
<el-button type="primary" size="default" @click="handleSave" <el-button type="primary" size="default" @click="handleSave"
:loading="saveLoading" :disabled="saveLoading">保存</el-button> :loading="saveLoading" :disabled="saveLoading">保存</el-button>
@@ -277,17 +277,21 @@ const handleDrop = (e, gridNum) => {
const targetArr = getMetricArrByGridNum(gridNum); const targetArr = getMetricArrByGridNum(gridNum);
if (!targetArr) return; if (!targetArr) return;
const currentChartId = dragItem.value.chartId; const currentChartId = dragItem.value.chartId;
getAllMetricArrays().forEach((arr, index) => { getAllMetricArrays().forEach((arr, index) => {
const pos = index + 1; const pos = index + 1;
if (pos !== gridNum && arr.value.some(item => item.chartId === currentChartId)) { if (pos !== gridNum && arr.value.some(item => item.chartId === currentChartId)) {
arr.value = []; arr.value = [];
} }
}); });
const originalSort = dragItem.value.sort || 0;
const currentFixedOldId = targetArr.value[0]?.fixedOldChartId || currentChartId; const currentFixedOldId = targetArr.value[0]?.fixedOldChartId || currentChartId;
const newItem = { const newItem = {
...dragItem.value, ...dragItem.value,
sort: gridNum, sort: gridNum,
oldSort: targetArr.value[0]?.sort || gridNum, oldSort: originalSort,
fixedOldChartId: currentFixedOldId, fixedOldChartId: currentFixedOldId,
oldChartId: currentFixedOldId oldChartId: currentFixedOldId
}; };
@@ -312,7 +316,6 @@ const handleReset = () => {
const handleSave = async () => { const handleSave = async () => {
saveLoading.value = true; saveLoading.value = true;
const saveData = getAllMetricArrays().map((arr, index) => { const saveData = getAllMetricArrays().map((arr, index) => {
const gridNum = index + 1; const gridNum = index + 1;
const currentItem = arr.value[0]; const currentItem = arr.value[0];
@@ -322,18 +325,19 @@ const handleSave = async () => {
oldChartId: currentItem?.fixedOldChartId || null, oldChartId: currentItem?.fixedOldChartId || null,
chartName: currentItem?.chartName || '', chartName: currentItem?.chartName || '',
chartCode: 'erp', chartCode: 'erp',
oldSort: currentItem?.oldSort || gridNum, oldSort: currentItem?.oldSort || 0,
color: currentItem?.color || '' color: currentItem?.color || ''
}; };
}).filter(item => item.chartId); }).filter(item => item.chartId);
try { try {
const res = await getChartSetting(saveData); const res = await getChartSetting(saveData);
ElMessage.success(res?.msg || '保存成功'); ElMessage.success(res?.msg);
return saveData; return saveData;
} catch (error) { } catch (error) {
console.error('保存失败:', error); console.error('保存失败:', error);
} finally { } finally {
getChartList();
saveLoading.value = false; saveLoading.value = false;
} }
}; };
@@ -343,12 +347,10 @@ const getRandomColor = () => {
return colors[Math.floor(Math.random() * colors.length)]; return colors[Math.floor(Math.random() * colors.length)];
}; };
async function getChartList(){ async function getChartList() {
try { try {
const reqParams = { const reqParams = { chartCode: 'erp' };
chartCode: 'erp' const res = await getChartListAll(reqParams);
}
const res = await getChartListAll(reqParams)
rawChartData.value = res || []; rawChartData.value = res || [];
rawChartData.value.forEach(item => { rawChartData.value.forEach(item => {

View File

@@ -38,18 +38,20 @@ public class ChartInfoController {
@PostMapping("setting") @PostMapping("setting")
public Result<Message> save(@RequestBody List<ChartConfig> configs) { public Result<Message> save(@RequestBody List<ChartConfig> configs) {
for (ChartConfig config : configs) { for (ChartConfig config : configs) {
LambdaQueryWrapper<ChartInfo> newQuery = new LambdaQueryWrapper<ChartInfo>()
.eq(ChartInfo::getChartId, config.getChartId()) System.out.println(config);
.eq(ChartInfo::getChartCode, config.getChartCode()); // LambdaQueryWrapper<ChartInfo> newQuery = new LambdaQueryWrapper<ChartInfo>()
ChartInfo newChartInfo = chartInfoService.getOne(newQuery); // .eq(ChartInfo::getChartId, config.getChartId())
newChartInfo.setSort(config.getSort()); // .eq(ChartInfo::getChartCode, config.getChartCode());
chartInfoService.updateById(newChartInfo); // ChartInfo newChartInfo = chartInfoService.getOne(newQuery);
LambdaQueryWrapper<ChartInfo> oldQuery = new LambdaQueryWrapper<ChartInfo>() // newChartInfo.setSort(config.getSort());
.eq(ChartInfo::getChartId, config.getOldChartId()) // chartInfoService.updateById(newChartInfo);
.eq(ChartInfo::getChartCode, config.getChartCode()); // LambdaQueryWrapper<ChartInfo> oldQuery = new LambdaQueryWrapper<ChartInfo>()
ChartInfo oldChartInfo = chartInfoService.getOne(oldQuery); // .eq(ChartInfo::getChartId, config.getOldChartId())
oldChartInfo.setSort(config.getOldSort()); // .eq(ChartInfo::getChartCode, config.getChartCode());
chartInfoService.updateById(oldChartInfo); // ChartInfo oldChartInfo = chartInfoService.getOne(oldQuery);
// oldChartInfo.setSort(config.getOldSort());
// chartInfoService.updateById(oldChartInfo);
} }
return Result.success(new Message("配置保存成功", 200)); return Result.success(new Message("配置保存成功", 200));
} }