!778 优化提取造型交互,优化userConfigStore

pull/778/MERGE
ZoeLeeFZ 5 years ago committed by ChenX
parent 6aba129e6d
commit 1059e4832b

@ -237,7 +237,6 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
cu.ColorIndex = color; cu.ColorIndex = color;
moveCus.push(cu); moveCus.push(cu);
} }
} }
let isOk = await selectOutlinePosition(moveCus); let isOk = await selectOutlinePosition(moveCus);
@ -246,9 +245,12 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
if (isOk) if (isOk)
{ {
//显示右侧状态栏 //显示右侧状态栏
store.modelingStore.isUpdate = false;
store.modelingStore.configName = "";
store.m_IsShow = true; store.m_IsShow = true;
store.m_TabId = RightTabId.Model; store.m_TabId = RightTabId.Model;
app.Editor.MaskManage.OnFocusEvent(); app.Editor.MaskManage.OnFocusEvent();
store.modelingStore.isUpdate = true;
} }
commandMachine.CommandEnd(); commandMachine.CommandEnd();

@ -107,7 +107,7 @@ export class UserConfig extends React.Component<IConfigProps, UserConfigState>{
curName = confNames[0]; curName = confNames[0];
this.props.store.configName = curName; 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); this.updateBoardOption(curName);
} }
if (type === BoardModalType.TempDes) if (type === BoardModalType.TempDes)

@ -78,7 +78,7 @@ export class ProcessingGroupModalStore extends Singleton implements IConfigStore
this.expandedNodesId = []; this.expandedNodesId = [];
}; };
// //
configName: string; configName: string = "default";
configsNames: string[]; configsNames: string[];
UpdateOption: Function; UpdateOption: Function;
} }
@ -126,6 +126,7 @@ export class ProcessingGroupModal extends React.Component<{ store: ProcessingGro
for (let f of this.removeFuncs) for (let f of this.removeFuncs)
f(); f();
this.removeFuncs.length = 0; this.removeFuncs.length = 0;
userConfigStore.SaveConfig(BoardModalType.ProcessGroupCategory, ProcessingGroupModalStore.GetInstance(), false);
} }
//检查加工类别中有无重复实体 //检查加工类别中有无重复实体
CheckSelect = () => CheckSelect = () =>
@ -439,7 +440,6 @@ export class ProcessingGroupModal extends React.Component<{ store: ProcessingGro
this.props.store.processGroupCategory.push(groupname); this.props.store.processGroupCategory.push(groupname);
this.canCreateGroup.set(false); this.canCreateGroup.set(false);
this.setState({ nodes: this.parseNodes() }); this.setState({ nodes: this.parseNodes() });
userConfigStore.SaveConfig(BoardModalType.ProcessGroupCategory, ProcessingGroupModalStore.GetInstance(), true);
} }
else 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.props.store.processGroupCategory = this.props.store.processGroupCategory.filter((g) => !this.props.store.selectedLeftNodeSet.has(g));
this.setState({ nodes: this.parseNodes() }); this.setState({ nodes: this.parseNodes() });
userConfigStore.SaveConfig(BoardModalType.ProcessGroupCategory, ProcessingGroupModalStore.GetInstance(), true);
this.props.store.selectedLeftNodeSet.clear(); this.props.store.selectedLeftNodeSet.clear();
} }

@ -104,7 +104,7 @@ export class ModelingComponent extends React.Component<{ store?: RightPanelStore
}) })
} }
</ul> </ul>
<UserConfig type={BoardModalType.Zx} store={this.props.store.modelingStore} /> <UserConfig type={BoardModalType.Zx} store={this.props.store.modelingStore} isUpdate={this.props.store.modelingStore.isUpdate} />
</> </>
); );
} }

@ -18,9 +18,9 @@ export class ModelingStore implements IConfigStore
{ {
@observable configName = "默认"; @observable configName = "默认";
@observable configsNames: string[] = []; @observable configsNames: string[] = [];
readConfigs: Set<string> = new Set(); //已经读取过的配置
@observable modelingItems: IModelingItem[] = []; @observable modelingItems: IModelingItem[] = [];
@observable UIModelingItems: IUIModeiling[] = []; @observable UIModelingItems: IUIModeiling[] = [];
isUpdate = true;
constructor() constructor()
{ {
this.InitModelingItems(); this.InitModelingItems();

@ -192,22 +192,6 @@ export class UserConfigStore extends Singleton
async SaveConfig(type: BoardModalType, store: IConfigStore, isInit: boolean = false, isCheckName = false) async SaveConfig(type: BoardModalType, store: IConfigStore, isInit: boolean = false, isCheckName = false)
{ {
let name = store.configName; 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 === "") if (name === "")
{ {
AppToaster.show({ AppToaster.show({
@ -225,22 +209,32 @@ export class UserConfigStore extends Singleton
}); });
return; 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(); let newConfig: IConfigOption = store.SaveConfig();
// 配置添加到数据库
configs[name] = newConfig;
observable(store.configsNames).replace(Object.keys(configs));
if (type === BoardModalType.Dr) let configs = {};
this.ChangeDrillRuleMap(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(); 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.ConfigData, GetIndexDBID(type), configs);
await dbStore.Put(StoreName.ConfigVersion, GetIndexDBID(type), data.version); await dbStore.Put(StoreName.ConfigVersion, GetIndexDBID(type), data.version);
appCache.set(type, configs); appCache.set(type, configs);
AppToaster.show({ if (type !== BoardModalType.ProcessGroupCategory)
message: isInit ? "初始化配置成功" : "配置保存成功", AppToaster.show({
timeout: 1000 message: isInit ? "初始化配置成功" : "配置保存成功",
}); timeout: 1000
});
userConfig.userConfigName[type] = name; userConfig.userConfigName[type] = name;
this.UpdateUserConfig(type, newConfig); this.UpdateUserConfig(type, newConfig);
await userConfig.UploadUserConfigNames(); await userConfig.UploadUserConfigNames();

Loading…
Cancel
Save