440 lines
20 KiB
Vue
440 lines
20 KiB
Vue
<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">
|
|
<config-list ref="make" :form="addForm" :form-model="addModel" :rules="createRules" />
|
|
<!-- <el-form ref="make" label-width="140px" :model="addModel" :rules="createRules" size="mini">
|
|
<el-form-item :label="$t('map.stationstandName')" prop="stationCode">
|
|
<el-select v-model="addModel.stationCode" filterable @change="changeStation">
|
|
<el-option
|
|
v-for="item in stationList"
|
|
:key="item.code"
|
|
:label="item.name + ' (' + item.code+ ')'"
|
|
:value="item.code"
|
|
/>
|
|
</el-select>
|
|
<el-button
|
|
:type="field === 'standSelectStationCode' ? 'danger' : 'primary'"
|
|
size="small"
|
|
@click="hover('standSelectStationCode')"
|
|
>{{ $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 '@/jmapNew/utils/Uid';
|
|
import ConfigList from './config/list';
|
|
import { deepAssign } from '@/utils/index';
|
|
|
|
export default {
|
|
name: 'StationStandDraft',
|
|
components: {
|
|
ConfigList
|
|
},
|
|
props: {
|
|
selected: {
|
|
type: Object,
|
|
default: function () {
|
|
return null;
|
|
}
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
activeName: 'first',
|
|
DoorLocationTypeList: [],
|
|
RunDirectionTypeList: [],
|
|
/*
|
|
{ code: '01', name: '朝下' },
|
|
{ code: '02', name: '朝上' }
|
|
*/
|
|
editModel: {
|
|
code: '',
|
|
name: '',
|
|
// doorLocationType: '', // 站台方向
|
|
deviceStationCode: '', // 设备集中站
|
|
// hasDoor: false, // 屏蔽门是否显示
|
|
width: 0,
|
|
height: 0,
|
|
stationCode: '', // 所属车站
|
|
position: { x: 0, y: 0 },
|
|
visible: true // 是否显示
|
|
// direction: '' // 上下行方向
|
|
},
|
|
field: '',
|
|
addModel: {
|
|
stationCode: '', // 所属车站
|
|
deviceStationCode: '', // 设备集中站
|
|
pointY: 0, // y坐标
|
|
width: 60,
|
|
height: 20,
|
|
doorType: '01', // 屏蔽门类型
|
|
standTrackCode: '', // 关联站台轨
|
|
standTrackUpCode: '', // 上行站台轨
|
|
standTrackDownCode: '', // 下行站台轨
|
|
stationstandDirection: '02' // 屏蔽门方向
|
|
}
|
|
};
|
|
},
|
|
computed: {
|
|
...mapGetters('map', [
|
|
'stationList',
|
|
'stationStandList',
|
|
'sectionList',
|
|
'psdList'
|
|
]),
|
|
form() {
|
|
const form = {
|
|
labelWidth: '130px',
|
|
items: {
|
|
code: {
|
|
name: '',
|
|
item: []
|
|
},
|
|
draw: {
|
|
name: this.$t('map.drawData'),
|
|
item: [
|
|
{ prop: 'code', label: this.$t('map.relStandCode'), type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.stationStandList, change: true, deviceChange: this.deviceChange },
|
|
{ prop: 'name', label: this.$t('map.stationstandNameColon'), type: 'input' },
|
|
{ prop: 'position', label: this.$t('map.stationstandPosition'), 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.stationVisible'), type: 'checkbox' },
|
|
{ prop: 'width', label: this.$t('map.stationstandWidth'), type: 'number', min: 0, max: 2000, placeholder: 'px' },
|
|
{ prop: 'height', label: this.$t('map.stationstandHeight'), type: 'number', min: 0, max: 2000, placeholder: 'px' }
|
|
]
|
|
},
|
|
map: {
|
|
name: this.$t('map.mapData'),
|
|
item: [
|
|
{ prop: 'deviceStationCode', label: this.$t('map.equipmentStation'), type: 'select', optionLabel: 'name', optionValue: 'code', options: this.stationList, disabled:true},
|
|
{ prop: 'stationCode', label: this.$t('map.belongsStation'), type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.stationList }
|
|
]
|
|
}
|
|
}
|
|
};
|
|
return form;
|
|
},
|
|
rules() {
|
|
const rules = {
|
|
code: [
|
|
{ required: true, message: this.$t('rules.pleaseReSelectDevice'), trigger: 'change' }
|
|
],
|
|
stationCode: [
|
|
{ required: true, message: this.$t('rules.stationCode'), trigger: 'change' }
|
|
],
|
|
name: [
|
|
{ required: true, message: this.$t('rules.stationstandCountName'), trigger: 'change' }
|
|
],
|
|
width: [
|
|
{ required: true, message: this.$t('rules.stationstandWidth'), trigger: 'change' }
|
|
],
|
|
height: [
|
|
{ required: true, message: this.$t('rules.stationstandHeight'), trigger: 'change' }
|
|
],
|
|
'position.x': [
|
|
{ required: true, message: this.$t('rules.trainPositionX'), trigger: 'change' }
|
|
],
|
|
'position.y': [
|
|
{ required: true, message: this.$t('rules.trainPositionY'), trigger: 'change' }
|
|
]
|
|
};
|
|
// 清空表单验证提示信息
|
|
this.$nextTick(() => {
|
|
this.$refs.dataform &&
|
|
this.$refs.dataform.clearValidate();
|
|
});
|
|
|
|
return rules;
|
|
},
|
|
addForm() {
|
|
return {
|
|
labelWidth: '130px',
|
|
items: {
|
|
stand: {
|
|
name: '站台数据',
|
|
item: [
|
|
{ prop: 'stationCode', label: this.$t('map.stationstandName'), type: 'selectHover', optionLabel: 'name&&code', optionValue: 'code', options: this.stationList, hover: this.hover, buttonType: 'standSelectStationCode', buttonShowType: this.isButtonType },
|
|
{ prop: 'pointY', label: 'Y 坐标:', type: 'number' },
|
|
{ prop: 'width', label: this.$t('map.stationstandWidth'), type: 'number', min: 0, max: 2000, placeholder: 'px' },
|
|
{ prop: 'height', label: this.$t('map.stationstandHeight'), type: 'number', min: 0, max: 2000, placeholder: 'px' }
|
|
]
|
|
},
|
|
door: {
|
|
name: '屏蔽门数据',
|
|
item: [
|
|
{ prop: 'doorType', label: '屏蔽门类型:', type: 'radio', radioList: [
|
|
{value: '01', label: '单侧屏蔽门' },
|
|
{value: '02', label: '双侧屏蔽门' }
|
|
] },
|
|
{ prop: 'standTrackCode', label: '站台轨:', type: 'selectHover', optionLabel: 'name&&code', optionValue: 'code', options: this.PhysicalSectionList, hover: this.hover, buttonType: 'sectionSelectCode', buttonShowType: this.isButtonTypeS, isHidden: !this.doorTypeOne },
|
|
{ prop: 'stationstandDirection', label: '屏蔽门朝向:', type: 'radio', radioList: this.DoorLocationTypeList, isHidden: !this.doorTypeOne },
|
|
{ prop: 'standTrackUpCode', label: '上行站台轨:', type: 'selectHover', optionLabel: 'name&&code', optionValue: 'code', options: this.PhysicalSectionList, hover: this.hover, buttonType: 'sectionSelectUpCode', buttonShowType: this.isButtonTypeU, isHidden: !this.doorTypeTwo },
|
|
{ prop: 'standTrackDownCode', label: '下行站台轨:', type: 'selectHover', optionLabel: 'name&&code', optionValue: 'code', options: this.PhysicalSectionList, hover: this.hover, buttonType: 'sectionSelectDownCode', buttonShowType: this.isButtonTypeD, isHidden: !this.doorTypeTwo }
|
|
]
|
|
}
|
|
}
|
|
};
|
|
},
|
|
createRules() {
|
|
return {
|
|
stationCode: [
|
|
{ required: true, message: this.$t('rules.stationCode'), trigger: 'change' }
|
|
],
|
|
pointY: [
|
|
{ required: true, message: '请输入y坐标', trigger: 'blur' }
|
|
],
|
|
width: [
|
|
{ required: true, message: '请输入站台宽度', trigger: 'blur' }
|
|
],
|
|
height: [
|
|
{ required: true, message: '请输入站台高度', trigger: 'blur' }
|
|
],
|
|
standTrackCode: [
|
|
{ required: true, message: '请选择关联站台轨', trigger: 'change' }
|
|
],
|
|
standTrackUpCode: [
|
|
{ required: true, message: '请选择站台轨', trigger: 'change' }
|
|
],
|
|
standTrackDownCode: [
|
|
{ required: true, message: '请选择站台轨', trigger: 'change' }
|
|
]
|
|
};
|
|
},
|
|
isButtonType() {
|
|
return this.field == 'standSelectStationCode';
|
|
},
|
|
isButtonTypeS() {
|
|
return this.field == 'sectionSelectCode';
|
|
},
|
|
isButtonTypeU() {
|
|
return this.field == 'sectionSelectUpCode';
|
|
},
|
|
isButtonTypeD() {
|
|
return this.field == 'sectionSelectDownCode';
|
|
},
|
|
doorTypeOne() {
|
|
return this.addModel.doorType == '01';
|
|
},
|
|
doorTypeTwo() {
|
|
return this.addModel.doorType == '02';
|
|
},
|
|
PhysicalSectionList() {
|
|
let list = [];
|
|
if (this.sectionList && this.sectionList.length) {
|
|
list = this.sectionList.filter(elem => { return elem.type === '01'; });
|
|
}
|
|
return list;
|
|
}
|
|
},
|
|
watch: {
|
|
selected: function (val, oldVal) {
|
|
this.deviceSelect(val);
|
|
}
|
|
},
|
|
mounted() {
|
|
this.$Dictionary.doorLocationType().then(list => {
|
|
this.DoorLocationTypeList = [];
|
|
list.forEach(item => {
|
|
const param = { value: item.code, label: item.name };
|
|
this.DoorLocationTypeList.push(param);
|
|
});
|
|
});
|
|
this.$Dictionary.runDirectionType().then(list => {
|
|
this.RunDirectionTypeList = list;
|
|
});
|
|
},
|
|
methods: {
|
|
deviceChange(code) {
|
|
this.$emit('setCenter', code);
|
|
this.deviceSelect(this.$store.getters['map/getDeviceByCode'](code));
|
|
this.edit();
|
|
},
|
|
changeStation(data) {
|
|
const station = this.stationList.find(elem => { return elem.code == data; });
|
|
if (station) {
|
|
if (station.centralized) {
|
|
this.addModel.deviceStationCode = station.code;
|
|
} else {
|
|
this.addModel.deviceStationCode = station.concentrateStationCode;
|
|
}
|
|
}
|
|
},
|
|
hover(field) {
|
|
this.field = field === this.field ? '' : field;
|
|
this.$emit('standStationCode', this.field);
|
|
},
|
|
deviceSelect(selected) {
|
|
if (this.field.toUpperCase() != 'standSelectStationCode'.toUpperCase() && selected && selected._type.toUpperCase() === 'StationStand'.toUpperCase()) {
|
|
this.$refs.dataform.resetFields();
|
|
this.activeName = 'first';
|
|
this.editModel = deepAssign(this.editModel, selected);
|
|
}
|
|
if (selected && selected._type.toUpperCase() === 'Station'.toUpperCase() && this.field.toUpperCase() === 'standSelectStationCode'.toUpperCase()) {
|
|
this.addModel.stationCode = selected.code;
|
|
this.activeName = 'second';
|
|
this.field = '';
|
|
this.$emit('standStationCode', '');
|
|
} else if (selected && selected._type.toUpperCase() === 'Section'.toUpperCase() && this.field.toUpperCase() === 'sectionSelectCode'.toUpperCase()) {
|
|
this.addModel.standTrackCode = selected.code;
|
|
this.activeName = 'second';
|
|
this.field = '';
|
|
this.$emit('standStationCode', '');
|
|
} else if (selected && selected._type.toUpperCase() === 'Section'.toUpperCase() && this.field.toUpperCase() === 'sectionSelectUpCode'.toUpperCase()) {
|
|
this.addModel.standTrackUpCode = selected.code;
|
|
this.activeName = 'second';
|
|
this.field = '';
|
|
this.$emit('standStationCode', '');
|
|
} else if (selected && selected._type.toUpperCase() === 'Section'.toUpperCase() && this.field.toUpperCase() === 'sectionSelectDownCode'.toUpperCase()) {
|
|
this.addModel.standTrackDownCode = selected.code;
|
|
this.activeName = 'second';
|
|
this.field = '';
|
|
this.$emit('standStationCode', '');
|
|
}
|
|
},
|
|
create() {
|
|
this.$refs.make.validate((valid) => {
|
|
if (valid) {
|
|
const models = [];
|
|
const space = 15;
|
|
const Standuid = getUID('PF', this.stationStandList);
|
|
const model = {
|
|
_type: 'StationStand',
|
|
code: Standuid,
|
|
name: `PF${this.stationStandList.length + 1}`,
|
|
width: this.addModel.width,
|
|
height: this.addModel.height,
|
|
deviceStationCode: this.addModel.deviceStationCode,
|
|
visible: true,
|
|
position: {
|
|
x: 0,
|
|
y: this.addModel.pointY
|
|
}
|
|
};
|
|
this.stationList.forEach(elem => {
|
|
if (elem.code == this.addModel.stationCode) {
|
|
model.position.x = elem.position.x;
|
|
model.stationCode = elem.code;
|
|
}
|
|
});
|
|
models.push(model);
|
|
if (this.addModel.doorType == '01') {
|
|
const uid = getUID('Psd', this.psdList);
|
|
const param = {
|
|
_type: 'Psd',
|
|
code: uid,
|
|
name: `Psd${this.psdList.length + 1}`,
|
|
width: this.addModel.width,
|
|
height: 4,
|
|
standCode: Standuid, // 关联站台唯一code
|
|
standTrackCode: this.addModel.standTrackCode, // 关联站台轨编码
|
|
position: {
|
|
x: models[0].position.x,
|
|
y: this.addModel.pointY - (this.addModel.height / 2) - space
|
|
}
|
|
};
|
|
if (this.addModel.stationstandDirection == '01') { // 朝下
|
|
param.position.y = this.addModel.pointY + (this.addModel.height / 2) + space;
|
|
}
|
|
models.push(param);
|
|
} else if (this.addModel.doorType == '02') {
|
|
const arr = [];
|
|
for (let index = 0; index < 2; index++) {
|
|
const uid = getUID('Psd', [...this.psdList, ...arr]);
|
|
const param = {
|
|
_type: 'Psd',
|
|
code: uid,
|
|
name: `Psd${[...this.psdList, ...arr].length + 1}`,
|
|
width: this.addModel.width,
|
|
height: 4,
|
|
standCode: Standuid, // 关联站台唯一code
|
|
standTrackCode: '', // 关联站台轨编码
|
|
position: {
|
|
x: models[0].position.x,
|
|
y: this.addModel.pointY
|
|
}
|
|
};
|
|
if (index == 0) {
|
|
param.standTrackCode = this.addModel.standTrackUpCode;
|
|
param.position.y = this.addModel.pointY - (this.addModel.height / 2) - space;
|
|
} else {
|
|
param.standTrackCode = this.addModel.standTrackDownCode;
|
|
param.position.y = this.addModel.pointY + (this.addModel.height / 2) + space;
|
|
}
|
|
arr.push(param);
|
|
}
|
|
arr.forEach(item => {
|
|
models.push(item);
|
|
});
|
|
}
|
|
this.$emit('updateMapModel', models);
|
|
}
|
|
});
|
|
},
|
|
// 修改对象
|
|
edit() {
|
|
this.$refs.dataform.validate((valid) => {
|
|
if (valid) {
|
|
const data = Object.assign({_type: 'StationStand'}, this.editModel);
|
|
this.$emit('updateMapModel', data);
|
|
}
|
|
});
|
|
},
|
|
// 删除对象
|
|
deleteObj() {
|
|
const selected = this.$store.getters['map/getDeviceByCode'](this.editModel.code);
|
|
if (selected && selected._type.toUpperCase() === 'StationStand'.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();
|
|
this.$refs.dataform.resetFields();
|
|
}).catch(() => {
|
|
_that.$message.info(this.$t('tip.cancelledDelete'));
|
|
});
|
|
}
|
|
}
|
|
}
|
|
};
|
|
</script>
|
|
<style rel="stylesheet/scss" lang="scss" scoped>
|
|
@import "src/styles/mixin.scss";
|
|
.view-control{
|
|
height: 100%;
|
|
}
|
|
|
|
.card {
|
|
height: 100%;
|
|
}
|
|
</style>
|