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

434 lines
19 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">
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-input v-model="scope.row.stationName" placeholder="请输入内容" size="mini" /> -->
<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>
</el-tabs>
</template>
<script>
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';
export default {
name: 'StationDraft',
components: {
ConfigList
},
props: {
selected: {
type: Object,
default: function () {
return null;
}
}
},
data() {
return {
activeName: 'first',
2019-12-06 10:31:19 +08:00
// 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-06 10:31:19 +08:00
turnBackPoint: {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: {
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
]
}
};
},
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},
2019-12-06 10:31:19 +08:00
{ prop: 'controlModePoint', label: this.$t('map.stationControlPosition'), type: 'coordinate', width: '120px', isHidden:!this.editModel.isCreateControlMode, 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-05 10:25:07 +08:00
{ prop: 'isCreateTurnBack', 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' }
] }
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();
2019-12-06 10:31:19 +08:00
if (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-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-12-06 10:31:19 +08:00
// hover(field) {
// this.field = field === this.field ? '' : field;
// this.$emit('stationSectionCode', this.field);
// },
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]);
const model = {
_type: 'Station',
code: uid,
2019-12-05 18:01:09 +08:00
name: item.stationName,
zcCode: '',
runPlanName: '',
visible: true,
nameFont: '22px consolas',
nameFontColor: '#FFFFFF',
kmPost: '1000km~2000km',
kmPostShow: true,
kmPostFont: '8px consolas',
kmPostFontColor: '#FFFFFF',
centralized: false,
concentrateStationCode: '',
2019-12-05 18:01:09 +08:00
controlled: false,
chargeStationCodeList:[],
isCreateControlMode: item.control,
isCreateTurnBack: false,
2019-12-06 10:31:19 +08:00
turnBackPoint: {x: 0, y: 0} // 按图折返坐标
};
this.sectionList.forEach(elem => {
2019-12-05 18:01:09 +08:00
if (elem.code === item.sectionCode) {
const l = 0;
const r = elem.points.length - 1;
model.position = {
x: elem.points[l].x + (elem.points[r].x - elem.points[l].x) / 2,
2019-12-05 18:01:09 +08:00
y: elem.points[l].y - this.addModel.positionY
};
2019-12-05 18:01:09 +08:00
if (item.control) {
model.controlModePoint = {
x: elem.points[l].x + (elem.points[r].x - elem.points[l].x) / 2,
y: elem.points[l].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 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
},
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";
.view-control{
height: 100%;
}
.card {
height: 100%;
}
</style>