From 83f73aab8d5f556bbeeb0af9c4a3b6bbe7394a4f 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, 6 Aug 2022 18:21:50 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=96=B0=E5=A2=9E=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E5=85=9C=E5=BA=95=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/chartEditStore/chartEditStore.ts | 61 +++++++++++-------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/src/store/modules/chartEditStore/chartEditStore.ts b/src/store/modules/chartEditStore/chartEditStore.ts index a74b4d43..a5207285 100644 --- a/src/store/modules/chartEditStore/chartEditStore.ts +++ b/src/store/modules/chartEditStore/chartEditStore.ts @@ -594,35 +594,48 @@ export const useChartEditStore = defineStore({ }, // * 创建分组 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) + try { + loadingStart() + 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) + loadingFinish() + } catch (error) { + window['$message'].error('创建分组失败,请联系管理员!') + loadingFinish() + } }, // * 解除分组 setUnGroup() { - const selectGroupIdArr = this.getTargetChart.selectId - - // 解组 - const unGroup = (targetIndex: number) => { - const targetGroup = this.getComponentList[targetIndex] as CreateComponentGroupType - targetGroup.groupList.forEach(item => { - this.addComponentList(item) - }) - this.setTargetSelectChart(targetGroup.id) - // 删除分组 - this.removeComponentList(false) - } + try { + loadingStart() + const selectGroupIdArr = this.getTargetChart.selectId + // 解组 + const unGroup = (targetIndex: number) => { + const targetGroup = this.getComponentList[targetIndex] as CreateComponentGroupType + targetGroup.groupList.forEach(item => { + this.addComponentList(item) + }) + this.setTargetSelectChart(targetGroup.id) + // 删除分组 + this.removeComponentList(false) + } - const targetIndex = this.fetchTargetGroupIndex(selectGroupIdArr[0]) - // 判断目标是否为分组父级 - if(targetIndex !== -1) { - unGroup(targetIndex) - } else { + const targetIndex = this.fetchTargetGroupIndex(selectGroupIdArr[0]) + // 判断目标是否为分组父级 + if(targetIndex !== -1) { + unGroup(targetIndex) + } else { + window['$message'].error('解除分组失败,请联系管理员!') + } + loadingFinish() + } catch (error) { window['$message'].error('解除分组失败,请联系管理员!') + loadingFinish() } }, // ----------------