mirror of https://gitee.com/cf-fz/WebCAD.git
parent
83f85fd816
commit
d24ee34780
@ -0,0 +1,86 @@
|
||||
import { IObservableValue } from 'mobx';
|
||||
import { observer } from 'mobx-react';
|
||||
import * as React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { begin } from 'xaop';
|
||||
import { app } from '../../ApplicationServices/Application';
|
||||
import { KeyBoard } from '../../Common/KeyEnum';
|
||||
import { GoodsList, IGoodInfo } from './GoodsList';
|
||||
|
||||
const GOODS_LIST_DIV_ID = "GoodsListDiv";
|
||||
|
||||
interface IGoodsListProps
|
||||
{
|
||||
select: (good: IGoodInfo) => void;
|
||||
open: IObservableValue<boolean>;
|
||||
}
|
||||
|
||||
@observer
|
||||
export class GoodsListDiv extends React.Component<IGoodsListProps> {
|
||||
_Event: Function;
|
||||
_StateContainer: HTMLElement;
|
||||
_CurrentModalKey = "";
|
||||
|
||||
constructor(props)
|
||||
{
|
||||
super(props);
|
||||
this._StateContainer = document.createElement('div');
|
||||
this._StateContainer.id = GOODS_LIST_DIV_ID;
|
||||
this._StateContainer.style.zIndex = "36";
|
||||
document.getElementById('modal').appendChild(this._StateContainer);
|
||||
|
||||
this._StateContainer.style.position = "absolute";
|
||||
|
||||
if (window.screen.width <= 1100)
|
||||
this._StateContainer.style.left = '0px';
|
||||
else
|
||||
this._StateContainer.style.left = `calc(50vw - 550px)`;
|
||||
|
||||
if (window.screen.height <= 620)
|
||||
this._StateContainer.style.top = `0px`;
|
||||
else
|
||||
this._StateContainer.style.top = `calc(50vh - 300px)`;
|
||||
|
||||
|
||||
ReactDOM.render(<GoodsList
|
||||
open={this.props.open}
|
||||
select={this.props.select}
|
||||
/>, this._StateContainer);
|
||||
}
|
||||
|
||||
componentDidMount()
|
||||
{
|
||||
this._CurrentModalKey = app.Editor.ModalManage.CurrentModalKey;
|
||||
app.Editor.ModalManage.CurrentModalKey = GOODS_LIST_DIV_ID;
|
||||
|
||||
this._Event = begin(app.Editor.ModalManage, app.Editor.ModalManage.OnKeyDown, (e: KeyboardEvent) =>
|
||||
{
|
||||
if (e.keyCode === KeyBoard.Escape)
|
||||
{
|
||||
app.Editor.ModalManage.stopKeyDownEvent = true;
|
||||
e.stopPropagation();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
componentWillUnmount()
|
||||
{
|
||||
app.Editor.ModalManage.CurrentModalKey = this._CurrentModalKey;
|
||||
document.getElementById('modal').removeChild(this._StateContainer);
|
||||
this._StateContainer = undefined;
|
||||
this._CurrentModalKey = "";
|
||||
if (this._Event)
|
||||
{
|
||||
this._Event();
|
||||
this._Event = null;
|
||||
}
|
||||
}
|
||||
|
||||
public render()
|
||||
{
|
||||
return (
|
||||
<>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue