This commit is contained in:
zyy 2020-10-23 15:09:33 +08:00
commit e9a5039c43
5 changed files with 104 additions and 47 deletions

View File

@ -69,7 +69,7 @@ export function createRectArea(opt, style={}) {
textAlign: 'center', textAlign: 'center',
...style ...style
}, },
z: 100 z: 50
} }
} }

View File

@ -1,8 +1,8 @@
<template> <template>
<el-dialog v-dialogDrag append-to-body title="Add area content" :visible.sync="dialogShow" width="30%" :close-on-click-modal="false" :before-close="doClose"> <el-dialog v-dialogDrag append-to-body title="Add area note" :visible.sync="dialogShow" width="30%" :close-on-click-modal="false" :before-close="doClose">
<el-form ref="form" label-width="100px" :model="formModel" > <el-form ref="form" label-width="100px" :model="formModel" >
<el-form-item label="Start station" prop="text"> <el-form-item label="Note" prop="text">
<el-input type="textarea" :rows="2" placeholder="Please enter the content." v-model="formModel.text" /> <el-input type="textarea" :rows="3" placeholder="Please enter the note." v-model="formModel.text" />
</el-form-item> </el-form-item>
</el-form> </el-form>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">

View File

@ -310,12 +310,6 @@ export default {
const startKmRange = data.startKmRange; const startKmRange = data.startKmRange;
const endKmRange = data.endKmRange; const endKmRange = data.endKmRange;
if (Math.abs(endTime - startTime) < 10*60) {
this.$refs.schedule.clearGraphic(['mark']);
this.$message.info('The time interval shall not be less than 10 min.')
return;
}
const model = { const model = {
fartherKmRange: startKmRange < endKmRange? data.endKmRange: data.startKmRange, fartherKmRange: startKmRange < endKmRange? data.endKmRange: data.startKmRange,
closerKmRange: startKmRange < endKmRange? data.startKmRange: data.endKmRange, closerKmRange: startKmRange < endKmRange? data.startKmRange: data.endKmRange,

View File

@ -18,6 +18,7 @@ export default {
}, },
selected: null, selected: null,
target: null, target: null,
drag: null,
dragging: false dragging: false
} }
}, },
@ -115,8 +116,11 @@ export default {
} }
}, },
onZrMouseDown(e) { onZrMouseDown(e) {
this.pixelExecCb(e, args => {
this.doSetTarget(args);
this.doSetDrag(args);
});
if (e.target && ['area'].includes(e.target.subType)) { if (e.target && ['area'].includes(e.target.subType)) {
this.pixelExecCb(e, this.doSetTarget);
if (this.model.choice == 'Construction') { if (this.model.choice == 'Construction') {
if (this.model.action == 'Note') { if (this.model.action == 'Note') {
this.pixelExecCb(e, this.doPopDialog); this.pixelExecCb(e, this.doPopDialog);
@ -149,10 +153,9 @@ export default {
this.dragging = false; this.dragging = false;
} }
// if (!e.target) { if (!e.target) {
// this.$emit('clear') this.$emit('clear')
// } }
}, },
onZrMouseOut(e) { onZrMouseOut(e) {
}, },
@ -207,17 +210,19 @@ export default {
} }
}, },
onShapeDragging(e) { onShapeDragging(e) {
if (this.selected && if (this.selected) {
this.model.choice == 'Plan') { if(this.model.choice == 'Plan') {
if (this.model.action == 'Translate') { if (this.model.action == 'Translate') {
this.pixelExecCb(e, this.doSeriesDragging); this.pixelExecCb(e, this.doSeriesDragging);
}
} }
} else if (this.target && } else if (this.target) {
this.model.choice == 'Construction') { if (this.model.choice == 'Construction') {
if (this.model.action == 'Translate') { if (this.model.action == 'Translate') {
this.pixelExecCb(e, this.doAreaDragging); this.pixelExecCb(e, this.doAreaDragging);
} else if (this.model.action == 'Edit') { } else if (this.model.action == 'Edit') {
this.pixelExecCb(e, this.doAreaHornDragging); this.pixelExecCb(e, this.doAreaHornDragging);
}
} }
} }
}, },
@ -293,16 +298,30 @@ export default {
} }
}, },
doSetTarget({e, pointInGrid}) { doSetTarget({e, pointInGrid}) {
if (e.target && ['area'].includes(e.target.subType)) { if (e.target) {
const target = e.target; if (['area'].includes(e.target.subType)) {
const model = target.model const model = e.target.model
Object.assign(model, { Object.assign(model, {
_x: pointInGrid[0], _x: pointInGrid[0],
_y: pointInGrid[1] _y: pointInGrid[1]
}) })
this.target = e.target; this.target = e.target;
this.$emit('tag', target); this.$emit('tag', e.target);
}
}
},
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]
})
this.drag = e.target;
}
} }
}, },
doSetSelected({e, pointInGrid}) { doSetSelected({e, pointInGrid}) {
@ -372,6 +391,7 @@ export default {
const model = this.target.model; const model = this.target.model;
const graph = option.graphic[0].elements.find(el => { return ['area'].includes(el.subType) && el.model.areaNo == model.areaNo; }); const graph = option.graphic[0].elements.find(el => { return ['area'].includes(el.subType) && el.model.areaNo == model.areaNo; });
graph.z = 90;
graph.draggable = true; graph.draggable = true;
graph.ondrag = echarts.util.curry(this.onShapeDragging); graph.ondrag = echarts.util.curry(this.onShapeDragging);
@ -494,40 +514,81 @@ export default {
} }
}, },
doAreaHornDragging({e, pointInGrid}) { doAreaHornDragging({e, pointInGrid}) {
if (e.target && ['drag'].includes(e.target.subType)) { if (this.drag && ['drag'].includes(this.drag.subType)) {
this.dragging = true; this.dragging = true;
const option = this.myChart.getOption(); const option = this.myChart.getOption();
const drag = this.drag;
const target = this.target; const target = this.target;
const model = target.model; const model = target.model;
const elemList = option.graphic[0].elements.filter(el => { return ['drag'].includes(el.subType) }); const elemList = option.graphic[0].elements.filter(el => { return ['drag'].includes(el.subType) });
const index = elemList.findIndex(el => { return e.target.name == el.name; }); const index = elemList.findIndex(el => { return drag.name == el.name; });
const dx = pointInGrid[0] - model._x;
const dy = pointInGrid[1] - model._y;
model._x = pointInGrid[0]; model._x = pointInGrid[0];
model._y = pointInGrid[1]; model._y = pointInGrid[1];
const time = pointInGrid[0];
const kmRange = this.planUtil.getKmRangeByCoordinateY(pointInGrid[1]);
const obj = Object.assign({}, model);
switch(index) { switch(index) {
case 0: case 0:
model.startTime += dx; if (time < model.endTime) {
model.fartherKmRange += dy; model.startTime = time;
}
if (model.closerKmRange < kmRange) {
model.fartherKmRange = kmRange;
}
break; break;
case 1: case 1:
model.endTime += dx; if (model.startTime < time) {
model.fartherKmRange += dy; model.endTime = time;
}
if (model.closerKmRange < kmRange) {
model.fartherKmRange = kmRange;
}
break; break;
case 2: case 2:
model.endTime += dx; if (model.startTime < time) {
model.closerKmRange += dy; model.endTime = time;
}
if (kmRange < model.fartherKmRange) {
model.closerKmRange = kmRange;
}
break; break;
case 3: case 3:
model.startTime += dx; if (time < model.endTime) {
model.closerKmRange += dy; model.startTime = time;
}
if (kmRange < model.fartherKmRange) {
model.closerKmRange = kmRange;
}
break; break;
} }
// switch(index) {
// case 0:
// obj.startTime = time;
// obj.fartherKmRange = kmRange;
// break;
// case 1:
// obj.endTime = time;
// obj.fartherKmRange = kmRange;
// break;
// case 2:
// obj.endTime = time;
// obj.closerKmRange = kmRange;
// break;
// case 3:
// obj.startTime = time;
// obj.closerKmRange = kmRange;
// break;
// }
// model.startTime = obj.startTime < obj.endTime ? obj.startTime: obj.endTime;
// model.endTime = obj.startTime < obj.endTime ? obj.endTime: obj.startTime;
// model.closerKmRange = obj.closerKmRange < obj.fartherKmRange ? obj.closerKmRange: obj.fartherKmRange;
// model.fartherKmRange = obj.closerKmRange < obj.fartherKmRange ? obj.fartherKmRange: obj.closerKmRange;
if (this.planUtil.limitAreaKmRange(this.stations, model)) { if (this.planUtil.limitAreaKmRange(this.stations, model)) {
this.onZrMouseUp(e); this.onZrMouseUp(e);
} }

View File

@ -265,6 +265,7 @@ export default {
if (this.model.choice == 'Construction') { if (this.model.choice == 'Construction') {
const elemList = option.graphic[0].elements.filter(el => { return el.subType == 'area'}); const elemList = option.graphic[0].elements.filter(el => { return el.subType == 'area'});
elemList.forEach(el => { elemList.forEach(el => {
el.z = 50,
el.draggable = true; el.draggable = true;
el.ondrag = echarts.util.curry(this.onShapeDragging); el.ondrag = echarts.util.curry(this.onShapeDragging);
}) })
@ -373,6 +374,7 @@ export default {
const elemList = elements.filter(el => { return labels.includes(el.subType)}); const elemList = elements.filter(el => { return labels.includes(el.subType)});
elemList.forEach(el => { elemList.forEach(el => {
el.z = 50;
el.draggable = false; el.draggable = false;
el.ondrag = null; el.ondrag = null;
}) })