|
|
|
@ -64,6 +64,12 @@ export class BoardModal extends React.Component<BoardModalProps, BoardModalState
|
|
|
|
|
handleSaveConfig = async () =>
|
|
|
|
|
{
|
|
|
|
|
let name = this.state.configName;
|
|
|
|
|
if (name === "")
|
|
|
|
|
{
|
|
|
|
|
alert("输入名称");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let dbstore = await IndexedDbStore.CADStore();
|
|
|
|
|
let brStore = this.props.store;
|
|
|
|
|
let type = this.props.type;
|
|
|
|
@ -81,7 +87,7 @@ export class BoardModal extends React.Component<BoardModalProps, BoardModalState
|
|
|
|
|
let brDataMap = await dbstore.Get(StoreName.ConfigData, type) as Map<string, configOption> || new Map();
|
|
|
|
|
|
|
|
|
|
let isContinue = true;
|
|
|
|
|
if (brDataMap.get(name))
|
|
|
|
|
if (brDataMap.has(name))
|
|
|
|
|
{
|
|
|
|
|
isContinue = confirm("该名字存在,是否覆盖值");
|
|
|
|
|
}
|
|
|
|
@ -97,18 +103,24 @@ export class BoardModal extends React.Component<BoardModalProps, BoardModalState
|
|
|
|
|
//删除配置
|
|
|
|
|
handleDeleteConfig = async () =>
|
|
|
|
|
{
|
|
|
|
|
// 删除视图中的对应项
|
|
|
|
|
let configs = this.state.configs;
|
|
|
|
|
let currentName = this.state.configName;
|
|
|
|
|
configs.delete(currentName);
|
|
|
|
|
this.setState({ configs });
|
|
|
|
|
|
|
|
|
|
//删除数据库中的对应项
|
|
|
|
|
let dbstore = await IndexedDbStore.CADStore();
|
|
|
|
|
let type = this.props.type;
|
|
|
|
|
let brDataMap = await dbstore.Get(StoreName.ConfigData, type) as Map<string, configOption>;
|
|
|
|
|
brDataMap.delete(currentName);
|
|
|
|
|
dbstore.Put(StoreName.ConfigData, type, brDataMap);
|
|
|
|
|
|
|
|
|
|
this.setState({ configName: "默认" });
|
|
|
|
|
await this.changeBoardOption("默认");
|
|
|
|
|
//切换到第一项
|
|
|
|
|
let confNames = Array.from(brDataMap.keys());
|
|
|
|
|
let newName = confNames.length > 0 ? confNames[0] : "";
|
|
|
|
|
this.setState({ configName: newName });
|
|
|
|
|
await this.changeBoardOption(newName);
|
|
|
|
|
}
|
|
|
|
|
//更新配置
|
|
|
|
|
changeBoardOption = async (k: string) =>
|
|
|
|
@ -137,7 +149,18 @@ export class BoardModal extends React.Component<BoardModalProps, BoardModalState
|
|
|
|
|
let type = this.props.type;
|
|
|
|
|
let brDataMap = await dbstore.Get(StoreName.ConfigData, type) as Map<string, configOption> || new Map();
|
|
|
|
|
this.setState({ configs: brDataMap });
|
|
|
|
|
console.log(this.state.configs.size);
|
|
|
|
|
|
|
|
|
|
let confNames = Array.from(brDataMap.keys());
|
|
|
|
|
//如果没保存过配置,添加一个默认
|
|
|
|
|
if (confNames.length === 0)
|
|
|
|
|
{
|
|
|
|
|
this.setState({ configName: "默认" });
|
|
|
|
|
await this.handleSaveConfig();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.setState({ configName: confNames[0] });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
render()
|
|
|
|
|
{
|
|
|
|
@ -206,8 +229,7 @@ export class BoardModal extends React.Component<BoardModalProps, BoardModalState
|
|
|
|
|
<Button
|
|
|
|
|
minimal={true}
|
|
|
|
|
rightIcon="caret-down"
|
|
|
|
|
disabled={this.state.configs.size === 0}>
|
|
|
|
|
</Button>} />}
|
|
|
|
|
></Button>} />}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|