增加批量反向操作(区段左右关联关系信号机运行方向反向), 信号机批量设置显示方向,新增信号机显示方向字段showRight

This commit is contained in:
fan 2021-09-24 15:05:50 +08:00
parent 8e34f93a9d
commit 549079fbdb
6 changed files with 262 additions and 216 deletions

View File

@ -218,7 +218,7 @@ class Signal extends Group {
create() {
const model = this.model;
const style = this.style;
const drict = this.model.right ? 1 : -1; // 朝向 左:右
const drict = this.model.showRight ? 1 : -1; // 朝向 左:右
const posit = this.model.positionType == '01' ? -1 : 1; // 位置 上:下
// 信号机高柱矮柱 (信号机底座)
@ -292,8 +292,8 @@ class Signal extends Group {
this.tText.hide();
}
if (style.Signal.insideTriangle) {
const right = model.right ? 1 : -1;
const angle = Math.PI / 6 * right;
const showRight = model.showRight ? 1 : -1;
const angle = Math.PI / 6 * showRight;
this.insideTriangle = new Isogon({
zlevel: this.zlevel,
z: this.z + 1,
@ -344,7 +344,7 @@ class Signal extends Group {
// 信号机名称
const sigNameX = model.position.x + model.positionPoint.x - drict * (style.Signal.post.standardVerticalWidth) + model.namePosition.x;
const sigNameY = model.position.y + model.positionPoint.y + posit * (style.Signal.distance + style.Section.line.width + style.Signal.lamp.radiusR * 2 + model.namePosition.y + style.Signal.text.distance);
const textAlign = style.Signal.text.isAlignCenter ? 'middle' : this.model.right ? 'left' : 'right';
const textAlign = style.Signal.text.isAlignCenter ? 'middle' : this.model.showRight ? 'left' : 'right';
const textVerticalAlign = posit == 1 ? 'top' : 'bottom';
this.sigName = new ESigName({
zlevel: this.zlevel,
@ -480,13 +480,13 @@ class Signal extends Group {
createTransmission() {
const model = this.model;
const style = this.style;
const drict = this.model.right ? 1 : -1; // 朝向 左:右
const drict = this.model.showRight ? 1 : -1; // 朝向 左:右
const posit = this.model.positionType == '01' ? -1 : 1; // 位置 上:下
// 信号机名称
const actual = this.mapDevice[model.linkSignalCode];
const sigNameX = model.position.x + model.positionPoint.x + drict * 0.433 * style.Signal.transmission.sideLength + model.namePosition.x;
const sigNameY = model.position.y + model.positionPoint.y + posit * (style.Signal.distance + style.Section.line.width + style.Signal.lamp.radiusR * 2 + model.namePosition.y + style.Signal.text.distance);
const textAlign = style.Signal.text.isAlignCenter ? 'middle' : this.model.right ? 'left' : 'right';
const textAlign = style.Signal.text.isAlignCenter ? 'middle' : this.model.showRight ? 'left' : 'right';
const textVerticalAlign = posit == 1 ? 'top' : 'bottom';
const fillColor = actual.virtual ? style.Signal.transmission.fillColorVirtual : style.Signal.transmission.fillColor;
this.sigName = new ESigName({
@ -1128,7 +1128,7 @@ class Signal extends Group {
rect = this.ciConfirm.getBoundingRect();
break;
default:
var drict = this.model.right ? 1 : -1; // 朝向 右:左
var drict = this.model.showRight ? 1 : -1; // 朝向 右:左
var offsetY = this.model.positionType == '01' ? this.style.Signal.text.fontSize : 0; // 位置 上:下
var shape = this.model.type == 'TRANSMISSION' ? this.transmission : this.sigPost;
rect = shape.getBoundingRect().clone();
@ -1168,7 +1168,7 @@ class Signal extends Group {
/* 始端信号机选择后信号机变为三角形 */
setLampToTriangle() {
const endPoint = this.sigPost.getLampPosition(this.model.lampPostType);
const drict = this.model.right ? 1 : -1; // 朝向 右:左
const drict = this.model.showRight ? 1 : -1; // 朝向 右:左
this.lampTriangle = new Polygon({
zelvel: this.zlevel,
z: this.z,

View File

@ -2,10 +2,10 @@ export function getBaseUrl() {
let BASE_API;
if (process.env.NODE_ENV === 'development') {
// BASE_API = 'https://joylink.club/jlcloud';
// BASE_API = 'https://test.joylink.club/jlcloud';
BASE_API = 'https://test.joylink.club/jlcloud';
// BASE_API = 'http://192.168.8.152:9000'; // 袁琪
// BASE_API = 'http://192.168.8.177:9000'; // 旭强
BASE_API = 'http://192.168.8.109:9000'; // 张赛
// BASE_API = 'http://192.168.8.109:9000'; // 张赛
// BASE_API = 'http://192.168.8.140:9000'; // 杜康
// BASE_API = 'http://b29z135112.zicp.vip';
// BASE_API = 'http://2925963m2a.zicp.vip'; // 杜康

View File

@ -35,6 +35,12 @@
<el-button type="" size="mini" @click="clearList">清空</el-button>
</div>
</el-tab-pane>
<el-tab-pane label="批量反向" name="forth">
<div class="button-box">
<el-button type="primary" size="mini" @click="handleReverse">批量反向</el-button>
<el-button type="" size="mini" @click="clearList">清空</el-button>
</div>
</el-tab-pane>
</el-tabs>
<div v-for="item in modelList" :key="item.type" class="content-box-list" style="margin-top: 10px">
<div class="title-box">{{ item.name }}</div>
@ -56,224 +62,242 @@
</template>
<script>
import { mapGetters } from 'vuex'
import { deepAssign } from '@/utils/index'
import { mapGetters } from 'vuex';
import { deepAssign } from '@/utils/index';
export default {
name: 'CheckboxDraft',
components: {},
props: {
selected: {
type: Object,
default: function () {
return null
},
name: 'CheckboxDraft',
components: {},
props: {
selected: {
type: Object,
default: function () {
return null;
}
}
},
},
data() {
return {
stationCode: '',
belongStationCode: '',
activeName: 'first',
modelList: [
{
type: 'Section',
name: '区段列表',
list: [],
logicSectionList: [],
},
{
type: 'Switch',
name: '道岔列表',
list: [],
},
{
type: 'Signal',
name: '信号机列表',
list: [],
},
],
}
},
computed: {
...mapGetters('map', ['seclectDeviceList', 'stationList']),
centralizedStationList() {
let list = []
list = this.stationList.filter(station => {
return station.centralized
})
return list
data() {
return {
stationCode: '',
belongStationCode: '',
activeName: 'first',
modelList: [
{
type: 'Section',
name: '区段列表',
list: [],
logicSectionList: []
},
{
type: 'Switch',
name: '道岔列表',
list: []
},
{
type: 'Signal',
name: '信号机列表',
list: []
}
]
};
},
},
mounted() {},
methods: {
computed: {
...mapGetters('map', ['seclectDeviceList', 'stationList']),
centralizedStationList() {
let list = [];
list = this.stationList.filter(station => {
return station.centralized;
});
return list;
}
},
mounted() {},
methods: {
// deviceChange(code) {
// this.$emit('setCenter', code);
// this.deviceSelect(this.$store.getters['map/getDeviceByCode'](code));
// },
deviceSelect(selected) {
if (selected && selected._type.toUpperCase() == 'CheckBox'.toUpperCase()) {
this.activeName = 'first'
this.clearModelList()
let count = 0
this.seclectDeviceList.forEach(item => {
if (item._type == 'Section') {
if (item.type != '02') {
this.modelList[0].list.push(item)
} else {
this.modelList[0].logicSectionList.push(item)
deviceSelect(selected) {
if (selected && selected._type.toUpperCase() == 'CheckBox'.toUpperCase()) {
this.activeName = 'first';
this.clearModelList();
let count = 0;
this.seclectDeviceList.forEach(item => {
if (item._type == 'Section') {
if (item.type != '02') {
this.modelList[0].list.push(item);
} else {
this.modelList[0].logicSectionList.push(item);
}
} else if (item._type == 'Switch') {
this.modelList[1].list.push(item);
} else if (item._type == 'Signal') {
this.modelList[2].list.push(item);
}
if (item.stationCode == this.seclectDeviceList[0].stationCode) {
count++;
}
});
if (count && count == this.seclectDeviceList.length) {
this.stationCode = this.seclectDeviceList[0].stationCode;
} else {
this.stationCode = '';
}
this.belongStationCode = this.stationList[0] && this.stationList[0].code;
}
} else if (item._type == 'Switch') {
this.modelList[1].list.push(item)
} else if (item._type == 'Signal') {
this.modelList[2].list.push(item)
}
if (item.stationCode == this.seclectDeviceList[0].stationCode) {
count++
}
})
if (count && count == this.seclectDeviceList.length) {
this.stationCode = this.seclectDeviceList[0].stationCode
} else {
this.stationCode = ''
}
this.belongStationCode = this.stationList[0] && this.stationList[0].code
}
},
clearModelList() {
this.modelList.forEach(item => {
item.list = []
if (item.logicSectionList) item.logicSectionList = []
})
},
//
delList(model, list) {
list.forEach((nor, index) => {
if (nor.code == model.code) {
list.splice(index, 1)
}
})
this.seclectDeviceList.forEach((item, index) => {
if (item.code == model.code) {
this.seclectDeviceList.splice(index, 1)
}
})
},
//
handleSectionStationCode() {
if (this.stationCode && this.seclectDeviceList && this.seclectDeviceList.length > 0) {
const models = []
this.modelList.forEach(model => {
//
model.list.forEach(item => {
const Model = deepAssign({}, this.$store.getters['map/getDeviceByCode'](item.code))
Model.stationCode = this.stationCode
if (Model._type == 'Section' && Model.logicSectionCodeList && Model.logicSectionCodeList.length) {
Model.logicSectionCodeList.forEach(children => {
const ModelChild = deepAssign({}, this.$store.getters['map/getDeviceByCode'](children))
ModelChild.stationCode = this.stationCode
models.push(ModelChild)
})
}
models.push(Model)
})
})
this.$emit('updateMapModel', models)
this.$message.success('设置设备集中站成功')
this.stationCode = ''
}
},
handleBelongStationCode() {
if (this.belongStationCode && this.seclectDeviceList && this.seclectDeviceList.length > 0) {
const models = []
this.modelList.forEach(model => {
//
model.list.forEach(item => {
const Model = deepAssign({}, this.$store.getters['map/getDeviceByCode'](item.code))
if (Model._type == 'Section') {
Model.belongStation = this.belongStationCode
} else {
Model.belongStationCode = this.belongStationCode
}
if (Model._type == 'Section' && Model.logicSectionCodeList && Model.logicSectionCodeList.length) {
Model.logicSectionCodeList.forEach(children => {
const ModelChild = deepAssign({}, this.$store.getters['map/getDeviceByCode'](children))
ModelChild.belongStation = this.belongStationCode
models.push(ModelChild)
})
}
models.push(Model)
})
})
this.$emit('updateMapModel', models)
this.$message.success('设置所属车站成功')
this.stationCode = ''
}
},
handleBatchExport() {
const exportData = this.generateExportData()
const content = new Blob([JSON.stringify(exportData)])
const url = URL.createObjectURL(content)
const el = document.createElement('a')
el.href = url
el.download = `export.json`
el.click()
URL.revokeObjectURL(url)
},
generateExportData() {
let res = {}
this.modelList.forEach(item => {
res[`${item.type.toLowerCase()}List`] = [...item.list.map(_ => _.code), ...(item.logicSectionList || []).map(_ => _.code)]
})
res.switchList = res.switchList.map(c => this.$store.state.map.map.switchList.find(_ => _.code === c))
res.switchList.forEach(swch => {
'ABC'.split('').forEach(c => {
if (!res.sectionList.includes(swch[`section${c}Code`])) {
res.sectionList.push(swch[`section${c}Code`])
}
})
})
for (let key in res) {
if (key !== 'switchList') res[key] = this.$store.state.map.map[key].filter(model => res[key].includes(model.code))
}
return res
},
clearList() {
//
this.stationCode = ''
this.belongStationCode = ''
this.$store.commit('map/setSeclectDeviceList', [])
this.modelList = [
{
type: 'Section',
name: '区段列表',
list: [],
logicSectionList: [],
},
{
type: 'Switch',
name: '道岔列表',
list: [],
clearModelList() {
this.modelList.forEach(item => {
item.list = [];
if (item.logicSectionList) item.logicSectionList = [];
});
},
{
type: 'Signal',
name: '信号机列表',
list: [],
//
delList(model, list) {
list.forEach((nor, index) => {
if (nor.code == model.code) {
list.splice(index, 1);
}
});
this.seclectDeviceList.forEach((item, index) => {
if (item.code == model.code) {
this.seclectDeviceList.splice(index, 1);
}
});
},
]
},
mouseenter(model) {
if (model._type == 'Section') {
model.instance.mouseover()
}
},
mouseleave(model) {
if (model._type == 'Section') {
model.instance.mouseout()
}
},
},
}
//
handleSectionStationCode() {
if (this.stationCode && this.seclectDeviceList && this.seclectDeviceList.length > 0) {
const models = [];
this.modelList.forEach(model => {
//
model.list.forEach(item => {
const Model = deepAssign({}, this.$store.getters['map/getDeviceByCode'](item.code));
Model.stationCode = this.stationCode;
if (Model._type == 'Section' && Model.logicSectionCodeList && Model.logicSectionCodeList.length) {
Model.logicSectionCodeList.forEach(children => {
const ModelChild = deepAssign({}, this.$store.getters['map/getDeviceByCode'](children));
ModelChild.stationCode = this.stationCode;
models.push(ModelChild);
});
}
models.push(Model);
});
});
this.$emit('updateMapModel', models);
this.$message.success('设置设备集中站成功');
this.stationCode = '';
}
},
handleBelongStationCode() {
if (this.belongStationCode && this.seclectDeviceList && this.seclectDeviceList.length > 0) {
const models = [];
this.modelList.forEach(model => {
//
model.list.forEach(item => {
const Model = deepAssign({}, this.$store.getters['map/getDeviceByCode'](item.code));
if (Model._type == 'Section') {
Model.belongStation = this.belongStationCode;
} else {
Model.belongStationCode = this.belongStationCode;
}
if (Model._type == 'Section' && Model.logicSectionCodeList && Model.logicSectionCodeList.length) {
Model.logicSectionCodeList.forEach(children => {
const ModelChild = deepAssign({}, this.$store.getters['map/getDeviceByCode'](children));
ModelChild.belongStation = this.belongStationCode;
models.push(ModelChild);
});
}
models.push(Model);
});
});
this.$emit('updateMapModel', models);
this.$message.success('设置所属车站成功');
this.stationCode = '';
}
},
handleBatchExport() {
const exportData = this.generateExportData();
const content = new Blob([JSON.stringify(exportData)]);
const url = URL.createObjectURL(content);
const el = document.createElement('a');
el.href = url;
el.download = `export.json`;
el.click();
URL.revokeObjectURL(url);
},
handleReverse() {
const models = [];
this.modelList.forEach(model => {
model.list.forEach(item => {
const Model = deepAssign({}, this.$store.getters['map/getDeviceByCode'](item.code));
if (Model._type == 'Section') {
const temValue = Model.leftSectionCode;
Model.leftSectionCode = Model.rightSectionCode;
Model.rightSectionCode = temValue;
} else if (Model._type == 'Signal') {
Model.right = !Model.right;
}
models.push(Model);
});
});
this.$emit('updateMapModel', models);
this.$message.success('设置所属车站成功');
},
generateExportData() {
const res = {};
this.modelList.forEach(item => {
res[`${item.type.toLowerCase()}List`] = [...item.list.map(_ => _.code), ...(item.logicSectionList || []).map(_ => _.code)];
});
res.switchList = res.switchList.map(c => this.$store.state.map.map.switchList.find(_ => _.code === c));
res.switchList.forEach(swch => {
'ABC'.split('').forEach(c => {
if (!res.sectionList.includes(swch[`section${c}Code`])) {
res.sectionList.push(swch[`section${c}Code`]);
}
});
});
for (const key in res) {
if (key !== 'switchList') res[key] = this.$store.state.map.map[key].filter(model => res[key].includes(model.code));
}
return res;
},
clearList() {
//
this.stationCode = '';
this.belongStationCode = '';
this.$store.commit('map/setSeclectDeviceList', []);
this.modelList = [
{
type: 'Section',
name: '区段列表',
list: [],
logicSectionList: []
},
{
type: 'Switch',
name: '道岔列表',
list: []
},
{
type: 'Signal',
name: '信号机列表',
list: []
}
];
},
mouseenter(model) {
if (model._type == 'Section') {
model.instance.mouseover();
}
},
mouseleave(model) {
if (model._type == 'Section') {
model.instance.mouseout();
}
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import 'src/styles/mixin.scss';

View File

@ -148,6 +148,11 @@
<el-button type="primary" class="signalSetting" size="small" @click="setSignalUniqueName">设置</el-button>
</div>
</el-collapse-item>
<el-collapse-item title="设置信号机显示方向" name="10">
<div class="flex_box">
<el-button type="primary" class="signalSetting" size="small" @click="setShowRight">设置</el-button>
</div>
</el-collapse-item>
</el-collapse>
</template>
<script>
@ -447,6 +452,16 @@ export default {
this.$emit('updateMapModel', models);
this.$message.success('数据构建成功!');
},
setShowRight() {
const models = [];
this.signalList.forEach(item => {
const signalModel = deepAssign({}, item); //
signalModel.showRight = item.right;
models.push(signalModel);
});
this.$emit('updateMapModel', models);
this.$message.success('数据构建成功!');
},
setData(type, data) {
switch (type) {
case 'signalStationCodeType': {

View File

@ -33,6 +33,7 @@ export default {
sectionCode: '',
name: '',
right: false,
showRight: false,
leftOrRight: 'L', //
positionType: '01',
stationCode: '',
@ -52,6 +53,9 @@ export default {
right: [
{ required: true, message: this.$t('map.pleaseSelect') + '' + this.$t('map.directionType'), trigger: 'change' }
],
showRight: [
{ required: true, message: this.$t('map.pleaseSelect') + '' + this.$t('map.directionType'), trigger: 'change' }
],
leftOrRight: [
{ required: true, message: this.$t('map.pleaseSelect') + '' + this.$t('map.leftOrRight'), trigger: 'change' }
],
@ -109,6 +113,7 @@ export default {
{ prop: 'name', label: this.$t('map.signalNameColon'), type: 'input' },
{ prop: 'leftOrRight', label: this.$t('map.leftOrRight'), type: 'radio', optionLabel: 'label', optionValue:'value', border:true, radioList: this.SignalLeftOrRightList},
{ prop: 'right', label: this.$t('map.signalDirectionTypeX'), type: 'radio', optionLabel: 'name', optionValue:'code', border:true, radioList: this.SignalDirectionList},
{ prop: 'showRight', label: '显示方向', type: 'radio', optionLabel: 'name', optionValue:'code', border:true, radioList: this.SignalDirectionList},
{ prop: 'positionType', label: this.$t('map.positionType'), type: 'radio', optionLabel: 'name', optionValue:'code', border:true, radioList: this.SignalPositionTypeList},
{ prop: 'stationCode', label: this.$t('map.equipmentStation'), type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.centralizedStationList},
{ prop: 'interlockStationCode', label: '所属联锁站:', type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.ciStationList}
@ -143,6 +148,7 @@ export default {
sectionCode: this.addModel.sectionCode,
positionType: this.addModel.positionType,
right: this.addModel.right,
showRight: this.addModel.showRight,
nameShow: true,
buttonShow: true,
stationCode: this.addModel.stationCode

View File

@ -130,6 +130,7 @@ export default {
{ prop: 'lampPostType', label: this.$t('map.lampPostType'), type: 'radio', optionLabel: 'name', optionValue: 'code', border: true, radioList: this.SignalLampPostTypeList },
{ prop: 'lampPositionType', label: this.$t('map.lampPositionType'), type: 'select', optionLabel: 'name', optionValue: 'code', options: this.SignalLampPositionTypeList },
{ prop: 'right', label: this.$t('map.signalDirectionTypeX'), type: 'radio', optionLabel: 'name', optionValue: 'code', border: true, radioList: this.SignalDirectionList },
{ prop: 'showRight', label: '显示方向', type: 'radio', optionLabel: 'name', optionValue: 'code', border: true, radioList: this.SignalDirectionList },
{ prop: 'positionType', label: this.$t('map.signalPositionType'), type: 'radio', optionLabel: 'name', optionValue: 'code', border: true, radioList: this.SignalPositionTypeList },
{ prop: 'rotate', label: this.$t('map.rotateAngle'), type: 'number', min: -180, max: 180, placeholder: this.$t('tip.angle') },
{ prop: 'nameRotated', label: this.$t('map.signalNameRotated'), type: 'checkbox' },