2020-03-05 16:39:49 +08:00
|
|
|
<template>
|
|
|
|
<el-tabs v-model="activeName" class="card" @tab-click="handleClick">
|
|
|
|
<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-data ref="make" :form="formMake" :form-model="addModel" :rules="createRules" />
|
|
|
|
</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 ConfigData from './config/data';
|
|
|
|
import { deepAssign } from '@/utils/index';
|
2020-03-17 16:12:15 +08:00
|
|
|
import { getRouteNewList, getAutoReentryList } from '@/api/jmap/mapdraft';
|
2020-03-05 16:39:49 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'AutoMaticRoute',
|
|
|
|
components: {
|
|
|
|
ConfigList,
|
|
|
|
ConfigData
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
selected: {
|
|
|
|
type: Object,
|
|
|
|
default: function () {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
activeName: 'first',
|
|
|
|
autoList: [],
|
2020-03-17 16:12:15 +08:00
|
|
|
typeList: [
|
2020-03-18 09:10:57 +08:00
|
|
|
{ name: '自动折返', value: 'AutoTurnBack' },
|
2020-03-17 16:12:15 +08:00
|
|
|
{ name: '计轴复位', value: 'AxleReset' },
|
|
|
|
{ name: '自动进路', value: 'AutomaticRoute' },
|
|
|
|
{ name: '引导总锁', value: 'GuideLock' },
|
|
|
|
{ name: '全线临时限速', value: 'LimitControl' }
|
|
|
|
],
|
2020-03-05 16:39:49 +08:00
|
|
|
editModel: {
|
|
|
|
code: '',
|
2020-03-17 16:12:15 +08:00
|
|
|
type: '',
|
2020-03-05 16:39:49 +08:00
|
|
|
name: '',
|
2020-03-17 16:12:15 +08:00
|
|
|
subtitleName: '',
|
2020-03-05 16:39:49 +08:00
|
|
|
automaticRouteCode: '', // 关联自动进路code
|
2020-03-17 16:12:15 +08:00
|
|
|
cycleCode: '', // 自动折返关联code
|
|
|
|
stationCode: '', // 所属设备集中站
|
2020-03-05 16:39:49 +08:00
|
|
|
position: {
|
|
|
|
x: 0,
|
|
|
|
y: 0
|
|
|
|
}
|
|
|
|
},
|
|
|
|
addModel: {
|
|
|
|
code: '',
|
2020-03-17 16:12:15 +08:00
|
|
|
type: '',
|
2020-03-05 16:39:49 +08:00
|
|
|
name: '',
|
2020-03-17 16:12:15 +08:00
|
|
|
subtitleName: '',
|
2020-03-05 16:39:49 +08:00
|
|
|
automaticRouteCode: '', // 关联自动进路code
|
2020-03-17 16:12:15 +08:00
|
|
|
cycleCode: '', // 自动折返关联code
|
|
|
|
stationCode: '', // 所属设备集中站
|
2020-03-05 16:39:49 +08:00
|
|
|
position: {
|
|
|
|
x: 0,
|
|
|
|
y: 0
|
|
|
|
}
|
|
|
|
},
|
|
|
|
rules: {
|
|
|
|
code: [
|
|
|
|
{ required: true, message: this.$t('rules.pleaseSelectEncoding'), trigger: 'change' }
|
|
|
|
],
|
|
|
|
name: [
|
|
|
|
{ required: true, message: this.$t('rules.pleaseEnterStatusSignal'), trigger: 'blur' }
|
|
|
|
],
|
|
|
|
'position.x': [
|
|
|
|
{ required: true, message: this.$t('rules.trainPositionX'), trigger: 'blur' }
|
|
|
|
],
|
|
|
|
'position.y': [
|
|
|
|
{ required: true, message: this.$t('rules.trainPositionY'), trigger: 'blur' }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapGetters('map', [
|
2020-03-17 16:12:15 +08:00
|
|
|
'automaticRouteButtonList',
|
|
|
|
'cycleButtonList',
|
|
|
|
'tempSpeedLimitList',
|
|
|
|
'axleCounterResetButtonList',
|
|
|
|
'totalGuideLockButtonVOList',
|
|
|
|
'stationList'
|
2020-03-05 16:39:49 +08:00
|
|
|
]),
|
|
|
|
form() {
|
|
|
|
const form = {
|
|
|
|
labelWidth: '150px',
|
|
|
|
items: {
|
|
|
|
code: {
|
|
|
|
name: '',
|
|
|
|
item: []
|
|
|
|
},
|
|
|
|
draw: {
|
|
|
|
name: this.$t('map.drawData'),
|
|
|
|
item: [
|
2020-03-17 16:12:15 +08:00
|
|
|
{ prop:'type', label: '功能类型:', type: 'select', optionLabel: 'name', optionValue: 'value', options: this.typeList, disabled: true },
|
|
|
|
{ prop: 'code', label: `${this.$t('map.code')}`, type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.selectLists, change: true, deviceChange: this.deviceChange },
|
|
|
|
{ prop: 'name', label: '按钮主名称:', type: 'input' },
|
|
|
|
{ prop: 'subtitleName', label: '按钮副名称:', type: 'input' },
|
2020-03-05 16:39:49 +08:00
|
|
|
{ prop: 'position', label: '坐标:', type: 'coordinate', width: '140px', children: [
|
|
|
|
{ prop: 'position.x', firstLevel: 'position', secondLevel: 'x', label: 'x:', type: 'number', labelWidth: '20px' },
|
|
|
|
{ prop: 'position.y', firstLevel: 'position', secondLevel: 'y', label: 'y:', type: 'number', labelWidth: '20px' }
|
|
|
|
] },
|
2020-03-18 09:10:57 +08:00
|
|
|
{ prop:'automaticRouteCode', label: '自动进路code:', type: 'select', optionLabel: 'name', optionValue: 'code', options: this.autoList, isHidden: !this.isHiddenAutomaticRoute, change: true, deviceChange: this.ChangeEditStation },
|
|
|
|
{ prop:'cycleCode', label: '自动折返进路code:', type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.autoList, isHidden: !this.isHiddenMapCycleButtonVO, change: true, deviceChange: this.ChangeEditStation },
|
2020-03-17 16:12:15 +08:00
|
|
|
{ prop:'stationCode', label: '所属集中站:', type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.stationList, disabled: this.isDisabledStation, isHidden: !this.isHiddenStation }
|
2020-03-05 16:39:49 +08:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
return form;
|
|
|
|
},
|
|
|
|
formMake() {
|
|
|
|
const form = {
|
|
|
|
labelWidth: '150px',
|
|
|
|
items: [
|
2020-03-17 16:12:15 +08:00
|
|
|
{ prop:'type', label: '功能类型:', type: 'select', optionLabel: 'name', optionValue: 'value', options: this.typeList, change: true, deviceChange: this.typeChange },
|
|
|
|
{ prop: 'name', label: '按钮主名称:', type: 'input' },
|
2020-03-05 16:39:49 +08:00
|
|
|
{ prop: 'position', label: '坐标:', type: 'coordinate', width: '140px', 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' }
|
2020-03-17 16:12:15 +08:00
|
|
|
] },
|
|
|
|
{ prop:'automaticRouteCode', label: '自动进路code:', type: 'select', optionLabel: 'name', optionValue: 'code', options: this.autoList, isHidden: !this.isHiddenCreateAutomaticRoute, change: true, deviceChange: this.ChangeStation },
|
|
|
|
{ prop:'cycleCode', label: '自动折返进路code:', type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.autoList, isHidden: !this.isHiddenCreateMapCycleButtonVO, change: true, deviceChange: this.ChangeStation },
|
|
|
|
{ prop:'stationCode', label: '所属集中站:', type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.stationList, disabled: this.isDisabledCreateStation, isHidden: !this.isHiddenCreateStation }
|
2020-03-05 16:39:49 +08:00
|
|
|
]
|
|
|
|
};
|
|
|
|
return form;
|
|
|
|
},
|
|
|
|
createRules: function () {
|
|
|
|
return {
|
2020-03-17 16:12:15 +08:00
|
|
|
type: [
|
|
|
|
{ required: true, message: '请选择功能类型', trigger: 'change' }
|
2020-03-05 16:39:49 +08:00
|
|
|
],
|
|
|
|
name: [
|
|
|
|
{ required: true, message: '请输入名称', trigger: 'blur' }
|
|
|
|
],
|
|
|
|
'position.x': [
|
|
|
|
{ required: true, message: this.$t('rules.trainPositionX'), trigger: 'blur' }
|
|
|
|
],
|
|
|
|
'position.y': [
|
|
|
|
{ required: true, message: this.$t('rules.trainPositionY'), trigger: 'blur' }
|
|
|
|
]
|
|
|
|
};
|
2020-03-17 16:12:15 +08:00
|
|
|
},
|
|
|
|
isHiddenAutomaticRoute() {
|
|
|
|
return this.editModel.type == 'AutomaticRoute';
|
|
|
|
},
|
|
|
|
isHiddenMapCycleButtonVO() {
|
2020-03-18 09:10:57 +08:00
|
|
|
return this.editModel.type == 'AutoTurnBack';
|
2020-03-17 16:12:15 +08:00
|
|
|
},
|
|
|
|
isDisabledStation() {
|
2020-03-18 09:10:57 +08:00
|
|
|
return this.editModel.type == 'AutoTurnBack' || this.editModel.type == 'AutomaticRoute';
|
2020-03-17 16:12:15 +08:00
|
|
|
},
|
|
|
|
isHiddenStation() {
|
2020-03-18 09:10:57 +08:00
|
|
|
return this.editModel.type == 'AutoTurnBack' || this.editModel.type == 'AutomaticRoute' || this.editModel.type == 'AxleReset';
|
2020-03-17 16:12:15 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
isHiddenCreateAutomaticRoute() {
|
|
|
|
return this.addModel.type == 'AutomaticRoute';
|
|
|
|
},
|
|
|
|
isHiddenCreateMapCycleButtonVO() {
|
2020-03-18 09:10:57 +08:00
|
|
|
return this.addModel.type == 'AutoTurnBack';
|
2020-03-17 16:12:15 +08:00
|
|
|
},
|
|
|
|
isDisabledCreateStation() {
|
2020-03-18 09:10:57 +08:00
|
|
|
return this.addModel.type == 'AutoTurnBack' || this.addModel.type == 'AutomaticRoute';
|
2020-03-17 16:12:15 +08:00
|
|
|
},
|
|
|
|
isHiddenCreateStation() {
|
2020-03-18 09:10:57 +08:00
|
|
|
return this.addModel.type == 'AutoTurnBack' || this.addModel.type == 'AutomaticRoute' || this.addModel.type == 'AxleReset';
|
2020-03-05 16:39:49 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
selected(val, oldVal) {
|
2020-03-18 09:10:57 +08:00
|
|
|
this.handleTypes(val._type);
|
2020-03-05 16:39:49 +08:00
|
|
|
this.deviceSelect(val);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
2020-03-17 16:12:15 +08:00
|
|
|
|
2020-03-05 16:39:49 +08:00
|
|
|
},
|
|
|
|
methods: {
|
2020-03-17 16:12:15 +08:00
|
|
|
typeChange(type) { // 根据类型来选择功能按钮列表
|
|
|
|
this.$refs.dataform.resetFields();
|
|
|
|
this.$refs.make.resetFields();
|
|
|
|
this.addModel.automaticRouteCode = '';
|
|
|
|
this.addModel.cycleCode = '';
|
|
|
|
this.addModel.concentrateStationList = '';
|
|
|
|
this.addModel.type = type; // 上面清除掉重新赋值
|
|
|
|
this.handleTypes(type);
|
|
|
|
},
|
|
|
|
handleTypes(type) {
|
|
|
|
switch (type) {
|
2020-03-18 09:10:57 +08:00
|
|
|
case 'AutoTurnBack':
|
2020-03-17 16:12:15 +08:00
|
|
|
this.selectLists = this.cycleButtonList;
|
|
|
|
this.getAutoTurnBackList();
|
|
|
|
break;
|
|
|
|
case 'AxleReset':
|
|
|
|
this.selectLists = this.axleCounterResetButtonList;
|
|
|
|
break;
|
|
|
|
case 'AutomaticRoute':
|
|
|
|
this.selectLists = this.automaticRouteButtonList;
|
|
|
|
this.getAutoMaticList();
|
|
|
|
break;
|
|
|
|
case 'LimitControl':
|
|
|
|
this.selectLists = this.tempSpeedLimitList;
|
|
|
|
break;
|
|
|
|
case 'GuideLock':
|
|
|
|
this.selectLists = this.totalGuideLockButtonVOList;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
ChangeStation(code) { // 选择对应的所属设备集中站
|
|
|
|
this.autoList.forEach(elem => {
|
|
|
|
if (elem.code == code) {
|
|
|
|
this.addModel.stationCode = elem.stationCode;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2020-03-18 09:10:57 +08:00
|
|
|
ChangeEditStation(code) { // 选择对应的所属设备集中站
|
|
|
|
this.autoList.forEach(elem => {
|
|
|
|
if (elem.code == code) {
|
|
|
|
this.editModel.stationCode = elem.stationCode;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2020-03-05 16:39:49 +08:00
|
|
|
deviceChange(code) {
|
|
|
|
this.$emit('setCenter', code);
|
|
|
|
this.deviceSelect(this.$store.getters['map/getDeviceByCode'](code));
|
|
|
|
},
|
|
|
|
handleClick() {
|
|
|
|
this.getAutoMaticList();
|
|
|
|
},
|
|
|
|
deviceSelect(selected) {
|
|
|
|
this.$refs.dataform.resetFields();
|
|
|
|
this.$refs.make.resetFields();
|
2020-03-18 09:10:57 +08:00
|
|
|
if (selected && selected._type.toUpperCase() == 'AutomaticRoute'.toUpperCase() || selected._type.toUpperCase() == 'AutoTurnBack'.toUpperCase() || selected._type.toUpperCase() == 'AxleReset'.toUpperCase() || selected._type.toUpperCase() == 'LimitControl'.toUpperCase()) {
|
2020-03-05 16:39:49 +08:00
|
|
|
this.activeName = 'first';
|
|
|
|
this.editModel = deepAssign(this.editModel, selected);
|
2020-03-17 16:12:15 +08:00
|
|
|
this.editModel.type = selected._type;
|
2020-03-05 16:39:49 +08:00
|
|
|
}
|
|
|
|
},
|
2020-03-17 16:12:15 +08:00
|
|
|
async getAutoMaticList() { // 获取自动信号列表
|
2020-03-05 16:39:49 +08:00
|
|
|
const params = {
|
|
|
|
pageSize: 9999,
|
|
|
|
pageNum: 1
|
|
|
|
};
|
|
|
|
const resp = await getRouteNewList(this.$route.params.mapId, params);
|
|
|
|
this.autoList = [];
|
|
|
|
resp.data && resp.data.list && resp.data.list.forEach(elem => {
|
|
|
|
if (elem.flt) {
|
|
|
|
this.autoList.push(elem);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2020-03-17 16:12:15 +08:00
|
|
|
async getAutoTurnBackList() { // 获取自动折返列表
|
|
|
|
const params = {
|
|
|
|
pageSize: 9999,
|
|
|
|
pageNum: 1
|
|
|
|
};
|
|
|
|
const resp = await getAutoReentryList(this.$route.params.mapId, params);
|
|
|
|
this.autoList = [];
|
|
|
|
resp.data && resp.data.list && resp.data.list.forEach(elem => {
|
|
|
|
this.autoList.push(elem);
|
|
|
|
});
|
|
|
|
},
|
2020-03-05 16:39:49 +08:00
|
|
|
// 创建对象
|
|
|
|
create() {
|
|
|
|
this.$refs.make.validate((valid) => {
|
|
|
|
if (valid) {
|
2020-03-17 16:12:15 +08:00
|
|
|
const uid = getUID(this.addModel.type, this.selectLists); // 根据类型写 uid 前缀命名
|
|
|
|
const models = [];
|
2020-03-05 16:39:49 +08:00
|
|
|
const model = {
|
2020-03-17 16:12:15 +08:00
|
|
|
_type: this.addModel.type,
|
2020-03-05 16:39:49 +08:00
|
|
|
code: uid,
|
|
|
|
name: this.addModel.name,
|
2020-03-17 16:12:15 +08:00
|
|
|
subtitleName: this.addModel.subtitleName,
|
2020-03-05 16:39:49 +08:00
|
|
|
position: {
|
|
|
|
x: this.addModel.position.x,
|
|
|
|
y: this.addModel.position.y
|
|
|
|
},
|
2020-03-17 16:12:15 +08:00
|
|
|
automaticRouteCode: this.addModel.automaticRouteCode, // 关联自动进路code
|
|
|
|
cycleCode: this.addModel.cycleCode, // 自动折返关联code
|
|
|
|
stationCode: this.addModel.stationCode // 所属设备集中站
|
2020-03-05 16:39:49 +08:00
|
|
|
};
|
2020-03-17 16:12:15 +08:00
|
|
|
models.push(model);
|
2020-03-05 16:39:49 +08:00
|
|
|
this.$emit('updateMapModel', models);
|
|
|
|
this.$refs.make.resetForm();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
// 修改对象
|
|
|
|
edit() {
|
|
|
|
this.$refs['dataform'].validate((valid) => {
|
|
|
|
if (valid) {
|
2020-03-17 16:12:15 +08:00
|
|
|
const data = Object.assign({_type: this.editModel.type}, this.editModel);
|
|
|
|
this.$emit('updateMapModel', [data]);
|
2020-03-05 16:39:49 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
// 删除对象
|
|
|
|
deleteObj() {
|
|
|
|
const selected = this.$store.getters['map/getDeviceByCode'](this.editModel.code);
|
2020-03-18 09:10:57 +08:00
|
|
|
if (selected && selected._type.toUpperCase() === 'AutomaticRoute'.toUpperCase() || selected._type.toUpperCase() === 'AutoTurnBack'.toUpperCase() || selected._type.toUpperCase() === 'AxleReset'.toUpperCase() || selected._type.toUpperCase() == 'LimitControl'.toUpperCase()) {
|
2020-03-05 16:39:49 +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-03-17 16:12:15 +08:00
|
|
|
this.$emit('updateMapModel', {...selected, _dispose: true});
|
|
|
|
this.$refs.dataform.resetFields();
|
2020-03-05 16:39:49 +08:00
|
|
|
}).catch(() => {
|
2020-03-17 16:12:15 +08:00
|
|
|
this.$message.info(this.$t('tip.cancelledDelete'));
|
2020-03-05 16:39:49 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<style rel="stylesheet/scss" lang="scss" scoped>
|
|
|
|
@import "src/styles/mixin.scss";
|
|
|
|
.view-control{
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.card {
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
.coordinate {
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
|
|
.title {
|
|
|
|
text-align: right;
|
|
|
|
font-size: 14px;
|
|
|
|
color: #606266;
|
|
|
|
line-height: 40px;
|
|
|
|
padding: 0 12px 0 0;
|
|
|
|
-webkit-box-sizing: border-box;
|
|
|
|
box-sizing: border-box;
|
|
|
|
line-height: 28px;
|
|
|
|
width: 160px;
|
|
|
|
font-weight: bold;
|
|
|
|
display: block;
|
|
|
|
float: left;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.map-draft-group {
|
|
|
|
color: #3E44BE;
|
|
|
|
}
|
|
|
|
</style>
|