Revert "Revert "Revert "显示配置调整"""

This reverts commit 15cfbd02
This commit is contained in:
fan 2021-09-13 10:00:03 +08:00
parent 6b35126161
commit ba7233d1c8

View File

@ -0,0 +1,220 @@
<template>
<div v-loading="loading" class="view-control-content">
<el-scrollbar wrap-class="scrollbar-wrapper">
<el-card class="box-card" shadow="never" style="width: 80%; margin: 0 auto 15px; border-top: none;">
<div slot="header">
<span>请选择行调显示设备</span>
</div>
<div style="padding: 10px;font-size: 14px;">
<div class="content-box-list" style="margin-top: 10px;">
<div class="title-box">设备列表</div>
<div class="list-box" style="height:400px;overflow:auto">
<div v-for="nor in addModel.elementList" :key="nor.code" class="list-content">
<div class="name">{{ getDeviceName(nor) }}</div>
<div class="close" @click="delList(nor, addModel.elementList)"><i class="el-icon-close" /></div>
</div>
</div>
</div>
</div>
</el-card>
<div style="display: table; margin-left: 150px; margin-top: 12px; margin-bottom: 20px;">
<el-button type="primary" size="small" @click="generateData">自动生成</el-button>
<el-button type="primary" size="small" :loading="dataLoading" @click="save">保存</el-button>
<el-button type="primary" size="small" @click="back">返回</el-button>
</div>
</el-scrollbar>
</div>
</template>
<script>
import { mapGetters } from 'vuex';
import { saveMap } from '@/api/jmap/mapdraft';
export default {
components: {
},
props: {
selected: {
type: Object,
default: function () {
return null;
}
}
},
data() {
return {
otherData: [],
addModel: {
type: 'CENTER',
elementList: []
},
loading: false,
dataLoading:false
};
},
computed: {
...mapGetters('map', [
'sectionList',
'stationList',
'signalList',
'switchList',
'stationStandList',
'automaticRouteButtonList',
'axleCounterResetButtonList',
'cycleButtonList',
'directionRodList',
'indicatorLightList',
'lineList',
'outerFrameList',
'psdList',
'responderList',
'tbStrategyList',
'tempSpeedLimitList',
'textList',
'totalGuideLockButtonVOList',
'seclectDeviceList'
])
},
watch: {
selected: function (val, oldVal) {
this.deviceSelect(val);
}
},
mounted() {
this.initData();
},
methods: {
initData() {
this.$store.state.map.map.displayList.forEach(item => {
if (item.type === 'CENTER') {
this.addModel = item;
} else {
this.otherData.push(item);
}
});
},
deviceSelect(selected) {
if (selected && selected._type.toUpperCase() == 'CheckBox'.toUpperCase()) {
this.seclectDeviceList.forEach(item => {
if (this.addModel.elementList.indexOf(item.code) < 0) {
this.addModel.elementList.push(item.code);
}
});
} else if (selected) {
if (this.addModel.elementList.indexOf(selected.code) < 0) {
this.addModel.elementList.push(selected.code);
}
}
},
getDeviceName(code) {
const device = this.$store.getters['map/getDeviceByCode'](code);
return device.name || device.code;
},
//
delList(model, list) {
list.forEach((nor, index) => {
if (nor == model) {
list.splice(index, 1);
}
});
this.seclectDeviceList.forEach((item, index) => {
if (item.code == model) {
this.seclectDeviceList.splice(index, 1);
}
});
},
save() {
const map = this.$store.state.map.map;
const param = {
displayList: [...this.otherData, this.addModel],
mapId: this.$route.params.mapId
};
this.dataLoading = true;
saveMap(Object.assign(map, param)).then(response => {
this.$message.success('保存行调配置成功');
this.dataLoading = false;
}).catch(() => {
this.dataLoading = false;
this.$messageBox('保存行调配置失败');
});
},
back() {
this.$emit('goDraw');
},
clear() {
this.addModel = {elementList: []};
},
generateData() {
this.loading = true;
this.tableData = [];
const station = this.stationList.find(item => item.depot);
[...this.sectionList, ...this.signalList, ...this.stationStandList, ...this.switchList, ...this.automaticRouteButtonList,
...this.axleCounterResetButtonList, ...this.cycleButtonList, ...this.indicatorLightList, ...this.lineList, ...this.outerFrameList,
...this.responderList, ...this.tbStrategyList, ...this.tempSpeedLimitList, ...this.textList, ...this.totalGuideLockButtonVOList].forEach(item => {
if (item.stationCode !== station.code) {
this.addModel.elementList.push(item.code);
}
});
[...this.directionRodList].forEach(item => {
if (item.deviceStationCode !== station.code) {
this.addModel.elementList.push(item.code);
}
});
this.psdList.forEach(item => {
const stand = this.$store.getters['map/getDeviceByCode'](item.standCode);
if (stand.stationCode !== station.code) {
this.addModel.elementList.push(item.code);
}
});
const map = this.$store.state.map.map;
const param = {
displayList: [...this.otherData, this.addModel],
mapId: this.$route.params.mapId
};
saveMap(Object.assign(map, param)).then(response => {
this.loading = false;
this.$message.success('保存行调配置成功');
}).catch(() => {
this.loading = false;
this.$messageBox('保存行调配置失败');
});
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.title-box{
padding-left: 10px;
border-left: 4px solid red;
margin-bottom: 10px;
}
.list-box{
overflow: hidden;
.list-content{
float: left;
background: #e2e2e2;
margin: 5px;
border-radius: 5px;
height: 30px;
line-height: 30px;
padding-left: 10px;
padding-right: 3px;
cursor: pointer;
&:hover{
background: #ccc;
}
.name{
float: left;
margin-right: 20px;
}
.close{
float: left;
width: 23px;
cursor: pointer;
}
}
}
</style>