运行图编制代码调整

This commit is contained in:
joylink_cuiweidong 2020-12-09 17:13:35 +08:00
parent dab2a00313
commit c16e9a528f
4 changed files with 1105 additions and 0 deletions

View File

@ -0,0 +1,86 @@
<template>
<el-dialog title="参数配置" :visible.sync="dialogShow" custom-class="content-route" width="100%" :fullscreen="true" top="0px" :before-close="close" :z-index="2000" :append-to-body="true">
<div class="content-box">
<jlmap-visual ref="jlmapVisual" @onMenu="onContextmenu" @onSelect="clickEvent" />
<div style="width: 29%;float: right;" :style="{height: $store.state.app.height-54+'px' }" />
</div>
</el-dialog>
</template>
<script>
import JlmapVisual from '@/views/newMap/jlmapNew/index';
import { loadMapDataById } from '@/utils/loaddata';
export default {
name: 'RunplanParams',
components: {
JlmapVisual
},
props:{
},
data() {
return {
dialogShow: false
};
},
methods:{
async doShow() {
this.dialogShow = true;
await this.setWindowSize();
await this.loadInitPage();
},
setWindowSize() {
this.$nextTick(() => {
const width = this.$store.state.app.width * 0.7;
const height = this.$store.state.app.height - 54;
this.$store.dispatch('config/resize', { width, height });
});
},
async loadInitPage() {
await this.$store.dispatch('training/changeMode', { mode: null });
loadMapDataById(this.$route.query.mapId).then(()=>{
this.$store.dispatch('training/over');
this.$store.dispatch('training/setMapDefaultState');
this.$store.dispatch('map/clearJlmapTrainView');
});
},
clickEvent(em) {
const device = this.getDeviceByEm(em);
this.deviceHighLight(this.oldDevice, false);
this.deviceHighLight(device, true);
this.oldDevice = device;
this.setSelected(device);
},
onContextmenu() {
},
close() {
this.dialogShow = false;
},
//
getDeviceByEm(em) {
var device = this.$store.getters['map/getDeviceByCode'](em.deviceCode) || null;
if (device) {
device._viewVal = em.val;
}
return device;
},
//
deviceHighLight(device, flag) {
if (device && device.instance && typeof device.instance.drawSelected === 'function' ) {
if (device._type === 'Section' && device.type === '04') {
device.relevanceSectionList.forEach(item => {
const sectionModel = this.$store.getters['map/getDeviceByCode'](item);
sectionModel && sectionModel.instance.drawSelected(flag);
});
} else if (device._type === 'Section' && device.type === '01' && device.logicSectionCodeList && device.logicSectionCodeList.length) {
device.logicSectionCodeList.forEach(item => {
const sectionModel = this.$store.getters['map/getDeviceByCode'](item);
sectionModel && sectionModel.instance.drawSelected(flag);
});
} else {
device.instance.drawSelected(flag);
}
}
}
}
};
</script>

View File

@ -0,0 +1,168 @@
<template>
<el-dialog
v-dialogDrag
class="planEdit__tool gernarate-plan-train"
:title="title"
:visible.sync="dialogShow"
width="500px"
:before-close="doClose"
:z-index="2000"
:modal="false"
top="10vh"
:close-on-click-modal="false"
>
<data-form ref="dataform" :form="form" :form-model="formModel" :rules="rules" />
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="doClose">{{ $t('global.cancel') }}</el-button>
<el-button type="primary" size="small" :loading="loading" @click="handleCommit">{{ $t('global.confirm') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { generatePlanTrain, listUserRoutingData } from '@/api/runplan';
export default {
props: {
loadRunPlanId: {
type: String,
default() {
return '';
}
}
},
data() {
return {
dialogShow: false,
routingList: [],
loading: false,
runLevelList: [
{ value: 1, label: '等级一' },
{ value: 2, label: '等级二' },
{ value: 3, label: '等级三'},
{ value: 4, label: '等级四' },
{ value: 5, label: '等级五' }
],
formModel: {
serviceNumber:'', //
beginTime: '', //
overTime: '', //
runLevel:'', //
inboundRouting:'', // code
outboundRouting:'', // code
runningRouting1: '', // code1
runningRouting2: '' // code2
},
rules: {
serviceNumber:[
{required: true, validator: this.validateServiceNumber, trigger: 'blur'}
],
beginTime: [
{ required: true, message: '请填写开始时间', trigger: 'blur' }
],
overTime: [
{ required: true, message: '请填写结束时间', trigger: 'blur' }
],
runLevel: [
{ required: true, message: '请选择运行等级', trigger: 'change' }
],
inboundRouting: [
{ required: true, message: '请选择回库交路', trigger: 'change' }
],
outboundRouting: [
{ required: true, message: '请选择出库交路', trigger: 'change' }
],
runningRouting1: [
{ required: true, message: '请选择环路', trigger: 'change' }
],
runningRouting2: [
{ required: true, message: '请选择环路', trigger: 'change' }
]
}
};
},
computed: {
title() {
return '生成计划';
},
form() {
return {
labelWidth: '100px',
size:'small',
items: [
{ prop: 'serviceNumber', label: '服务号', type: 'text', rightWidth:true, maxlength:3 },
{ prop: 'beginTime', label: '开始时间', type: 'timePicker'},
{ prop: 'overTime', label: '结束时间', type: 'timePicker'},
{ prop: 'runLevel', label: '运行等级', type: 'select', options: this.runLevelList },
{ prop: 'outboundRouting', label: '出库交路', type: 'select', options: this.covertRouting('OUTBOUND') },
{ prop: 'runningRouting1', label: '环路交路1', type: 'select', options: this.covertRouting('LOOP') },
{ prop: 'runningRouting2', label: '环路交路2', type: 'select', options: this.covertRouting('LOOP') },
{ prop: 'inboundRouting', label: '入库交路', type: 'select', options: this.covertRouting('INBOUND') }
]
};
}
},
methods: {
doShow(params) {
this.loading = false;
const mapId = this.$route.query.mapId;
if (mapId) {
listUserRoutingData(mapId).then(response => {
this.routingList = response.data.map(elem => { return { value: elem.code, label: elem.name, routingType:elem.routingType }; });
}).catch(() => {
this.$messageBox(`获取交路列表失败`);
});
}
this.dialogShow = true;
},
validateServiceNumber(rule, value, callback) {
if (value.trim().length == 0) {
return callback(new Error('请填写服务号'));
} else {
const serviceNumberList = Object.keys(this.$store.state.runPlan.editData);
if (serviceNumberList.includes(value.trim())) {
return callback(new Error('该服务号已存在,请重新填写'));
} else {
return callback();
}
}
},
doClose() {
this.loading = false;
this.$refs.dataform.resetForm();
this.dialogShow = false;
},
covertRouting(routingType) {
return this.routingList.filter(route=>{ return route.routingType == routingType; });
},
handleCommit() {
this.$refs.dataform.validateForm(() => {
const serviceNumberList = Object.keys(this.$store.state.runPlan.editData);
if (serviceNumberList.includes(this.formModel.serviceNumber)) {
this.$messageBox('该服务号已存在,请重新填写');
return false;
}
if (this.formModel.runningRouting1 == this.formModel.runningRouting2) {
this.$messageBox('环路1和环路2不能相同');
return false;
}
if (this.formModel.overTime <= this.formModel.beginTime) {
this.$messageBox('结束时间必须大于开始时间');
return false;
}
this.loading = true;
generatePlanTrain(this.$route.query.planId || this.loadRunPlanId, this.formModel).then(res => {
this.loading = false;
this.doClose();
this.$store.dispatch('runPlan/refresh');
}).catch(error => {
console.log(error);
this.doClose();
});
});
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
</style>

View File

@ -0,0 +1,644 @@
<template>
<div class="routeConfig">
<div>
<div class="clearfix" style="padding-right: 20px;">
<el-button type="text" class="mapEdit_box" @click="previewRouteEvent">{{ $t('map.preview') }}</el-button>
<el-button type="text" class="mapEdit_box" @click="createRouteEvent">{{ $t('map.newConstruction') }}</el-button>
</div>
<el-form ref="form" :model="addModel" :rules="rules" label-width="120px" size="mini">
<div class="definition">
<el-form-item :label="$t('map.routingName')" prop="name">
<el-input v-model="addModel.name" />
</el-form-item>
<el-form-item :label="$t('map.startStationCodeColon')" prop="startStationCode">
<el-select v-model="addModel.startStationCode" clearable :filterable="true" @change="changeStartStation">
<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" :disabled="editShow" @change="changeStartSection">
<el-option
v-for="item in filterSectionList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
<el-button
:disabled="editShow"
: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" :disabled="!isStartSelected" @change="changeEndStation">
<el-option
v-for="item in filterStationList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
<el-button
:disabled="!isStartSelected"
: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" :disabled="editShow || !isStartSelected" @change="changeEndSection">
<el-option
v-for="item in filterSectionList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
<el-button
:disabled="editShow || !isStartSelected"
:type=" field === 'endSectionCode' ? 'danger' : 'primary'"
@click="hover('endSectionCode')"
>{{ $t('map.activate') }}</el-button>
</el-form-item>
<el-form-item :label="$t('map.destinationCode')" prop="destinationCode" :disabled="editShow">
<el-input v-model="addModel.destinationCode" />
</el-form-item>
<el-form-item :label="$t('map.routingDirection')" prop="directionCode">
<el-select v-model="addModel.right" clearable :filterable="true" :placeholder="$t('map.pleaseSelect')">
<el-option
v-for="item in DirectionCodeList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<!-- <el-form-item v-if="!editShow" label="是否生成回路" prop="withLoop">
<el-checkbox v-model="addModel.withLoop" />
</el-form-item> -->
<el-form-item :label="$t('map.remarksColon')" prop="remarks">
<el-input v-model="addModel.remarks" type="textarea" :rows="4" :placeholder="$t('map.pleaseSelect')" />
</el-form-item>
<el-form-item :label="$t('map.trafficSegmentData')" prop="parkSectionCodeList">
<el-table
:data="addModel.parkSectionCodeList"
border
style="width:97%"
height="300"
class="el-parkSectionCode-table"
>
<el-table-column prop="sectionCode" :label="$t('map.stationName')">
<template slot-scope="scope">
<span>{{ formatName(scope.row.stationCode) }}</span>
</template>
</el-table-column>
<el-table-column prop="sectionCode" :label="$t('map.sectionName')">
<template slot-scope="scope">
<span>{{ formatName(scope.row.sectionCode) }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('map.operation')" width="50">
<template slot-scope="scope">
<el-button
v-show="scope.$index!=0&&scope.$index!=addModel.parkSectionCodeList.length-1"
type="text"
size="small"
@click.native.prevent="deleteSection(addModel.parkSectionCodeList, scope.$index)"
>
{{ $t('map.remove') }}
</el-button>
</template>
</el-table-column>
</el-table>
<div style="margin-top:10px;">
<span>车站:</span>
<el-select v-model="stationCode" clearable :filterable="true" :placeholder="$t('map.pleaseSelect')">
<el-option
v-for="item in filterStationList"
:key="item.code"
:label="`${item.name}(${item.code})`"
:value="item.code"
/>
</el-select>
<el-button
:disabled="!allowSelect"
:type="field === 'routingStation' ? 'danger' : 'primary'"
@click="hover('routingStation')"
>{{ $t('map.activate') }}</el-button>
</div>
<div style="margin-top:10px;">
<span>区段:</span>
<el-select v-model="sectionCode" clearable :filterable="true" :placeholder="$t('map.pleaseSelect')">
<el-option
v-for="item in filterStandSection"
:key="item.code"
:label="`${item.name}(${item.code})`"
:value="item.code"
/>
</el-select>
<el-button
:type=" field === 'routingSection' ? 'danger' : 'primary'"
:disabled="!allowSelect"
@click="hover('routingSection')"
>{{ $t('map.activate') }}</el-button>
<el-button
type="primary"
:disabled="!allowSelect"
@click="pushSection({stationCode: stationCode, sectionCode: sectionCode},'center')"
>
{{ $t('map.add') }}
</el-button>
</div>
</el-form-item>
<el-form-item>
<el-button-group style="padding-bottom:10px">
<el-button v-if="isSave" type="primary" size="small" :loading="loading" @click="save">{{ $t('map.save') }}
</el-button>
<el-button v-else type="warning" size="small" :loading="loading" @click="update">{{ $t('map.updata') }}
</el-button>
</el-button-group>
</el-form-item>
</div>
</el-form>
</div>
<route-operate ref="routeOperate" @routingSelected="routingSelected" />
</div>
</template>
<script>
import RouteOperate from './routeOperate';
import { setUID } from '@/jmapNew/utils/Uid';
import { addRoutingData, updateRoutingData } from '@/api/jmap/mapdraft';
import { mapGetters } from 'vuex';
import { formatName } from '@/utils/runPlan';
import Sortable from 'sortablejs';
export default {
name:'RouteConfig',
components: {
RouteOperate
},
data() {
return {
field: '',
editShow: false,
isSave: true,
isStartSelected:false,
allowSelect:false,
loading: false,
stationCode: '',
sectionCode: '',
DirectionCodeList: [{label: '右行', value: true}, {label: '左行', value: false}],
addModel: {
name: '',
mapId: '',
code: '',
// withLoop:false,
right: true,
destinationCode: '',
startStationCode: '',
startSectionCode: '',
endStationCode: '',
endSectionCode: '',
remarks: '',
userId: '',
parkSectionCodeList: []
},
rules: {
name: [
{ required: true, message: '请输入交路名称', trigger: 'change' }
],
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) {
// || elem.reentryTrack
return this.sectionList.filter(elem => { return elem.standTrack || elem.transferTrack; });
} else {
return [];
}
},
filterStandSection() {
if (this.sectionList) {
// || elem.reentryTrack
return this.sectionList.filter(elem => { return elem.standTrack; });
} else {
return [];
}
},
filterStationList() {
if (this.stationList) {
return this.stationList.filter(elem => { return true; });
} else {
return [];
}
},
routeName: {
get() {
var name = '';
if (this.isSave) {
let begStation = ''; let endStation = '';
let begSection = ''; let endSection = '';
if (this.stationList) {
this.stationList.forEach(elem => {
if (elem.code === this.addModel.startStationCode) begStation = elem.name;
if (elem.code === this.addModel.endStationCode) endStation = elem.name;
});
}
if (this.sectionList) {
this.sectionList.forEach(elem => {
if (elem.code === this.addModel.startSectionCode) begSection = '(' + elem.name + ')';
if (elem.code === this.addModel.endSectionCode) endSection = '(' + elem.name + ')';
});
}
name = begStation + begSection + '-' + endStation + endSection;
}
return name;
}
}
},
watch: {
mapInfo(val) {
if (val) {
this.addModel.mapId = val.id;
}
},
'addModel.parkSectionCodeList':function(val, old) {
if (val.length > 0) {
this.changeSectionSelected(val, true);
}
},
routeName(val, old) {
if (val) {
this.addModel.name = val;
}
},
sectionCode(val) {
val && this.changeBelongSection(val);
}
},
mounted() {
this.rowDrop();
},
methods:{
previewRouteEvent() {
this.$refs.routeOperate.doShow();
},
createRouteEvent() {
this.clear();
},
routingSelected(data) {
this.editData(data);
},
editData(data) {
this.isSave = false;
this.allowSelect = true;
this.isStartSelected = true;
this.editShow = true;
this.addModel = data;
},
clear() {
if (this.$refs && this.$refs.form) {
this.changeSectionSelected(this.addModel.parkSectionCodeList, false);
delete this.addModel.id;
this.$refs.form.resetFields();
this.addModel.mapId = this.$route.query.mapId;
this.addModel.parkSectionCodeList = [];
this.addModel.code = '';
this.stationCode = '';
this.sectionCode = '';
this.isSave = true;
this.allowSelect = false;
this.isStartSelected = false;
// this.addModel.withLoop = false;
this.editShow = false;
this.field = '';
}
},
setSelected(selected) {
if (selected._type.toUpperCase() === 'Station'.toUpperCase() && this.field.toUpperCase() === 'startStationCode'.toUpperCase()) {
this.addModel.startStationCode = selected.code;
this.judgeAllowSelected();
this.addStartSectionData(true);
} else if (selected._type.toUpperCase() === 'Station'.toUpperCase() && this.field.toUpperCase() === 'endStationCode'.toUpperCase()) {
this.addModel.endStationCode = selected.code;
this.judgeAllowSelected();
this.addEndSectionData(true);
} else if (selected._type.toUpperCase() === 'Section'.toUpperCase() && this.field.toUpperCase() === 'startSectionCode'.toUpperCase()) {
// selected.reentryTrack ||
if (selected.standTrack || selected.transferTrack) {
if (selected.belongStation) {
this.addModel.startStationCode = selected.belongStation;
}
this.addModel.startSectionCode = selected.code;
this.judgeAllowSelected();
this.addStartSectionData(false);
} else {
// (//)
this.$message.error('请选择正确的起始区段');
}
} else if (selected._type.toUpperCase() === 'Section'.toUpperCase() && this.field.toUpperCase() === 'endSectionCode'.toUpperCase()) {
// selected.reentryTrack ||
if (selected.standTrack || selected.transferTrack) {
if (selected.belongStation) {
this.addModel.endStationCode = selected.belongStation;
}
this.addModel.endSectionCode = selected.code;
this.judgeAllowSelected();
this.addEndSectionData(false);
this.addModel.destinationCode = selected.destinationCode || '';
} else {
this.$message.error('请选择正确的终到区段');
}
} else if (selected._type.toUpperCase() === 'Section'.toUpperCase() && this.field.toUpperCase() == 'routingSection'.toUpperCase()) {
if (selected.standTrack) {
// || selected.reentryTrack || selected.transferTrack
this.sectionCode = selected.code;
} else {
this.$message.error('请选择正确的区段');
}
} else if (selected._type.toUpperCase() === 'Station'.toUpperCase() && this.field.toUpperCase() == 'routingStation'.toUpperCase()) {
this.stationCode = selected.code;
}
},
changeBelongSection(code) {
const section = this.$store.getters['map/getDeviceByCode'](code);
if (section && section.belongStation) {
this.stationCode = section.belongStation;
}
},
changeSectionSelected(selectedList, flag) {
if (this.addModel.parkSectionCodeList && this.addModel.parkSectionCodeList.length > 0) {
if (flag) {
if (this.oldsection && this.oldsection.length > 0) {
this.oldsection.forEach((section)=>{
section.instance.drawBatchSelected(section, '');
});
this.oldsection = [];
}
selectedList.forEach(each=>{
const section = this.$store.getters['map/getDeviceByCode'](each.sectionCode);
const list = section.logicSectionCodeList;
if (list && list.length > 0) {
list.forEach(logicSectionCode=>{
const logicSection = this.$store.getters['map/getDeviceByCode'](logicSectionCode);
this.oldsection && this.oldsection.push(logicSection);
logicSection.instance.drawBatchSelected(section, 'routingSection');
});
} else {
this.oldsection && this.oldsection.push(section);
section.instance.drawBatchSelected(section, 'routingSection');
}
});
} else {
selectedList.forEach(each=>{
const section = this.$store.getters['map/getDeviceByCode'](each.sectionCode);
const list = section.logicSectionCodeList;
if (list && list.length > 0) {
list.forEach(logicSectionCode=>{
const logicSection = this.$store.getters['map/getDeviceByCode'](logicSectionCode);
logicSection.instance.drawBatchSelected(section, '');
});
} else {
section.instance.drawBatchSelected(section, '');
}
});
}
}
},
changeStartStation() {
this.judgeAllowSelected();
this.addStartSectionData(true);
},
changeStartSection(data) {
const section = this.$store.getters['map/getDeviceByCode'](data);
if (section.belongStation) {
this.addModel.startStationCode = section.belongStation;
}
this.judgeAllowSelected();
this.addStartSectionData(false);
},
changeEndStation() {
this.judgeAllowSelected();
this.addEndSectionData(true);
},
changeEndSection(data) {
const section = this.$store.getters['map/getDeviceByCode'](data);
if (section.belongStation) {
this.addModel.endStationCode = section.belongStation;
}
this.judgeAllowSelected();
this.addEndSectionData(false);
},
judgeAllowSelected() {
if (this.addModel.startStationCode != '' && this.addModel.startSectionCode != '' && this.addModel.endStationCode != '' && this.addModel.endSectionCode != '') {
this.allowSelect = true;
} else {
this.allowSelect = false;
}
},
addStartSectionData(isStation) {
if (this.addModel.startStationCode != '' && this.addModel.startSectionCode != '') {
this.isStartSelected = true;
const result = this.pushSection({stationCode: this.addModel.startStationCode, sectionCode: this.addModel.startSectionCode}, 'top', isStation);
return result;
}
return false;
},
addEndSectionData(isStation) {
if (this.addModel.endStationCode != '' && this.addModel.endSectionCode != '') {
const result = this.pushSection({stationCode: this.addModel.endStationCode, sectionCode: this.addModel.endSectionCode}, 'bottom', isStation);
return result;
}
return false;
},
buildModel(code) {
const model = Object.assign({}, this.addModel);
// if (model.withLoop) { model.withLoop = true; } else { model.withLoop = false; }
model['mapId'] = this.$route.query.mapId;
model['userId'] = this.$store.state.user.id;
if (code) { model['code'] = code; }
return model;
},
update() {
this.$refs.form.validate((valid) => {
if (valid) {
this.loading = true;
const data = this.buildModel();
// delete data.withLoop;
updateRoutingData(data).then(resp => {
this.$message.success(this.$t('tip.pathUpdataSuccessful'));
this.loading = false;
this.clear();
}).catch((error) => {
this.$messageBox(this.$t('tip.pathUpdataFailed') + ':' + error.message);
this.loading = false;
});
}
});
},
save() {
this.addModel;
this.$refs.form.validate((valid) => {
if (valid) {
this.loading = true;
addRoutingData(this.buildModel(setUID('Routing'))).then(resp => {
this.$message.success(this.$t('tip.pathCreationSuccessful'));
this.loading = false;
this.clear();
}).catch((error) => {
this.$messageBox(this.$t('tip.createRoutingFailed') + ':' + error.message);
this.loading = false;
});
}
});
},
formatName(code) {
return formatName(code);
},
deleteSection(list, index) {
const data = list.splice(index, 1);
if (data.length > 0) {
const section = this.$store.getters['map/getDeviceByCode'](data[0].sectionCode);
section.instance.drawBatchSelected(section, '');
}
},
hover(field) {
this.field = field === this.field ? '' : field;
},
//
rowDrop() {
const that = this;
const tbody = document.querySelector('.el-parkSectionCode-table tbody', {filter:'.ignoreDrag'});
if (tbody) {
Sortable.create(tbody, {
onEnd({ newIndex, oldIndex }) {
const length = that.addModel.parkSectionCodeList.length - 1;
if (newIndex != 0 && oldIndex != 0 && newIndex != length && oldIndex != length) {
that.addModel.parkSectionCodeList.splice(newIndex, 0, that.addModel.parkSectionCodeList.splice(oldIndex, 1)[0]);
const newArray = that.addModel.parkSectionCodeList.slice(0);
that.addModel.parkSectionCodeList = [];
that.$nextTick(function () {
that.addModel.parkSectionCodeList = newArray;
});
} else {
const newArray = that.addModel.parkSectionCodeList.slice(0);
that.addModel.parkSectionCodeList = [];
that.$nextTick(function () {
that.addModel.parkSectionCodeList = newArray;
});
}
}
});
}
},
pushSection(data, type, isStation) {
const list = this.addModel.parkSectionCodeList;
if (data && data.stationCode && data.sectionCode) {
const index = list.findIndex(elem => { return elem.sectionCode == data.sectionCode; });
switch (type) {
case 'center': {
if (index < 0) {
list.splice(list.length - 1, 0, data);
} else {
this.$messageBox('该区段已经在交路区段中存在');
}
break;
}
case 'top': {
if (isStation) {
list.splice(0, 1, data);
} else {
if (index < 0) {
list.splice(0, 1, data);
} else {
if (index == list.length - 1 && list.length >= 2) {
this.addModel.startSectionCode = list[0].sectionCode;
this.addModel.startStationCode = list[0].stationCode;
this.$messageBox('起始区段和终到区段不能相同');
} else if (index != list.length - 1 && index != 0) {
this.$messageBox('该区段已经在交路区段中存在');
}
}
}
break;
}
case 'bottom': {
if (isStation) {
if (list.length >= 2) {
list.splice(list.length - 1, 1, data);
} else {
if (index < 0) {
list.push(data);
}
}
} else {
if (index < 0) {
if (list.length >= 2) {
list.splice(list.length - 1, 1, data);
} else {
list.push(data);
}
} else {
if (index == 0 && list.length >= 2) {
this.addModel.endSectionCode = list[list.length - 1].sectionCode;
this.addModel.endStationCode = list[list.length - 1].stationCode;
this.$messageBox('起始区段和终到区段不能相同');
} else if (index != list.length - 1 && index != 0) {
this.$messageBox('该区段已经在交路区段中存在');
}
}
}
break;
}
default: {
if (index < 0) {
list.splice(list.length - 1, 0, data);
} else {
this.$messageBox(this.$t('tip.routeSameID'));
}
break;
}
}
this.sectionCode = '';
this.stationCode = '';
}
}
}
};
</script>
<style lang="scss" scoped>
.mapEdit_box{
float: right;
padding: 3px 0;
margin-right: 5px;
}
</style>

View File

@ -0,0 +1,207 @@
<template>
<div class="runPlanConfig">
<div class="reentryConfig">折返配置</div>
<div class="reentryConfigTable">
<div style="margin-bottom:10px;">
<span>区段:</span>
<el-select v-model="sectionCode" clearable :filterable="true" :placeholder="$t('map.pleaseSelect')" size="small">
<el-option
v-for="item in filterReentrySection"
:key="item.code"
:label="`${item.name}(${item.code})`"
:value="item.code"
/>
</el-select>
<el-button
size="small"
:type=" field === 'reentrySection' ? 'danger' : 'primary'"
@click="hover('reentrySection')"
>{{ $t('map.activate') }}</el-button>
<el-button
type="primary"
size="small"
@click="pushSection(sectionCode)"
>
{{ $t('map.add') }}
</el-button>
</div>
<el-table
:data="sectionCodeList"
border
style="width:87%"
height="300"
class="el-parkSectionCode-table"
>
<el-table-column prop="sectionCode" :label="$t('map.sectionName')">
<template slot-scope="scope">
<span>{{ formatName(scope.row.sectionCode) }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('map.operation')" width="150">
<template slot-scope="scope">
<el-button
type="text"
size="small"
@click.native.prevent="deleteSection(sectionCodeList, scope.$index)"
>
{{ $t('map.remove') }}
</el-button>
</template>
</el-table-column>
</el-table>
<el-button-group style="padding:10px">
<el-button type="primary" size="small" :loading="loading" @click="save">{{ $t('map.save') }}
</el-button>
</el-button-group>
</div>
</div>
</template>
<script>
import { mapGetters } from 'vuex';
import { formatName } from '@/utils/runPlan';
import { addRunplanConfig, getRunplanConfig } from '@/api/jmap/mapdraft';
export default {
name:'RunPlanConfig',
data() {
return {
sectionCodeList:[],
sectionCode:'',
field:'',
loading:false
};
},
computed: {
...mapGetters('map', [
'sectionList'
]),
filterReentrySection() {
if (this.sectionList) {
return this.sectionList.filter(elem => { return elem.reentryTrack; });
} else {
return [];
}
}
},
methods:{
doShow() {
this.sectionCodeList = [];
this.sectionCode = '';
this.field = '';
this.loading = false;
getRunplanConfig(this.$route.query.mapId).then(resp => {
if (resp.data.config) {
const runPlanUserReentryData = resp.data.config.runPlanUserReentryData;
const runPlanUserReentryDataKey = Object.keys(runPlanUserReentryData);
if (runPlanUserReentryDataKey && runPlanUserReentryDataKey.length > 0) {
runPlanUserReentryDataKey.forEach(each=>{
this.sectionCodeList.push({stationCode:each, sectionCode:runPlanUserReentryData[each]});
});
//
// this.changeSectionSelected(this.sectionCodeList, true);
}
}
});
},
deleteSection(list, index) {
const data = list.splice(index, 1);
if (data.length > 0) {
const section = this.$store.getters['map/getDeviceByCode'](data[0].sectionCode);
section.instance.drawBatchSelected(section, '');
}
},
hover(field) {
this.field = field === this.field ? '' : field;
},
setSelected(selected) {
if (selected._type.toUpperCase() === 'Section'.toUpperCase() && this.field.toUpperCase() == 'reentrySection'.toUpperCase()) {
if (selected.reentryTrack) {
this.sectionCode = selected.code;
} else {
this.$message.error('请选择正确的区段');
}
}
},
formatName(code) {
return formatName(code);
},
pushSection(sectionCode) {
if (sectionCode) {
const index = this.sectionCodeList.findIndex(elem => { return elem.sectionCode == sectionCode; });
if (index < 0) {
const section = this.$store.getters['map/getDeviceByCode'](sectionCode);
let stationCode = '';
if (section && section.belongStation) {
stationCode = section.belongStation;
}
const sectionState = this.sectionCodeList.find(elem => { return elem.stationCode == stationCode; });
if (!sectionState) {
this.sectionCodeList.push({'sectionCode':sectionCode, 'stationCode':stationCode});
this.setSectionColor({'sectionCode':sectionCode}, 'routingSection');
} else {
this.$messageBox('一个车站只能添加一个折返区段');
}
} else {
this.$messageBox('该折返区段已添加');
}
}
},
setSectionColor(sectionParam, type) {
const section = this.$store.getters['map/getDeviceByCode'](sectionParam.sectionCode);
console.log(this.$store.state.map.mapDevice);
const list = section.logicSectionCodeList;
if (list && list.length > 0) {
list.forEach(logicSectionCode=>{
const logicSection = this.$store.getters['map/getDeviceByCode'](logicSectionCode);
logicSection.instance.drawBatchSelected(section, type);
});
} else {
// this.oldsection && this.oldsection.push(section);
section.instance.drawBatchSelected(section, type);
}
},
changeSectionSelected(selectedList, flag) {
if (selectedList && selectedList.length > 0) {
if (flag) {
selectedList.forEach(each=>{
this.setSectionColor({'sectionCode':each.sectionCode}, 'routingSection');
});
} else {
selectedList.forEach(each=>{
this.setSectionColor({'sectionCode':each.sectionCode}, '');
});
}
}
},
save() {
if (this.sectionCodeList.length > 0) {
this.loading = true;
const runPlanUserReentryData = {};
this.sectionCodeList.forEach(each=>{
runPlanUserReentryData[each.stationCode] = each.sectionCode;
});
addRunplanConfig(this.$route.query.mapId, {runPlanUserReentryData:runPlanUserReentryData}).then(resp => {
this.$message.success('折返区段配置成功');
this.loading = false;
}).catch((error) => {
this.$messageBox('折返区段配置失败' + ':' + error.message);
this.loading = false;
});
} else {
this.$messageBox('该添加折返区段');
}
},
clear() {
this.changeSectionSelected(this.sectionCodeList, false);
}
}
};
</script>
<style lang="scss" scoped>
.reentryConfig{
}
.reentryConfigTable{
margin-top: 10px;
}
.runPlanConfig{padding:15px 20px}
</style>