From f470817c01b47a80c841a4254aa336598ad977ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Sat, 1 Oct 2022 19:59:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=89=8D=E8=BF=9B?= =?UTF-8?q?=E6=92=A4=E5=9B=9E=E4=B8=AD=E9=94=81=E5=AE=9A/=E9=9A=90?= =?UTF-8?q?=E8=97=8F=E6=97=A0=E6=B3=95=E6=AD=A3=E5=B8=B8=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/chartEditStore/chartEditStore.ts | 74 ++++++++++--------- .../chartHistoryStore/chartHistoryStore.ts | 22 +++--- 2 files changed, 53 insertions(+), 43 deletions(-) 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) } } })