优化代码

This commit is contained in:
lVAL 2020-10-26 11:17:45 +08:00
parent 773522b8f0
commit 1bea58747a

View File

@ -149,13 +149,13 @@ export default {
this.pixelExecCb(e, args => {
if(this.model.choice == 'Plan') {
if (this.model.action == 'Translate') {
this.doTranslate(args);
this.doTranslateSeries(args);
}
} else if(this.model.choice == 'Construction') {
if (this.model.action == 'Translate') {
this.doTranslate(args);
this.doTranslateArea(args);
} else if (this.model.action == 'Edit') {
this.doTranslate(args);
this.doTranslateHorn(args);
}
}
});
@ -309,43 +309,38 @@ export default {
}
},
doSetDrag({e, pointInGrid}) {
if (e.target) {
if (['drag'].includes(e.target.subType)) {
const model = e.target.model
Object.assign(model, {
_x: pointInGrid[0],
_y: pointInGrid[1]
})
if (e.target && ['drag'].includes(e.target.subType)) {
this.dragging = false;
this.drag = e.target;
}
this.drag = e.target;
this.drag.model._x = pointInGrid[0];
this.drag.model._y = pointInGrid[1];
}
},
doSetTarget({e, pointInGrid}) {
if (e.target) {
if (['area'].includes(e.target.subType)) {
const model = e.target.model
Object.assign(model, {
_x: pointInGrid[0],
_y: pointInGrid[1]
})
if (e.target && ['area'].includes(e.target.subType)) {
this.dragging = false;
if (this.target &&
this.target.model.areaNo != e.target.model.areaNo) {
this.setTargetReset();
}
this.target = e.target;
this.setTargetLight();
this.$emit('tag', e.target);
if (this.target &&
this.target.model.areaNo != e.target.model.areaNo) {
this.setTargetReset();
}
this.target = e.target;
this.target.model._x = pointInGrid[0];
this.target.model._y = pointInGrid[1];
this.$emit('tag', e.target);
this.setTargetLight();
}
},
doSetSelected({e, pointInGrid}) {
if (e.componentType == "series" &&
e.componentSubType == "line" &&
e.seriesName.includes('service')) {
this.dragging = false;
const value = e.value;
const option = this.myChart.getOption();
const dataList = option.series[e.seriesIndex].data;
@ -508,21 +503,21 @@ export default {
if (model._x == undefined || model._y == undefined) {
model._x = pointInGrid[0];
model._y = pointInGrid[1];
} else {
const dx = pointInGrid[0] - model._x;
const dy = pointInGrid[1] - model._y;
}
model._x = pointInGrid[0];
model._y = pointInGrid[1];
const dx = pointInGrid[0] - model._x;
const dy = pointInGrid[1] - model._y;
model.startTime += dx;
model.endTime += dx;
model.fartherKmRange += dy;
model.closerKmRange += dy;
model._x = pointInGrid[0];
model._y = pointInGrid[1];
if (this.planUtil.limitAreaKmRange(this.stations, model)) {
this.onZrMouseUp(e);
}
model.startTime += dx;
model.endTime += dx;
model.fartherKmRange += dy;
model.closerKmRange += dy;
if (this.planUtil.limitAreaKmRange(this.stations, model)) {
this.onZrMouseUp(e);
}
}
},
@ -597,7 +592,19 @@ export default {
this.myChart.setOption(option, {notMerge: true});
}
},
doTranslate({e}) {
doTranslateSeries({e}) {
if (this.dragging) {
this.dragging = false;
this.$emit('translate');
}
},
doTranslateArea({e}) {
if (this.dragging) {
this.dragging = false;
this.$emit('translate');
}
},
doTranslateHorn({e}) {
if (this.dragging) {
this.dragging = false;
this.$emit('translate');