rt-sim-training-client/src/views/newMap/newMapdraft/mapoperate/station.vue

448 lines
22 KiB
Vue
Raw Normal View History

2019-11-29 12:51:58 +08:00
<template>
<el-tabs v-model="activeName" class="card">
2020-04-30 14:50:27 +08:00
<el-tab-pane class="view-control" :label="$t('map.property')" name="first" :lazy="lazy">
2020-07-16 10:50:59 +08:00
<div class="view-control-content">
2019-11-29 12:51:58 +08:00
<el-scrollbar wrap-class="scrollbar-wrapper">
<config-list ref="dataform" :form="form" :form-model="editModel" :rules="rules" />
</el-scrollbar>
</div>
<div class="button_box">
<el-button-group class="map-draft-group">
<el-button type="primary" size="small" @click="edit">{{ $t('map.updateObj') }}</el-button>
<el-button type="danger" size="small" @click="deleteObj">{{ $t('map.deleteObj') }}</el-button>
</el-button-group>
</div>
</el-tab-pane>
2020-04-30 14:50:27 +08:00
<el-tab-pane class="view-control" :label="$t('map.newConstruction')" name="second" :lazy="lazy">
2020-07-16 10:50:59 +08:00
<div class="view-control-content">
2019-11-29 12:51:58 +08:00
<el-scrollbar wrap-class="scrollbar-wrapper">
2019-12-05 18:01:09 +08:00
<el-button
2019-12-06 10:31:19 +08:00
icon="el-icon-plus"
circle
2019-12-05 18:01:09 +08:00
size="small"
2019-12-06 10:31:19 +08:00
style="position: absolute; right: 50px; top: 0px; z-index: 10;"
class="point-button"
@click="addModelList"
/>
2019-11-29 12:51:58 +08:00
<el-form ref="make" label-width="140px" :model="addModel" size="mini" :rules="mergeRules">
2019-12-05 18:01:09 +08:00
<el-form-item label="距区段高度:" prop="positionY">
<el-input-number v-model="addModel.positionY" />
2019-11-29 12:51:58 +08:00
</el-form-item>
2019-12-05 18:01:09 +08:00
<el-table :data="addModel.modelList" style="width: 100%">
2019-12-06 10:31:19 +08:00
<el-table-column label="计轴区段" prop="sectionName" width="160">
<template slot-scope="scope">
<el-select v-model="scope.row.sectionCode" filterable size="mini" placeholder="请选择">
<el-option
v-for="item in PhysicalSectionList"
:key="item.code"
:label="item.name + '(' + item.code +')'"
:value="item.code"
/>
</el-select>
</template>
</el-table-column>
2019-12-05 18:01:09 +08:00
<el-table-column label="车站名称">
<template slot-scope="scope">
<el-input v-model="scope.row.stationName" placeholder="请输入内容" size="mini" />
</template>
</el-table-column>
<el-table-column label="控制模式">
<template slot-scope="scope">
<el-checkbox v-model="scope.row.control" />
</template>
</el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button size="mini" type="text" @click="handleDelete(scope.$index, scope.row)">{{ $t('map.deleteObj') }}</el-button>
</template>
</el-table-column>
</el-table>
2019-11-29 12:51:58 +08:00
</el-form>
</el-scrollbar>
</div>
<div class="button_box">
<el-button-group class="map-draft-group">
<el-button type="primary" size="small" @click="create">{{ $t('map.create') }}</el-button>
</el-button-group>
</div>
</el-tab-pane>
2020-04-30 14:50:27 +08:00
<el-tab-pane class="view-control" :label="$t('map.batchSettings')" name="three" :lazy="lazy">
<div style="height: 100%;">
<el-scrollbar wrap-class="scrollbar-wrapper">
<el-form ref="oprt" :model="allModel" label-width="130px" size="mini">
2020-05-25 15:06:34 +08:00
<el-form-item label="车站字体大小:" prop="nameFont">
<el-font v-model="allModel.nameFont" :placeholder="this.$t('tip.stationFont')" />
</el-form-item>
2020-05-25 15:06:34 +08:00
<el-form-item label="公里标字体大小:" prop="kmPostFont">
<el-font v-model="allModel.kmPostFont" :placeholder="this.$t('tip.stationFont')" />
</el-form-item>
<el-form-item label="车站Y坐标:" prop="positionY">
<el-input-number v-model="allModel.positionY" />
</el-form-item>
<el-form-item>
<el-button-group>
<el-button type="primary" @click="batchSettings">{{ $t('global.set') }}</el-button>
</el-button-group>
</el-form-item>
</el-form>
</el-scrollbar>
</div>
</el-tab-pane>
2019-11-29 12:51:58 +08:00
</el-tabs>
</template>
<script>
import ElFont from '@/views/components/font/index';
2019-11-29 12:51:58 +08:00
import { mapGetters } from 'vuex';
2019-12-06 10:31:19 +08:00
import { getUID } from '@/jmapNew/utils/Uid';
2019-11-29 12:51:58 +08:00
import ConfigList from './config/list';
import { deepAssign } from '@/utils/index';
2020-07-01 18:08:42 +08:00
import getModel from './models.js';
2019-11-29 12:51:58 +08:00
export default {
name: 'StationDraft',
components: {
ConfigList,
ElFont
2019-11-29 12:51:58 +08:00
},
props: {
selected: {
type: Object,
default: function () {
return null;
}
}
},
data() {
return {
activeName: 'first',
2020-04-30 14:50:27 +08:00
lazy: true,
2019-12-06 10:31:19 +08:00
// field: '',
2019-12-03 13:24:22 +08:00
chargeStation:[],
relStationList: [], // 车站列表
controlled:false,
2020-07-01 18:08:42 +08:00
editModel: getModel('Station'),
2019-11-29 12:51:58 +08:00
addModel: {
2019-12-05 18:01:09 +08:00
modelList: [],
positionY: 0
2019-11-29 12:51:58 +08:00
},
skins: [],
mergeRules: {
2019-12-05 18:01:09 +08:00
positionY: [
{ required: true, message: '请输入高度值', trigger: 'blur' }
2019-11-29 12:51:58 +08:00
]
},
allModel: {
nameFont: '',
kmPostFont: '',
positionY: 0
2019-11-29 12:51:58 +08:00
}
};
},
computed: {
...mapGetters('map', [
'stationList',
'sectionList',
'zcList',
2019-12-03 14:56:18 +08:00
'lineCode',
'stationStandList'
2019-11-29 12:51:58 +08:00
]),
form() {
return {
labelWidth: '130px',
items: {
code: {
name: '',
item: []
},
draw: {
name: this.$t('map.drawData'),
item: [
{ prop: 'code', label: this.$t('map.stationCode'), type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.stationList, change: true, deviceChange: this.deviceChange },
{ prop: 'name', label: this.$t('map.stationName'), type: 'input' },
2019-12-13 14:58:28 +08:00
{ prop: 'number', label: this.$t('map.stationNumber'), type: 'input' },
2019-11-29 12:51:58 +08:00
{ prop: 'position', label: this.$t('map.stationPosition'), type: 'coordinate', width: '120px', children: [
{ prop: 'position.x', firstLevel: 'position', secondLevel: 'x', label: 'x:', type: 'number', labelWidth: '25px' },
{ prop: 'position.y', firstLevel: 'position', secondLevel: 'y', label: 'y:', type: 'number', labelWidth: '25px' }
] },
{ prop: 'visible', label: this.$t('map.stationstandShowName'), type: 'checkbox' },
{ prop: 'nameFont', label: this.$t('map.stationNameFont'), type: 'font', placeholder: this.$t('tip.stationFont') },
{ prop: 'nameFontColor', label: this.$t('map.stationNameFontColor'), type: 'color' },
2019-12-13 16:13:10 +08:00
{ prop: 'subheadDisplay', label: this.$t('map.subheadDisplay'), type: 'checkbox' },
{ prop: 'subhead', label: this.$t('map.subhead'), type: 'input', isHidden:!this.editModel.subheadDisplay },
{ prop: 'subheadFont', label: this.$t('map.subheadFont'), type: 'font', isHidden:!this.editModel.subheadDisplay },
{ prop: 'subheadFontColor', label: this.$t('map.subheadFontColor'), type: 'color', isHidden:!this.editModel.subheadDisplay },
{ prop: 'subheadPosition', label: this.$t('map.subheadPosition'), type: 'coordinate', width: '120px', isHidden:!this.editModel.subheadDisplay, children: [
{ prop: 'subheadPosition.x', firstLevel: 'subheadPosition', secondLevel: 'x', label: 'x:', type: 'number', labelWidth: '25px' },
{ prop: 'subheadPosition.y', firstLevel: 'subheadPosition', secondLevel: 'y', label: 'y:', type: 'number', labelWidth: '25px' }
] },
{ prop: 'depot', label: this.$t('map.isParkingArea'), type: 'checkbox' },
2020-05-28 18:17:15 +08:00
{ prop: 'reentry', label: this.$t('map.isReentryStation'), type: 'checkbox' }, // 是否折返车站
{ prop: 'smallRouting', label: '是否小交路:', type: 'checkbox', isHidden:!this.isReentry },
{ prop: 'kilometerPosition', label: '公里标偏移坐标:', type: 'coordinate', width: '120px', children: [
{ prop: 'kilometerPosition.x', firstLevel: 'kilometerPosition', secondLevel: 'x', label: 'x:', type: 'number', labelWidth: '25px' },
{ prop: 'kilometerPosition.y', firstLevel: 'kilometerPosition', secondLevel: 'y', label: 'y:', type: 'number', labelWidth: '25px' }
] },
2019-11-29 12:51:58 +08:00
{ prop: 'kmRange', label: this.$t('map.stationKmRange'), type: 'number', min: 0, placeholder: this.$t('tip.meter') },
{ prop: 'kmPost', label: this.$t('map.stationKmPost'), type: 'input' },
{ prop: 'kmPostFont', label: this.$t('map.stationKmPostFont'), type: 'font', placeholder: this.$t('tip.kilometerFont') },
2019-12-04 18:39:28 +08:00
{ prop: 'kmPostFontColor', label: this.$t('map.stationKmPostFontColor'), type: 'color' },
{ prop: 'createControlMode', label: '控制模式:', type: 'checkbox' },
2019-12-18 13:05:29 +08:00
{ prop: 'controlModePoint', label: this.$t('map.stationControlPosition'), type: 'coordinate', width: '120px', isHidden:!this.editModel.createControlMode, children: [
2019-12-05 10:19:41 +08:00
{ prop: 'controlModePoint.x', firstLevel: 'controlModePoint', secondLevel: 'x', label: 'x:', type: 'number', labelWidth: '25px'},
{ prop: 'controlModePoint.y', firstLevel: 'controlModePoint', secondLevel: 'y', label: 'y:', type: 'number', labelWidth: '25px'}
] },
2019-12-18 13:05:29 +08:00
{ prop: 'createTurnBack', label: '按图折返:', type: 'checkbox' },
2019-12-06 10:31:19 +08:00
{ prop: 'turnBackPoint', label: '按图折返坐标:', type: 'coordinate', width: '120px', isHidden: !this.isPointsShow, children: [
{ prop: 'turnBackPoint.x', firstLevel: 'turnBackPoint', secondLevel: 'x', label: 'x:', type: 'number', labelWidth: '25px' },
{ prop: 'turnBackPoint.y', firstLevel: 'turnBackPoint', secondLevel: 'y', label: 'y:', type: 'number', labelWidth: '25px' }
2020-04-14 15:45:13 +08:00
] }
2019-11-29 12:51:58 +08:00
]
},
map: {
name: this.$t('map.mapData'),
item: [
2019-12-18 13:05:29 +08:00
{ prop: 'ciStation', label: this.$t('map.isCIStation'), type: 'checkbox'},
{ prop: 'centralized', label: this.$t('map.centralized'), type: 'checkbox', disabled:this.controlled },
2019-12-17 19:03:38 +08:00
{ prop: 'zcCode', label: this.$t('map.zcCode'), type: 'select', optionLabel: 'code&&name', optionValue: 'code', options: this.zcList, isHidden: !this.isZcCode, disabled:true },
{ prop: 'chargeStationCodeList', label: '管理车站列表:', type: 'multiSelect', optionLabel: 'name', optionValue: 'code', options: this.chargeStation, isHidden: !this.isZcCode },
{ prop: 'relStationCodeList', label: '联锁站关联车站:', type: 'multiSelect', optionLabel: 'name', optionValue: 'code', options: this.relStationList, isHidden: !this.idCiStation},
2019-12-04 18:39:28 +08:00
{ prop: 'runPlanName', label: this.$t('map.stationRunPlanName'), type: 'input' }
2019-11-29 12:51:58 +08:00
]
}
}
};
},
rules() {
return {
code: [
{ required: true, message: this.$t('rules.selectEquipment'), trigger: 'change' }
],
name: [
{ required: true, message: this.$t('rules.stationName'), trigger: 'blur' }
],
kmRange: [
{ required: true, message: this.$t('rules.stationKmRange'), trigger: 'blur' }
],
kmPost: [
{ required: true, message: this.$t('rules.stationKmPost'), trigger: 'blur' }
],
'position.x': [
{ required: true, message: this.$t('rules.pleaseEnterXCoordinate'), trigger: 'blur' }
],
'position.y': [
{ required: true, message: this.$t('rules.pleaseEnterYCoordinate'), trigger: 'blur' }
]
};
},
PhysicalSectionList() {
2020-07-03 11:11:57 +08:00
return this.sectionList.filter(elem => { return elem.type === '01' && !elem.switchSection; });
2019-11-29 12:51:58 +08:00
},
2019-12-05 10:25:07 +08:00
isPointsShow() {
2019-12-18 13:05:29 +08:00
return this.editModel.createTurnBack;
2019-12-05 10:25:07 +08:00
},
2019-11-29 12:51:58 +08:00
isZcCode() {
return this.editModel.centralized;
},
idCiStation() {
return this.editModel.ciStation;
2020-05-28 18:17:15 +08:00
},
isReentry() {
return this.editModel.reentry;
2019-11-29 12:51:58 +08:00
}
},
methods: {
deviceChange(code) {
this.$emit('setCenter', code);
this.deviceSelect(this.$store.getters['map/getDeviceByCode'](code));
},
deviceSelect(selected) {
2019-12-06 10:31:19 +08:00
if (selected && selected._type.toUpperCase() === 'Station'.toUpperCase()) {
2020-07-01 18:08:42 +08:00
this.editModel = getModel('Station');
2020-05-18 17:08:21 +08:00
this.$refs.dataform && this.$refs.dataform.resetFields();
2019-11-29 12:51:58 +08:00
this.activeName = 'first';
this.editModel = deepAssign(this.editModel, selected);
2019-12-17 19:03:38 +08:00
// 被控制的车站数据
const beCentralizedStation = {};
this.relStationList = JSON.parse(JSON.stringify(this.stationList));
this.stationList.forEach(data=>{
2019-12-17 19:03:38 +08:00
if (data.centralized) {
data.chargeStationCodeList.forEach(charge=>{
2019-12-17 19:03:38 +08:00
beCentralizedStation[charge] = data.code;
});
}
if (data.ciStation && data.code != this.selected.code) {
const arr = data.relStationCodeList || [];
arr.forEach(stationCode => {
this.relStationList.forEach((data, index) => {
if (data.code == stationCode) {
this.relStationList.splice(index, 1);
}
});
});
}
});
2019-12-03 14:56:18 +08:00
// 筛选数据 去掉已经是集中站的数据,去掉自己本身,去掉被别的集中站选中的数据
2019-12-03 13:24:22 +08:00
this.chargeStation = this.stationList.filter(data=>{
return !data.centralized && data.code != this.editModel.code && !(beCentralizedStation[data.code] && beCentralizedStation[data.code] != this.editModel.code);
2019-12-03 13:24:22 +08:00
});
2019-12-17 19:03:38 +08:00
this.controlled = !!beCentralizedStation[selected.code];
2019-11-29 12:51:58 +08:00
}
},
2019-12-03 14:56:18 +08:00
// 选择管理车站
changeChargeStation(list) {
let lists = [];
if (list.length > 0) {
2019-12-03 13:24:22 +08:00
this.chargeStation.forEach(station=>{
lists = lists.concat(this.setStationStand(station, ''));
list.forEach(each=>{
2019-12-03 13:24:22 +08:00
switch (each) {
case station.code: {
lists = lists.concat(this.setStationStand(station, this.editModel.code));
2019-12-03 13:24:22 +08:00
break;
}
}
});
});
} else {
2019-12-03 15:22:16 +08:00
// 没有选中数据,直接将其他车站设置为非控制
lists = lists.concat(this.modifyChargeStation());
2019-12-03 13:24:22 +08:00
}
return lists;
2019-12-03 13:24:22 +08:00
},
changeCentralized(data) {
let list = [];
if (!data) { // 将当前车站选为非集中站
2019-12-03 13:24:22 +08:00
this.editModel.chargeStationCodeList = [];
const arr = this.modifyChargeStation();
const arr1 = this.setStationStand(this.editModel, '');
list = [...arr, ...arr1];
2019-12-03 17:52:39 +08:00
} else {
list = list.concat(this.setStationStand(this.editModel, this.editModel.code));
2019-12-03 13:24:22 +08:00
}
return list;
2019-12-03 13:24:22 +08:00
},
2019-12-03 15:22:16 +08:00
modifyChargeStation() {
let list = [];
2019-12-03 14:56:18 +08:00
this.chargeStation.forEach(station=>{
list = list.concat(this.setStationStand(station, ''));
2019-12-03 14:56:18 +08:00
});
return list;
2019-12-03 14:56:18 +08:00
},
// 设置站台 {设备集中站}
2019-12-03 15:22:16 +08:00
setStationStand(station, code) {
const list = [];
2019-12-03 14:56:18 +08:00
this.stationStandList.forEach(elem=>{
2019-12-03 15:22:16 +08:00
if (elem.stationCode == station.code) {
const stationStand = deepAssign({}, elem);
2019-12-03 15:22:16 +08:00
stationStand.deviceStationCode = code;
list.push(stationStand);
2019-12-03 14:56:18 +08:00
}
});
return list;
2019-12-03 14:56:18 +08:00
},
2019-11-29 12:51:58 +08:00
create() {
this.$refs['make'].validate((valid) => {
if (valid) {
2019-12-05 18:01:09 +08:00
if (this.addModel.modelList.length) {
const models = [];
2019-12-05 18:01:09 +08:00
this.addModel.modelList.forEach((item) => {
2019-12-06 13:56:18 +08:00
const uid = getUID('Station', [...this.stationList, ...models]);
2020-07-01 18:08:42 +08:00
const stationModel = getModel('Station');
const data = {
code: uid,
2019-12-05 18:01:09 +08:00
name: item.stationName,
2020-07-01 18:08:42 +08:00
createControlMode: item.control
};
2020-07-01 18:08:42 +08:00
const model = Object.assign(stationModel, data);
2020-07-03 11:11:57 +08:00
const sectionModel = this.$store.getters['map/getDeviceByCode'](item.sectionCode);
const last = sectionModel.points.length - 1;
model.position = {
x: sectionModel.points[0].x + (sectionModel.points[last].x - sectionModel.points[0].x) / 2,
y: sectionModel.points[0].y - this.addModel.positionY
};
if (item.control) {
model.controlModePoint = {
x: sectionModel.points[0].x + (sectionModel.points[last].x - sectionModel.points[0].x) / 2,
y: sectionModel.points[0].y - this.addModel.positionY + 30
};
}
models.push(model);
2019-11-29 12:51:58 +08:00
});
this.$emit('updateMapModel', models);
2019-12-05 18:01:09 +08:00
this.addModel = {
modelList: [],
positionY: 0
};
} else {
this.$message('请添加数据');
2019-11-29 12:51:58 +08:00
}
}
});
},
// 修改对象
edit() {
this.$refs['dataform'].validate((valid) => {
if (valid) {
const list = this.changeChargeStation(this.editModel.chargeStationCodeList);
let centralizedList = [];
if (this.editModel.centralized != this.selected.centralized) {
centralizedList = this.changeCentralized(this.editModel.centralized);
}
const models = [this.editModel, ...list, ...centralizedList];
this.$emit('updateMapModel', models);
2019-11-29 12:51:58 +08:00
}
});
},
// 删除对象
deleteObj() {
const selected = this.$store.getters['map/getDeviceByCode'](this.editModel.code);
2020-07-03 11:11:57 +08:00
if (selected && selected._type == 'Station') {
2019-11-29 12:51:58 +08:00
this.$confirm(this.$t('tip.confirmDeletion'), this.$t('tip.hint'), {
confirmButtonText: this.$t('tip.confirm'),
cancelButtonText: this.$t('tip.cancel'),
type: 'warning'
}).then(() => {
2020-05-18 17:08:21 +08:00
this.$emit('updateMapModel', {...selected, _dispose: true});
this.$refs.dataform && this.$refs.dataform.resetFields();
2019-11-29 12:51:58 +08:00
}).catch(() => {
2020-05-18 17:08:21 +08:00
this.$message.info(this.$t('tip.cancelledDelete'));
2019-11-29 12:51:58 +08:00
});
}
2019-12-05 10:25:07 +08:00
},
// 批量设置
batchSettings() {
2020-03-17 16:12:15 +08:00
const models = [];
this.stationList.forEach(station => {
const model = deepAssign({}, station);
model.nameFont = this.allModel.nameFont;
model.kmPostFont = this.allModel.kmPostFont;
model.position.y = this.allModel.positionY;
models.push(model);
2020-03-17 16:12:15 +08:00
});
this.$emit('updateMapModel', models);
},
2019-12-05 18:01:09 +08:00
handleDelete(index, row) {
this.addModel.modelList.splice(index, 1);
2019-12-06 10:31:19 +08:00
},
addModelList() {
this.addModel.modelList.push({
sectionCode: '',
sectionName: '',
stationName: `车站 ${this.addModel.modelList.length + 1}`,
control: false
});
2019-11-29 12:51:58 +08:00
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
.card {
height: 100%;
}
</style>