|
|
|
@ -8,12 +8,73 @@ import { BoardModalType } from "../Components/Board/BoardModal";
|
|
|
|
|
import { IConfigOption } from "../Components/Board/UserConfig";
|
|
|
|
|
import { AppToaster } from "../Components/Toaster";
|
|
|
|
|
import { IConfigStore } from "./BoardStore";
|
|
|
|
|
import { BoardProcessOption, BehindBoardOption, BehindHeightPositon, LinesType, BrRelativePos } from "./BoardInterface";
|
|
|
|
|
import { EBoardKeyList } from "../../Common/BoardKeyList";
|
|
|
|
|
import { DrillStore } from "./DrillStore";
|
|
|
|
|
|
|
|
|
|
export class UserConfigStore extends Singleton
|
|
|
|
|
{
|
|
|
|
|
@observable configName = "默认";
|
|
|
|
|
@observable configsNames: string[] = [];
|
|
|
|
|
readConfigs: Set<string> = new Set(); //已经读取过的配置
|
|
|
|
|
async InitBehindBrConfig(store: IConfigStore)
|
|
|
|
|
{
|
|
|
|
|
let config = store.SaveConfig() as { option: BehindBoardOption, processData: BoardProcessOption };
|
|
|
|
|
let configs = {};
|
|
|
|
|
configs["默认"] = config;
|
|
|
|
|
configs["18mm背板"] = Object.assign({}, config);
|
|
|
|
|
|
|
|
|
|
let cloneConfig = Object.assign({}, config);
|
|
|
|
|
cloneConfig.option.spaceSize = 20;
|
|
|
|
|
cloneConfig.option.thickness = 9;
|
|
|
|
|
cloneConfig.option.leftExt = 5;
|
|
|
|
|
cloneConfig.option.rightExt = 5;
|
|
|
|
|
cloneConfig.option.topExt = 5;
|
|
|
|
|
cloneConfig.option.bottomExt = 5;
|
|
|
|
|
configs["薄背板"] = cloneConfig;
|
|
|
|
|
|
|
|
|
|
cloneConfig = Object.assign({}, config);
|
|
|
|
|
cloneConfig.option.name = "上挡板";
|
|
|
|
|
cloneConfig.option.boardPosition = BehindHeightPositon.ForTop;
|
|
|
|
|
cloneConfig.option.boardRelative = BrRelativePos.Front;
|
|
|
|
|
cloneConfig.option.calcHeight = "60";
|
|
|
|
|
cloneConfig.processData[EBoardKeyList.Lines] = LinesType.Reverse;
|
|
|
|
|
configs["前上挡板"] = cloneConfig;
|
|
|
|
|
|
|
|
|
|
cloneConfig = Object.assign({}, cloneConfig);
|
|
|
|
|
cloneConfig.option.name = "下挡板";
|
|
|
|
|
cloneConfig.option.boardPosition = BehindHeightPositon.ForBottom;
|
|
|
|
|
configs["前下挡板"] = cloneConfig;
|
|
|
|
|
|
|
|
|
|
cloneConfig = Object.assign({}, cloneConfig);
|
|
|
|
|
cloneConfig.option.name = "后上挡板";
|
|
|
|
|
cloneConfig.option.boardPosition = BehindHeightPositon.ForTop;
|
|
|
|
|
configs["后上挡板"] = cloneConfig;
|
|
|
|
|
|
|
|
|
|
cloneConfig = Object.assign({}, cloneConfig);
|
|
|
|
|
cloneConfig.option.name = "后下挡板";
|
|
|
|
|
cloneConfig.option.boardPosition = BehindHeightPositon.ForBottom;
|
|
|
|
|
configs["后下挡板"] = cloneConfig;
|
|
|
|
|
let type = BoardModalType.Be;
|
|
|
|
|
observable(this.configsNames).replace(Object.keys(configs));
|
|
|
|
|
let data = await PostJson(ConfigUrls.Edit, { key: type, value: JSON.stringify(configs) });
|
|
|
|
|
if (data.err_code === RequestStatus.Ok)
|
|
|
|
|
{
|
|
|
|
|
AppToaster.show({
|
|
|
|
|
message: "初始化配置成功",
|
|
|
|
|
timeout: 1000
|
|
|
|
|
});
|
|
|
|
|
localStorage.setItem("configName_" + type, "默认");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
async InitDrillConfig()
|
|
|
|
|
{
|
|
|
|
|
let config = await this.GetConfig(BoardModalType.Dr);
|
|
|
|
|
if (config)
|
|
|
|
|
userConfig.DrillConfigs = config.ruleMap;
|
|
|
|
|
else
|
|
|
|
|
await userConfigStore.SaveConfig(BoardModalType.Dr, DrillStore.GetInstance(), true);
|
|
|
|
|
}
|
|
|
|
|
async GetConfig(type: BoardModalType): Promise<IConfigOption | null>
|
|
|
|
|
{
|
|
|
|
|
let configs = await this.GetAllConfigs(type);
|
|
|
|
@ -94,6 +155,7 @@ export class UserConfigStore extends Singleton
|
|
|
|
|
localStorage.setItem("configName_" + type, name);
|
|
|
|
|
if (type === BoardModalType.Dr)
|
|
|
|
|
userConfig.DrillConfigs = newConfig.ruleMap;
|
|
|
|
|
console.log('userConfig.DrillConfigs: ', userConfig.DrillConfigs);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//删除配置
|
|
|
|
@ -101,14 +163,14 @@ export class UserConfigStore extends Singleton
|
|
|
|
|
{
|
|
|
|
|
// 删除视图中的对应项
|
|
|
|
|
let currentName = this.configName;
|
|
|
|
|
if (currentName === "默认")
|
|
|
|
|
{
|
|
|
|
|
AppToaster.show({
|
|
|
|
|
message: "默认配置不允许删除",
|
|
|
|
|
timeout: 1000
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// if (currentName === "默认")
|
|
|
|
|
// {
|
|
|
|
|
// AppToaster.show({
|
|
|
|
|
// message: "默认配置不允许删除",
|
|
|
|
|
// timeout: 1000
|
|
|
|
|
// });
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
observable(this.configsNames).remove(currentName);
|
|
|
|
|
|
|
|
|
|