!2086 优化:排钻类型需要可以排序、排钻类型名称可重命名 #398

pull/2087/MERGE
林三 1 year ago committed by ChenX
parent e5b45c110a
commit b2ebf215ec

@ -4,7 +4,7 @@ import { Command } from "../../Editor/CommandMachine";
import { PromptStatus } from "../../Editor/PromptResult";
import { AppConfirm } from "../../UI/Components/Common/Confirm";
import { CustomNumberPanel, CustomNumberStore } from "./CustomNumberPanel";
import { CurtomNumberItem } from "./CustomNumContainer";
import { CustomNumberItem } from "./CustomNumContainer";
export class Command_CustomNumber implements Command
{
@ -62,7 +62,7 @@ export class Command_CustomNumber implements Command
store.onDoubleClick = onDoubleClick;
//编辑界面移动修改编号
const onChange = (item: CurtomNumberItem[], dragIndex: number, hoverIndex: number) =>
const onChange = (item: CustomNumberItem[], dragIndex: number, hoverIndex: number) =>
{
for (let i = Math.min(dragIndex, hoverIndex); i <= Math.max(dragIndex, hoverIndex); i++)
{
@ -70,9 +70,11 @@ export class Command_CustomNumber implements Command
}
};
store.onChange = onChange;
store.title = "自定义板件编号排序";
store.label = "板件名";
store.orderName = "编号";
app.Editor.ModalManage.RenderModeless(CustomNumberPanel, { store }, { canMinimize: false });
let state = await app.Editor.ModalManage.Wait();
await app.Editor.ModalManage.Wait();
}
}

@ -10,7 +10,9 @@ export const ItemTypes = {
export interface CardProps
{
id: any;
text: string;
label: string;
orderName: string;
value: string;
index: number;
moveCard: (dragIndex: number, hoverIndex: number) => void;
onDoubleClick: (id: number) => void;
@ -21,7 +23,7 @@ interface DragItem
index: number;
}
export const CurtomNumCard: FC<CardProps> = ({ id, text, index, moveCard, onDoubleClick }) =>
export const CustomNumCard: FC<CardProps> = ({ id, label, orderName, value, index, moveCard, onDoubleClick }) =>
{
const ref = useRef<HTMLDivElement>(null);
const [{ handlerId }, drop] = useDrop<
@ -51,7 +53,7 @@ export const CurtomNumCard: FC<CardProps> = ({ id, text, index, moveCard, onDoub
return;
}
// Determine rectangle on screen
// Determine rectangle on screenn
const hoverBoundingRect = ref.current?.getBoundingClientRect();
// Get vertical middle
@ -113,8 +115,8 @@ export const CurtomNumCard: FC<CardProps> = ({ id, text, index, moveCard, onDoub
className="item"
onDoubleClick={() => onDoubleClick(id)}
>
<div>:{text}</div>
<div>:{index + 1}</div>
<div>{label}:{value}</div>
<div>{orderName}:{index + 1}</div>
</div>
);
};

@ -1,35 +1,36 @@
import update from 'immutability-helper';
import type { FC } from 'react';
import React, { useCallback, useState } from 'react';
import { CurtomNumCard } from './CurtomNumCard';
import { CustomNumberStore } from './CustomNumberPanel';
import { CustomNumCard } from './CustomNumCard';
const style = {
width: 400,
};
export interface CurtomNumberItem
export interface CustomNumberItem
{
id: number;
text: string;
}
export const CurtomNumContainer: FC<{ state: CustomNumberStore; }> = (prop) =>
export const CustomNumContainer: FC<{ state: CustomNumberStore; }> = (prop) =>
{
{
const [cards, setCards] = useState(prop.state.option.items);
const moveCard = useCallback((dragIndex: number, hoverIndex: number) =>
{
setCards((prevCards: CurtomNumberItem[]) =>
setCards((prevCards: CustomNumberItem[]) =>
{
let cards = update(prevCards, {
$splice: [
[dragIndex, 1],
[hoverIndex, 0, prevCards[dragIndex] as CurtomNumberItem],
[hoverIndex, 0, prevCards[dragIndex] as CustomNumberItem],
],
});
prop.state.onChange(cards, dragIndex, hoverIndex);
if (prop.state.onChange)
prop.state.onChange(cards, dragIndex, hoverIndex);
return cards;
});
}, []);
@ -38,11 +39,13 @@ export const CurtomNumContainer: FC<{ state: CustomNumberStore; }> = (prop) =>
(card: { id: number; text: string; }, index: number) =>
{
return (
<CurtomNumCard
<CustomNumCard
id={card.id}
key={card.id}
label={prop.state.label}
orderName={prop.state.orderName}
index={index}
id={card.id}
text={card.text}
value={card.text}
moveCard={moveCard}
onDoubleClick={prop.state.onDoubleClick}
/>

@ -4,8 +4,9 @@ import React from "react";
import { DndProvider } from "react-dnd";
import { HTML5Backend } from 'react-dnd-html5-backend';
import { app } from "../../ApplicationServices/Application";
import { ModalState } from "../../UI/Components/Modal/ModalInterface";
import "./CustomNumberPanelCss.less";
import { CurtomNumberItem, CurtomNumContainer } from "./CustomNumContainer";
import { CustomNumberItem, CustomNumContainer } from "./CustomNumContainer";
@observer
export class CustomNumberPanel extends React.Component<{ store: CustomNumberStore; }>
@ -17,18 +18,22 @@ export class CustomNumberPanel extends React.Component<{ store: CustomNumberStor
<div className={Classes.DIALOG} >
<div className={Classes.DIALOG_HEADER} data-id="dragArea">
<Icon icon="numbered-list" iconSize={18} />
<h4 className={Classes.HEADING}></h4>
<h4 className={Classes.HEADING}>{this.props.store.title}</h4>
<Button
icon="cross"
aria-label="Close"
minimal={true}
onClick={() => { app.Editor.ModalManage.Destory(); }}
onClick={() =>
{
app.Editor.ModalManage.m_PromisRes({ Status: ModalState.Cancel });
app.Editor.ModalManage.Destory();
}}
/>
</div>
<div >
<div className={Classes.DIALOG_BODY}>
<DndProvider backend={HTML5Backend}>
<CurtomNumContainer
<CustomNumContainer
state={this.props.store}
/>
</DndProvider>
@ -39,7 +44,12 @@ export class CustomNumberPanel extends React.Component<{ store: CustomNumberStor
<Button
intent="success"
text="确定"
onClick={() => { app.Editor.ModalManage.Destory(); }}
onClick={async () =>
{
if (this.props.store.onOk)
await this.props.store.onOk();
app.Editor.ModalManage.Destory();
}}
/>
</div>
</div>
@ -54,9 +64,13 @@ export class CustomNumberPanel extends React.Component<{ store: CustomNumberStor
//只是用来保存配置
export class CustomNumberStore
{
title: string;
label: string;
orderName: string;
option: React.PropsWithChildren<{
items: CurtomNumberItem[];
items: CustomNumberItem[];
}> = { items: [] };
onChange: (items: CurtomNumberItem[], dragIndex: number, hoverIndex: number) => void;
onChange: (items: CustomNumberItem[], dragIndex: number, hoverIndex: number) => void;
onDoubleClick: (id: number) => void;
onOk: () => Promise<void>;
}

@ -11,7 +11,6 @@
border : 1px dashed gray;
padding : 0.5rem 1rem;
margin-bottom : 0.5rem;
background-color: white;
justify-content : space-between;
}
}

@ -75,6 +75,18 @@ export function arraySortByNumber<T>(arr: Array<T>): Array<T>
return arr;
}
/**
* mapKey
* reverse:
*/
export function mapSortByCN(map: Map<string, any>, reverse: boolean = false): Map<string, any>
{
return new Map([...map].sort((x1, x2) =>
{
return reverse ? x2[0].localeCompare(x1[0], 'zh-CN') : x1[0].localeCompare(x2[0], 'zh-CN');
}));
}
/**
*
* @param {(e1, e2) => boolean} [checkFuction] , e2

@ -2,48 +2,109 @@ import { Button, Card, Checkbox, Classes, HTMLSelect, Intent, IOptionProps, Popo
import { action, observable } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
import { CustomNumberPanel, CustomNumberStore } from '../../../Add-on/CustomNumber/CustomNumberPanel';
import { CustomNumberItem } from '../../../Add-on/CustomNumber/CustomNumContainer';
import { app } from '../../../ApplicationServices/Application';
import { DrillStore } from '../../Store/DrillStore';
import { arrayRemoveOnce, mapSortByCN } from '../../../Common/ArrayExt';
import { userConfig } from '../../../Editor/UserConfig';
import { DrillingOption } from '../../Store/drillInterface';
import { DrillConfigSortType, DrillStore } from '../../Store/DrillStore';
import { userConfigStore } from '../../Store/UserConfigStore';
import { PopoverButton } from '../Common/PopoverButton';
import { DrillingTemplateManage } from '../Modal/DrillingTemplateManage';
import { AppToaster } from '../Toaster';
import { BoardModalType } from './BoardModalType';
import { DrillModal } from './GangDrillModal';
@observer
export class DrillTypeCom extends React.Component<{ store: DrillStore; }, { typeName: string; }>
export class DrillTypeCom extends React.Component<{ store: DrillStore; }, { typeName: string; modifyTypeName: string; }>
{
constructor(props)
{
super(props);
this.state = {
typeName: ""
typeName: "",
modifyTypeName: ""
};
}
private addDrillType = () =>
{
this.props.store.AddNewDrillType(this.state.typeName);
this.props.store.type = this.state.typeName;
this.props.store.currentConfigTypeName = this.state.typeName;
this.handleUpdate();
};
private modifyDrillTypeName = () =>
{
let key = this.props.store.currentConfigTypeName;
//要处理初始的配置
let config = this.props.store.defaultfDrillConfig;
let sortType = this.props.store.drillConfigSortType;
config.set(this.state.modifyTypeName, config.get(key));
config.delete(key);
//自定义单独删除
arrayRemoveOnce(this.props.store.customConfigSort, key);
this.props.store.customConfigSort.push(this.state.modifyTypeName);//加在最后
if (sortType === DrillConfigSortType.Default)
this.props.store.drillConfig = config;
else if (sortType === DrillConfigSortType.CH)
this.props.store.drillConfig = mapSortByCN(config);
else if (sortType === DrillConfigSortType.CHD) //按拼音首字母倒序
this.props.store.drillConfig = mapSortByCN(config, true);
else if (sortType === DrillConfigSortType.ZDY)
{
//自定义调取配置的customConfigSort列表 单独处理
this.props.store.drillConfig.set(this.state.modifyTypeName, config.get(this.state.modifyTypeName));
this.props.store.drillConfig.delete(key);
}
this.props.store.currentConfigTypeName = this.state.modifyTypeName;
this.handleUpdate();
};
private handleOnChange = (e) =>
{
const store = this.props.store;
store.type = e.currentTarget.value;
store.currentConfigTypeName = e.currentTarget.value;
this.handleUpdate();
};
private handleOnChangeSortType = async (e) =>
{
let drillStore = this.props.store;
drillStore.drillConfigSortType = e.currentTarget.value;
if (e.currentTarget.value === DrillConfigSortType.Default)
drillStore.drillConfig = drillStore.defaultfDrillConfig;
else if (e.currentTarget.value === DrillConfigSortType.CH)
drillStore.drillConfig = mapSortByCN(drillStore.defaultfDrillConfig);
else if (e.currentTarget.value === DrillConfigSortType.CHD)//按拼音首字母倒序
drillStore.drillConfig = mapSortByCN(drillStore.defaultfDrillConfig, true);
else if (e.currentTarget.value === DrillConfigSortType.ZDY)
{
//自定义不采用初始的配置defaultfDrillConfig 要单独设置
drillStore.drillConfig.clear();
for (let key of drillStore.customConfigSort)
drillStore.drillConfig.set(key, drillStore.defaultfDrillConfig.get(key));
}
userConfig.DrillConfigs = drillStore.drillConfig;
};
private handleDelete = () =>
{
const store = this.props.store;
store.drillConfig.delete(store.type);
store.drillConfig.delete(store.currentConfigTypeName);
store.defaultfDrillConfig.delete(store.currentConfigTypeName);
arrayRemoveOnce(store.customConfigSort, store.currentConfigTypeName);
let types = [...store.drillConfig.keys()];
if (types.length > 0)
{
store.type = types[0];
store.currentConfigTypeName = types[0];
this.handleUpdate();
}
};
private handleUpdate = action(() =>
{
const store = this.props.store;
observable(store.rules).replace(store.drillConfig.get(store.type));
observable(store.rules).replace(store.drillConfig.get(store.currentConfigTypeName));
store.ChangeRules(0);
});
private renderRadiosType = () =>
@ -52,7 +113,7 @@ export class DrillTypeCom extends React.Component<{ store: DrillStore; }, { type
return (
<RadioGroup
inline={true}
selectedValue={store.type}
selectedValue={store.currentConfigTypeName}
onChange={this.handleOnChange}
>
{
@ -67,11 +128,69 @@ export class DrillTypeCom extends React.Component<{ store: DrillStore; }, { type
const options = [...store.drillConfig.keys()];
return (
<HTMLSelect
value={store.type}
options={options}
onChange={this.handleOnChange}
/>
<div className='drillOptionSelect'>
<HTMLSelect
value={store.currentConfigTypeName}
options={options}
onChange={this.handleOnChange}
/>
<div style={{ marginTop: -2 }}>
<span>:</span>
<HTMLSelect
className='drillSortType'
value={store.drillConfigSortType}
options={[
{ label: "默认", value: DrillConfigSortType.Default },
{ label: "按拼音首字母", value: DrillConfigSortType.CH },
{ label: "按拼音首字母倒序", value: DrillConfigSortType.CHD },
{ label: "自定义排序", value: DrillConfigSortType.ZDY },
]}
onChange={this.handleOnChangeSortType}
/>
<Button
className='popover'
text="自定义排序"
intent={Intent.NONE}
onClick={async () =>
{
app.Editor.ModalManage.Destory();
let store = new CustomNumberStore();
store.title = "排钻类型排序自定义";
store.label = "排钻类型";
store.orderName = "排序";
let drillList = [...this.props.store.drillConfig.keys()];
for (let i = 0; i < drillList.length; i++)
store.option.items.push({ id: i + 1, text: drillList[i] });
store.onChange = (items: CustomNumberItem[], dragIndex: number, hoverIndex: number) =>
{
store.option.items = items;
};
store.onOk = async () =>
{
//得到自定义排序的list 上传配置
let newDrillConfigMap: Map<string, DrillingOption[]> = new Map();
for (let item of store.option.items)
{
newDrillConfigMap.set(item.text, this.props.store.drillConfig.get(item.text));
}
this.props.store.drillConfig = newDrillConfigMap;
this.props.store.customConfigSort = [...newDrillConfigMap.keys()];
this.props.store.drillConfigSortType = DrillConfigSortType.ZDY;
//自定义后自动保存配置
await userConfigStore.SaveConfig(BoardModalType.Dr, this.props.store);
};
app.Editor.ModalManage.RenderModal(CustomNumberPanel, { store });
await app.Editor.ModalManage.Wait();
app.Editor.ModalManage.RenderModal(DrillModal, { store: this.props.store });
}}
/>
</div>
</div>
);
};
render()
@ -83,9 +202,10 @@ export class DrillTypeCom extends React.Component<{ store: DrillStore; }, { type
{
store.drillConfig.size > 7 ? this.renderSelectType() : this.renderRadiosType()
}
<div>
<div style={{ display: "flex" }}>
<Popover
position={Position.LEFT}
className='popover'
position={Position.TOP}
onClosed={() => this.setState({ typeName: "" })}
usePortal={false}
content={
@ -110,7 +230,54 @@ export class DrillTypeCom extends React.Component<{ store: DrillStore; }, { type
intent={Intent.PRIMARY}
/>}
/>
<Popover
className='popover'
position={Position.TOP}
usePortal={false}
content={
<Card>
<input type="text"
style={{ height: 30 }}
className={Classes.INPUT}
value={this.state.modifyTypeName}
autoFocus={true}
onFocus={(e) => { e.target.select(); }}
onChange={e => this.setState({ modifyTypeName: e.target.value })}
onKeyDown={(e => { e.stopPropagation(); })}
onKeyUp={(e) => { e.currentTarget.value = e.currentTarget.value.replace(/\s+/g, ''); }}
/>
<Button
text="确定"
className={Classes.POPOVER_DISMISS}
style={{ margin: 0 }}
intent={Intent.SUCCESS}
onClick={() =>
{
if (this.props.store.currentConfigTypeName === this.state.modifyTypeName) return;
if (this.props.store.drillConfig.has(this.state.modifyTypeName))
{
AppToaster.show({
message: "存在该类型名称!",
timeout: 5000,
intent: Intent.DANGER,
});
return;
}
this.modifyDrillTypeName();
}}
/>
</Card>
}
target={
<Button
text="修改类型名称"
intent={Intent.SUCCESS}
onClick={() => this.setState({ modifyTypeName: store.currentConfigTypeName })}
/>
}
/>
<PopoverButton
className='popover'
message="确认删除选择类型?"
targetTitle="删除选中类型"
confirmCallback={this.handleDelete}

@ -9,6 +9,7 @@ import { AnyObject, BoardProcessOption, IDrawBoardAutoCutOption, IGrooveOption,
import { IConfigStore } from '../../Store/BoardStore';
import { IDoorInfo, IDrawerInfo } from '../../Store/DoorInterface';
import { DrillingOption } from '../../Store/drillInterface';
import { DrillConfigSortType } from '../../Store/DrillStore';
import { userConfigStore } from '../../Store/UserConfigStore';
import { PopoverCheckBoxes } from '../Common/PopoverCheckBoxes';
import { PopoverInput } from '../Common/PopoverInput';
@ -28,6 +29,8 @@ export interface IConfigOption<T = AnyObject>
doorsInfo?: (IDrawerInfo | IDoorInfo)[];
processGroupCategory?: string[];//加工组(工序组)数据
autoCutOption?: IDrawBoardAutoCutOption;//绘制板件时是否自动切割&&关联切割
drillConfigSortType?: DrillConfigSortType;//排钻类型排序方式
customConfigSort?: string[];//排钻类型自定义排序
other?: any;
CADFilerData?: any[];//序列化数据
}

@ -95,23 +95,39 @@
}
&>div:first-child {
width : 680px;
overflow-x : auto;
white-space: nowrap;
width : 510px;
overflow-x : auto;
white-space : nowrap;
margin-bottom: 10px;
}
&>div.bp3-html-select {
width : 300px;
padding-bottom: 10px;
select {
height: 30px;
.drillOptionSelect{
display : flex;
margin-left : 10px;
justify-content: space-between;
.bp3-html-select {
width: 220px;
select {
height: 30px;
}
.bp3-icon {
top : 7px;
right: 5px;
}
}
.bp3-icon {
top: 7px;
.drillSortType{
width : 130px;
margin-left: 5px;
}
}
.popover{
margin: 2px;
}
}
#commonModal .collsion {

@ -1,6 +1,7 @@
import { Intent } from "@blueprintjs/core";
import { action, observable, toJS } from "mobx";
import { appCache } from "../../Common/AppCache";
import { mapSortByCN } from "../../Common/ArrayExt";
import { CheckObjectType, CheckoutValid } from "../../Common/CheckoutVaildValue";
import { DataAdapter } from "../../Common/DataAdapter";
import { DirUrl, TemplateUrls } from "../../Common/HostUrl";
@ -15,6 +16,13 @@ import { AppToaster } from "../Components/Toaster";
import { BoardStore } from "./BoardStore";
import { DrillingOption, SpacingType } from "./drillInterface";
export enum DrillConfigSortType
{
Default = "1", //默认
CH = "2", //拼音首字母
CHD = "3", //拼音首字母倒序
ZDY = "4", //自定义
}
export interface IExportDrillOption
{
@ -25,11 +33,14 @@ export class DrillStore extends BoardStore
{
@observable m_CurrentRuleIndex = 0;
@observable type = "三合一";
@observable currentConfigTypeName = "三合一";
@observable rules: DrillingOption[] = [];
@observable drillConfigSortType: DrillConfigSortType;//排钻类型排序方式
@observable customConfigSort: string[] = []; //自定义的排序[...Keys]
@observable m_Option: DrillingOption;
@observable drillConfig: Map<string, DrillingOption[]> = new Map();
@observable drillConfig: Map<string, DrillingOption[]> = new Map(); //类似UI_option
defaultfDrillConfig: Map<string, DrillingOption[]> = new Map(); //排钻类型初始排序
deleteHoleTemps = new Set();
constructor()
{
@ -141,13 +152,30 @@ export class DrillStore extends BoardStore
opt.wsHoleLength = 28;
return opt;
}));
this.defaultfDrillConfig = this.drillConfig;
this.drillConfigSortType = DrillConfigSortType.Default;
this.customConfigSort = [...this.defaultfDrillConfig.keys()];
this.currentConfigTypeName = this.customConfigSort[0]; //防止全部删除配置后遗留
}
AddNewDrillType(name: string)
{
this.drillConfig.set(name, this.rules.map(option =>
this.defaultfDrillConfig.set(name, this.rules.map(option =>
{
return { ...option };
}));
//自定义是独立的 要都添加上
this.customConfigSort.push(name);
if (this.drillConfigSortType === DrillConfigSortType.Default)
this.drillConfig = this.defaultfDrillConfig;
else if (this.drillConfigSortType === DrillConfigSortType.CH)
this.drillConfig = mapSortByCN(this.defaultfDrillConfig);
else if (this.drillConfigSortType === DrillConfigSortType.CHD)
this.drillConfig = mapSortByCN(this.defaultfDrillConfig, true);
else if (this.drillConfigSortType === DrillConfigSortType.ZDY)
this.drillConfig.set(name, this.defaultfDrillConfig.get(name));
}
SaveRuleOption()
{
@ -186,9 +214,10 @@ export class DrillStore extends BoardStore
{
Object.assign(this.rules[this.m_CurrentRuleIndex], this.m_Option);
}
this.drillConfig.set(this.currentConfigTypeName, toJS(this.rules));
//写入时修改用户当前配置
this.drillConfig.set(this.type, toJS(this.rules));
userConfig.DrillConfigs = this.drillConfig;
this.defaultfDrillConfig = this.drillConfig;
this.HandleDrillConfig(this.drillConfig);
}
SaveConfig()
@ -197,9 +226,13 @@ export class DrillStore extends BoardStore
let newConfig: IConfigOption = {};
this.SaveRuleOption();
let config = this.drillConfig;
if (config.has(this.type))
config.set(this.type, toJS(this.rules));
if (config.has(this.currentConfigTypeName))
config.set(this.currentConfigTypeName, toJS(this.rules));
newConfig.ruleMap = toJS(config, { exportMapsAsObjects: false });
newConfig.drillConfigSortType = this.drillConfigSortType;
newConfig.customConfigSort = toJS(this.customConfigSort); //自定义的排序保存到数据库 其他排序根据初始的配置来sort()
return newConfig;
}
@action
@ -207,14 +240,29 @@ export class DrillStore extends BoardStore
{
this.drillConfig.clear();
this.HandleDrillConfig(cof.ruleMap);
for (let [k, v] of cof.ruleMap)
this.defaultfDrillConfig = cof.ruleMap;
this.drillConfigSortType = cof.drillConfigSortType ?? DrillConfigSortType.Default;
this.customConfigSort = cof.customConfigSort ?? [...this.defaultfDrillConfig.keys()];
//排钻类型排序
if (this.drillConfigSortType === DrillConfigSortType.Default)
this.drillConfig = this.defaultfDrillConfig;
else if (this.drillConfigSortType === DrillConfigSortType.CH)
this.drillConfig = mapSortByCN(this.defaultfDrillConfig);
else if (this.drillConfigSortType === DrillConfigSortType.CHD) //按拼音首字母倒序
this.drillConfig = mapSortByCN(this.defaultfDrillConfig, true);
else if (this.drillConfigSortType === DrillConfigSortType.ZDY) //自定义的排序
{
this.drillConfig.set(k, v);
this.drillConfig.clear();
for (let key of this.customConfigSort)
this.drillConfig.set(key, this.defaultfDrillConfig.get(key));
}
if (cof.ruleMap.size > 0)
{
this.type = [...cof.ruleMap.keys()][0];
observable(this.rules).replace(cof.ruleMap.get(this.type));
this.currentConfigTypeName = [...cof.ruleMap.keys()][0];
observable(this.rules).replace(cof.ruleMap.get(this.currentConfigTypeName));
this.ChangeRules(0);
}
}

@ -4,6 +4,7 @@ import React from "react";
import { TemplateTagCommand, templateTagCommand } from "../../Add-on/Template/TemplateTagCommand";
import { app } from "../../ApplicationServices/Application";
import { appCache } from "../../Common/AppCache";
import { mapSortByCN } from "../../Common/ArrayExt";
import { ColorMaterial } from "../../Common/ColorPalette";
import { ConfigUrls, RenderUrl } from "../../Common/HostUrl";
import { PostJson, RequestStatus } from "../../Common/Request";
@ -34,7 +35,8 @@ import { IConfigStore } from "./BoardStore";
import { DoorStore } from "./DoorDrawerStore/DoorStore";
import { DrawerStore } from "./DoorDrawerStore/DrawerStore";
import { DownPanelStore } from "./DownPanelStore";
import { DrillStore } from "./DrillStore";
import { DrillingOption } from "./drillInterface";
import { DrillConfigSortType, DrillStore } from "./DrillStore";
import { RightPanelStore } from "./RightPanelStore/RightPanelStore";
import { TopPanelStore } from "./TopPanelStore";
import { updateBoardInfoStore } from "./UpdateBoardInfoStore";
@ -82,7 +84,19 @@ export class UserConfigStore extends Singleton
if (config && config.ruleMap)
{
drillStore.HandleDrillConfig(config.ruleMap);
userConfig.DrillConfigs = config.ruleMap;
//按拼音首字母排序
if (config.drillConfigSortType === DrillConfigSortType.CH)
userConfig.DrillConfigs = mapSortByCN(config.ruleMap);
else if (config.drillConfigSortType === DrillConfigSortType.CHD) //按拼音首字母倒序
userConfig.DrillConfigs = mapSortByCN(config.ruleMap, true);
else if (config.drillConfigSortType === DrillConfigSortType.ZDY) //自定义
{
for (let key of config.customConfigSort)
userConfig.DrillConfigs.set(key, config.ruleMap.get(key));
}
else
userConfig.DrillConfigs = config.ruleMap;
}
else
await this.SaveConfig(BoardModalType.Dr, drillStore, { isInit: true });
@ -456,7 +470,22 @@ export class UserConfigStore extends Singleton
private UpdateUserConfig(type: BoardModalType, newConfig: IConfigOption)
{
if (type === BoardModalType.Dr)
{
userConfig.DrillConfigs = newConfig.ruleMap;
if (newConfig.drillConfigSortType === DrillConfigSortType.CH)
userConfig.DrillConfigs = mapSortByCN(userConfig.DrillConfigs);
else if (newConfig.drillConfigSortType === DrillConfigSortType.CHD) //按拼音首字母倒序
userConfig.DrillConfigs = mapSortByCN(userConfig.DrillConfigs, true);
else if (newConfig.drillConfigSortType === DrillConfigSortType.ZDY)
{
//自定义单独设置
let customMap: Map<string, DrillingOption[]> = new Map();
for (let config of newConfig.customConfigSort)
customMap.set(config, userConfig.DrillConfigs.get(config));
userConfig.DrillConfigs = customMap;
}
}
else if (type === BoardModalType.JG)
userConfig.winerackConfig = newConfig.option as IWineRackOption;
}

Loading…
Cancel
Save