mirror of
https://gitee.com/dromara/go-view.git
synced 2026-04-23 00:00:12 +08:00
fix: 新增多选的全部列表添加, 结构设计
This commit is contained in:
+5
-4
@@ -1,4 +1,4 @@
|
||||
import { CreateComponentType, FilterEnum } from '@/packages/index.d'
|
||||
import { CreateComponentType, CreateComponentGroupType, FilterEnum } from '@/packages/index.d'
|
||||
import { HistoryActionTypeEnum } from '@/store/modules/chartHistoryStore/chartHistoryStore.d'
|
||||
import {
|
||||
RequestHttpEnum,
|
||||
@@ -117,7 +117,7 @@ export type TargetChartType = {
|
||||
|
||||
// 数据记录
|
||||
export type RecordChartType = {
|
||||
charts: CreateComponentType | CreateComponentType[]
|
||||
charts: CreateComponentType | CreateComponentType[] | CreateComponentGroupType
|
||||
type: HistoryActionTypeEnum.CUT | HistoryActionTypeEnum.COPY
|
||||
}
|
||||
|
||||
@@ -180,11 +180,12 @@ export interface ChartEditStoreType {
|
||||
[ChartEditStoreEnum.TARGET_CHART]: TargetChartType
|
||||
[ChartEditStoreEnum.RECORD_CHART]?: RecordChartType
|
||||
[ChartEditStoreEnum.REQUEST_GLOBAL_CONFIG]: RequestGlobalConfigType
|
||||
[ChartEditStoreEnum.COMPONENT_LIST]: CreateComponentType[]
|
||||
[ChartEditStoreEnum.COMPONENT_LIST]: Array<CreateComponentType | CreateComponentGroupType>
|
||||
}
|
||||
|
||||
// 存储数据类型
|
||||
export interface ChartEditStorage {
|
||||
[ChartEditStoreEnum.EDIT_CANVAS_CONFIG]: EditCanvasConfigType
|
||||
[ChartEditStoreEnum.REQUEST_GLOBAL_CONFIG]: RequestGlobalConfigType
|
||||
[ChartEditStoreEnum.COMPONENT_LIST]: CreateComponentType[]
|
||||
[ChartEditStoreEnum.COMPONENT_LIST]: Array<CreateComponentType | CreateComponentGroupType>
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d'
|
||||
import { PublicGroupConfigClass } from '@/packages/public/publicConfig'
|
||||
import debounce from 'lodash/debounce'
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
import { defaultTheme, globalThemeJson } from '@/settings/chartThemes/index'
|
||||
import { requestInterval, previewScaleType, requestIntervalUnit } from '@/settings/designSetting'
|
||||
import { RequestBodyEnum } from '@/enums/httpEnum'
|
||||
// 记录记录
|
||||
import { useChartHistoryStore } from '@/store/modules/chartHistoryStore/chartHistoryStore'
|
||||
// 全局设置
|
||||
@@ -148,7 +148,7 @@ export const useChartEditStore = defineStore({
|
||||
getRequestGlobalConfig(): RequestGlobalConfigType {
|
||||
return this.requestGlobalConfig
|
||||
},
|
||||
getComponentList(): CreateComponentType[] {
|
||||
getComponentList(): Array<CreateComponentType | CreateComponentGroupType> {
|
||||
return this.componentList
|
||||
},
|
||||
// 获取需要存储的数据项
|
||||
@@ -243,7 +243,7 @@ export const useChartEditStore = defineStore({
|
||||
* @param isHistory 是否进行记录
|
||||
* @returns
|
||||
*/
|
||||
addComponentList(chartConfig: CreateComponentType, isHead = false, isHistory = false): void {
|
||||
addComponentList(chartConfig: CreateComponentType | CreateComponentGroupType, isHead = false, isHistory = false): void {
|
||||
if (isHistory) {
|
||||
chartHistoryStore.createAddHistory(chartConfig)
|
||||
}
|
||||
@@ -253,7 +253,7 @@ export const useChartEditStore = defineStore({
|
||||
}
|
||||
this.componentList.push(chartConfig)
|
||||
},
|
||||
// * 删除组件列表
|
||||
// * 删除单个组件
|
||||
removeComponentList(isHistory = true): void {
|
||||
try {
|
||||
loadingStart()
|
||||
@@ -269,7 +269,7 @@ export const useChartEditStore = defineStore({
|
||||
}
|
||||
},
|
||||
// * 更新组件列表某一项的值
|
||||
updateComponentList(index: number, newData: CreateComponentType) {
|
||||
updateComponentList(index: number, newData: CreateComponentType | CreateComponentGroupType) {
|
||||
if (index < 1 && index > this.getComponentList.length) return
|
||||
this.componentList[index] = newData
|
||||
},
|
||||
@@ -303,7 +303,7 @@ export const useChartEditStore = defineStore({
|
||||
}
|
||||
|
||||
// 记录原有位置
|
||||
const setIndex = (t:CreateComponentType, i:number) => {
|
||||
const setIndex = (t:CreateComponentType | CreateComponentGroupType, i:number) => {
|
||||
const temp = cloneDeep(t)
|
||||
temp.attr.zIndex = i
|
||||
return temp
|
||||
@@ -412,7 +412,7 @@ export const useChartEditStore = defineStore({
|
||||
loadingFinish()
|
||||
return
|
||||
}
|
||||
const parseHandle = (e: CreateComponentType) => {
|
||||
const parseHandle = (e: CreateComponentType | CreateComponentGroupType) => {
|
||||
e = cloneDeep(e)
|
||||
// 生成新 id
|
||||
e.id = getUUID()
|
||||
@@ -566,6 +566,22 @@ export const useChartEditStore = defineStore({
|
||||
break;
|
||||
}
|
||||
},
|
||||
// * 创建分组
|
||||
setGroup() {
|
||||
const groupClass = new PublicGroupConfigClass()
|
||||
this.getTargetChart.selectId.forEach((id: string) => {
|
||||
// 获取目标数据并从 list 中移除 (成组后不可再次成组, 断言处理)
|
||||
const item = this.componentList.splice(this.fetchTargetIndex(id), 1)[0] as CreateComponentType
|
||||
groupClass.groupList.push(item)
|
||||
})
|
||||
this.addComponentList(groupClass)
|
||||
// todo 输出
|
||||
console.log(this.getComponentList)
|
||||
},
|
||||
// * 解除分组
|
||||
setUnGroup() {
|
||||
|
||||
},
|
||||
// ----------------
|
||||
// * 设置页面大小
|
||||
setPageSize(scale: number): void {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d'
|
||||
import { EditCanvasType } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||
|
||||
// 操作类型枚举
|
||||
@@ -55,7 +55,7 @@ export interface HistoryItemType {
|
||||
[HistoryStackItemEnum.ID]: string | string[]
|
||||
[HistoryStackItemEnum.TARGET_TYPE]: HistoryTargetTypeEnum
|
||||
[HistoryStackItemEnum.ACTION_TYPE]: HistoryActionTypeEnum
|
||||
[HistoryStackItemEnum.HISTORY_DATA]: CreateComponentType | EditCanvasType
|
||||
[HistoryStackItemEnum.HISTORY_DATA]: CreateComponentType | CreateComponentGroupType | EditCanvasType
|
||||
}
|
||||
|
||||
// 历史 Store 类型
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d'
|
||||
import { EditCanvasType } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||
import { loadingStart, loadingFinish, loadingError } from '@/utils'
|
||||
import { editHistoryMax } from '@/settings/designSetting'
|
||||
@@ -35,7 +35,7 @@ export const useChartHistoryStore = defineStore({
|
||||
* @param targetType 对象类型(默认图表)
|
||||
*/
|
||||
createStackItem(
|
||||
item: CreateComponentType | EditCanvasType,
|
||||
item: CreateComponentType | CreateComponentGroupType | EditCanvasType,
|
||||
actionType: HistoryActionTypeEnum,
|
||||
targetType: HistoryTargetTypeEnum = HistoryTargetTypeEnum.CHART
|
||||
) {
|
||||
@@ -148,7 +148,7 @@ export const useChartHistoryStore = defineStore({
|
||||
}
|
||||
},
|
||||
// * 新增组件记录
|
||||
createAddHistory(item: CreateComponentType) {
|
||||
createAddHistory(item: CreateComponentType | CreateComponentGroupType) {
|
||||
this.createStackItem(
|
||||
item,
|
||||
HistoryActionTypeEnum.ADD,
|
||||
@@ -156,7 +156,7 @@ export const useChartHistoryStore = defineStore({
|
||||
)
|
||||
},
|
||||
// * 更新属性记录(大小、图表属性)
|
||||
createUpdateHistory(item: CreateComponentType) {
|
||||
createUpdateHistory(item: CreateComponentType | CreateComponentGroupType) {
|
||||
this.createStackItem(
|
||||
item,
|
||||
HistoryActionTypeEnum.UPDATE,
|
||||
@@ -164,7 +164,7 @@ export const useChartHistoryStore = defineStore({
|
||||
)
|
||||
},
|
||||
// * 删除组件记录
|
||||
createDeleteHistory(item: CreateComponentType) {
|
||||
createDeleteHistory(item: CreateComponentType | CreateComponentGroupType) {
|
||||
this.createStackItem(
|
||||
item,
|
||||
HistoryActionTypeEnum.DELETE,
|
||||
@@ -172,7 +172,7 @@ export const useChartHistoryStore = defineStore({
|
||||
)
|
||||
},
|
||||
// * 移动组件记录
|
||||
createMoveHistory(item: CreateComponentType) {
|
||||
createMoveHistory(item: CreateComponentType | CreateComponentGroupType) {
|
||||
this.createStackItem(
|
||||
item,
|
||||
HistoryActionTypeEnum.MOVE,
|
||||
@@ -181,7 +181,7 @@ export const useChartHistoryStore = defineStore({
|
||||
},
|
||||
// * 改变层级组件记录
|
||||
createLayerHistory(
|
||||
item: CreateComponentType,
|
||||
item: CreateComponentType | CreateComponentGroupType,
|
||||
type:
|
||||
| HistoryActionTypeEnum.TOP
|
||||
| HistoryActionTypeEnum.DOWN
|
||||
@@ -195,7 +195,7 @@ export const useChartHistoryStore = defineStore({
|
||||
)
|
||||
},
|
||||
// * 剪切组件记录
|
||||
createPasteHistory(item: CreateComponentType) {
|
||||
createPasteHistory(item: CreateComponentType | CreateComponentGroupType) {
|
||||
this.createStackItem(
|
||||
item,
|
||||
HistoryActionTypeEnum.CUT,
|
||||
|
||||
Reference in New Issue
Block a user