调整:代码修改

This commit is contained in:
fan 2019-07-25 15:42:40 +08:00
parent 0d878bcc6a
commit 33b37f9e89
3 changed files with 51 additions and 4 deletions

View File

@ -226,7 +226,7 @@ export default class TrainBody extends Group {
const show = arr.includes('targetCode');
const serverNoShow = arr.includes('serviceNumber');
if (show) {
this.textTrainTarget.setStsetShapeStyleyle('x', parseInt(model.point.x + (3 * model.fontSize * (2 / 3)) - 3 - style.Train.lrPadding));
this.textTrainTarget.setShapeStyle('x', parseInt(model.point.x + (3 * model.fontSize * (2 / 3)) - 3 - style.Train.lrPadding));
}
if (serverNoShow) {
this.textTrainTarget.setShapeStyle('x', parseInt(model.point.x + (2 * model.fontSize * (2 / 3)) - 3 - style.Train.lrPadding));
@ -251,8 +251,8 @@ export default class TrainBody extends Group {
}
});
} else {
this.textTrainServer.setStyle('x', parseInt(model.point.x + 27 - style.Train.lrPadding));
this.textTrainTarget.setStyle('x', parseInt(model.point.x + 43 - style.Train.lrPadding));
this.textTrainServer.setShapeStyle('x', parseInt(model.point.x + 27 - style.Train.lrPadding));
this.textTrainTarget.setShapeStyle('x', parseInt(model.point.x + 43 - style.Train.lrPadding));
this.add(this.textTrainServer);
this.add(this.textTrainTarget);
this.add(this.textTrainNumber);

View File

@ -1,6 +1,8 @@
import Group from 'zrender/src/container/Group';
import TrainHead from './TrainHead/index';
import TrainBody from './TrainBody/index';
import BoundingRect from 'zrender/src/core/BoundingRect';
import Rect from 'zrender/src/graphic/shape/Rect';
/** 列车 */
export default class Train extends Group {
@ -98,6 +100,9 @@ export default class Train extends Group {
this.add(this.trainL);
this.add(this.trainR);
}
if (style.Train.haveTrainBorder) {
this.createTrainBorder();
}
}
// 获取设备提示坐标
@ -294,4 +299,46 @@ export default class Train extends Group {
removeTrainDetail() {
this.trainB.removeTrainDetail();
}
getBoundingRect() {
const list = [this.trainB, this.trainL, this.trainR];
let rect = null;
list.forEach(elem => {
if (elem) {
const tempRect = elem.getBoundingRect();
if (tempRect.x && tempRect.y && tempRect.width && tempRect.height) {
if (rect) {
rect.union(tempRect);
} else {
rect = tempRect;
}
}
}
});
return rect || new BoundingRect(0, 0, 0, 0);
}
createTrainBorder() {
const rect = Object.assign({}, this.getBoundingRect());
rect.x -= this.style.Train.trainWidth / 2;
rect.y -= 5;
rect.width += this.style.Train.trainWidth;
rect.height += 10;
this.trainBorder = new Rect({
zlevel: this.zlevel,
z: this.z,
silent: true,
shape: rect,
style: {
lineDash: [3, 3],
stroke: this.style.borderColor,
fill: this.style.transparentColor
}
});
this.add(this.trainBorder);
this.mouseStatusRecover();
}
}

View File

@ -13,7 +13,7 @@ class TrainWindow extends Group {
this.style = style;
this.z = 1;
this._create(model);
this.setState(state);
this.setStatus(state);
}
_create(model) {
const prdType = '02';// store.state.map.prdType;