mirror of https://gitee.com/cf-fz/WebCAD.git
!792 功能:V型刀,走刀造型
parent
6d3e1d52e5
commit
e66b6d1c14
@ -0,0 +1,12 @@
|
|||||||
|
import { Command } from './../../Editor/CommandMachine';
|
||||||
|
import { app } from './../../ApplicationServices/Application';
|
||||||
|
import { KnifeManage } from '../../UI/Components/RightPanel/Modeling/KnifeManage';
|
||||||
|
|
||||||
|
|
||||||
|
export class ShowKinfeManageModal implements Command
|
||||||
|
{
|
||||||
|
async exec()
|
||||||
|
{
|
||||||
|
app.Editor.ModalManage.RenderModeless(KnifeManage);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,239 @@
|
|||||||
|
import { Button, Card, Checkbox, Classes, Intent, Popover, Position, ContextMenu, Menu, MenuItem } from '@blueprintjs/core';
|
||||||
|
import { IObservableValue } from 'mobx';
|
||||||
|
import { observer } from 'mobx-react';
|
||||||
|
import * as React from 'react';
|
||||||
|
import { TempEditor } from '../../../../Editor/TempEditor';
|
||||||
|
import { app } from '../../../../ApplicationServices/Application';
|
||||||
|
import { Polyline } from '../../../../DatabaseServices/Entity/Polyline';
|
||||||
|
import { PostJson, RequestStatus } from '../../../../Common/Request';
|
||||||
|
import { ToplineUrls } from '../../../../Common/HostUrl';
|
||||||
|
import { inflate, toplineFileIn, getPolylineSVG, deflate } from '../../../../Common/SerializeMaterial';
|
||||||
|
import { CADFiler } from '../../../../DatabaseServices/CADFiler';
|
||||||
|
import { commandMachine } from '../../../../Editor/CommandMachine';
|
||||||
|
import { AppToaster } from '../../Toaster';
|
||||||
|
import { ModalPosition } from '../../Modal/ModalInterface';
|
||||||
|
import { IDirectoryProps } from '../../SourceManage/CommonPanel';
|
||||||
|
import { ZoomToEntity } from '../../../Store/RightPanelStore/BoardEdgesEditor';
|
||||||
|
import { MouseKey } from '../../../../Common/KeyEnum';
|
||||||
|
import { KnifeManage } from './KnifeManage';
|
||||||
|
|
||||||
|
export interface IKnifeListProps
|
||||||
|
{
|
||||||
|
deleteFun?: (topline: { topline_id; }) => void;
|
||||||
|
dataList?: any[];
|
||||||
|
select?: (e: React.FormEvent<HTMLInputElement>, data: any) => void;
|
||||||
|
draw: (id: string) => void;
|
||||||
|
isRename: IObservableValue<boolean>;
|
||||||
|
updata: (name: string, dir: IDirectoryProps, call: Function) => void;
|
||||||
|
getData?: () => void;
|
||||||
|
info: { id: string, name: string; };
|
||||||
|
}
|
||||||
|
|
||||||
|
@observer
|
||||||
|
export class KnifeList extends React.Component<IKnifeListProps, { isContextMenuOpen: boolean; }> {
|
||||||
|
private _cameraFiler: CADFiler;
|
||||||
|
constructor(props)
|
||||||
|
{
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
isContextMenuOpen: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
private handleDbClick = async (tpdata: { topline_id: string; }) =>
|
||||||
|
{
|
||||||
|
this.props.draw(tpdata.topline_id);
|
||||||
|
};
|
||||||
|
private handleMounseDown = (e: React.MouseEvent<HTMLElement>, tpline: any) =>
|
||||||
|
{
|
||||||
|
this.props.info.id = tpline.topline_id;
|
||||||
|
this.props.info.name = tpline.name;
|
||||||
|
if (e.button === MouseKey.Right)
|
||||||
|
{
|
||||||
|
this.showContextMenu(e, tpline);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private exitEditor = () =>
|
||||||
|
{
|
||||||
|
if (!this._cameraFiler) return;
|
||||||
|
app.Viewer.CameraCtrl.ReadFile(this._cameraFiler);
|
||||||
|
TempEditor.End();
|
||||||
|
this._cameraFiler = undefined;
|
||||||
|
app.Editor.SelectCtrl.Cancel();
|
||||||
|
app.Editor.ModalManage.RenderModal(KnifeManage, {}, { position: ModalPosition.Old });
|
||||||
|
};
|
||||||
|
private renderToasterMessage = () =>
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
<div className="flex-between toaster-message">
|
||||||
|
<span>正在编辑刀路</span>
|
||||||
|
<div>
|
||||||
|
<Button text="保存" minimal onClick={this.handleUpdateTopline} />
|
||||||
|
<Button text="取消" minimal onClick={() =>
|
||||||
|
{
|
||||||
|
AppToaster.clear();
|
||||||
|
}} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
private startEditorTopline = async (tpline) =>
|
||||||
|
{
|
||||||
|
TempEditor.Start();
|
||||||
|
app.Editor.ModalManage.Destory();
|
||||||
|
|
||||||
|
let data = await PostJson(ToplineUrls.detail, { topline_id: tpline.topline_id });
|
||||||
|
|
||||||
|
if (data.err_code === RequestStatus.Ok)
|
||||||
|
{
|
||||||
|
let file = inflate(data.toplines.file);
|
||||||
|
let pl = toplineFileIn(file);
|
||||||
|
app.Database.ModelSpace.Append(pl);
|
||||||
|
app.Database.hm.lockIndex++;//禁止初始化动作被撤销
|
||||||
|
this._cameraFiler = new CADFiler;
|
||||||
|
app.Viewer.CameraCtrl.WriteFile(this._cameraFiler);
|
||||||
|
ZoomToEntity(pl);
|
||||||
|
commandMachine.ExecCommand('fs');
|
||||||
|
AppToaster.show({
|
||||||
|
message: this.renderToasterMessage(),
|
||||||
|
intent: Intent.PRIMARY,
|
||||||
|
timeout: 0,
|
||||||
|
onDismiss: this.exitEditor
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private handleUpdateTopline = async () =>
|
||||||
|
{
|
||||||
|
await app.Editor.ModalManage.EndExecingCmd();
|
||||||
|
|
||||||
|
let pl = app.Viewer.VisibleEntitys.find(en => en instanceof Polyline) as Polyline;
|
||||||
|
if (pl)
|
||||||
|
{
|
||||||
|
let topline_id = this.props.info.id;
|
||||||
|
let vf = new CADFiler();
|
||||||
|
pl.WriteFile(vf);
|
||||||
|
|
||||||
|
let fileJson = JSON.stringify(vf.Data);
|
||||||
|
let logo = getPolylineSVG(pl);
|
||||||
|
let data = await PostJson(ToplineUrls.update, {
|
||||||
|
topline_id,
|
||||||
|
logo,
|
||||||
|
file: deflate(fileJson),
|
||||||
|
zip_type: "gzip",
|
||||||
|
});
|
||||||
|
AppToaster.clear();
|
||||||
|
if (data.err_code === RequestStatus.Ok)
|
||||||
|
{
|
||||||
|
this.props.getData();
|
||||||
|
AppToaster.show({
|
||||||
|
message: "刀路保存成功",
|
||||||
|
timeout: 1000,
|
||||||
|
intent: Intent.SUCCESS,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AppToaster.clear();
|
||||||
|
AppToaster.show({
|
||||||
|
message: "顶线轮廓错误,保存失败",
|
||||||
|
timeout: 1000,
|
||||||
|
intent: Intent.DANGER,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
//展示右键菜单
|
||||||
|
private showContextMenu = (e: React.MouseEvent<HTMLElement>, tpline) =>
|
||||||
|
{
|
||||||
|
ContextMenu.show(
|
||||||
|
<Menu>
|
||||||
|
<MenuItem
|
||||||
|
icon="folder-new"
|
||||||
|
text="重命名"
|
||||||
|
onClick={() => this.props.isRename.set(true)}
|
||||||
|
/>
|
||||||
|
<MenuItem
|
||||||
|
icon="folder-new"
|
||||||
|
text="编辑"
|
||||||
|
onClick={() => this.startEditorTopline(tpline)}
|
||||||
|
/>
|
||||||
|
</Menu>,
|
||||||
|
{ left: e.clientX, top: e.clientY },
|
||||||
|
() => this.setState({ isContextMenuOpen: false }),
|
||||||
|
);
|
||||||
|
this.setState({ isContextMenuOpen: true });
|
||||||
|
|
||||||
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
|
};
|
||||||
|
public render()
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
<ul
|
||||||
|
className="mat-list"
|
||||||
|
>
|
||||||
|
{
|
||||||
|
this.props.dataList.map(tpline =>
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
<li
|
||||||
|
key={tpline.topline_id}
|
||||||
|
data-id={tpline.topline_id}
|
||||||
|
onMouseDown={(e) => this.handleMounseDown(e, tpline)}
|
||||||
|
style={{
|
||||||
|
background: this.props.info.id === tpline.topline_id && "rgba(162, 186, 197, 0.34)",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
draggable
|
||||||
|
onDoubleClick={() => this.handleDbClick(tpline)}
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
width="100px"
|
||||||
|
height="100px"
|
||||||
|
version="1.1"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
|
<path d={tpline.logo} fill="transparent" stroke="black" stroke-width="1" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<p title={tpline.name}>{tpline.name}</p>
|
||||||
|
<Popover
|
||||||
|
position={Position.RIGHT}
|
||||||
|
onOpening={node => node.parentElement.parentElement.style.zIndex = "33"}
|
||||||
|
content={
|
||||||
|
<Card>
|
||||||
|
<p>确认删除文件</p>
|
||||||
|
<div>
|
||||||
|
<Button style={{ marginRight: 10 }}
|
||||||
|
className={Classes.POPOVER_DISMISS}
|
||||||
|
text="取消" />
|
||||||
|
<Button
|
||||||
|
className={Classes.POPOVER_DISMISS}
|
||||||
|
intent={Intent.PRIMARY}
|
||||||
|
onClick={() => this.props.deleteFun(tpline)}
|
||||||
|
text="确定" />
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
}
|
||||||
|
target={<Button
|
||||||
|
icon="cross"
|
||||||
|
minimal
|
||||||
|
/>}
|
||||||
|
/>
|
||||||
|
<Checkbox
|
||||||
|
className={tpline.isChecked && "selected"}
|
||||||
|
inline={true}
|
||||||
|
checked={tpline.isChecked}
|
||||||
|
onChange={e =>
|
||||||
|
{
|
||||||
|
this.props.select(e, tpline);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,266 @@
|
|||||||
|
import React, { Component } from 'react';
|
||||||
|
import { CommonModal } from '../../Modal/ModalContainer';
|
||||||
|
import { app } from '../../../../ApplicationServices/Application';
|
||||||
|
import { CommonPanel } from '../../SourceManage/CommonPanel';
|
||||||
|
import { DirectoryId, PostJson, RequestStatus } from '../../../../Common/Request';
|
||||||
|
import { ToplineUrls } from '../../../../Common/HostUrl';
|
||||||
|
import { KnifeList } from './KnifeList';
|
||||||
|
import { Button } from '@blueprintjs/core';
|
||||||
|
import { Intent } from '@blueprintjs/core';
|
||||||
|
import { observable } from 'mobx';
|
||||||
|
import { HandleDirComponent } from '../../SourceManage/HandleDirComponent';
|
||||||
|
import { AppToaster } from '../../Toaster';
|
||||||
|
import { IDirectoryProps } from '../../SourceManage/CommonPanel';
|
||||||
|
import { PromptStatus } from '../../../../Editor/PromptResult';
|
||||||
|
import { Polyline } from '../../../../DatabaseServices/Entity/Polyline';
|
||||||
|
import { inflate, toplineFileIn, deflate, getPolylineSVG } from '../../../../Common/SerializeMaterial';
|
||||||
|
import { commandMachine, CommandWrap } from '../../../../Editor/CommandMachine';
|
||||||
|
import { buildTopline } from '../../../../Add-on/DrawTopline';
|
||||||
|
import { CADFiler } from '../../../../DatabaseServices/CADFiler';
|
||||||
|
import { observer } from 'mobx-react';
|
||||||
|
import { hot } from 'react-hot-loader/root';
|
||||||
|
import { GetCloseContour } from '../../../../Add-on/Sweep';
|
||||||
|
import { MoveMatrix } from '../../../../Geometry/GeUtils';
|
||||||
|
import { Matrix4 } from 'three';
|
||||||
|
|
||||||
|
interface IKnifeManageProps
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
interface IKnifeManageState
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@hot
|
||||||
|
@observer
|
||||||
|
export class KnifeManage extends Component<IKnifeManageProps, IKnifeManageState> {
|
||||||
|
private canAddPath = observable.box(false);
|
||||||
|
@observable private currentInfo = { id: "", name: "" };
|
||||||
|
renderNav = () =>
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
icon="cloud-upload"
|
||||||
|
style={{
|
||||||
|
marginRight: 10
|
||||||
|
}}
|
||||||
|
text="添加刀具"
|
||||||
|
intent={Intent.SUCCESS}
|
||||||
|
onClick={this.startAddKinfePath}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
renderMenuItems = () =>
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
render()
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
<CommonModal
|
||||||
|
title="刀具管理"
|
||||||
|
className="topline"
|
||||||
|
icon="bold"
|
||||||
|
close={this.close}
|
||||||
|
hasConfig={false}
|
||||||
|
footerStyle={{ width: "100%" }}
|
||||||
|
footerChildren={
|
||||||
|
<>
|
||||||
|
<Button
|
||||||
|
disabled={!this.currentInfo.id}
|
||||||
|
text="预览"
|
||||||
|
intent={Intent.SUCCESS}
|
||||||
|
onClick={this.show}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
text="确定"
|
||||||
|
onClick={this.close}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<CommonPanel
|
||||||
|
maxDirLength={0}
|
||||||
|
defaultDirId={DirectoryId.KnifePathDir}
|
||||||
|
renderNav={this.renderNav}
|
||||||
|
renderMenuItems={this.renderMenuItems}
|
||||||
|
getUrl={ToplineUrls.get}
|
||||||
|
deleteUrl={ToplineUrls.delete}
|
||||||
|
clickTree={() => this.currentInfo.id = ""}
|
||||||
|
>
|
||||||
|
<KnifeList
|
||||||
|
draw={this.drawTopline}
|
||||||
|
isRename={this.canAddPath}
|
||||||
|
updata={this.handleCreateTopline}
|
||||||
|
info={this.currentInfo}
|
||||||
|
/>
|
||||||
|
{
|
||||||
|
this.canAddPath.get() && <HandleDirComponent
|
||||||
|
defualtValue={this.currentInfo.name}
|
||||||
|
isReset={false}
|
||||||
|
isOpen={this.canAddPath}
|
||||||
|
handleFunc={this.handleKnifePath}
|
||||||
|
title="输入刀路名称"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
</CommonPanel>
|
||||||
|
</CommonModal>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
handleKnifePath = async (name: string, currentDir, callback: Function) =>
|
||||||
|
{
|
||||||
|
if (!name.trim())
|
||||||
|
{
|
||||||
|
AppToaster.show({
|
||||||
|
message: "名称不能为空",
|
||||||
|
intent: Intent.DANGER,
|
||||||
|
timeout: 1000
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.currentInfo.id)
|
||||||
|
{
|
||||||
|
await this.handleRenameKP(name);
|
||||||
|
await callback();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!currentDir)
|
||||||
|
{
|
||||||
|
AppToaster.show({
|
||||||
|
message: "未知错误,请重试",
|
||||||
|
timeout: 1000
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
app.Editor.ModalManage.ToggleShow();
|
||||||
|
app.Editor.MaskManage.Clear();
|
||||||
|
await this.handleCreateTopline(name, currentDir, callback);
|
||||||
|
app.Editor.ModalManage.ToggleShow();
|
||||||
|
this.canAddPath.set(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private handleCreateTopline = async (name: string, currentDir: IDirectoryProps, callback: Function) =>
|
||||||
|
{
|
||||||
|
let plRes = await app.Editor.GetSelection({
|
||||||
|
Once: true,
|
||||||
|
AllowNone: false,
|
||||||
|
Msg: "选择闭合轮廓",
|
||||||
|
Filter: {
|
||||||
|
filterTypes: [Polyline],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (plRes.Status !== PromptStatus.OK)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
let pl = GetCloseContour(plRes.SelectSet.SelectEntityList[0] as Polyline);
|
||||||
|
if (!pl)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!pl) return;
|
||||||
|
let ptRes = await app.Editor.GetPoint({
|
||||||
|
Msg: "指定基点"
|
||||||
|
});
|
||||||
|
|
||||||
|
//基点移动到基点
|
||||||
|
pl.ApplyMatrix(MoveMatrix(ptRes.Point.negate()))
|
||||||
|
.ApplyMatrix(new Matrix4().extractRotation(pl.OCSInv));
|
||||||
|
|
||||||
|
let vf = new CADFiler();
|
||||||
|
pl.WriteFile(vf);
|
||||||
|
pl.Erase();
|
||||||
|
|
||||||
|
let fileJson = JSON.stringify(vf.Data);
|
||||||
|
|
||||||
|
let logo = getPolylineSVG(pl);
|
||||||
|
|
||||||
|
let data: { err_code: RequestStatus; };
|
||||||
|
|
||||||
|
if (this.currentInfo.id)
|
||||||
|
{
|
||||||
|
data = await PostJson(ToplineUrls.update, {
|
||||||
|
topline_id: this.currentInfo.id,
|
||||||
|
logo,
|
||||||
|
file: deflate(fileJson),
|
||||||
|
zip_type: "gzip",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data = await PostJson(ToplineUrls.create, {
|
||||||
|
dir_id: currentDir.id,
|
||||||
|
name,
|
||||||
|
logo,
|
||||||
|
file: deflate(fileJson),
|
||||||
|
zip_type: "gzip",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.err_code === RequestStatus.Ok)
|
||||||
|
{
|
||||||
|
await callback();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
handleRenameKP = async (name: string) =>
|
||||||
|
{
|
||||||
|
let data = await PostJson(ToplineUrls.update, {
|
||||||
|
topline_id: this.currentInfo.id,
|
||||||
|
name
|
||||||
|
});
|
||||||
|
if (data.code === RequestStatus.Ok)
|
||||||
|
{
|
||||||
|
AppToaster.show({
|
||||||
|
message: "重命名成功",
|
||||||
|
timeout: 1000
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.canAddPath.set(false);
|
||||||
|
};
|
||||||
|
private drawTopline = async (topline_id: string) =>
|
||||||
|
{
|
||||||
|
app.Editor.ModalManage.Destory();
|
||||||
|
|
||||||
|
let data = await PostJson(ToplineUrls.detail, { topline_id });
|
||||||
|
|
||||||
|
if (data.err_code === RequestStatus.Ok)
|
||||||
|
{
|
||||||
|
let file = inflate(data.toplines.file);
|
||||||
|
let polyline = toplineFileIn(file);
|
||||||
|
if (!commandMachine.CommandStart("_drawtopline"))
|
||||||
|
return;
|
||||||
|
await buildTopline(polyline, data.toplines.name);
|
||||||
|
commandMachine.CommandEnd();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private startAddKinfePath = () =>
|
||||||
|
{
|
||||||
|
this.currentInfo.id = "";
|
||||||
|
this.currentInfo.name = "";
|
||||||
|
this.canAddPath.set(true);
|
||||||
|
};
|
||||||
|
private show = async () =>
|
||||||
|
{
|
||||||
|
app.Editor.ModalManage.Destory();
|
||||||
|
|
||||||
|
let data = await PostJson(ToplineUrls.detail, { topline_id: this.currentInfo.id });
|
||||||
|
|
||||||
|
if (data.err_code === RequestStatus.Ok)
|
||||||
|
{
|
||||||
|
let file = inflate(data.toplines.file);
|
||||||
|
let polyline = toplineFileIn(file);
|
||||||
|
CommandWrap(() =>
|
||||||
|
{
|
||||||
|
app.Database.ModelSpace.Append(polyline);
|
||||||
|
}, "_showPath");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private close()
|
||||||
|
{
|
||||||
|
app.Editor.ModalManage.Destory();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,85 @@
|
|||||||
|
import { Classes, HTMLSelect, Label, IOptionProps } from '@blueprintjs/core';
|
||||||
|
import { observer } from 'mobx-react';
|
||||||
|
import * as React from 'react';
|
||||||
|
import { ColorMaterial } from '../../../../Common/ColorPalette';
|
||||||
|
import { FaceDirection } from '../../../Store/BoardInterface';
|
||||||
|
import { safeEval } from '../../../../Common/eval';
|
||||||
|
import { PostJson, DirectoryId, RequestStatus } from '../../../../Common/Request';
|
||||||
|
import { ToplineUrls } from '../../../../Common/HostUrl';
|
||||||
|
import { observable } from 'mobx';
|
||||||
|
import { Modeling2Store } from '../../../Store/RightPanelStore/Modeling2Store';
|
||||||
|
|
||||||
|
@observer
|
||||||
|
export class ModelingComponent2 extends React.Component<{ store?: Modeling2Store; }>
|
||||||
|
{
|
||||||
|
@observable private knifeData: IOptionProps[] = [];
|
||||||
|
UNSAFE_componentWillMount()
|
||||||
|
{
|
||||||
|
this.getKnifeList();
|
||||||
|
}
|
||||||
|
render()
|
||||||
|
{
|
||||||
|
const data = this.props.store.modelingItems;
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ul className={"modeling modeling2 " + Classes.LIST_UNSTYLED}>
|
||||||
|
<li>
|
||||||
|
<Label>颜色</Label>
|
||||||
|
<Label>正反面</Label>
|
||||||
|
<Label>刀具</Label>
|
||||||
|
</li>
|
||||||
|
{
|
||||||
|
data.map((item, index) =>
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
<li>
|
||||||
|
<span
|
||||||
|
className={Classes.INPUT}
|
||||||
|
style={{
|
||||||
|
background: ColorMaterial.GetColor(item.color).getStyle()
|
||||||
|
}}
|
||||||
|
>{item.color}</span>
|
||||||
|
<HTMLSelect
|
||||||
|
options={
|
||||||
|
[{
|
||||||
|
label: "正", value: FaceDirection.Front
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "反", value: FaceDirection.Back
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
value={item.dir}
|
||||||
|
onChange={e =>
|
||||||
|
{
|
||||||
|
data[index].dir = safeEval(e.target.value) as FaceDirection;
|
||||||
|
item.dir = safeEval(e.target.value);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<HTMLSelect
|
||||||
|
options={this.knifeData.slice()}
|
||||||
|
value={item.knife.id}
|
||||||
|
onChange={e =>
|
||||||
|
{
|
||||||
|
item.knife.id = e.target.value;
|
||||||
|
item.knife.name = this.knifeData[e.target.selectedIndex].label;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
|
{/* <UserConfig type={BoardModalType.Zx} store={this.props.store.modelingStore} isUpdate={this.props.store.modelingStore.isUpdate} /> */}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
private getKnifeList = async () =>
|
||||||
|
{
|
||||||
|
let data = await PostJson(ToplineUrls.get, { dir_id: DirectoryId.KnifePathDir });
|
||||||
|
console.log('data: ', data);
|
||||||
|
if (data.err_code === RequestStatus.Ok)
|
||||||
|
{
|
||||||
|
observable(this.knifeData).replace(data.toplines.map(t => { return { value: t.topline_id, label: t.name }; }));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
import { observable } from "mobx";
|
||||||
|
import { FaceDirection } from "../BoardInterface";
|
||||||
|
import { IConfigOption } from "../../Components/Board/UserConfig";
|
||||||
|
import { IConfigStore } from "../BoardStore";
|
||||||
|
|
||||||
|
export interface IModeling2Item
|
||||||
|
{
|
||||||
|
readonly color: number;
|
||||||
|
dir: FaceDirection;
|
||||||
|
knife: { id: string; name: string; };
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export class Modeling2Store implements IConfigStore
|
||||||
|
{
|
||||||
|
@observable configName = "默认";
|
||||||
|
@observable configsNames: string[] = [];
|
||||||
|
@observable modelingItems: IModeling2Item[] = [];
|
||||||
|
isUpdate = true;
|
||||||
|
constructor()
|
||||||
|
{
|
||||||
|
this.InitModelingItems();
|
||||||
|
}
|
||||||
|
InitModelingItems()
|
||||||
|
{
|
||||||
|
this.modelingItems.length = 0;
|
||||||
|
for (let i = 0; i < 24; i++)
|
||||||
|
{
|
||||||
|
this.modelingItems.push({
|
||||||
|
color: i + 1,
|
||||||
|
dir: FaceDirection.Front,
|
||||||
|
knife: { id: "", name: "" }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
InitOption()
|
||||||
|
{
|
||||||
|
this.InitModelingItems();
|
||||||
|
}
|
||||||
|
SaveConfig()
|
||||||
|
{
|
||||||
|
//新的配置
|
||||||
|
let newConfig: IConfigOption = {};
|
||||||
|
return newConfig;
|
||||||
|
}
|
||||||
|
UpdateOption(cof: IConfigOption)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue