!2866 修复:子账号配置初始化同步配置时错误,新增子账号添加同步主账号配置按钮

pull/2475/MERGE
黄诗津 3 months ago committed by ChenX
parent a323e1550e
commit d688dac512

@ -8,14 +8,18 @@ import { CompareIsEqual } from "../../../Add-on/BoardFindModify";
import { CustomNumContainer, CustomNumberItem } from "../../../Add-on/CustomNumber/CustomNumContainer";
import { CustomNumberStore } from "../../../Add-on/CustomNumber/CustomNumberPanel";
import { templateTagCommand } from "../../../Add-on/Template/TemplateTagCommand";
import { ConfigUrls } from "../../../Common/HostUrl";
import { KeyBoard } from "../../../Common/KeyEnum";
import { PostJson } from "../../../Common/Request";
import { commandReg } from "../../../Common/Utils";
import { CommandServer } from "../../../DatabaseServices/CommandServer";
import { userConfig } from "../../../Editor/UserConfig";
import { ECompareType } from "../../Store/BoardFindInterface";
import { IConfigStore } from "../../Store/BoardStore";
import { configListMapStore } from "../../Store/ConfigListMapStore";
import { userConfigStore } from "../../Store/UserConfigStore";
import { CommandList } from "../CommandPanel/CommandList";
import { AppConfirm } from "../Common/Confirm";
import { AppToaster } from "../Toaster";
import { BoardModalType } from "./BoardModalType";
import { TabContainer } from "./ConfigListTabContainer";
@ -199,6 +203,20 @@ export class ConfigList extends React.Component<IConfigListProps>
/>
}
/>
{
!userConfig.isMaster &&
<div style={{ marginLeft: 2 }}>
<Tooltip
content={"同步主账号配置"}
position={Position.TOP}
>
<Button
icon={"swap-vertical"}
small
onClick={this.SyncMasterConfig}
/>
</Tooltip>
</div>}
</label>
</>
);
@ -253,16 +271,18 @@ export class ConfigList extends React.Component<IConfigListProps>
<div className='config-list'>
<div className="flex-between">
<h4 className="bp3-heading">{`${this.isShowCoustomNumList.get() ? "列表排序" : "配置列表"}`}</h4>
<input
tabIndex={1}
className="bp3-input"
style={{ width: 80, height: 24 }}
placeholder="搜索..."
onChange={(e) =>
{
this.searchName = e.currentTarget.value.trim();
}}
/>
<div style={{ flex: 1, height: 24, margin: "0 2px" }}>
<input
tabIndex={1}
className="bp3-input"
style={{ width: "100%", height: "100%" }}
placeholder="搜索..."
onChange={(e) =>
{
this.searchName = e.currentTarget.value.trim();
}}
/>
</div>
<Tooltip
content={"自定义排序"}
position={Position.TOP}
@ -275,6 +295,18 @@ export class ConfigList extends React.Component<IConfigListProps>
onClick={() => { this.isShowCoustomNumList.set(true); }}
/>
</Tooltip>
{
!userConfig.isMaster &&
<Tooltip
content={"同步主账号配置"}
position={Position.TOP}
>
<Button
icon={"swap-vertical"}
small
onClick={this.SyncMasterConfig}
/>
</Tooltip>}
</div>
{
this.isShowCoustomNumList.get() ?
@ -342,6 +374,19 @@ export class ConfigList extends React.Component<IConfigListProps>
);
};
SyncMasterConfig = async () =>
{
let isSync = await AppConfirm.show({ message: "是否同步成主账号的配置?", intent: Intent.PRIMARY });
if (isSync)
{
const { type, store } = this.props;
if (store.configsNames.length > 0)
await PostJson(ConfigUrls.Edit, { key: type, sys_init: false, value: {} });
await userConfigStore.SubAccountInitSaveConfig(type, store);
}
};
renderCustomNumList = () =>
{
const { store, type } = this.props;

@ -75,7 +75,8 @@ interface IConfigProps
* usertconfig.ts
*/
@observer
export class UserConfigComponent extends React.Component<IConfigProps, {}>{
export class UserConfigComponent extends React.Component<IConfigProps, {}>
{
static defaultProps = {
isUpdate: true,
isImpExp: false,
@ -286,20 +287,27 @@ export class DialogUserConfig
//如果有配置了 那么不再初始化
if (this._Store.configsNames.length) return;
this._Store.configName = "默认";
this._Store.InitOption();
if (userConfig.isMaster)
{
this._Store.configName = "默认";
this._Store.InitOption();
let configs = this._Store.InitConfigs ? this._Store.InitConfigs() : undefined;
let configs = this._Store.InitConfigs ? this._Store.InitConfigs() : undefined;
if (configs)
{
let confNames = Object.keys(configs);
if (configs)
{
let confNames = Object.keys(configs);
await userConfigStore.InitConfigs(configs, this._UIType);//多个配置上传到云端
await configListMapStore.AddConfig(this._UIType, confNames, this._Store, true);
await userConfigStore.InitConfigs(configs, this._UIType);//多个配置上传到云端
await configListMapStore.AddConfig(this._UIType, confNames, this._Store, true);
}
else
await this.SaveCurConfig(true);//上传到云端
}
else
await this.SaveCurConfig(true);//上传到云端
{
await userConfigStore.SubAccountInitSaveConfig(this._UIType, this._Store);
}
}
/**

@ -115,6 +115,27 @@
display: flex;
align-items: center;
.bp3-input-group {
flex:1;
}
.bp3-input {
width: 100%;
}
}
}
#RightPanel .userconfig
{
.input-select {
width: 150px;
}
}
#SpotLightModel .userconfig
{
.input-select {
width: 180px;
}
}
@ -128,8 +149,17 @@
}
.input-select {
width: 150px;
display: flex;
align-items: center;
.bp3-input-group {
flex:1;
}
.bp3-input {
width: 100%;
}
}
&>:nth-child(n) {

@ -384,6 +384,51 @@ export class UserConfigStore extends Singleton
this.ChangeDrillRuleMap(configs);
return configs;
}
async SubAccountInitSaveConfig(type: BoardModalType, store: IConfigStore,)
{
let dbStore = await IndexedDbStore.CADStore();
dbStore.Delete(StoreName.ConfigData, GetIndexDBID(type));
dbStore.Delete(StoreName.ConfigVersion, GetIndexDBID(type));
appCache.delete(type);
store.configsNames = [];
let configs = (await this.GetAllConfigs(type)) || {};
if (type === BoardModalType.Dr)
this.ChangeDrillRuleMap(configs);
if (JSON.stringify(configs) === "{}")
{
store.InitOption();
configs = store.InitConfigs ? store.InitConfigs() : undefined;
}
let configNames = Object.keys(configs);
await configListMapStore.ResetConfig(type, configNames, store);
const configName = configNames[0];
store.configName = configName;
let data = await PostJson(ConfigUrls.Edit, { key: type, sys_init: true, value: JSON.stringify(configs) });
if (data.err_code === RequestStatus.Ok)
{
let dbStore = await IndexedDbStore.CADStore();
dbStore.Put(StoreName.ConfigData, GetIndexDBID(type), configs);
dbStore.Put(StoreName.ConfigVersion, GetIndexDBID(type), data.version);
appCache.set(type, configs);
AppToaster.show({
message: "初始化配置成功",
timeout: 5000,
intent: Intent.SUCCESS,
});
let firstConfig = configs[configName];
this.UpdateUserConfig(type, firstConfig);
userConfig.userConfigName[type] = configName;
await this.UploadUserConfigNames(dbStore);
}
await this.UpdateBoardOption(configName, type, store);
}
async SaveConfig(type: BoardModalType, store: IConfigStore, option: ISaveOption = {}, tagName?: string)
{
const { isInit = false, isCheckName = false, toaster = true, isUploadUserConfigNames = true } = option;

Loading…
Cancel
Save