diff --git a/src/store/modules/chartEditStore/chartEditStore.ts b/src/store/modules/chartEditStore/chartEditStore.ts index 131e8763..5b37abfe 100644 --- a/src/store/modules/chartEditStore/chartEditStore.ts +++ b/src/store/modules/chartEditStore/chartEditStore.ts @@ -532,6 +532,10 @@ export const useChartEditStore = defineStore({ return } + // 取消选中 + this.setTargetSelectChart() + + // 重新选中 let historyData = HistoryItem.historyData as Array if (isArray(historyData)) { // 选中目标元素,支持多个 @@ -619,30 +623,36 @@ export const useChartEditStore = defineStore({ return } - switch (HistoryItem.actionType) { - // 锁定处理 - case HistoryActionTypeEnum.LOCK: - case HistoryActionTypeEnum.UNLOCK: - if (!isForward) { - // 恢复原来状态 - if (HistoryItem.actionType === HistoryActionTypeEnum.LOCK) historyData[0].status.lock = false - if (HistoryItem.actionType === HistoryActionTypeEnum.UNLOCK) historyData[0].status.lock = true - return - } - this.setLock(!historyData[0].status.lock, false) - break + // 处理锁定 + const isLock = HistoryItem.actionType === HistoryActionTypeEnum.LOCK + const isUnLock = HistoryItem.actionType === HistoryActionTypeEnum.UNLOCK + if (isLock || isUnLock) { + if ((isLock && isForward) || (isUnLock && !isForward)) { + historyData.forEach(item => { + this.setLock(!item.status.lock, false) + }) + return + } + historyData.forEach(item => { + this.setUnLock(false) + }) + return + } - // 隐藏处理 - case HistoryActionTypeEnum.HIDE: - case HistoryActionTypeEnum.SHOW: - if (!isForward) { - // 恢复原来状态 - if (HistoryItem.actionType === HistoryActionTypeEnum.HIDE) historyData[0].status.hide = false - if (HistoryItem.actionType === HistoryActionTypeEnum.SHOW) historyData[0].status.hide = true - return - } - this.setHide(!historyData[0].status.hide, false) - break + // 处理隐藏 + const isHide = HistoryItem.actionType === HistoryActionTypeEnum.HIDE + const isShow = HistoryItem.actionType === HistoryActionTypeEnum.SHOW + if (isHide || isShow) { + if ((isHide && isForward) || (isShow && !isForward)) { + historyData.forEach(item => { + this.setHide(!item.status.hide, false) + }) + return + } + historyData.forEach(item => { + this.setShow(false) + }) + return } }, // * 撤回 @@ -837,14 +847,13 @@ export const useChartEditStore = defineStore({ // 历史记录 if (isHistory) { - chartHistoryStore.createLockHistory( - [targetItem], - status ? HistoryActionTypeEnum.LOCK : HistoryActionTypeEnum.UNLOCK - ) + status + ? chartHistoryStore.createLockHistory([targetItem]) + : chartHistoryStore.createUnLockHistory([targetItem]) } this.updateComponentList(index, targetItem) // 锁定添加失焦效果 - if(status) this.setTargetSelectChart(undefined) + if (status) this.setTargetSelectChart(undefined) loadingFinish() return } @@ -869,12 +878,11 @@ export const useChartEditStore = defineStore({ const targetItem = this.getComponentList[index] targetItem.status.hide = status - // 历史记录 + // 历史记录 if (isHistory) { - chartHistoryStore.createHideHistory( - [targetItem], - status ? HistoryActionTypeEnum.HIDE : HistoryActionTypeEnum.SHOW - ) + status + ? chartHistoryStore.createHideHistory([targetItem]) + : chartHistoryStore.createShowHistory([targetItem]) } this.updateComponentList(index, targetItem) loadingFinish() diff --git a/src/store/modules/chartHistoryStore/chartHistoryStore.ts b/src/store/modules/chartHistoryStore/chartHistoryStore.ts index b773300b..dc67ca97 100644 --- a/src/store/modules/chartHistoryStore/chartHistoryStore.ts +++ b/src/store/modules/chartHistoryStore/chartHistoryStore.ts @@ -169,18 +169,20 @@ export const useChartHistoryStore = defineStore({ this.createStackItem(item, HistoryActionTypeEnum.UN_GROUP, HistoryTargetTypeEnum.CHART) }, // * 锁定记录 - createLockHistory( - item: Array, - type: HistoryActionTypeEnum.LOCK | HistoryActionTypeEnum.UNLOCK - ) { - this.createStackItem(item, type, HistoryTargetTypeEnum.CHART) + createLockHistory(item: Array) { + this.createStackItem(item, HistoryActionTypeEnum.LOCK, HistoryTargetTypeEnum.CHART) + }, + // * 解锁记录 + createUnLockHistory(item: Array) { + this.createStackItem(item, HistoryActionTypeEnum.UNLOCK, HistoryTargetTypeEnum.CHART) }, // * 隐藏记录 - createHideHistory( - item: Array, - type: HistoryActionTypeEnum.HIDE | HistoryActionTypeEnum.SHOW - ) { - this.createStackItem(item, type, HistoryTargetTypeEnum.CHART) + createHideHistory(item: Array) { + this.createStackItem(item, HistoryActionTypeEnum.HIDE, HistoryTargetTypeEnum.CHART) + }, + // * 展示记录 + createShowHistory(item: Array) { + this.createStackItem(item, HistoryActionTypeEnum.SHOW, HistoryTargetTypeEnum.CHART) } } })