Merge pull request !382 from ZoeLeeFZ/modifyDefult
pull/381/MERGE
ZoeLeeFZ 5 years ago committed by ChenX
parent 7cf01b0607
commit 2dc2be4fef

@ -243,6 +243,7 @@ export class DrillModal extends React.Component<{ store?: DrillStore }, {}> {
type={CheckObjectType.DR}
key={k}
optKey={k}
uiOption={store.UIOption}
option={store.m_Option}
title={v}
/>
@ -279,6 +280,7 @@ export class DrillModal extends React.Component<{ store?: DrillStore }, {}> {
type={CheckObjectType.DR}
key={k}
optKey={k}
uiOption={store.UIOption}
option={store.m_Option}
title={v}
/>

@ -42,17 +42,29 @@ export class UserConfig extends React.Component<IConfigProps, UserConfigState>{
super(props);
this._userConfigStore = userConfigStore;
}
handleSaveConfig = async (isInit: boolean = false) =>
private handleInitConfig = async () =>
{
if (this.props.type === BoardModalType.Be)
{
await this._userConfigStore.InitBehindBrConfig(this.props.store);
}
else
{
this._userConfigStore.configName = "默认";
await this.handleSaveConfig(true);
}
}
private handleSaveConfig = async (isInit: boolean = false) =>
{
await this._userConfigStore.SaveConfig(this.props.type, this.props.store, isInit);
}
//删除配置
handleDeleteConfig = async () =>
private handleDeleteConfig = async () =>
{
await this._userConfigStore.DeleteConfig(this.props.type, this.props.store);
}
//更新配置
updateBoardOption = async (k: string) =>
private updateBoardOption = async (k: string) =>
{
await this._userConfigStore.UpdateBoardOption(k, this.props.type, this.props.store);
}
@ -66,8 +78,7 @@ export class UserConfig extends React.Component<IConfigProps, UserConfigState>{
//如果没保存过配置,添加一个默认
if (confNames.length === 0)
{
this._userConfigStore.configName = "默认";
await this.handleSaveConfig(true);
await this.handleInitConfig();
}
else if (type !== BoardModalType.Zx && !this._userConfigStore.readConfigs.has(type))
{

@ -39,6 +39,7 @@ export default class Login extends React.Component<{ store?: TopPanelStore }, IL
this.props.store.isLogin = true;
this.props.store.openMain = true;
userConfigStore.readConfigs.clear();
await userConfigStore.InitDrillConfig();
}
this.isLoginIng = false;
}

@ -26,11 +26,7 @@ export class MainContent extends React.Component<{ store?: TopPanelStore }>
async componentDidMount()
{
//TODO:暂时在页面加载完后初始化排钻配置
let config = await userConfigStore.GetConfig(BoardModalType.Dr);
if (config)
userConfig.DrillConfigs = config.ruleMap;
else
await userConfigStore.SaveConfig(BoardModalType.Dr, DrillStore.GetInstance(), true);
await userConfigStore.InitDrillConfig();
}
render()
{

@ -131,12 +131,18 @@ export class SideBoardStore extends BoardStore
@observable m_Option: SideBoardOption = {
type: BoardType.Vertical,
name: "",
height: 1200,
height: 2000,
width: 600,
thickness: 18,
spaceSize: 836
spaceSize: 1200
};
title = "左右侧板";
constructor()
{
super();
this.m_BoardProcessOption[EBoardKeyList.RoomName] = "主卧";
this.m_BoardProcessOption[EBoardKeyList.CabinetName] = "下柜";
}
}
export class TopBottomBoardStore extends BoardStore
@ -240,12 +246,24 @@ export class BehindBoardStore extends BoardStore
grooveAddDepth: "0",
knifeRadius: "3",
}
constructor()
{
super();
this.m_BoardProcessOption[EBoardKeyList.RoomName] = "主卧";
this.m_BoardProcessOption[EBoardKeyList.CabinetName] = "下柜";
this.m_BoardProcessOption[EBoardKeyList.BigHole] = FaceDirection.Back;
this.m_BoardProcessOption.frontDrill = false;
}
SaveConfig()
{
let newConfig = super.SaveConfig();
newConfig.grooveData = toJS(this.grooveOption);
return newConfig;
}
InitData()
{
let data: [string, BoardProcessOption][] = [];
}
UpdateOption(cof: IConfigOption)
{
super.UpdateOption(cof);
@ -267,7 +285,7 @@ export class LayerBoardStore extends BoardStore
boardRelative: BrRelativePos.Div,
thickness: 18,
count: 1,
spaceSize: 0,
spaceSize: 300,
isActive: false
}
@observable layerNailOption: LayerNailOption = {
@ -284,6 +302,13 @@ export class LayerBoardStore extends BoardStore
depth: 13.5
}
uiLayerNailOption: any;
constructor()
{
super();
this.m_BoardProcessOption[EBoardKeyList.RoomName] = "主卧";
this.m_BoardProcessOption[EBoardKeyList.CabinetName] = "下柜";
this.m_BoardProcessOption[EBoardKeyList.BigHole] = FaceDirection.Back;
}
get NailUiOption()
{
if (!this.uiLayerNailOption)

@ -54,7 +54,7 @@ export class DrillStore extends BoardStore
pxlDepth: 13.5,
ljgRad: 3,
ljgLength: 34,
ymjRad: 5,
ymjRad: 2.5,
ymjDepth: 13.5,
ljgPos: "H*0.5",
woodPinPos: "H*0.5",
@ -62,24 +62,22 @@ export class DrillStore extends BoardStore
};
let opt1 = Object.assign({}, originOption);
opt1.count = 1;
opt1.isForceDiv=true;
opt1.startDist = 40;
opt1.endDist = 80;
opt1.endDist = 60;
let opt2 = Object.assign({}, opt1);
opt2.count = 2;
opt2.isForceDiv = true;
opt2.startDist = 80;
opt2.startDist = 60;
opt2.endDist = 200;
let opt3 = Object.assign({}, opt2);
opt3.isForceDiv = false;
opt3.startDist = 200;
opt3.endDist = 500;
opt3.endDist = 600;
let opt4 = Object.assign({}, opt3);
opt4.count = 3;
opt4.startDist = 500;
opt4.startDist = 600;
opt4.endDist = 900;
let opt5 = Object.assign({}, opt4);

@ -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);

Loading…
Cancel
Save