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">
|
2019-12-03 15:30:41 +08:00
|
|
|
<el-button type="primary" size="small" @click="edit">{{ $t('map.updateObj') }}</el-button>
|
2019-11-29 12:51:58 +08:00
|
|
|
<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" :rules="createRules" size="mini">
|
|
|
|
<el-form-item :label="$t('map.stationstandName')" prop="stationCode">
|
2019-12-03 15:22:16 +08:00
|
|
|
<el-select v-model="addModel.stationCode" filterable @change="changeStation">
|
2019-11-29 12:51:58 +08:00
|
|
|
<el-option
|
|
|
|
v-for="item in stationList"
|
|
|
|
:key="item.code"
|
|
|
|
:label="item.name + ' (' + item.code+ ')'"
|
|
|
|
:value="item.code"
|
|
|
|
/>
|
|
|
|
</el-select>
|
2019-12-04 13:00:24 +08:00
|
|
|
<el-button
|
|
|
|
:type="field === 'standSelectStationCode' ? 'danger' : 'primary'"
|
|
|
|
size="small"
|
|
|
|
@click="hover('standSelectStationCode')"
|
|
|
|
>{{ $t('map.activate') }}</el-button>
|
2019-11-29 12:51:58 +08:00
|
|
|
</el-form-item>
|
2019-12-03 17:52:39 +08:00
|
|
|
<!-- <el-form-item :label="$t('map.equipmentStation')" prop="deviceStationCode">
|
2019-12-03 13:24:22 +08:00
|
|
|
<el-select v-model="addModel.deviceStationCode" filterable disabled>
|
2019-11-29 12:51:58 +08:00
|
|
|
<el-option
|
|
|
|
v-for="item in stationList"
|
|
|
|
:key="item.code"
|
|
|
|
:label="item.name"
|
|
|
|
:value="item.code"
|
|
|
|
/>
|
|
|
|
</el-select>
|
2019-12-03 17:52:39 +08:00
|
|
|
</el-form-item> -->
|
2019-11-29 12:51:58 +08:00
|
|
|
<el-form-item :label="$t('map.stationstandDirection')" prop="doorLocationType">
|
|
|
|
<el-select v-model="addModel.doorLocationType" filterable :placeholder="$t('map.pleaseSelect')">
|
|
|
|
<el-option
|
|
|
|
v-for="item in DoorLocationTypeList"
|
|
|
|
:key="item.code"
|
|
|
|
:label="item.name"
|
|
|
|
:value="item.code"
|
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="$t('map.stationstandHasDoor')" prop="hasDoor">
|
|
|
|
<el-checkbox v-model="addModel.hasDoor" />
|
|
|
|
</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: '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: '',
|
|
|
|
nameShow: '',
|
|
|
|
doorLocationType: '',
|
|
|
|
deviceStationCode: '',
|
|
|
|
hasDoor: false,
|
|
|
|
width: 0,
|
|
|
|
height: 0,
|
|
|
|
stationCode: '',
|
|
|
|
position: {
|
|
|
|
x: 0,
|
|
|
|
y: 0
|
|
|
|
},
|
|
|
|
visible: true,
|
|
|
|
direction: ''
|
|
|
|
},
|
2019-12-04 13:00:24 +08:00
|
|
|
field: '',
|
2019-11-29 12:51:58 +08:00
|
|
|
addModel: {
|
|
|
|
stationCode: '',
|
|
|
|
doorLocationType: '01',
|
|
|
|
deviceStationCode: '',
|
|
|
|
hasDoor: true
|
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapGetters('map', [
|
|
|
|
'stationList',
|
|
|
|
'stationStandList',
|
|
|
|
'lineCode'
|
|
|
|
]),
|
|
|
|
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 },
|
2019-12-02 13:57:25 +08:00
|
|
|
{ prop: 'name', label: this.$t('map.stationstandNameColon'), type: 'input', change:true, deviceChange:this.updateView },
|
2019-11-29 12:51:58 +08:00
|
|
|
{ prop: 'position', label: this.$t('map.stationstandPosition'), type: 'coordinate', width: '120px', children: [
|
2019-12-02 13:57:25 +08:00
|
|
|
{ prop: 'position.x', firstLevel: 'position', secondLevel: 'x', label: 'x:', type: 'number', labelWidth: '25px', change:true, deviceChange:this.updateView },
|
|
|
|
{ prop: 'position.y', firstLevel: 'position', secondLevel: 'y', label: 'y:', type: 'number', labelWidth: '25px', change:true, deviceChange:this.updateView }
|
2019-11-29 12:51:58 +08:00
|
|
|
] },
|
2019-12-02 13:17:41 +08:00
|
|
|
{ prop: 'direction', label: this.$t('map.stationstandTopBottom'), type: 'select', optionLabel: 'name', optionValue: 'code', options: this.RunDirectionTypeList, change: true, deviceChange:this.updateView },
|
|
|
|
{ prop: 'visible', label: this.$t('map.stationVisible'), type: 'checkbox', change: true, deviceChange: this.updateView},
|
|
|
|
{ prop: 'doorLocationType', label: this.$t('map.stationstandDirection'), type: 'select', optionLabel: 'name', optionValue: 'code', options: this.DoorLocationTypeList, change: true, deviceChange:this.updateView },
|
|
|
|
{ prop: 'hasDoor', label: this.$t('map.stationstandHasDoor'), type: 'checkbox', change: true, deviceChange:this.updateView },
|
|
|
|
{ prop: 'width', label: this.$t('map.stationstandWidth'), type: 'number', min: 0, max: 2000, placeholder: 'px', change:true, deviceChange:this.updateView},
|
|
|
|
{ prop: 'height', label: this.$t('map.stationstandHeight'), type: 'number', min: 0, max: 2000, placeholder: 'px', change:true, deviceChange:this.updateView}
|
2019-11-29 12:51:58 +08:00
|
|
|
]
|
|
|
|
},
|
|
|
|
map: {
|
|
|
|
name: this.$t('map.mapData'),
|
|
|
|
item: [
|
2019-12-03 13:24:22 +08:00
|
|
|
{ prop: 'deviceStationCode', label: this.$t('map.equipmentStation'), type: 'select', optionLabel: 'name', optionValue: 'code', options: this.stationList, change: true, deviceChange:this.updateView, disabled:true},
|
2019-12-02 13:57:25 +08:00
|
|
|
{ prop: 'stationCode', label: this.$t('map.belongsStation'), type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.stationList, change: true, deviceChange:this.updateView }
|
2019-11-29 12:51:58 +08:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
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' }
|
|
|
|
],
|
|
|
|
doorLocationType: [
|
|
|
|
{ required: true, message: this.$t('rules.doorLocationType'), trigger: 'change' }
|
|
|
|
],
|
|
|
|
direction: [
|
|
|
|
{ required: true, message: this.$t('rules.stationstandDirection'), 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;
|
|
|
|
},
|
|
|
|
createRules() {
|
|
|
|
return {
|
|
|
|
stationCode: [
|
|
|
|
{ required: true, message: this.$t('rules.stationCode'), trigger: 'change' }
|
|
|
|
],
|
|
|
|
doorLocationType: [
|
|
|
|
{ required: true, message: this.$t('rules.doorLocationType'), trigger: 'change' }
|
2019-12-03 17:52:39 +08:00
|
|
|
]
|
2019-11-29 12:51:58 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
selected: function (val, oldVal) {
|
|
|
|
this.deviceSelect(val);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.$Dictionary.doorLocationType().then(list => {
|
|
|
|
this.DoorLocationTypeList = list;
|
|
|
|
});
|
|
|
|
this.$Dictionary.runDirectionType().then(list => {
|
|
|
|
this.RunDirectionTypeList = list;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
deviceChange(code) {
|
|
|
|
this.$emit('setCenter', code);
|
|
|
|
this.deviceSelect(this.$store.getters['map/getDeviceByCode'](code));
|
2019-12-02 13:17:41 +08:00
|
|
|
this.edit();
|
|
|
|
},
|
|
|
|
updateView() {
|
|
|
|
this.edit();
|
2019-11-29 12:51:58 +08:00
|
|
|
},
|
2019-12-03 17:52:39 +08:00
|
|
|
changeStation(data) {
|
2019-12-04 13:00:24 +08:00
|
|
|
const station = this.stationList.find(elem => { return elem.code == data; });
|
2019-12-03 17:52:39 +08:00
|
|
|
if (station) {
|
|
|
|
if (station.centralized) {
|
|
|
|
this.addModel.deviceStationCode = station.code;
|
|
|
|
} else {
|
|
|
|
this.addModel.deviceStationCode = station.concentrateStationCode;
|
2019-12-03 15:22:16 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2019-12-04 13:00:24 +08:00
|
|
|
hover(field) {
|
|
|
|
this.field = field === this.field ? '' : field;
|
|
|
|
this.$emit('stationSectionCode', this.field);
|
|
|
|
},
|
2019-11-29 12:51:58 +08:00
|
|
|
deviceSelect(selected) {
|
|
|
|
this.$refs.dataform.resetFields();
|
2019-12-04 13:00:24 +08:00
|
|
|
// this.$refs.make.resetFields();
|
|
|
|
if (this.field.toUpperCase() != 'standSelectStationCode'.toUpperCase() && selected && selected._type.toUpperCase() === 'StationStand'.toUpperCase()) {
|
2019-11-29 12:51:58 +08:00
|
|
|
this.activeName = 'first';
|
|
|
|
this.editModel = deepAssign(this.editModel, selected);
|
2019-12-04 13:00:24 +08:00
|
|
|
}
|
|
|
|
// else if (selected && selected._type.toUpperCase() === 'Station'.toUpperCase()) {
|
|
|
|
// this.addModel.stationCode = selected.code;
|
|
|
|
// }
|
|
|
|
|
|
|
|
if (selected && selected._type.toUpperCase() === 'Station'.toUpperCase() && this.field.toUpperCase() === 'standSelectStationCode'.toUpperCase()) {
|
2019-11-29 12:51:58 +08:00
|
|
|
this.addModel.stationCode = selected.code;
|
2019-12-04 13:00:24 +08:00
|
|
|
this.activeName = 'second';
|
|
|
|
this.field = '';
|
|
|
|
this.$emit('stationSectionCode', '');
|
2019-11-29 12:51:58 +08:00
|
|
|
}
|
2019-12-04 13:00:24 +08:00
|
|
|
|
|
|
|
// else if (selected && selected._type.toUpperCase() === 'Section'.toUpperCase() && this.field.toUpperCase() === 'relevanceSectionList'.toUpperCase()) {
|
|
|
|
// this.fromData.relevanceSectionList.push(selected.code);
|
|
|
|
// }
|
2019-11-29 12:51:58 +08:00
|
|
|
},
|
|
|
|
create() {
|
|
|
|
this.$refs.make.validate((valid) => {
|
|
|
|
if (valid) {
|
|
|
|
const uid = getUID('StationStand');
|
|
|
|
const model = {
|
|
|
|
_type: 'StationStand',
|
|
|
|
code: uid,
|
|
|
|
width: 40,
|
|
|
|
height: 20,
|
|
|
|
doorLocationType: this.addModel.doorLocationType,
|
|
|
|
deviceStationCode: this.addModel.deviceStationCode,
|
|
|
|
visible: true,
|
|
|
|
direction: '01',
|
|
|
|
hasDoor: this.addModel.hasDoor
|
|
|
|
};
|
|
|
|
this.stationList.forEach(elem => {
|
|
|
|
if (elem.code === this.addModel.stationCode) {
|
|
|
|
model.name = 'StationStand_' + elem.name.replace('Station_', '');
|
|
|
|
model.position = { x: elem.position.x, y: elem.position.y + 40 };
|
|
|
|
model.stationCode = elem.code;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
this.$emit('updateMapModel', model);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
// 修改对象
|
|
|
|
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();
|
|
|
|
}).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>
|