整理代码

This commit is contained in:
fan 2019-12-27 09:40:52 +08:00
parent dafd6d42cd
commit 573bf83ea8
6 changed files with 29 additions and 85 deletions

View File

@ -23,7 +23,7 @@
</el-tab-pane>
<el-tab-pane label="自动折返" class="tab_pane_box" name="turned">
<turned-operate
ref="trunedOperate"
ref="turnedOperate"
:map-info="mapInfo"
:selected="selected"
@setCenter="setCenter"
@ -100,7 +100,15 @@ export default {
data() {
return {
enabledTab: 'route',
oldDevice: null
oldDevice: null,
enabledTabMenu: {
route: 'routeOperate',
routing: 'routingOperate',
automatic: 'automaticOperate',
signal: 'signalOperate',
path: 'pathOperate',
turned: 'turnedOperate'
}
};
},
mounted() {
@ -110,100 +118,37 @@ export default {
this.$emit('showMap');
},
initLoad() {
switch (this.enabledTab) {
case 'route':
this.$refs.routeOperate.initLoad();
break;
if (this.enabledTab === 'route') {
this.$refs[this.enabledTabMenu[this.enabledTab]].initLoad();
}
},
createRouteEvent() {
switch (this.enabledTab) {
case 'route':
this.$refs.routeOperate.createRouteEvent();
break;
case 'routing':
this.$refs.routingOperate.createRouteEvent();
break;
case 'automatic':
this.$refs.automaticOperate.createRouteEvent();
break;
case 'signal':
this.$refs.signalOperate.createRouteEvent();
break;
case 'path':
this.$refs.pathOperate.createRouteEvent();
break;
case 'turned':
this.$refs.trunedOperate.createRouteEvent();
break;
}
this.$refs[this.enabledTabMenu[this.enabledTab]].createRouteEvent();
},
previewRouteEvent() {
switch (this.enabledTab) {
case 'route':
this.$refs.routeOperate.previewRouteEvent();
break;
case 'routing':
this.$refs.routingOperate.previewRouteEvent();
break;
case 'automatic':
this.$refs.automaticOperate.previewRouteEvent();
break;
case 'signal':
this.$refs.signalOperate.previewRouteEvent();
break;
case 'path':
this.$refs.pathOperate.previewRouteEvent();
break;
case 'turned':
this.$refs.trunedOperate.previewRouteEvent();
break;
}
this.$refs[this.enabledTabMenu[this.enabledTab]].previewRouteEvent();
},
changePane(data) {
this.enabledTab = data.name;
},
setSelected(selected) {
this.handleHightLight(selected);
switch (this.enabledTab) {
case 'route':
this.$refs.routeOperate.setSelected(selected);
break;
case 'routing':
this.$refs.routingOperate.setSelected(selected);
break;
case 'automatic':
this.$refs.automaticOperate.setSelected(selected);
break;
case 'signal':
this.$refs.signalOperate.setSelected(selected);
break;
case 'path':
this.$refs.pathOperate.setSelected(selected);
break;
case 'turned':
this.$refs.trunedOperate.setSelected(selected);
break;
}
this.$refs[this.enabledTabMenu[this.enabledTab]].setSelected(selected);
},
setCenter(code) {
this.$emit('setCenter', code);
},
drawMap() {
this.$refs.routeOperate.routeSectionListFocus(false);
this.$refs.signalOperate.signalNearSectionListFocus(false);
this.$refs.routeOperate.batchSectionListFocus(false);
this.$refs.signalOperate.batchSectionListFocus(false);
this.$emit('selectView', 'draft');
},
tabBeforeLeave(activeName, oldActiveName) {
if (activeName === 'route') {
this.$refs.routeOperate.routeSectionListFocus(true);
} else if (activeName === 'signal') {
this.$refs.signalOperate.signalNearSectionListFocus(true);
if (activeName === 'route' || activeName === 'signal') {
this.$refs[this.enabledTabMenu[activeName]].batchSectionListFocus(true);
}
if (oldActiveName === 'route') {
this.$refs.routeOperate.routeSectionListFocus(false);
} else if (oldActiveName === 'signal') {
this.$refs.signalOperate.signalNearSectionListFocus(false);
if (oldActiveName === 'route' || oldActiveName === 'signal') {
this.$refs[this.enabledTabMenu[oldActiveName]].batchSectionListFocus(false);
}
},
handleHightLight(selected) {

View File

@ -75,7 +75,6 @@ export default {
createRouteEvent: function () {
if (this.$refs && this.$refs.routeEdit) {
this.$refs.routeEdit.clear();
}
},
setSelected(selected) {
@ -84,8 +83,8 @@ export default {
setCenter(code) {
this.$emit('setCenter', code);
},
routeSectionListFocus(flag) {
this.$refs.routeEdit.routeSectionListFocus(flag);
batchSectionListFocus(flag) {
this.$refs.routeEdit.batchSectionListFocus(flag);
}
}
};

View File

@ -398,7 +398,7 @@ export default {
}
});
},
routeSectionListFocus(flag) {
batchSectionListFocus(flag) {
this.changeSectionSelected(this.addOverlapModel.routeOverlapSectionList, flag, 'continueProtectSection');
}
}

View File

@ -504,11 +504,11 @@ export default {
this.protectData = resp.data.list[0];
});
},
routeSectionListFocus(flag) {
batchSectionListFocus(flag) {
this.changeSectionSelected(this.addModel.routeSectionList, flag, 'routePhysicalSection');
this.changeSignalSelected(this.addModel.startSignalCode, flag, 'routeSignal');
this.changeSignalSelected(this.addModel.endSignalCode, flag, 'routeSignal');
this.$refs['protect'].routeSectionListFocus(flag);
this.$refs['protect'].batchSectionListFocus(flag);
},
changeSectionSelected(list, flag, type) {
list && list.forEach((item) => {

View File

@ -79,8 +79,8 @@ export default {
setCenter(code) {
this.$emit('setCenter', code);
},
signalNearSectionListFocus(flag) {
this.$refs.routeEdit.signalNearSectionListFocus(flag);
batchSectionListFocus(flag) {
this.$refs.routeEdit.batchSectionListFocus(flag);
}
}
};

View File

@ -222,7 +222,7 @@ export default {
this.isSave = true;
}
},
signalNearSectionListFocus(flag) {
batchSectionListFocus(flag) {
this.changeSectionSelected(this.addModel.routeSectionList, flag, 'signalNearSection');
this.changeSignalSelected(this.addModel.signalCode, flag, 'routeSignal');
},