rt-sim-training-client/src/views/newMap/newMapdraft/dataRelation/turnedoperate/route.vue

347 lines
13 KiB
Vue
Raw Normal View History

2019-12-10 16:50:38 +08:00
<template>
<div style="height: 100%;">
<el-scrollbar wrap-class="scrollbar-wrapper">
<el-form ref="form" :model="addModel" :rules="rules" label-width="180px" size="mini">
<div class="definition">
2019-12-10 17:55:43 +08:00
<el-form-item label="折返名称:" prop="name">
2019-12-11 13:56:46 +08:00
<el-input v-model="addModel.name" style="width: 178px" />
2019-12-10 16:50:38 +08:00
</el-form-item>
<el-form-item label="所属车站:" prop="stationCode">
<el-select v-model="addModel.stationCode" filterable>
2019-12-11 13:56:46 +08:00
<el-option
v-for="item in stationList"
2019-12-11 13:56:46 +08:00
:key="item.code"
:label="item.name + ' (' + item.code+ ')'"
:value="item.code"
/>
</el-select>
2019-12-10 16:50:38 +08:00
</el-form-item>
<el-card style="width: 400px;position: relative; left: 80px; padding-top: 10px; margin-bottom: 20px">
<el-form-item label="折返进路:" prop="turnBackRouteName" label-width="100px">
2020-04-17 11:29:50 +08:00
<el-input v-model="addModel.turnBackRouteName" :readonly="true" style="width: 178px" />
<el-button type="primary" @click="selectedRoute('turnBackRoute')">选择</el-button>
</el-form-item>
<el-form-item label="基础进路:" prop="basicRouteName" label-width="100px">
2020-04-17 11:29:50 +08:00
<el-input v-model="addModel.basicRouteName" :readonly="true" style="width: 178px" />
<el-button type="primary" @click="selectedRoute('basicRoute')">选择</el-button>
</el-form-item>
<el-form-item label="折返区段:" prop="reentryTrackCode" label-width="100px">
<el-select v-model="addModel.reentryTrackCode" filterable>
<el-option
v-for="item in sectionList"
:key="item.code"
:label="item.name + ' (' + item.code+ ')'"
:value="item.code"
/>
</el-select>
<el-button
:type=" field === 'reentryTrackCode' ? 'danger' : 'primary'"
@click="hover('reentryTrackCode')"
>{{ $t('map.activate') }}</el-button>
</el-form-item>
<el-button
v-show="!showSecond"
icon="el-icon-plus"
style="position: absolute; right: 10px; bottom: 10px;"
size="small"
circle
class="point-button"
@click="setShowSecond(true)"
/>
</el-card>
<el-card v-show="showSecond" style="width: 400px;position: relative; left: 80px; padding-top: 10px; margin-bottom: 20px">
<el-form-item label="折返进路2:" prop="turnBackRoute2Name" label-width="100px">
2020-04-17 11:29:50 +08:00
<el-input v-model="addModel.turnBackRoute2Name" :readonly="true" style="width: 178px" />
<el-button type="primary" @click="selectedRoute('turnBackRoute2')">选择</el-button>
</el-form-item>
<el-form-item label="基础进路2:" prop="basicRoute2Name" label-width="100px">
2020-04-17 11:29:50 +08:00
<el-input v-model="addModel.basicRoute2Name" :readonly="true" style="width: 178px" />
<el-button type="primary" @click="selectedRoute('basicRoute2')">选择</el-button>
</el-form-item>
<el-form-item label="折返区段2:" prop="reentryTrack2Code" label-width="100px">
<el-select v-model="addModel.reentryTrack2Code" filterable>
<el-option
v-for="item in sectionList"
:key="item.code"
:label="item.name + ' (' + item.code+ ')'"
:value="item.code"
/>
</el-select>
<el-button
:type=" field === 'reentryTrack2Code' ? 'danger' : 'primary'"
@click="hover('reentryTrack2Code')"
>{{ $t('map.activate') }}</el-button>
</el-form-item>
<el-button
icon="el-icon-minus"
style="position: absolute; right: 10px; bottom: 10px;"
size="small"
circle
class="point-button"
@click="setShowSecond(false)"
/>
</el-card>
2019-12-10 16:50:38 +08:00
<el-form-item>
<el-button-group>
<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>
</el-scrollbar>
2019-12-11 13:56:46 +08:00
<route-detail ref="routeDetail" :map-info="mapInfo" @setRouteCode="setRouteCode" />
2019-12-10 16:50:38 +08:00
</div>
</template>
<script>
import { mapGetters } from 'vuex';
2019-12-20 13:48:37 +08:00
import { setUID } from '@/jmapNew/utils/Uid';
2019-12-11 13:56:46 +08:00
import { postAutoReentry, putAutoReentry, getRouteNewList } from '@/api/jmap/mapdraft';
2019-12-10 16:50:38 +08:00
import { ViewMode } from '@/scripts/ConstDic';
import { formatName } from '@/utils/runPlan';
2019-12-11 13:56:46 +08:00
import RouteDetail from '../routeoperate/detail';
import { deepAssign } from '@/utils/index';
2019-12-10 16:50:38 +08:00
export default {
name: 'RouteOperation',
2019-12-11 13:56:46 +08:00
components: {
RouteDetail
},
2019-12-10 16:50:38 +08:00
props: {
selected: {
type: Object,
default() {
return null;
}
},
mapInfo: {
type: Object,
default() {
return null;
}
},
routeData: {
type: Object,
default() {
return null;
}
}
},
data() {
return {
ViewMode: ViewMode,
field: '',
isSave: true,
loading: false,
showSecond: false,
2019-12-10 16:50:38 +08:00
addModel: {
id: '',
code: '',
mapId: '',
2019-12-10 17:55:43 +08:00
name: '',
2020-02-18 14:45:32 +08:00
stationCode: '',
2019-12-10 17:55:43 +08:00
turnBackRouteName: '',
basicRouteName:'',
turnBackRouteCode: '',
2019-12-11 13:56:46 +08:00
basicRouteCode:'',
2019-12-11 18:25:03 +08:00
priority: 0,
reentryTrackCode: '',
turnBackRoute2Name: '',
basicRoute2Name: '',
reentryTrack2Code: null,
turnBackRoute2Code: null,
basicRoute2Code: null
2019-12-10 16:50:38 +08:00
},
editShow: false,
rules: {
2019-12-10 17:55:43 +08:00
name: [
{ required: true, message: '请输入折返名称', trigger: 'blur' }
],
2020-02-18 14:45:32 +08:00
stationCode: [
{ required: true, message: '请选择所属车站', trigger: 'change'}
],
2019-12-11 13:56:46 +08:00
turnBackRouteName: [
2019-12-10 17:55:43 +08:00
{ required: true, message: '请选择折返进路', trigger: 'blur' }
2019-12-10 16:50:38 +08:00
],
2019-12-11 13:56:46 +08:00
basicRouteName: [
2019-12-10 17:55:43 +08:00
{ required: true, message: '请选择基础进路', trigger: 'blur'}
2019-12-11 13:56:46 +08:00
],
reentryTrackCode: [
{ required: true, message: '请选择折返区段', trigger: 'change'}
2019-12-10 16:50:38 +08:00
]
}
};
},
computed: {
...mapGetters('map', [
2020-02-18 14:45:32 +08:00
'sectionList',
'stationList'
2019-12-10 16:50:38 +08:00
])
},
watch: {
mapInfo(val) {
if (val) {
this.addModel.mapId = val.id;
}
},
routeData(val, old) {
if (val) {
2019-12-11 13:56:46 +08:00
this.handelRouteName(val);
2019-12-10 16:50:38 +08:00
this.editShow = true;
}
}
},
mounted() {
},
methods: {
hover(field) {
this.field = field === this.field ? '' : field;
},
formatName(code) {
return formatName(code);
},
2019-12-11 13:56:46 +08:00
selectedRoute(codeType) {
this.$refs.routeDetail.doShow('select', codeType);
},
2019-12-10 16:50:38 +08:00
setSelected(selected) {
if (selected) {
2019-12-11 13:56:46 +08:00
if (selected._type.toUpperCase() === 'Section'.toUpperCase() && this.field.toUpperCase() === 'reentryTrackCode'.toUpperCase()) {
this.addModel.reentryTrackCode = selected.code;
2020-03-09 18:35:01 +08:00
} else if (selected._type.toUpperCase() === 'Section'.toUpperCase() && this.field.toUpperCase() === 'reentryTrack2Code'.toUpperCase()) {
this.addModel.reentryTrack2Code = selected.code;
2019-12-10 16:50:38 +08:00
}
}
},
setShowSecond(flag) {
this.showSecond = flag;
2020-03-11 15:50:47 +08:00
if (flag) {
this.rules.turnBackRoute2Name = [{ required: true, message: '请选择折返进路2', trigger: 'blur' }];
this.rules.basicRoute2Name = [{ required: true, message: '请选择基础进路2', trigger: 'blur'}];
this.rules.reentryTrack2Code = [{ required: true, message: '请选择折返区段2', trigger: 'change'}];
} else {
delete this.rules.turnBackRoute2Name;
delete this.rules.basicRoute2Name;
delete this.rules.reentryTrack2Code;
}
},
2019-12-10 16:50:38 +08:00
buildModel(code) {
const model = Object.assign({}, this.addModel);
if (code) { model['code'] = code; }
model['mapId'] = this.mapInfo.id;
return model;
},
save() {
this.$refs.form.validate((valid) => {
if (valid) {
this.loading = true;
2019-12-20 13:48:37 +08:00
postAutoReentry(this.buildModel(setUID('TurnedAround'))).then(resp => {
2019-12-11 13:56:46 +08:00
this.$message.success('创建折返成功!');
2019-12-10 16:50:38 +08:00
this.loading = false;
this.clear();
}).catch(() => {
2019-12-11 13:56:46 +08:00
this.$messageBox('创建折返失败!');
2019-12-10 16:50:38 +08:00
this.loading = false;
});
}
});
},
update() {
this.$refs.form.validate((valid) => {
if (valid) {
this.loading = true;
2019-12-11 13:56:46 +08:00
putAutoReentry(this.buildModel()).then(resp => {
this.$message.success('更新折返成功!');
2019-12-10 16:50:38 +08:00
this.loading = false;
this.clear();
}).catch(() => {
2019-12-11 13:56:46 +08:00
this.$messageBox('更新折返失败!');
2019-12-10 16:50:38 +08:00
this.loading = false;
});
}
});
},
clear() {
if (this.$refs && this.$refs.form && this.mapInfo) {
delete this.addModel.id;
2019-12-11 13:56:46 +08:00
this.addModel.basicRouteName = '';
this.addModel.basicRouteCode = '';
this.addModel.turnBackRouteName = '';
this.addModel.turnBackRouteCode = '';
this.addModel.turnBackRoute2Name = '';
this.addModel.basicRoute2Name = '';
this.addModel.reentryTrack2Code = null;
this.addModel.turnBackRoute2Code = null;
this.addModel.basicRoute2Code = null;
2020-02-18 14:45:32 +08:00
this.addModel.stationCode = '';
2019-12-10 16:50:38 +08:00
this.addModel.mapId = this.mapInfo.id;
this.addModel.code = '';
2019-12-11 13:56:46 +08:00
this.$refs.form.resetFields();
2019-12-10 16:50:38 +08:00
this.isSave = true;
2020-03-11 15:50:47 +08:00
this.showSecond = false;
2019-12-10 16:50:38 +08:00
}
2019-12-11 13:56:46 +08:00
},
setRouteCode(data, type) {
if (type === 'basicRoute') {
this.addModel.basicRouteName = data.name;
this.addModel.basicRouteCode = data.code;
} else if (type === 'turnBackRoute') {
this.addModel.turnBackRouteName = data.name;
this.addModel.turnBackRouteCode = data.code;
} else if (type === 'basicRoute2') {
this.addModel.basicRoute2Name = data.name;
this.addModel.basicRoute2Code = data.code;
} else if (type === 'turnBackRoute2') {
this.addModel.turnBackRoute2Name = data.name;
this.addModel.turnBackRoute2Code = data.code;
2019-12-11 13:56:46 +08:00
}
},
async handelRouteName(data) {
const model = {
reentryTrack2Code: null,
turnBackRoute2Code: null,
basicRoute2Code: null
};
const resp1 = await getRouteNewList(this.$route.params.mapId, {pageSize:9999, pageNum:1});
if (resp1 && resp1.code == '200') {
resp1.data.list.forEach(item => {
if (item.code === data.turnBackRouteCode) {
model.turnBackRouteName = item.name;
} else if (item.code === data.basicRouteCode) {
model.basicRouteName = item.name;
} else if (item.code === data.turnBackRoute2Code) {
model.turnBackRoute2Name = item.name;
} else if (item.code === data.basicRoute2Code) {
model.basicRoute2Name = item.name;
}
});
} else {
this.$messageBox('获取进路列表失败!');
}
2019-12-11 13:56:46 +08:00
this.addModel = deepAssign(model, data);
2019-12-10 16:50:38 +08:00
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
/deep/ .el-radio {
margin-right: 10px;
}
/deep/ {
.el-select .el-tag {
height: auto;
display: flex;
align-items: center;
justify-content: center;
padding-right: 15px;
box-sizing: border-box;
white-space: normal;
}
.el-input__suffix{
right: 2px;
}
}
</style>