大屏页面初始化
This commit is contained in:
@@ -5,9 +5,9 @@
|
||||
<div class="work-section work-top-header">
|
||||
<div class="work-card full-card">
|
||||
<div class="chart-top-inner">
|
||||
<h2>财务可视化大屏指标配置</h2>
|
||||
<h2>系统可视化大屏指标配置</h2>
|
||||
<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>
|
||||
<el-button type="warning" size="default" @click="handleReset">重置</el-button>
|
||||
</div>
|
||||
@@ -276,22 +276,26 @@ const handleDrop = (e, gridNum) => {
|
||||
if (!dragItem.value) return;
|
||||
const targetArr = getMetricArrByGridNum(gridNum);
|
||||
if (!targetArr) return;
|
||||
const currentChartId = dragItem.value.chartId;
|
||||
const currentChartId = dragItem.value.chartId;
|
||||
|
||||
getAllMetricArrays().forEach((arr, index) => {
|
||||
const pos = index + 1;
|
||||
if (pos !== gridNum && arr.value.some(item => item.chartId === currentChartId)) {
|
||||
arr.value = [];
|
||||
}
|
||||
});
|
||||
|
||||
const originalSort = dragItem.value.sort || 0;
|
||||
const currentFixedOldId = targetArr.value[0]?.fixedOldChartId || currentChartId;
|
||||
|
||||
const newItem = {
|
||||
...dragItem.value,
|
||||
sort: gridNum,
|
||||
oldSort: targetArr.value[0]?.sort || gridNum,
|
||||
oldSort: originalSort,
|
||||
fixedOldChartId: currentFixedOldId,
|
||||
oldChartId: currentFixedOldId
|
||||
};
|
||||
|
||||
|
||||
targetArr.value = [newItem];
|
||||
dragItem.value = null;
|
||||
};
|
||||
@@ -312,7 +316,6 @@ const handleReset = () => {
|
||||
|
||||
const handleSave = async () => {
|
||||
saveLoading.value = true;
|
||||
|
||||
const saveData = getAllMetricArrays().map((arr, index) => {
|
||||
const gridNum = index + 1;
|
||||
const currentItem = arr.value[0];
|
||||
@@ -322,18 +325,19 @@ const handleSave = async () => {
|
||||
oldChartId: currentItem?.fixedOldChartId || null,
|
||||
chartName: currentItem?.chartName || '',
|
||||
chartCode: 'erp',
|
||||
oldSort: currentItem?.oldSort || gridNum,
|
||||
oldSort: currentItem?.oldSort || 0,
|
||||
color: currentItem?.color || ''
|
||||
};
|
||||
}).filter(item => item.chartId);
|
||||
|
||||
try {
|
||||
const res = await getChartSetting(saveData);
|
||||
ElMessage.success(res?.msg || '保存成功');
|
||||
ElMessage.success(res?.msg);
|
||||
return saveData;
|
||||
} catch (error) {
|
||||
console.error('保存失败:', error);
|
||||
} finally {
|
||||
getChartList();
|
||||
saveLoading.value = false;
|
||||
}
|
||||
};
|
||||
@@ -343,12 +347,10 @@ const getRandomColor = () => {
|
||||
return colors[Math.floor(Math.random() * colors.length)];
|
||||
};
|
||||
|
||||
async function getChartList(){
|
||||
async function getChartList() {
|
||||
try {
|
||||
const reqParams = {
|
||||
chartCode: 'erp'
|
||||
}
|
||||
const res = await getChartListAll(reqParams)
|
||||
const reqParams = { chartCode: 'erp' };
|
||||
const res = await getChartListAll(reqParams);
|
||||
rawChartData.value = res || [];
|
||||
|
||||
rawChartData.value.forEach(item => {
|
||||
|
||||
@@ -38,18 +38,20 @@ public class ChartInfoController {
|
||||
@PostMapping("setting")
|
||||
public Result<Message> save(@RequestBody List<ChartConfig> configs) {
|
||||
for (ChartConfig config : configs) {
|
||||
LambdaQueryWrapper<ChartInfo> newQuery = new LambdaQueryWrapper<ChartInfo>()
|
||||
.eq(ChartInfo::getChartId, config.getChartId())
|
||||
.eq(ChartInfo::getChartCode, config.getChartCode());
|
||||
ChartInfo newChartInfo = chartInfoService.getOne(newQuery);
|
||||
newChartInfo.setSort(config.getSort());
|
||||
chartInfoService.updateById(newChartInfo);
|
||||
LambdaQueryWrapper<ChartInfo> oldQuery = new LambdaQueryWrapper<ChartInfo>()
|
||||
.eq(ChartInfo::getChartId, config.getOldChartId())
|
||||
.eq(ChartInfo::getChartCode, config.getChartCode());
|
||||
ChartInfo oldChartInfo = chartInfoService.getOne(oldQuery);
|
||||
oldChartInfo.setSort(config.getOldSort());
|
||||
chartInfoService.updateById(oldChartInfo);
|
||||
|
||||
System.out.println(config);
|
||||
// LambdaQueryWrapper<ChartInfo> newQuery = new LambdaQueryWrapper<ChartInfo>()
|
||||
// .eq(ChartInfo::getChartId, config.getChartId())
|
||||
// .eq(ChartInfo::getChartCode, config.getChartCode());
|
||||
// ChartInfo newChartInfo = chartInfoService.getOne(newQuery);
|
||||
// newChartInfo.setSort(config.getSort());
|
||||
// chartInfoService.updateById(newChartInfo);
|
||||
// LambdaQueryWrapper<ChartInfo> oldQuery = new LambdaQueryWrapper<ChartInfo>()
|
||||
// .eq(ChartInfo::getChartId, config.getOldChartId())
|
||||
// .eq(ChartInfo::getChartCode, config.getChartCode());
|
||||
// ChartInfo oldChartInfo = chartInfoService.getOne(oldQuery);
|
||||
// oldChartInfo.setSort(config.getOldSort());
|
||||
// chartInfoService.updateById(oldChartInfo);
|
||||
}
|
||||
return Result.success(new Message("配置保存成功", 200));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user