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

399 lines
18 KiB
Vue
Raw Normal View History

2019-11-29 12:51:58 +08:00
<template>
<el-tabs v-model="activeName" class="card">
<el-tab-pane class="view-control" :label="$t('map.property')" name="first">
<div style="height: calc(100% - 46px);">
<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>
<el-tab-pane class="view-control" :label="$t('map.newConstruction')" name="second">
<div style="height: calc(100% - 46px);">
<el-scrollbar wrap-class="scrollbar-wrapper">
<el-form ref="make" label-width="140px" :model="addModel" size="mini" :rules="mergeRules">
<el-form-item :label="$t('map.physicalSegmentName')" prop="sectionCode">
<el-select v-model="addModel.sectionCode" multiple filterable style="width:300px;">
2019-11-29 12:51:58 +08:00
<el-option
v-for="item in PhysicalSectionList"
:key="item.code"
:label="item.name + ' (' + item.code+ ')'"
:value="item.code"
/>
</el-select>
<el-button
:type="field === 'selectStationCode' ? 'danger' : 'primary'"
size="small"
@click="hover('selectStationCode')"
>{{ $t('map.activate') }}</el-button>
</el-form-item>
</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>
</el-tabs>
</template>
<script>
import { mapGetters } from 'vuex';
import { getUID } from '@/jmap/utils/Uid';
import ConfigList from './config/list';
import { deepAssign } from '@/utils/index';
export default {
name: 'StationDraft',
components: {
ConfigList
},
props: {
selected: {
type: Object,
default: function () {
return null;
}
}
},
data() {
return {
activeName: 'first',
field: '',
2019-12-03 13:24:22 +08:00
chargeStation:[],
2019-11-29 12:51:58 +08:00
editModel: {
centralized: false,
concentrateStationCode: '',
code: '',
zcCode: '',
visible: true,
runPlanName: '',
name: '',
nameFont: '',
nameFontColor: '#FFFFFF',
kmPostShow: '',
kmRange: 0,
kmPost: '',
kmPostFont: '',
kmPostFontColor: '#FFFFFF',
isShowControlMode: '',
2019-12-03 13:24:22 +08:00
chargeStationCodeList:[],
2019-12-04 14:59:04 +08:00
position: { x: 0, y: 0 },
2019-12-04 14:41:08 +08:00
controlled:false,
isCreateControlMode:false,
2019-12-04 18:39:28 +08:00
isCreateTurnBack:false,
2019-12-05 10:25:07 +08:00
turnBackList: [{x: 0, y: 0}], // 按图折返坐标
2019-12-04 18:39:28 +08:00
controlModePoint: { x: 0, y: 0 } // 控制模式坐标
2019-11-29 12:51:58 +08:00
},
addModel: {
sectionCode: []
2019-11-29 12:51:58 +08:00
},
skins: [],
mergeRules: {
sectionCode: [
{ required: true, message: this.$t('rules.selectPhysicalExtentName'), trigger: 'blur' }
]
}
};
},
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' },
{ 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' },
{ 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' },
2019-12-05 10:19:41 +08:00
{ prop: 'isCreateControlMode', label: '控制模式:', type: 'checkbox', change:true, deviceChange:this.changeControlMode},
{ prop: 'controlModePoint', label: this.$t('map.stationControlPosition'), type: 'coordinate', width: '150px', isHidden:!this.editModel.isCreateControlMode, children: [
{ 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-05 10:25:07 +08:00
{ prop: 'isCreateTurnBack', label: '按图折返:', type: 'checkbox' },
{ prop: 'turnBackList', label: '按图折返坐标', type: 'coordinatePoint', width: '110px', isHidden: !this.isPointsShow, addPoint: this.addPoint, delPoint: this.delPoint }
2019-11-29 12:51:58 +08:00
]
},
map: {
name: this.$t('map.mapData'),
item: [
2019-12-03 13:24:22 +08:00
{ prop: 'concentrateStationCode', label: this.$t('map.concentrateStationCode'), type: 'select', optionLabel: 'code&&name', optionValue: 'code', options: this.stationList, disabled:this.editModel.controlled },
{ prop: 'centralized', label: this.$t('map.centralized'), type: 'checkbox', disabled:this.editModel.controlled, change:true, deviceChange:this.changeCentralized },
2019-11-29 12:51:58 +08:00
{ prop: 'zcCode', label: this.$t('map.zcCode'), type: 'select', optionLabel: 'code&&name', optionValue: 'code', options: this.zcList, isHidden: !this.isZcCode },
2019-12-03 13:24:22 +08:00
{ prop: 'chargeStationCodeList', label: this.$t('map.chargeStationList'), type: 'multiSelect', optionLabel: 'name', optionValue: 'code', options: this.chargeStation, isHidden: !this.isZcCode, deviceChange:this.changeChargeStation},
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() {
let list = [];
if (this.sectionList && this.sectionList.length) {
list = this.sectionList.filter(elem => { return elem.type === '01' && !elem.isSwitchSection; });
}
return list;
},
2019-12-05 10:25:07 +08:00
isPointsShow() {
return this.editModel.isCreateTurnBack;
},
2019-11-29 12:51:58 +08:00
isZcCode() {
return this.editModel.centralized;
}
},
watch: {
selected: function (val) {
this.deviceSelect(val);
}
},
methods: {
deviceChange(code) {
this.$emit('setCenter', code);
this.deviceSelect(this.$store.getters['map/getDeviceByCode'](code));
},
deviceSelect(selected) {
2019-12-04 13:00:24 +08:00
// this.$refs.make.resetFields();
if (this.field.toUpperCase() != 'selectStationCode'.toUpperCase() && selected && selected._type.toUpperCase() === 'Station'.toUpperCase()) {
2019-12-04 13:38:32 +08:00
this.$refs.dataform.resetFields();
2019-11-29 12:51:58 +08:00
this.activeName = 'first';
this.editModel = deepAssign(this.editModel, selected);
this.editModel.runPlanName = selected.runPlanName || '';
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 && !(data.controlled && data.concentrateStationCode != this.editModel.code);
});
2019-11-29 12:51:58 +08:00
}
2019-12-04 13:00:24 +08:00
if (selected && selected._type.toUpperCase() === 'Section'.toUpperCase() && this.field.toUpperCase() === 'selectStationCode'.toUpperCase()) {
if (selected.type == '01') {
this.addModel.sectionCode.push(selected.code);
2019-12-04 13:00:24 +08:00
this.activeName = 'second';
this.field = '';
this.$emit('stationSectionCode', '');
} else if (selected.type == '02') {
this.addModel.sectionCode = selected.parentCode;
this.activeName = 'second';
this.field = '';
this.$emit('stationSectionCode', '');
}
2019-11-29 12:51:58 +08:00
}
},
2019-12-05 10:19:41 +08:00
changeControlMode(data) {
if (data) {
this.editModel.controlModePoint = {
x:this.editModel.position.x,
y:this.editModel.position.y + 30
};
} else {
this.editModel.controlModePoint = {
x:0,
y:0
};
}
},
2019-12-03 14:56:18 +08:00
// 选择管理车站
2019-12-03 13:24:22 +08:00
changeChargeStation(data) {
if (data.length > 0) {
this.chargeStation.forEach(station=>{
const newModal = Object.assign({}, station);
newModal.controlled = false;
newModal.concentrateStationCode = '';
2019-12-03 17:52:39 +08:00
this.setStationStand(station, '');
2019-12-03 13:24:22 +08:00
data.forEach(each=>{
switch (each) {
case station.code: {
newModal.controlled = true;
newModal.concentrateStationCode = this.editModel.code;
2019-12-03 17:52:39 +08:00
this.setStationStand(station, this.editModel.code);
2019-12-03 13:24:22 +08:00
break;
}
}
});
this.$emit('updateMapModel', newModal);
});
} else {
2019-12-03 15:22:16 +08:00
// 没有选中数据,直接将其他车站设置为非控制
2019-12-03 14:56:18 +08:00
this.modifyChargeStation();
2019-12-03 13:24:22 +08:00
}
this.edit();
},
changeCentralized(data) {
if (!data) {
2019-12-03 14:56:18 +08:00
// 将当前车站选为非集中站
2019-12-03 13:24:22 +08:00
this.editModel.chargeStationCodeList = [];
this.edit();
2019-12-03 14:56:18 +08:00
this.modifyChargeStation();
2019-12-03 15:22:16 +08:00
this.setStationStand(this.editModel, '');
2019-12-03 17:52:39 +08:00
} else {
2019-12-03 15:22:16 +08:00
this.setStationStand(this.editModel, this.editModel.code);
2019-12-03 13:24:22 +08:00
}
},
2019-12-03 15:22:16 +08:00
modifyChargeStation() {
2019-12-03 14:56:18 +08:00
this.chargeStation.forEach(station=>{
const newModal = Object.assign({}, station);
newModal.controlled = false;
newModal.concentrateStationCode = '';
// 将原来被控制的车站下的站台,属性{所属设备集中站}设置为空
2019-12-03 15:22:16 +08:00
this.setStationStand(station, '');
2019-12-03 14:56:18 +08:00
this.$emit('updateMapModel', newModal);
});
},
// 设置属性{所属设备集中站}
2019-12-03 15:22:16 +08:00
setStationStand(station, code) {
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) {
2019-12-03 14:56:18 +08:00
const stationStand = Object.assign({}, elem);
2019-12-03 15:22:16 +08:00
stationStand.deviceStationCode = code;
2019-12-03 14:56:18 +08:00
this.$emit('updateMapModel', stationStand);
}
});
},
2019-11-29 12:51:58 +08:00
hover(field) {
this.field = field === this.field ? '' : field;
this.$emit('stationSectionCode', this.field);
},
create() {
this.$refs['make'].validate((valid) => {
if (valid) {
if (this.addModel.sectionCode.length) {
const models = [];
this.addModel.sectionCode.forEach((item) => {
const uid = getUID('Station');
const model = {
_type: 'Station',
code: uid,
zcCode: '',
runPlanName: '',
visible: true,
nameFont: '14px consolas',
nameFontColor: '#FFFFFF',
kmPost: '1000km~2000km',
kmPostShow: true,
kmPostFont: '8px consolas',
kmPostFontColor: '#FFFFFF',
centralized: false,
concentrateStationCode: '',
controlled:false,
chargeStationCodeList:[]
};
this.sectionList.forEach(elem => {
if (elem.code === item) {
const l = 0;
const r = elem.points.length - 1;
model.name = 'Station_' + elem.name.replace('Station_', '');
model.position = {
x: elem.points[l].x + (elem.points[r].x - elem.points[l].x) / 2,
y: elem.points[l].y - 100
};
}
});
models.push(model);
2019-11-29 12:51:58 +08:00
});
this.$emit('updateMapModel', models);
2019-11-29 12:51:58 +08:00
}
}
});
},
// 修改对象
edit() {
this.$refs['dataform'].validate((valid) => {
if (valid) {
const data = Object.assign({_type: 'Station'}, this.editModel);
this.$emit('updateMapModel', data);
}
});
},
// 删除对象
deleteObj() {
const selected = this.$store.getters['map/getDeviceByCode'](this.editModel.code);
if (selected && selected._type.toUpperCase() === 'Station'.toUpperCase()) {
const _that = this;
this.$confirm(this.$t('tip.confirmDeletion'), this.$t('tip.hint'), {
confirmButtonText: this.$t('tip.confirm'),
cancelButtonText: this.$t('tip.cancel'),
type: 'warning'
}).then(() => {
_that.$emit('updateMapModel', {...selected, _dispose: true});
_that.deviceSelect();
}).catch(() => {
_that.$message.info(this.$t('tip.cancelledDelete'));
});
}
2019-12-05 10:25:07 +08:00
},
addPoint(index) {
const data = { x: 0, y: 0 };
this.editModel.turnBackList.splice(index + 1, 0, data);
},
delPoint(index) {
this.editModel.turnBackList.splice(index, 1);
2019-11-29 12:51:58 +08:00
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
.view-control{
height: 100%;
}
.card {
height: 100%;
}
</style>