删除路径单元模块 新增设置站间运行等级

This commit is contained in:
zyy 2020-03-25 13:45:58 +08:00
parent fd63b2cfa0
commit d5c9799189
9 changed files with 521 additions and 578 deletions

View File

@ -378,3 +378,55 @@ export function postRunPlanTemplate(data) {
method: 'post'
});
}
// 根据地图起始-终点车站站台区段生成站间运行等级
export function postGenerateLevel(data) {
return request({
url: `/api/draftMap/runLevel/generate`,
method: 'post',
data
});
}
// 新建站间运行等级
export function postSaveLevel(data) {
return request({
url: `/api/draftMap/runLevel`,
method: 'post',
data
});
}
// 更新站间运行等级数据
export function putUploadLevel(id, data) {
return request({
url: `/api/draftMap/runLevel/${id}`,
method: 'put',
data
});
}
// 删除站间运行等级
export function deleteRunLevel(id) {
return request({
url: `/api/draftMap/runLevel/${id}`,
method: 'delete'
});
}
// 查询站间运行等级列表
export function getRunLevelList(mapId, params) {
return request({
url: `/api/draftMap/runLevel/${mapId}/listAll`,
method: 'get',
params
});
}
// 查询站间运行等级明细
export function getRunLevelDetail(id) {
return request({
url: `/api/draftMap/runLevel/${id}`,
method: 'get'
});
}

View File

@ -29,7 +29,7 @@ import messages from '@/i18n/index';
Vue.use(ELEMENT);
Vue.use(VueI18n);
Vue.config.devtools = true; // 开发环境显示vue控制台
Vue.config.productionTip = false;
export const i18n = new VueI18n({

View File

@ -45,9 +45,9 @@
@setCenter="setCenter"
/>
</el-tab-pane>
<el-tab-pane :label="$t('map.pathUnit')" class="tab_pane_box" name="path">
<path-operate
ref="pathOperate"
<el-tab-pane label="设置运行等级" class="tab_pane_box" name="runLevel">
<run-level-operate
ref="runLevelOperate"
:map-info="mapInfo"
:selected="selected"
@setCenter="setCenter"
@ -71,7 +71,8 @@
import RouteOperate from './routeoperate/index';
import RoutingOperate from './routingoperate/index';
import AutomaticOperate from './automaticoperate/index';
import PathOperate from './pathoperate/index';
// import PathOperate from './pathoperate/index';
import RunLevelOperate from './runLeveloperate/index';
import SignalOperate from './signaloperate/index';
import TurnedOperate from './turnedoperate/index';
@ -81,7 +82,8 @@ export default {
RouteOperate,
RoutingOperate,
AutomaticOperate,
PathOperate,
RunLevelOperate,
// PathOperate,
SignalOperate,
TurnedOperate
},
@ -106,7 +108,7 @@ export default {
routing: 'routingOperate',
automatic: 'automaticOperate',
signal: 'signalOperate',
path: 'pathOperate',
runLevel: 'runLevelOperate',
turned: 'turnedOperate'
}
};
@ -122,10 +124,10 @@ export default {
this.$refs[this.enabledTabMenu[this.enabledTab]].initLoad();
}
},
createRouteEvent() {
createRouteEvent() { //
this.$refs[this.enabledTabMenu[this.enabledTab]].createRouteEvent();
},
previewRouteEvent() {
previewRouteEvent() { //
this.$refs[this.enabledTabMenu[this.enabledTab]].previewRouteEvent();
},
changePane(data) {

View File

@ -1,200 +0,0 @@
<template>
<el-dialog v-dialogDrag :title="$t('map.pathUnitList')" :visible.sync="show" width="85%" :before-do-close="doClose">
<div>
<QueryListPage
ref="queryListPage"
:pager-config="pagerConfig"
:query-form="queryForm"
:query-list="queryList"
/>
</div>
</el-dialog>
</template>
<script>
import { mapGetters } from 'vuex';
import { listMap, listRouteRoute } from '@/api/jmap/mapdraft';
export default {
name: 'PathRoute',
components: {
},
props: {
mapInfo: {
type: Object,
default() {
return null;
}
}
},
data() {
return {
show: false,
mapList: [],
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
queryForm: {
labelWidth: '120px',
queryObject: {
name: {
type: 'select',
label: this.$t('map.pathName'),
config: {
data: []
}
},
stationCode: {
type: 'select',
label: this.$t('map.routeStationName'),
config: {
data: []
}
},
startSignalCode: {
type: 'select',
label: this.$t('map.startingSignalName'),
config: {
data: []
}
},
endSignalCode: {
type: 'select',
label: this.$t('map.endingSignalName'),
config: {
data: []
}
}
}
},
queryList: {
query: this.queryFunction,
afterQuery: this.afterQuery,
selectCheckShow: true,
indexShow: true,
columns: [
{
title: this.$t('map.routeID'),
prop: 'code'
},
{
title: this.$t('map.pathName'),
prop: 'name'
},
{
title: this.$t('map.pathUnitMapName'),
prop: 'mapId'
},
{
title: this.$t('map.routeStationName'),
prop: 'stationCode'
},
{
title: this.$t('map.startingSignalName'),
prop: 'startSignalCode'
},
{
title: this.$t('map.endingSignalName'),
prop: 'endSignalCode'
},
{
type: 'button',
title: this.$t('map.operation'),
width: '200',
buttons: [
{
name: this.$t('map.add'),
handleClick: this.addObj
}
]
}
],
selectAllClick: this.selectAll
}
};
},
computed: {
...mapGetters('map', [
'signalList',
'switchList',
'sectionList',
'stationList',
'stationStandList'
])
},
watch: {
signalList: function (val, old) {
const list = [];
if (val && val.length) {
for (let i = 0; i < val.length; i++) {
list.push({ label: val[i].uniqueName, value: val[i].code });
}
this.queryForm.queryObject.startSignalCode.config.data = list;
this.queryForm.queryObject.endSignalCode.config.data = list;
}
},
stationList: function (val, old) {
const list = [];
if (val && val.length) {
for (let i = 0; i < val.length; i++) {
list.push({ label: val[i].name, value: val[i].code });
}
this.queryForm.queryObject.stationCode.config.data = list;
}
}
},
mounted() {
this.acquireMapList();
},
methods: {
doShow() {
this.show = true;
this.reloadTable();
},
doClose() {
this.show = false;
},
queryFunction(params) {
if (this.mapInfo && this.mapInfo.id) {
return listRouteRoute(this.mapInfo.id, params);
}
},
acquireMapList() {
//
listMap({ drawWay:true}).then(response => {
this.mapList = response.data;
});
},
afterQuery(data) {
if (data && data.list) {
const that = this;
const list = data.list;
if (list) {
list.map(elem => {
that.$convertSpecifiedField(elem, that.mapList, 'id', 'name', ['mapId']);
that.$convertSpecifiedField(elem, that.stationList, 'code', 'name', ['stationCode']);
that.$convertSpecifiedField(elem, that.signalList, 'code', 'name', ['startSignalCode', 'endSignalCode']);
});
}
}
return data;
},
addObj(index, row) {
const data = [];
data.push(row);
this.$emit('routeSelected', data);
this.doClose();
},
selectAll(data) {
this.$emit('routeSelected', data);
this.doClose();
},
reloadTable() {
if (this.queryList && this.queryList.reload) {
this.queryList.reload();
}
}
}
};
</script>

View File

@ -1,293 +0,0 @@
<template>
<div style="height: 100%;">
<el-scrollbar wrap-class="scrollbar-wrapper">
<el-form ref="form" :model="addModel" :rules="rules" label-width="120px" size="mini">
<div class="path-box">
<el-steps :active="display" style="display: none;">
<el-step title="路径单元创建" icon="el-icon-edit" />
<el-step title="路径单元整合" icon="el-icon-setting" />
</el-steps>
<div v-show="display == 1" class="definition">
<el-form-item :label="$t('map.startSectionCodeColon')" prop="startSectionCode">
<el-select v-model="addModel.startSectionCode" clearable :filterable="true">
<el-option
v-for="item in filterSectionList"
:key="item.code"
:label="formatName(item.code)"
:value="item.code"
/>
<!-- </el-input> -->
</el-select>
<el-button
:type=" field === 'startSectionCode' ? 'danger' : 'primary'"
@click="hover('startSectionCode')"
>{{ $t('map.activate') }}</el-button>
</el-form-item>
<el-form-item :label="$t('map.endSectionCodeColon')" prop="endSectionCode">
<el-select v-model="addModel.endSectionCode" clearable :filterable="true">
<el-option
v-for="item in filterSectionList"
:key="item.code"
:label="formatName(item.code)"
:value="item.code"
/>
</el-select>
<el-button
:type=" field === 'endSectionCode' ? 'danger' : 'primary'"
@click="hover('endSectionCode')"
>{{ $t('map.activate') }}</el-button>
</el-form-item>
<el-form-item>
<el-button-group>
<el-button type="primary" size="small" style="margin-top: 10px" @click="nextStep">下一步
</el-button>
</el-button-group>
</el-form-item>
</div>
<div v-show="display == 2" class="rule">
<el-button
type="primary"
size="small"
style="float: right; margin-right: 20px; margin-bottom: 10px;"
@click="pushSwitch"
>{{ $t('map.add') }}</el-button>
<el-table :data="addModel.mapRouteUnitRelList" row-key="id" border style="width: 95%; margin: 0 auto">
<el-table-column type="index" />
<el-table-column prop="routeCode" label="进路code" />
<el-table-column prop="routeName" label="进路名称" />
<el-table-column fixed="right" :label="$t('map.operation')" width="50">
<template slot-scope="scope">
<el-button type="text" size="small" @click.native.prevent="deletePathUnit(scope.$index, addModel.mapRouteUnitRelList)">
{{ $t('map.remove') }}
</el-button>
</template>
</el-table-column>
</el-table>
<el-form-item>
<el-button-group>
<el-button type="primary" size="small" style="margin-top: 10px" @click="lastStep">{{ $t('map.lastStep') }}
</el-button>
</el-button-group>
<el-button-group>
<el-button v-if="!editShow" type="primary" size="small" :loading="loading" style="margin-top: 10px" @click="save">{{ $t('map.save') }}</el-button>
<el-button v-if="editShow" type="warning" size="small" :loading="loading" style="margin-top: 10px" @click="save">{{ $t('map.updata') }}</el-button>
</el-button-group>
</el-form-item>
</div>
</div>
</el-form>
</el-scrollbar>
<path-route ref="pathRoute" :map-info="mapInfo" @routeSelected="routeSelected" />
</div>
</template>
<script>
import { mapGetters } from 'vuex';
import { setUID } from '@/jmapNew/utils/Uid';
import { addRouteUnit, setRouteUnit } from '@/api/jmap/pathunit';
import PathRoute from './pathRoute';
import { ViewMode } from '@/scripts/ConstDic';
// import Sortable from 'sortablejs';
export default {
name: 'RouteOperation',
components: {
PathRoute
},
props: {
selected: {
type: Object,
default() {
return null;
}
},
mapInfo: {
type: Object,
default() {
return null;
}
},
routeData: {
type: Object,
default() {
return null;
}
}
},
data() {
return {
ViewMode: ViewMode,
field: '',
code: '',
type: '',
loading: false,
addModel: {
mapId: '',
code: setUID('RouteUnit'),
startSectionCode: '',
endSectionCode: '',
mapRouteUnitRelList: []
},
editShow: false,
display: 1,
rules: {
startSectionCode: [
{ required: true, message: this.$t('rules.pleaseSelectStartSignal'), trigger: 'change' }
],
endSectionCode: [
{ required: true, message: this.$t('rules.pleaseSelectEndSignal'), trigger: 'change' }
]
}
};
},
computed: {
...mapGetters('map', [
'sectionList'
]),
filterSectionList() {
if (this.sectionList) {
return this.sectionList.filter(elem => { return elem.standTrack || elem.reentryTrack || elem.transferTrack; });
} else {
return [];
}
}
},
watch: {
mapInfo(val) {
if (val) {
this.addModel.mapId = val.id;
}
},
routeData(val, old) {
if (val) {
this.addModel = val;
this.display = 1;
this.editShow = true;
}
}
},
mounted() {
// this.rowDrop();
},
methods: {
//
// rowDrop() {
// const that = this;
// const tbody = document.querySelector('.el-table__body-wrapper tbody');
// if (tbody) {
// Sortable.create(tbody, {
// onEnd({ newIndex, oldIndex }) {
// const currRow = that.addModel.mapRouteUnitRelList.splice(oldIndex, 1)[0];
// that.addModel.mapRouteUnitRelList.splice(newIndex, 0, currRow);
// }
// });
// }
// },
hover(field) {
this.field = field === this.field ? '' : field;
},
formatName(code) {
let name = '';
const section = this.$store.getters['map/getDeviceByCode'](code);
if (section) {
const station = this.$store.getters['map/getDeviceByCode'](section.stationCode);
if (station) {
name += `${station.name} `;
}
name += `${section.name} (${section.code})`;
}
return name;
},
pushSwitch() {
if (this.$refs && this.$refs.pathRoute) {
this.$refs.pathRoute.doShow();
}
},
routeSelected(data) {
data.forEach((element, index) => {
this.addModel.mapRouteUnitRelList.push({
routeCode: element.code,
routeName: element.name
// routeUnitCode: this.addModel.code
});
});
},
//
nextStep() {
this.$refs.form.validate((valid) => {
if (valid) {
this.display = 2;
}
});
},
lastStep() {
this.display = 1;
},
buildModel() {
this.addModel.mapRouteUnitRelList.forEach((elem, index) => {
elem['orderNum'] = index + 1;
});
const model = Object.assign({}, this.addModel);
model['mapId'] = this.mapInfo.id;
return model;
},
save() {
this.loading = true;
if (this.editShow) {
setRouteUnit(this.buildModel()).then(response => {
this.$message.success(this.$t('tip.updateSuccessfully'));
this.clear();
}).catch(() => {
this.$messageBox(this.$t('tip.operationAbnormal'));
this.loading = false;
});
} else {
addRouteUnit(this.buildModel()).then(response => {
this.$message.success(this.$t('tip.createSuccess'));
this.clear();
}).catch(() => {
this.$messageBox(this.$t('tip.operationAbnormal'));
this.loading = false;
});
}
},
clear() {
if (this.$refs && this.$refs.form && this.mapInfo) {
delete this.addModel.id;
this.$refs.form.resetFields();
this.display = 1;
this.editShow = false;
this.addModel = {
mapId: this.mapInfo.id,
code: setUID('RouteUnit'),
startSectionCode: '',
endSectionCode: '',
mapRouteUnitRelList: []
};
this.loading = false;
}
},
//
deletePathUnit(index, data) {
this.addModel.mapRouteUnitRelList.splice(index, 1);
},
setSelected(selected) {
if (selected) {
if (selected._type.toUpperCase() === 'Section'.toUpperCase() && this.field.toUpperCase() === 'startSectionCode'.toUpperCase()) {
this.addModel.startSectionCode = selected.code;
} else if (selected._type.toUpperCase() === 'Section'.toUpperCase() && this.field.toUpperCase() === 'endSectionCode'.toUpperCase()) {
this.addModel.endSectionCode = selected.code;
}
}
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
/deep/ .el-radio {
margin-right: 10px;
}
</style>

View File

@ -31,40 +31,40 @@
<script>
export default {
name: 'DictionaryDetailEdit',
props: {
mapInfo: {
type: Object,
default() {
return null;
}
}
},
data() {
return {
show: false,
title: '',
name: '',
form: [],
data: []
};
},
methods: {
doShow(fieldList, dataList) {
if (fieldList.model) {
const items = fieldList.model.items;
if (items) {
this.form = items;
this.name = fieldList.name;
this.data = dataList;
this.title = fieldList.title;
}
this.show = true;
}
},
doClose(done) {
this.show = false;
}
}
name: 'DictionaryDetailEdit',
props: {
mapInfo: {
type: Object,
default() {
return null;
}
}
},
data() {
return {
show: false,
title: '',
name: '',
form: [],
data: []
};
},
methods: {
doShow(fieldList, dataList) {
if (fieldList.model) {
const items = fieldList.model.items;
if (items) {
this.form = items;
this.name = fieldList.name;
this.data = dataList;
this.title = fieldList.title;
}
this.show = true;
}
},
doClose(done) {
this.show = false;
}
}
};
</script>

View File

@ -1,5 +1,5 @@
<template>
<el-dialog v-dialogDrag :title="$t('map.pathUnitList')" :visible.sync="show" width="85%" :before-do-close="doClose">
<el-dialog v-dialogDrag :title="$t('map.thenList')" :visible.sync="show" width="85%" :before-do-close="doClose">
<div>
<QueryListPage
ref="queryListPage"
@ -14,12 +14,10 @@
<script>
import { mapGetters } from 'vuex';
import { listMap } from '@/api/jmap/mapdraft';
import { getRouteUnitList, delRouteUnit, getRouteUnit } from '@/api/jmap/pathunit';
import { getRunLevelList, deleteRunLevel, getRunLevelDetail } from '@/api/runplan';
export default {
name: 'RouteDetail',
components: {
},
props: {
mapInfo: {
type: Object,
@ -32,6 +30,10 @@ export default {
return {
show: false,
mapList: [],
PermissionUseList: [
{ label: '向右', value: true },
{ label: '向左', value: false }
],
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
@ -41,14 +43,14 @@ export default {
queryObject: {
startSectionCode: {
type: 'select',
label: this.$t('map.startSectionCode'),
label: '起始区段',
config: {
data: []
}
},
endSectionCode: {
type: 'select',
label: this.$t('map.endSectionCode'),
label: '终点区段',
config: {
data: []
}
@ -62,25 +64,48 @@ export default {
indexShow: true,
columns: [
{
title: this.$t('map.pathUnitCode'),
prop: 'code'
},
{
title: this.$t('map.pathUnitMapName'),
prop: 'mapId'
},
{
title: this.$t('map.startSectionCode'),
prop: 'startSectionCode'
title: this.$t('map.startStation'),
prop: 'startStationCode'
},
{
title: this.$t('map.endSectionCode'),
title: this.$t('map.startStationCode'),
prop: 'startSectionCode'
},
{
title: this.$t('map.endStation'),
prop: 'endStationCode'
},
{
title: this.$t('map.endStationCode'),
prop: 'endSectionCode'
},
{
title: this.$t('map.orderNum'),
prop: 'orderNum'
title: '行驶方向',
prop: 'right',
type: 'tag',
columnValue: (row) => { return this.translate(row.right, 'PermissionUseList'); },
tagType: (row) => { return 'success'; }
},
{
title: '第一等级时间',
prop: 'l1'
},
{
title: '第二等级时间',
prop: 'l2'
},
{
title: '第三等级时间',
prop: 'l3'
},
{
title: '第四等级时间',
prop: 'l4'
},
{
title: '第五等级时间',
prop: 'l5'
},
{
type: 'button',
@ -104,7 +129,8 @@ export default {
},
computed: {
...mapGetters('map', [
'sectionList'
'sectionList',
'stationList'
])
},
watch: {
@ -112,9 +138,7 @@ export default {
const list = [];
if (val && val.length) {
val.forEach(elem => {
if (elem.standTrack || elem.reentryTrack || elem.transferTrack) {
list.push({ label: this.formatName(elem.code), value: elem.code });
}
list.push({ label: `${elem.name}(${elem.code})`, value: elem.code });
});
this.queryForm.queryObject.startSectionCode.config.data = list;
this.queryForm.queryObject.endSectionCode.config.data = list;
@ -134,25 +158,26 @@ export default {
},
formatName(code) {
let name = '';
const section = this.$store.getters['map/getDeviceByCode'](code);
if (section) {
const station = this.$store.getters['map/getDeviceByCode'](section.stationCode);
if (station) {
name += `${station.name} `;
}
name += `${section.name} (${section.code})`;
const device = this.$store.getters['map/getDeviceByCode'](code);
if (device) {
name = device.name;
}
return name;
},
queryFunction(params) {
if (this.mapInfo && this.mapInfo.id) {
return getRouteUnitList(this.mapInfo.id, params);
return getRunLevelList(this.mapInfo.id, params);
}
},
translate(rowData, listName) {
const obj = this[listName].filter((item) => {
return item.value === rowData;
});
return obj && obj.label;
},
acquireMapList() {
//
listMap({ drawWay:true}).then(response => {
listMap({drawWay: true}).then(response => {
this.mapList = response.data;
});
},
@ -163,7 +188,9 @@ export default {
if (list) {
list.map(elem => {
that.$convertSpecifiedField(elem, that.mapList, 'id', 'name', ['mapId']);
elem.startStationCode = that.formatName(elem.startStationCode);
elem.startSectionCode = that.formatName(elem.startSectionCode);
elem.endStationCode = that.formatName(elem.endStationCode);
elem.endSectionCode = that.formatName(elem.endSectionCode);
});
}
@ -171,20 +198,19 @@ export default {
return data;
},
editObj(index, row) {
getRouteUnit(row.id).then(response => {
getRunLevelDetail(row.id).then(response => { // id
const data = response.data;
this.$emit('routeSelected', data);
this.$emit('routingSelected', data);
this.doClose();
});
},
deleteObj(index, row) {
if (this.mapInfo && this.mapInfo.id && row) {
//
delRouteUnit(row.id).then(response => {
this.$message.success(this.$t('tip.successfullyDelete'));
deleteRunLevel(row.id).then(response => { //
this.$message.success('删除成功');
this.reloadTable();
}).catch(() => {
this.$messageBox(this.$t('tip.failDelete'));
this.$messageBox('删除失败');
});
}
},

View File

@ -6,7 +6,7 @@
:map-info="mapInfo"
:route-data="routeData"
/>
<route-detail ref="routeDetail" :map-info="mapInfo" @routeSelected="routeSelected" />
<route-detail ref="routeDetail" :map-info="mapInfo" @routingSelected="routingSelected" />
</div>
</template>
<script>
@ -57,7 +57,7 @@ export default {
});
}
},
routeSelected: function (data) {
routingSelected: function (data) {
this.routeData = data;
if (this.$refs && this.$refs.routeEdit) {
this.$refs.routeEdit.isSave = false;

View File

@ -0,0 +1,356 @@
<template>
<div style="height: 100%;">
<el-scrollbar wrap-class="scrollbar-wrapper">
<el-form ref="form" :model="addModel" :rules="rules" label-width="120px" size="mini">
<div class="path-box">
<el-steps :active="display" style="display: none;">
<el-step title="生成默认" icon="el-icon-edit" />
<el-step title="保存运行等级" icon="el-icon-setting" />
</el-steps>
<div v-show="display == 1" class="definition">
<el-form-item :label="$t('map.startStationCodeColon')" prop="startStationCode">
<el-select v-model="addModel.startStationCode" clearable :filterable="true">
<el-option
v-for="item in filterStationList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
<el-button
:type=" field === 'startStationCode' ? 'danger' : 'primary'"
@click="hover('startStationCode')"
>{{ $t('map.activate') }}</el-button>
</el-form-item>
<el-form-item :label="$t('map.startSectionColon')" prop="startSectionCode">
<el-select v-model="addModel.startSectionCode" clearable :filterable="true">
<el-option
v-for="item in filterSectionList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
<el-button
:type=" field === 'startSectionCode' ? 'danger' : 'primary'"
@click="hover('startSectionCode')"
>{{ $t('map.activate') }}</el-button>
</el-form-item>
<el-form-item :label="$t('map.endStationColon')" prop="endStationCode">
<el-select v-model="addModel.endStationCode" clearable :filterable="true">
<el-option
v-for="item in filterStationList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
<el-button
:type=" field === 'endStationCode' ? 'danger' : 'primary'"
@click="hover('endStationCode')"
>{{ $t('map.activate') }}</el-button>
</el-form-item>
<el-form-item :label="$t('map.endSectionColon')" prop="endSectionCode">
<el-select v-model="addModel.endSectionCode" clearable :filterable="true">
<el-option
v-for="item in filterSectionList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
<el-button
:type=" field === 'endSectionCode' ? 'danger' : 'primary'"
@click="hover('endSectionCode')"
>{{ $t('map.activate') }}</el-button>
</el-form-item>
<el-form-item label="是否向右:" prop="right">
<el-checkbox v-model="addModel.right" />
</el-form-item>
<el-form-item>
<el-button-group>
<el-button type="primary" size="small" style="margin-top: 10px" @click="generateLevel">生成等级</el-button>
</el-button-group>
</el-form-item>
</div>
<div v-show="display == 2" class="rule">
<el-form-item :label="$t('map.startStationCodeColon')" prop="startStationCode">
<el-select v-model="addModel.startStationCode" clearable :filterable="true">
<el-option
v-for="item in filterStationList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
<el-button
:type=" field === 'startStationCode' ? 'danger' : 'primary'"
@click="hover('startStationCode')"
>{{ $t('map.activate') }}</el-button>
</el-form-item>
<el-form-item :label="$t('map.startSectionColon')" prop="startSectionCode">
<el-select v-model="addModel.startSectionCode" clearable :filterable="true">
<el-option
v-for="item in filterSectionList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
<el-button
:type=" field === 'startSectionCode' ? 'danger' : 'primary'"
@click="hover('startSectionCode')"
>{{ $t('map.activate') }}</el-button>
</el-form-item>
<el-form-item :label="$t('map.endStationColon')" prop="endStationCode">
<el-select v-model="addModel.endStationCode" clearable :filterable="true">
<el-option
v-for="item in filterStationList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
<el-button
:type=" field === 'endStationCode' ? 'danger' : 'primary'"
@click="hover('endStationCode')"
>{{ $t('map.activate') }}</el-button>
</el-form-item>
<el-form-item :label="$t('map.endSectionColon')" prop="endSectionCode">
<el-select v-model="addModel.endSectionCode" clearable :filterable="true">
<el-option
v-for="item in filterSectionList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
<el-button
:type=" field === 'endSectionCode' ? 'danger' : 'primary'"
@click="hover('endSectionCode')"
>{{ $t('map.activate') }}</el-button>
</el-form-item>
<el-form-item label="是否向右:" prop="right">
<el-checkbox v-model="addModel.right" />
</el-form-item>
<el-form-item label="等级一时间:" prop="l1">
<el-input-number v-model="addModel.l1" :min="0" />
<span>s</span>
</el-form-item>
<el-form-item label="等级二时间:" prop="l1">
<el-input-number v-model="addModel.l2" :min="0" />
<span>s</span>
</el-form-item>
<el-form-item label="等级三时间:" prop="l1">
<el-input-number v-model="addModel.l3" :min="0" />
<span>s</span>
</el-form-item>
<el-form-item label="等级四时间:" prop="l1">
<el-input-number v-model="addModel.l4" :min="0" />
<span>s</span>
</el-form-item>
<el-form-item label="等级五时间:" prop="l1">
<el-input-number v-model="addModel.l5" :min="0" />
<span>s</span>
</el-form-item>
<el-form-item>
<el-button-group>
<el-button type="primary" size="small" style="margin-top: 10px" @click="lastStep">{{ $t('map.lastStep') }}
</el-button>
</el-button-group>
<el-button-group>
<el-button v-if="!editShow" type="primary" size="small" :loading="loading" style="margin-top: 10px" @click="save">{{ $t('map.save') }}</el-button>
<el-button v-if="editShow" type="warning" size="small" :loading="loading" style="margin-top: 10px" @click="save">{{ $t('map.updata') }}</el-button>
</el-button-group>
</el-form-item>
</div>
</div>
</el-form>
</el-scrollbar>
</div>
</template>
<script>
import { setUID } from '@/jmapNew/utils/Uid';
import { mapGetters } from 'vuex';
import { postGenerateLevel, postSaveLevel, putUploadLevel } from '@/api/runplan';
export default {
props: {
selected: {
type: Object,
default() {
return null;
}
},
mapInfo: {
type: Object,
default() {
return null;
}
},
routeData: {
type: Object,
default() {
return null;
}
}
},
data() {
return {
display: 1, //
field: '',
editShow: false,
runLevelId: '', // id
addModel: {
mapId: '',
code: setUID('RunLevel'),
endSectionCode: '', // code
endStationCode: '', // code
startSectionCode: '', // code
startStationCode: '', // code
right: false, //
l1: 0, // (s)
l2: 0, // (s)
l3: 0, // (s)
l4: 0, // (s)
l5: 0 // (s)
},
rules: {
startStationCode: [
{ required: true, message: '请选择起始车站', trigger: 'change' }
],
startSectionCode: [
{ required: true, message: '请选择起始区段', trigger: 'change' }
],
endStationCode: [
{ required: true, message: '请选择末端车站', trigger: 'change' }
],
endSectionCode: [
{ required: true, message: '请选择末端区段', trigger: 'change' }
]
}
};
},
computed: {
...mapGetters('map', [
'sectionList',
'stationList'
]),
filterSectionList() {
if (this.sectionList) {
return this.sectionList.filter(elem => { return elem.standTrack || elem.reentryTrack || elem.transferTrack; });
} else {
return [];
}
},
filterStationList() {
if (this.stationList) {
return this.stationList.filter(elem => { return true; });
} else {
return [];
}
}
},
watch: {
mapInfo(val) {
if (val) {
console.log(val);
this.addModel.mapId = val.id;
}
},
routeData(val, old) {
if (val) {
this.addModel = val;
this.display = 1;
this.editShow = true;
this.runLevelId = '';
if (val.id) {
this.runLevelId = val.id;
}
}
}
},
methods: {
generateLevel() { //
this.$refs.form.validate(async (valid) => {
if (valid) {
const res = await postGenerateLevel(this.addModel);
if (res.code == 200) {
this.display = 2;
this.addModel.l1 = res.data.l1;
this.addModel.l2 = res.data.l2;
this.addModel.l3 = res.data.l3;
this.addModel.l4 = res.data.l4;
this.addModel.l5 = res.data.l5;
}
}
});
},
save() {
this.loading = true;
if (this.editShow) {
putUploadLevel(this.runLevelId, this.addModel).then(res => { //
this.$message.success('更新成功');
this.clear();
}).catch(() => {
this.$messageBox('更新失败');
this.loading = false;
});
} else {
postSaveLevel(this.addModel).then(res => { //
this.$message.success('保存成功');
this.clear();
}).catch(() => {
this.$messageBox('保存失败');
this.loading = false;
});
}
},
clear() {
if (this.$refs && this.$refs.form && this.mapInfo) {
this.$refs.form.resetFields();
this.display = 1;
this.editShow = false;
this.addModel = {
mapId: this.mapInfo.id,
code: setUID('RunLevel'),
endSectionCode: '',
endStationCode: '',
startSectionCode: '',
startStationCode: '',
right: false,
l1: 0,
l2: 0,
l3: 0,
l4: 0,
l5: 0
};
this.loading = false;
}
},
lastStep() {
this.display = 1;
},
hover(field) {
this.field = field === this.field ? '' : field;
},
setSelected(selected) {
if (selected) {
if (selected._type.toUpperCase() === 'Station'.toUpperCase() && this.field.toUpperCase() === 'startStationCode'.toUpperCase()) {
this.addModel.startStationCode = selected.code;
} else if (selected._type.toUpperCase() === 'Station'.toUpperCase() && this.field.toUpperCase() === 'endStationCode'.toUpperCase()) {
this.addModel.endStationCode = selected.code;
} else if (selected._type.toUpperCase() === 'Section'.toUpperCase() && this.field.toUpperCase() === 'startSectionCode'.toUpperCase()) {
this.addModel.startSectionCode = selected.code;
} else if (selected._type.toUpperCase() === 'Section'.toUpperCase() && this.field.toUpperCase() === 'endSectionCode'.toUpperCase()) {
this.addModel.endSectionCode = selected.code;
}
}
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
</style>