feat: 增加右键菜单功能及处理逻辑

This commit is contained in:
tnt group
2022-09-28 16:47:12 +08:00
parent e559ca928a
commit 634b5c2bea
10 changed files with 212 additions and 62 deletions
@@ -602,7 +602,8 @@ export const useChartEditStore = defineStore({
ids.push(item.id)
})
} else {
(historyData[0] as CreateComponentGroupType).groupList.forEach(item => {
const group = historyData[0] as CreateComponentGroupType
group.groupList.forEach(item => {
ids.push(item.id)
})
}
@@ -795,6 +796,70 @@ export const useChartEditStore = defineStore({
loadingFinish()
}
},
// * 锁定
setLock(status: boolean = true, isHistory: boolean = true) {
try {
// 暂不支持多选
if (this.getTargetChart.selectId.length > 1) return
loadingStart()
const index: number = this.fetchTargetIndex()
if (index !== -1) {
// 更新状态
const targetItem = this.getComponentList[index]
targetItem.status.lock = status
// 历史记录
if (isHistory) {
chartHistoryStore.createLayerHistory(
[targetItem],
status ? HistoryActionTypeEnum.LOCK : HistoryActionTypeEnum.UNLOCK
)
}
this.updateComponentList(index, targetItem)
loadingFinish()
return
}
} catch (value) {
loadingError()
}
},
// * 解除锁定
setUnLock(isHistory: boolean = true) {
this.setLock(false, isHistory)
},
// * 隐藏
setHide(status: boolean = true, isHistory: boolean = true) {
try {
// 暂不支持多选
if (this.getTargetChart.selectId.length > 1) return
loadingStart()
const index: number = this.fetchTargetIndex()
if (index !== -1) {
// 更新状态
const targetItem = this.getComponentList[index]
targetItem.status.hide = status
// 历史记录
if (isHistory) {
chartHistoryStore.createLayerHistory(
[targetItem],
status ? HistoryActionTypeEnum.HIDE : HistoryActionTypeEnum.SHOW
)
}
this.updateComponentList(index, targetItem)
loadingFinish()
return
}
} catch (value) {
loadingError()
}
},
// * 显示
setShow(isHistory: boolean = true) {
this.setHide(false, isHistory)
},
// ----------------
// * 设置页面大小
setPageSize(scale: number): void {