优化代码

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