商品管理,购买并插入

pull/457/MERGE
ChenX 5 years ago
parent faba50f391
commit a83ab45dfd

@ -0,0 +1,97 @@
import { Command, CommandWrap } from "../Editor/CommandMachine";
import * as React from 'react';
import { Classes, Button } from "@blueprintjs/core";
import { TemplateUrls } from "../Common/HostUrl";
import { app } from "../ApplicationServices/Application";
import { ModalPosition } from "../UI/Components/Modal/ModalsManage";
import { PostJson, RequestStatus } from "../Common/Request";
import { inflate, TemplateIn } from "../Common/SerializeMaterial";
import { Board } from "../DatabaseServices/Entity/Board";
import { JigUtils } from "../Editor/JigUtils";
import { Vector3 } from "three";
import { MoveMatrix } from "../Geometry/GeUtils";
import { PromptStatus } from "../Editor/PromptResult";
import { DuplicateRecordCloning } from "../Common/Status";
export class Command_TemplateSearch implements Command
{
async exec()
{
app.Editor.ModalManage.RenderModal(TemplateSearchDialog, ModalPosition.Center, {});
}
}
export class TemplateSearchDialog extends React.Component<{}, {}>{
OnMessage = (e: MessageEvent) =>
{
CommandWrap(async () =>
{
let data = await PostJson(TemplateUrls.detail, { module_id: e.data.module_id });
if (data.err_code === RequestStatus.Ok)
{
app.Editor.ModalManage.Clear();
app.Editor.MaskManage.Clear();
let file = JSON.parse(inflate(data.modules.file));
let template = TemplateIn(file).Root;
let ens = template.Db.ModelSpace.Entitys as Board[];
let nens = ens.map(e => JigUtils.Draw(e));
let pos = new Vector3();
let ptRes = await app.Editor.GetPoint({
Msg: "点取位置",
Callback: (p: Vector3) =>
{
nens.forEach(en => en.ApplyMatrix(MoveMatrix(p.clone().sub(pos))));
pos.copy(p);
}
});
if (ptRes.Status === PromptStatus.OK)
{
nens = app.Database.WblockCloneObejcts(ens, app.Database.ModelSpace, new Map(), DuplicateRecordCloning.Ignore) as Board[];
pos = new Vector3();
nens.forEach(en => en.ApplyMatrix(MoveMatrix(ptRes.Point.clone().sub(pos))));
}
}
}, "购买模块并插入");
}
componentDidMount()
{
window.addEventListener("message", this.OnMessage);
}
componentWillUnmount()
{
window.removeEventListener("message", this.OnMessage);
}
render()
{
return (
<div className={Classes.DIALOG_CONTAINER}>
<div className={Classes.DIALOG + " board-config"}>
<div className={Classes.DIALOG_HEADER} data-id="dragArea">
<h4 className="bp3-heading"></h4>
<Button
aria-label="Close"
minimal
icon="cross"
className={Classes.DIALOG_CLOSE_BUTTON}
/>
</div>
<div className={Classes.DIALOG_BODY}>
<iframe
width="1000"
height="600"
src={TemplateUrls.search}
/>
</div>
</div>
</div>
);
}
}

@ -68,6 +68,7 @@ export const TemplateUrls = {
detail: CURRENT_HOST + "/CAD-moduleDetail",
list: CURRENT_HOST + "/CAD-moduleList",
update: CURRENT_HOST + "/CAD-moduleUpdate",
search: CURRENT_HOST + "/GoodsSearch-WebCad",
}
export const ConfigUrls = {

@ -107,6 +107,7 @@ import { CMD_Conceptual, CMD_Physical, CMD_Wireframe } from '../Add-on/SwitchVis
import { DrawTangentLine } from '../Add-on/Tangent';
import { ShowTemplate } from '../Add-on/Template/ShowTemplate';
import { ShowTopLine } from '../Add-on/Template/ShowTopline';
import { Command_TemplateSearch } from '../Add-on/TemplateSearch';
// import { DrawFloor } from '../Add-on/DrawFloor';
// import { RevTarget, SaveTarget } from '../Add-on/RenderTarget';
import { TestIntersect } from '../Add-on/test/testIntersect';
@ -350,6 +351,8 @@ export function registerCommand()
commandMachine.RegisterCommand("template", new ShowTemplate());
commandMachine.RegisterCommand("TemplateSearch", new Command_TemplateSearch());
RegistCustomCommand();
}

Loading…
Cancel
Save