|
|
|
|
@ -493,28 +493,75 @@ export const useChartEditStore = defineStore({
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const index: number = this.fetchTargetIndex();
|
|
|
|
|
const targetData = this.getComponentList[index];
|
|
|
|
|
if (index !== -1) {
|
|
|
|
|
// 下移排除最底层, 上移排除最顶层
|
|
|
|
|
if ((isDown && index === 0) || (!isDown && index === length - 1)) {
|
|
|
|
|
if (targetData.isGroup) {
|
|
|
|
|
const groupIndex = targetData.groupList.findIndex(
|
|
|
|
|
(item) => item.id === this.getTargetChart.selectId[0],
|
|
|
|
|
);
|
|
|
|
|
// 分组
|
|
|
|
|
if (groupIndex === -1) {
|
|
|
|
|
// 下移排除最底层, 上移排除最顶层
|
|
|
|
|
if ((isDown && index === 0) || (!isDown && index === length - 1)) {
|
|
|
|
|
loadingFinish();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 互换位置
|
|
|
|
|
const swapIndex = isDown ? index - 1 : index + 1;
|
|
|
|
|
const targetItem = this.getComponentList[index];
|
|
|
|
|
const swapItem = this.getComponentList[swapIndex];
|
|
|
|
|
|
|
|
|
|
// 历史记录
|
|
|
|
|
if (isHistory) {
|
|
|
|
|
chartHistoryStore.createLayerHistory(
|
|
|
|
|
[targetItem],
|
|
|
|
|
isDown ? HistoryActionTypeEnum.DOWN : HistoryActionTypeEnum.UP,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
this.updateComponentList(index, swapItem);
|
|
|
|
|
this.updateComponentList(swapIndex, targetItem);
|
|
|
|
|
loadingFinish();
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
// 分组里面的单组件
|
|
|
|
|
const groupLength = targetData.groupList.length;
|
|
|
|
|
// 下移排除最底层, 上移排除最顶层
|
|
|
|
|
if ((!isDown && groupIndex === 0) || (isDown && groupIndex === groupLength - 1)) {
|
|
|
|
|
loadingFinish();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 互换位置
|
|
|
|
|
const swapIndex = isDown ? groupIndex + 1 : groupIndex - 1;
|
|
|
|
|
const targetItem = targetData.groupList[groupIndex];
|
|
|
|
|
const swapItem = targetData.groupList[swapIndex];
|
|
|
|
|
targetData.groupList[groupIndex] = swapItem;
|
|
|
|
|
targetData.groupList[swapIndex] = targetItem;
|
|
|
|
|
this.componentList[index] = targetData;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 下移排除最底层, 上移排除最顶层
|
|
|
|
|
if ((isDown && index === 0) || (!isDown && index === length - 1)) {
|
|
|
|
|
loadingFinish();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 互换位置
|
|
|
|
|
const swapIndex = isDown ? index - 1 : index + 1;
|
|
|
|
|
const targetItem = this.getComponentList[index];
|
|
|
|
|
const swapItem = this.getComponentList[swapIndex];
|
|
|
|
|
|
|
|
|
|
// 历史记录
|
|
|
|
|
if (isHistory) {
|
|
|
|
|
chartHistoryStore.createLayerHistory(
|
|
|
|
|
[targetItem],
|
|
|
|
|
isDown ? HistoryActionTypeEnum.DOWN : HistoryActionTypeEnum.UP,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
this.updateComponentList(index, swapItem);
|
|
|
|
|
this.updateComponentList(swapIndex, targetItem);
|
|
|
|
|
loadingFinish();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 互换位置
|
|
|
|
|
const swapIndex = isDown ? index - 1 : index + 1;
|
|
|
|
|
const targetItem = this.getComponentList[index];
|
|
|
|
|
const swapItem = this.getComponentList[swapIndex];
|
|
|
|
|
|
|
|
|
|
// 历史记录
|
|
|
|
|
if (isHistory) {
|
|
|
|
|
chartHistoryStore.createLayerHistory(
|
|
|
|
|
[targetItem],
|
|
|
|
|
isDown ? HistoryActionTypeEnum.DOWN : HistoryActionTypeEnum.UP,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
this.updateComponentList(index, swapItem);
|
|
|
|
|
this.updateComponentList(swapIndex, targetItem);
|
|
|
|
|
loadingFinish();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} catch (value) {
|
|
|
|
|
loadingError();
|
|
|
|
|
@ -1015,7 +1062,6 @@ export const useChartEditStore = defineStore({
|
|
|
|
|
try {
|
|
|
|
|
// 暂不支持多选
|
|
|
|
|
if (this.getTargetChart.selectId.length > 1) return;
|
|
|
|
|
|
|
|
|
|
loadingStart();
|
|
|
|
|
const index: number = this.fetchTargetIndex();
|
|
|
|
|
if (index !== -1) {
|
|
|
|
|
|