85 lines
2.4 KiB
JavaScript
85 lines
2.4 KiB
JavaScript
|
/*
|
||
|
* 防淹门
|
||
|
*/
|
||
|
import Group from 'zrender/src/container/Group';
|
||
|
import Rect from 'zrender/src/graphic/shape/Rect';
|
||
|
import {isShowThePrdType} from '../../utils/handlePath';
|
||
|
|
||
|
export default class FloodGate extends Group {
|
||
|
constructor(model, style) {
|
||
|
super();
|
||
|
this.z = 20;
|
||
|
this._code = model.code;
|
||
|
this._type = model._type;
|
||
|
this.zlevel = model.zlevel;
|
||
|
this.z = model.z;
|
||
|
this.model = model;
|
||
|
this.style = style;
|
||
|
this.isShowShape = true;
|
||
|
if (isShowThePrdType(model.prdType, style.FloodGate.displayCondition) || model.previewOrMapDraw) {
|
||
|
this.create();
|
||
|
this.createMouseEvent();
|
||
|
this.setState(model);
|
||
|
}
|
||
|
if (model.previewOrMapDraw) {
|
||
|
this.setShowMode();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
create() {
|
||
|
this.floodGate = new Rect({
|
||
|
zlevel: this.zlevel,
|
||
|
z: this.z,
|
||
|
shape: {
|
||
|
x: this.model.position.x,
|
||
|
y: this.model.position.y,
|
||
|
width: this.model.width,
|
||
|
height: this.model.height
|
||
|
},
|
||
|
style: {
|
||
|
lineWidth: this.style.FloodGate.lineWidth,
|
||
|
stroke: this.style.FloodGate.spareStrokeColor,
|
||
|
fill: this.style.FloodGate.spareFillColor
|
||
|
}
|
||
|
});
|
||
|
this.add(this.floodGate);
|
||
|
}
|
||
|
recover() {
|
||
|
this.floodGate.setStyle({ stroke: this.style.FloodGate.spareStrokeColor, fill: this.style.FloodGate.spareFillColor });
|
||
|
}
|
||
|
// 设置状态
|
||
|
setState(model) {
|
||
|
if (!this.isShowShape) return;
|
||
|
this.recover();
|
||
|
}
|
||
|
|
||
|
createMouseEvent() {
|
||
|
}
|
||
|
|
||
|
setShowMode() {
|
||
|
const showMode = this.model.showMode;
|
||
|
const showConditions = this.style.FloodGate.displayCondition;
|
||
|
if (!showConditions || showConditions === '01' || showMode === showConditions) {
|
||
|
this.showMode();
|
||
|
} else {
|
||
|
this.hideMode();
|
||
|
}
|
||
|
}
|
||
|
setShowStation(stationCode) {
|
||
|
if (!stationCode || this.model.stationCode === stationCode) {
|
||
|
this.isShowShape = true;
|
||
|
this.showMode();
|
||
|
} else {
|
||
|
this.isShowShape = false;
|
||
|
this.hideMode();
|
||
|
}
|
||
|
}
|
||
|
showMode() {
|
||
|
this.floodGate && this.floodGate.show();
|
||
|
this.setState(this.model);
|
||
|
}
|
||
|
hideMode() {
|
||
|
this.floodGate && this.floodGate.hide();
|
||
|
}
|
||
|
}
|