From 1059e4832b4fdcb3cc5f95944881bff9239ae816 Mon Sep 17 00:00:00 2001 From: ZoeLeeFZ Date: Tue, 3 Mar 2020 17:59:09 +0800 Subject: [PATCH] =?UTF-8?q?!778=20=E4=BC=98=E5=8C=96=E6=8F=90=E5=8F=96?= =?UTF-8?q?=E9=80=A0=E5=9E=8B=E4=BA=A4=E4=BA=92,=E4=BC=98=E5=8C=96userConf?= =?UTF-8?q?igStore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/UI/Components/Board/BoardConfigModal.tsx | 4 +- src/UI/Components/Board/UserConfig.tsx | 2 +- .../Components/Modal/ProcessingGroupModal.tsx | 5 +- .../RightPanel/ModelingComponent.tsx | 2 +- src/UI/Store/RightPanelStore/ModelingStore.ts | 2 +- src/UI/Store/UserConfigStore.ts | 59 +++++++++---------- 6 files changed, 35 insertions(+), 39 deletions(-) diff --git a/src/UI/Components/Board/BoardConfigModal.tsx b/src/UI/Components/Board/BoardConfigModal.tsx index 91a063051..376fd619a 100644 --- a/src/UI/Components/Board/BoardConfigModal.tsx +++ b/src/UI/Components/Board/BoardConfigModal.tsx @@ -237,7 +237,6 @@ export class BoardConfigModal extends React.Component{ cu.ColorIndex = color; moveCus.push(cu); } - } let isOk = await selectOutlinePosition(moveCus); @@ -246,9 +245,12 @@ export class BoardConfigModal extends React.Component{ if (isOk) { //显示右侧状态栏 + store.modelingStore.isUpdate = false; + store.modelingStore.configName = ""; store.m_IsShow = true; store.m_TabId = RightTabId.Model; app.Editor.MaskManage.OnFocusEvent(); + store.modelingStore.isUpdate = true; } commandMachine.CommandEnd(); diff --git a/src/UI/Components/Board/UserConfig.tsx b/src/UI/Components/Board/UserConfig.tsx index 2098f500d..cb4b2177d 100644 --- a/src/UI/Components/Board/UserConfig.tsx +++ b/src/UI/Components/Board/UserConfig.tsx @@ -107,7 +107,7 @@ export class UserConfig extends React.Component{ curName = confNames[0]; this.props.store.configName = curName; - if (type !== BoardModalType.TempDes && type !== BoardModalType.Zx && !this._userConfigStore.readConfigs.has(type)) + if (type !== BoardModalType.TempDes && !this._userConfigStore.readConfigs.has(type)) this.updateBoardOption(curName); } if (type === BoardModalType.TempDes) diff --git a/src/UI/Components/Modal/ProcessingGroupModal.tsx b/src/UI/Components/Modal/ProcessingGroupModal.tsx index b52d63d25..cfc90bb18 100644 --- a/src/UI/Components/Modal/ProcessingGroupModal.tsx +++ b/src/UI/Components/Modal/ProcessingGroupModal.tsx @@ -78,7 +78,7 @@ export class ProcessingGroupModalStore extends Singleton implements IConfigStore this.expandedNodesId = []; }; // - configName: string; + configName: string = "default"; configsNames: string[]; UpdateOption: Function; } @@ -126,6 +126,7 @@ export class ProcessingGroupModal extends React.Component<{ store: ProcessingGro for (let f of this.removeFuncs) f(); this.removeFuncs.length = 0; + userConfigStore.SaveConfig(BoardModalType.ProcessGroupCategory, ProcessingGroupModalStore.GetInstance(), false); } //检查加工类别中有无重复实体 CheckSelect = () => @@ -439,7 +440,6 @@ export class ProcessingGroupModal extends React.Component<{ store: ProcessingGro this.props.store.processGroupCategory.push(groupname); this.canCreateGroup.set(false); this.setState({ nodes: this.parseNodes() }); - userConfigStore.SaveConfig(BoardModalType.ProcessGroupCategory, ProcessingGroupModalStore.GetInstance(), true); } else { @@ -474,7 +474,6 @@ export class ProcessingGroupModal extends React.Component<{ store: ProcessingGro } this.props.store.processGroupCategory = this.props.store.processGroupCategory.filter((g) => !this.props.store.selectedLeftNodeSet.has(g)); this.setState({ nodes: this.parseNodes() }); - userConfigStore.SaveConfig(BoardModalType.ProcessGroupCategory, ProcessingGroupModalStore.GetInstance(), true); this.props.store.selectedLeftNodeSet.clear(); } diff --git a/src/UI/Components/RightPanel/ModelingComponent.tsx b/src/UI/Components/RightPanel/ModelingComponent.tsx index aaf451309..6e0b3953c 100644 --- a/src/UI/Components/RightPanel/ModelingComponent.tsx +++ b/src/UI/Components/RightPanel/ModelingComponent.tsx @@ -104,7 +104,7 @@ export class ModelingComponent extends React.Component<{ store?: RightPanelStore }) } - + ); } diff --git a/src/UI/Store/RightPanelStore/ModelingStore.ts b/src/UI/Store/RightPanelStore/ModelingStore.ts index e2cb46d50..fd975e537 100644 --- a/src/UI/Store/RightPanelStore/ModelingStore.ts +++ b/src/UI/Store/RightPanelStore/ModelingStore.ts @@ -18,9 +18,9 @@ export class ModelingStore implements IConfigStore { @observable configName = "默认"; @observable configsNames: string[] = []; - readConfigs: Set = new Set(); //已经读取过的配置 @observable modelingItems: IModelingItem[] = []; @observable UIModelingItems: IUIModeiling[] = []; + isUpdate = true; constructor() { this.InitModelingItems(); diff --git a/src/UI/Store/UserConfigStore.ts b/src/UI/Store/UserConfigStore.ts index eebcf47b5..9fb530b11 100644 --- a/src/UI/Store/UserConfigStore.ts +++ b/src/UI/Store/UserConfigStore.ts @@ -192,22 +192,6 @@ export class UserConfigStore extends Singleton async SaveConfig(type: BoardModalType, store: IConfigStore, isInit: boolean = false, isCheckName = false) { let name = store.configName; - if (type === BoardModalType.ProcessGroupCategory) - { - let newConfig: IConfigOption = store.SaveConfig(); - let dbStore = await IndexedDbStore.CADStore(); - let data = await PostJson(ConfigUrls.Edit, { key: type, value: JSON.stringify(newConfig.processGroupCategory) });// - if (data.err_code === RequestStatus.Ok) - { - await dbStore.Put(StoreName.ConfigData, GetIndexDBID(type), newConfig.processGroupCategory);// - await dbStore.Put(StoreName.ConfigVersion, GetIndexDBID(type), data.version); - appCache.set(type, newConfig.processGroupCategory);// - userConfig.userConfigName[type] = type; - this.UpdateUserConfig(type, newConfig);// - await userConfig.UploadUserConfigNames(); - } - return; - } if (name === "") { AppToaster.show({ @@ -225,22 +209,32 @@ export class UserConfigStore extends Singleton }); return; } - let configs = (await this.GetAllConfigs(type)) || {}; - - let isContinue = true; - if (configs.hasOwnProperty(name) && !isInit && isCheckName) - isContinue = confirm("配置名称已存在,是否覆盖"); - - if (!isContinue) return; //新的配置 let newConfig: IConfigOption = store.SaveConfig(); - // 配置添加到数据库 - configs[name] = newConfig; - observable(store.configsNames).replace(Object.keys(configs)); - if (type === BoardModalType.Dr) - this.ChangeDrillRuleMap(configs); + let configs = {}; + + if (type === BoardModalType.ProcessGroupCategory) + { + configs = newConfig.processGroupCategory; + } + else + { + configs = (await this.GetAllConfigs(type)) || {}; + let isContinue = true; + if (configs.hasOwnProperty(name) && !isInit && isCheckName) + isContinue = confirm("配置名称已存在,是否覆盖"); + + if (!isContinue) return; + + // 配置添加到数据库 + configs[name] = newConfig; + observable(store.configsNames).replace(Object.keys(configs)); + + if (type === BoardModalType.Dr) + this.ChangeDrillRuleMap(configs); + } let dbStore = await IndexedDbStore.CADStore(); @@ -251,10 +245,11 @@ export class UserConfigStore extends Singleton await dbStore.Put(StoreName.ConfigData, GetIndexDBID(type), configs); await dbStore.Put(StoreName.ConfigVersion, GetIndexDBID(type), data.version); appCache.set(type, configs); - AppToaster.show({ - message: isInit ? "初始化配置成功" : "配置保存成功", - timeout: 1000 - }); + if (type !== BoardModalType.ProcessGroupCategory) + AppToaster.show({ + message: isInit ? "初始化配置成功" : "配置保存成功", + timeout: 1000 + }); userConfig.userConfigName[type] = name; this.UpdateUserConfig(type, newConfig); await userConfig.UploadUserConfigNames();