整理代码

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

View File

@ -75,7 +75,6 @@ export default {
createRouteEvent: function () { createRouteEvent: function () {
if (this.$refs && this.$refs.routeEdit) { if (this.$refs && this.$refs.routeEdit) {
this.$refs.routeEdit.clear(); this.$refs.routeEdit.clear();
} }
}, },
setSelected(selected) { setSelected(selected) {
@ -84,8 +83,8 @@ export default {
setCenter(code) { setCenter(code) {
this.$emit('setCenter', code); this.$emit('setCenter', code);
}, },
routeSectionListFocus(flag) { batchSectionListFocus(flag) {
this.$refs.routeEdit.routeSectionListFocus(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'); this.changeSectionSelected(this.addOverlapModel.routeOverlapSectionList, flag, 'continueProtectSection');
} }
} }

View File

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

View File

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

View File

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