rt-sim-training-client/src/views/newMap/newMapdraft/mapoperate/section.vue

1245 lines
62 KiB
Vue
Raw Normal View History

2019-11-29 12:51:58 +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.bothCreate')" name="second">
<div class="flex_box">
<el-button type="primary" @click="create">{{ $t('map.createSection') }}</el-button>
</div>
<div style="height: calc(100% - 46px);">
<el-scrollbar wrap-class="scrollbar-wrapper">
<el-card v-if="questionList.length" class="box-card">
<div v-for="(item, index) in questionList" :key="index" class="text item">{{ item }}</div>
</el-card>
</el-scrollbar>
</div>
</el-tab-pane>
<el-tab-pane class="view-control" :label="$t('map.splitMerge')" name="three">
<div style="height: 100%;">
<el-scrollbar wrap-class="scrollbar-wrapper">
<el-form ref="oprt" :model="addModel" label-width="130px" size="mini" :rules="addRules">
<el-form-item :label="$t('map.sectionNameColon')" prop="code">
<el-select v-model="addModel.code" filterable>
<el-option
v-for="item in PhysicalSectionList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
<el-button
:type="field === 'splitSection' ? 'danger' : 'primary'"
size="small"
@click="hover('splitSection')"
>{{ $t('map.activate') }}</el-button>
</el-form-item>
<el-form-item :label="$t('map.breakUpNumber')" prop="splitNumber">
<el-input-number v-model="addModel.splitNumber" :min="1" :max="addModel.splitOffsetMax" />
</el-form-item>
<el-form-item :label="$t('map.trainDirection')" prop="trainPosType">
<el-select v-model="addModel.trainPosType" filterable>
<el-option
v-for="item in TrainPositionTypeList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button-group>
<el-button type="primary" size="big" @click="split">{{ $t('map.split') }}</el-button>
</el-button-group>
</el-form-item>
</el-form>
<el-form ref="oprt1" :model="mergeModel" label-width="130px" size="mini" :rules="mergeRules">
<el-form-item :label="$t('map.sectionLsectioncode')" prop="lsectioncode">
<el-select v-model="mergeModel.lsectioncode" filterable :placeholder="$t('rules.pleaseSelect')">
<el-option
v-for="item in ReverseSectionList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
<el-button
:type="field === 'leftSection' ? 'danger' : 'primary'"
size="small"
@click="hover('leftSection')"
>{{ $t('map.activate') }}</el-button>
</el-form-item>
<el-form-item :label="$t('map.sectionRsectioncode')" prop="rsectioncode">
<el-select v-model="mergeModel.rsectioncode" filterable :placeholder="$t('rules.pleaseSelect')">
<el-option
v-for="item in ReverseSectionList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
<el-button
:type="field === 'rightSection' ? 'danger' : 'primary'"
size="small"
@click="hover('rightSection')"
>{{ $t('map.activate') }}</el-button>
</el-form-item>
<el-form-item>
<el-button-group>
<el-button type="primary" size="big" @click="merge">{{ $t('map.merge') }}</el-button>
</el-button-group>
</el-form-item>
</el-form>
</el-scrollbar>
</div>
</el-tab-pane>
<el-tab-pane class="view-control" :label="$t('map.logicBlock')" name="four">
<div style="height: calc(100% - 46px);">
<el-scrollbar wrap-class="scrollbar-wrapper">
<el-table :data="tableData" style="width: 80%; margin: 0 auto;">
<el-table-column :label="$t('map.sectionPolyline')" width="150">
<template slot-scope="scope">
<span style="margin-left: 10px">{{ $t('map.aux') }}{{ scope.row.index }}{{ $t('map.sectionLine') }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('map.sectionLogicalNumber')" width="130">
<template slot-scope="scope">
<el-input v-model="scope.row.num" size="mini" />
</template>
</el-table-column>
<el-table-column :label="$t('map.operation')">
<template slot-scope="scope">
<el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">{{ $t('map.empty') }}
</el-button>
</template>
</el-table-column>
</el-table>
</el-scrollbar>
</div>
<div class="button_box">
<el-button-group class="map-draft-group">
<el-button type="primary" size="small" @click="editSectionNum">{{ $t('map.updateObj') }}</el-button>
</el-button-group>
</div>
</el-tab-pane>
<el-tab-pane class="view-control" label="批量操作" name="five">
<el-form label-width="130px" size="mini">
<el-form-item label="选择link:">
<el-select v-model="linkCodeList" filterable multiple size="mini">
<el-option
v-for="item in linkList"
:key="item.code"
:label="item.name + ' (' + item.code + ')'"
:value="item.code"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button-group>
<el-button type="primary" @click="delRelevanceSection">删除link相关元素</el-button>
</el-button-group>
</el-form-item>
</el-form>
<el-form ref="operationModel" :model="operationModel" label-width="130px" size="mini" :rules="operationRules">
<el-form-item :label="$t('map.sectionData') + ':'" prop="sectionList">
<el-select v-model="operationModel.sectionList" filterable multiple>
<el-option
v-for="item in PhysicalSectionList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
<el-button
:type="field === 'handleSection' ? 'danger' : 'primary'"
size="small"
@click="hover('handleSection')"
>{{ $t('map.activate') }}</el-button>
</el-form-item>
<el-form-item :label="$t('map.equipmentStation')" prop="stationCode">
<el-select v-model="operationModel.stationCode" filterable>
<el-option
v-for="item in stationList"
:key="item.code"
:label="item.name + item.code"
:value="item.code"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button-group>
<el-button type="primary" @click="handleScetionStationCode">{{ $t('map.setStationCode') }}</el-button>
</el-button-group>
</el-form-item>
</el-form>
</el-tab-pane>
</el-tabs>
</template>
<script>
import { mapGetters } from 'vuex';
import { getUID } from '@/jmap/utils/Uid';
import JTriangle from '@/jmap/utils/JTriangle';
import ConfigList from './config/list';
import { deepAssign } from '@/utils/index';
export default {
name: 'SectionDraft',
components: {
ConfigList
},
props: {
selected: {
type: Object,
default() {
return {};
}
}
},
data() {
return {
questionList: [],
linksCollection: [],
activeName: 'first',
SectionTypeList: [],
SectionSepTypeList: [],
TrainPositionTypeList: [],
regionList: [],
viewSelect: false,
editModel: {
code: '',
name: '',
type: '',
relStandCode: '', // 关联站台编码
leftStopPointOffset: 0, // 左向停车点偏移量
rightStopPointOffset: 0, // 右向停车点偏移量
destinationCode: '', // 目的地码
destinationCodePoint: { x: 0, y: 0 }, // 目的地码坐标
axleShow: false,
namePosition: { x: 0, y: 0 },
kmRangeRight: 0,
kmRangeLeft: 0,
region: '',
logicSectionNum: [],
logicSectionShow: false,
isStandTrack: false,
standTrackName: '',
standTrackNamePosition: { x: 0, y: 0 },
isReentryTrack: false,
reentryTrackName: '',
reentryTrackNamePosition: { x: 0, y: 0 },
isTransferTrack: false,
isSegmentation: false,
segmentationPosition: { x: 0, y: 0 },
transferTrackName: '',
transferTrackNamePosition: { x: 0, y: 0 },
isSwitchSection: '',
relSwitchCode: '',
stationCode: '',
logicSectionNameSort: '',
linkCode: '',
sepTypeLeft: '',
offsetLeft: 0,
sepTypeRight: '',
offsetRight: 0,
trainPosType: '', // 列车所在方向
parentCode: '',
points: [],
lengthFact: 0,
isCurve: false
},
linkCodeList: [],
tableData: [],
oldPoint: [], // 区段未修改前 坐标
addModel: {
code: '',
splitNumber: 2,
trainPosType: '', // 列车所在方向
splitOffsetMax: 15
},
operationModel: { // 区段集中站列表
sectionList: [],
stationCode: ''
},
mergeModel: {
lsectioncode: '',
rsectioncode: ''
},
logicSectionNums: [1],
fieldS: '',
field: '',
addRules: {
code: [
{ required: true, message: this.$t('rules.pleaseSelectSectionName'), trigger: 'change' }
],
splitNumber: [
{ required: true, message: this.$t('rules.pleaseEnterSplit'), trigger: 'blur' }
],
trainPosType: [
{ required: true, message: this.$t('rules.pleaseSelectTrainDir'), trigger: 'change' }
]
},
mergeRules: {
lsectioncode: [
{ required: true, message: this.$t('rules.pleaseSelectLeftSectionName'), trigger: 'change' }
],
rsectioncode: [
{ required: true, message: this.$t('rules.pleaseSelectRightSectionName'), trigger: 'change' }
]
},
editRule: {
pointY: [
{ required: true, message: this.$t('rules.pleaseEnterYValue'), trigger: 'blur' }
]
},
operationRules: {
sectionList: [
{ required: true, message: this.$t('rules.pleaseSelectSection'), trigger: 'change' }
],
stationCode: [
{ required: true, message: this.$t('rules.pleaseSelectStationCode'), trigger: 'change' }
]
}
};
},
computed: {
...mapGetters('map', [
'map',
'linkList',
'sectionList',
'switchList',
'stationList',
'stationStandList',
'lineCode'
]),
form() {
const form = {
labelWidth: '160px',
items: {
code: {
name: '',
item: []
},
draw: {
name: this.$t('map.drawData'),
item: [
{ prop: 'code', label: this.$t('map.blockCoding'), type: 'select', mode: false, optionLabel: 'name&&code', optionValue: 'code', options: this.sectionList, change: true, deviceChange: this.deviceChange },
{ prop: 'name', label: this.$t('map.sectionNameColon'), type: 'input' },
{ prop: 'namePosition', label: this.$t('map.sectionNameOffset'), type: 'coordinate', width: '150px', children: [
{ prop: 'namePosition.x', firstLevel: 'namePosition', secondLevel: 'x', label: 'x:', type: 'number', labelWidth: '25px' },
{ prop: 'namePosition.y', firstLevel: 'namePosition', secondLevel: 'y', label: 'y:', type: 'number', labelWidth: '25px' }
] },
{ prop: 'type', label: this.$t('map.sectionType'), type: 'select', optionLabel: 'name', optionValue: 'code', options: this.SectionTypeList, disabled: true },
{ prop: 'linkCode', label: this.$t('map.relevanceLinkCode'), type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.linkList, disabled: true, isHidden: !this.isSectionType },
{ prop: 'parentCode', label: this.$t('map.associatedSection'), type: 'select', mode: true, optionLabel: 'name&&code', optionValue: 'code', disabled: true, options: this.sectionList, isHidden: !this.isParentCode },
{ prop: 'isStandTrack', label: this.$t('map.isStandTrack'), type: 'checkbox', isHidden: !this.isSwitchSectionShow }, // 1
{ prop: 'standTrackName', label: this.$t('map.standTrackName'), type: 'input', isHidden: !this.isstandTrackNameShow },
{ prop: 'standTrackNamePosition', label: this.$t('map.standTrackNamePosition'), type: 'coordinate', width: '150px', isHidden: !this.isstandTrackNameShow, children: [
{ prop: 'standTrackNamePosition.x', firstLevel: 'standTrackNamePosition', secondLevel: 'x', label: 'x:', type: 'number', labelWidth: '20px'},
{ prop: 'standTrackNamePosition.y', firstLevel: 'standTrackNamePosition', secondLevel: 'y', label: 'y:', type: 'number', labelWidth: '20px'}
] },
{ prop: 'relStandCode', label: this.$t('map.relStandCode'), type: 'selectHover', optionLabel: 'code&&name', optionValue: 'code', options: this.stationStandList, hover: this.hover, buttonType: 'relStandCode', buttonShowType: this.isButtonType, isHidden: !this.isrelStandCode },
{ prop: 'isReentryTrack', label: this.$t('map.isReentryTrack'), type: 'checkbox', isHidden: !this.isSwitchSectionShow }, // 1
{ prop: 'reentryTrackName', label: this.$t('map.reentryTrackName'), type: 'input', isHidden: !this.isreentryTrackName },
{ prop: 'reentryTrackNamePosition', label: this.$t('map.reentryTrackNamePosition'), type: 'coordinate', width: '150px', isHidden: !this.isreentryTrackName, children: [
{ prop: 'reentryTrackNamePosition.x', firstLevel: 'reentryTrackNamePosition', secondLevel: 'x', label: 'x:', type: 'number', labelWidth: '20px'},
{ prop: 'reentryTrackNamePosition.y', firstLevel: 'reentryTrackNamePosition', secondLevel: 'y', label: 'y:', type: 'number', labelWidth: '20px'}
] },
{ prop: 'isTransferTrack', label: this.$t('map.isTransferTrack'), type: 'checkbox', isHidden: !this.isSwitchSectionShow }, // 1
{ prop: 'transferTrackName', label: this.$t('map.transferTrackName'), type: 'input', isHidden: !this.istransferTrackName },
{ prop: 'transferTrackNamePosition', label: this.$t('map.transferTrackNamePosition'), type: 'coordinate', width: '150px', isHidden: !this.istransferTrackName, children: [
{ prop: 'transferTrackNamePosition.x', firstLevel: 'transferTrackNamePosition', secondLevel: 'x', label: 'x:', type: 'number', labelWidth: '20px'},
{ prop: 'transferTrackNamePosition.y', firstLevel: 'transferTrackNamePosition', secondLevel: 'y', label: 'y:', type: 'number', labelWidth: '20px'}
] },
{ prop: 'destinationCode', label: this.$t('map.destinationCode'), type: 'input', isHidden: !this.isdestinationCode },
{ prop: 'destinationCodePoint', label: this.$t('map.destinationCodePoint'), type: 'coordinate', width: '150px', isHidden: !this.isdestinationCode, children: [
{ prop: 'destinationCodePoint.x', firstLevel: 'destinationCodePoint', secondLevel: 'x', label: 'x:', type: 'number', labelWidth: '20px'},
{ prop: 'destinationCodePoint.y', firstLevel: 'destinationCodePoint', secondLevel: 'y', label: 'y:', type: 'number', labelWidth: '20px'}
] },
{ prop: 'isSwitchSection', label: this.$t('map.isSwitchSection'), type: 'checkbox', isHidden: !this.isSectionType, disabled: true },
{ prop: 'relSwitchCode', label: this.$t('map.relSwitchCode'), type: 'select', optionLabel: 'code&&name', optionValue: 'code', options: this.switchList, change: true, deviceChange: this.deviceChange, isHidden: !this.isRelSwitchCode, disabled: true },
{ prop: 'logicSectionShow', label: this.$t('map.displayLogicalExtents'), type: 'checkbox', isHidden: !this.isSwitchSectionShow }, // 1
{ prop: 'logicSectionNameSort', label: this.$t('map.logicSectionNameSort'), type: 'radio', isHidden: !this.isLogicSectionNameSort, radioList: [
{value: true, label: this.$t('map.fromSmallToLarge')},
{value: false, label: this.$t('map.fromLargeToSmall')}
] }, // 1
{ prop: 'sepTypeLeft', label: this.$t('map.sepTypeLeft'), type: 'select', optionLabel: 'name', optionValue: 'code', options: this.SectionSepTypeList, isHidden: !this.isSectionType },
{ prop: 'sepTypeRight', label: this.$t('map.sepTypeRight'), type: 'select', optionLabel: 'name', optionValue: 'code', options: this.SectionSepTypeList, isHidden: !this.isSectionType },
{ prop: 'isSegmentation', label: this.$t('map.isSegmentation'), type: 'checkbox', isHidden: !this.isSectionType },
{ prop: 'segmentationPosition', label: this.$t('map.segmentationPosition'), type: 'coordinate', width: '150px', isHidden: !this.issegmentationPosition, children: [
{ prop: 'segmentationPosition.x', firstLevel: 'segmentationPosition', secondLevel: 'x', label: 'x:', type: 'number', labelWidth: '20px', disabled: true },
{ prop: 'segmentationPosition.y', firstLevel: 'segmentationPosition', secondLevel: 'y', label: 'y:', type: 'number', labelWidth: '20px', disabled: true }
] },
{ prop: 'isCurve', label: this.$t('map.isCurve'), type: 'checkbox', isHidden: !this.isSectionType },
{ prop: 'points', label: this.$t('map.segmentCoordinates'), type: 'points', width: '100px', isHidden: !this.isPointsShow, pointDisabled: this.isStationCodeDisabled, addPoint: this.addPoint, delPoint: this.delPoint }
]
},
map: {
name: this.$t('map.mapData'),
item: [
{ prop: 'stationCode', label: this.$t('map.equipmentStation'), type: 'select', mode: true, optionLabel: 'name&&code', optionValue: 'code', disabled: this.isStationCodeDisabled, options: this.stationList },
{ prop: 'offsetLeft', label: this.$t('map.sectionOffsetLeft'), type: 'number', min: 0, placeholder: this.$t('map.meter'), isHidden: !this.isPhysicalSection },
{ prop: 'offsetRight', label: this.$t('map.sectionOffsetRight'), type: 'number', min: 0, placeholder: this.$t('map.meter'), isHidden: !this.isPhysicalSection },
{ prop: 'lengthFact', label: this.$t('map.actualLength'), type: 'number', min: 0, placeholder: this.$t('map.meter'), isHidden: !this.isPhysicalSection },
{ prop: 'leftStopPointOffset', label: this.$t('map.leftStopPointOffset'), type: 'number', min: 0, isHidden: !this.isStopPointOffset },
{ prop: 'rightStopPointOffset', label: this.$t('map.rightStopPointOffset'), type: 'number', min: 0, isHidden: !this.isStopPointOffset },
{ prop: 'region', label: this.$t('map.sectionColon'), type: 'select', optionLabel: 'label', optionValue: 'value', options: this.regionList, isHidden: !this.sectionColonShow },
{ prop: 'kmRangeLeft', label: this.$t('map.leftKilometerMark'), type: 'number', min: 0, placeholder: this.$t('map.meter') },
{ prop: 'kmRangeRight', label: this.$t('map.rightKilometerMark'), type: 'number', min: 0, placeholder: this.$t('map.meter') },
{ prop: 'trainPosType', label: this.$t('map.trainDirection'), type: 'select', optionLabel: 'name', optionValue: 'code', options: this.TrainPositionTypeList, isHidden: !this.isSectionType }
]
}
}
};
return form;
},
rules() {
const rules = {
code: [
{ required: true, message: this.$t('rules.selectEquipment'), trigger: 'change' }
],
name: [
{ required: true, message: this.$t('rules.pleaseEnterSectionName'), trigger: 'blur' }
],
type: [
{ required: true, message: this.$t('rules.pleaseEnterSectionType'), trigger: 'blur' }
],
relStandCode: [
{ required: true, message: this.$t('rules.pleaseSelectAssociatedPlatform'), trigger: 'change' }
],
leftStopPointOffset: [
{ required: true, message: this.$t('rules.pleaseEnterLeftStopPointOffset'), trigger: 'blur' }
],
rightStopPointOffset: [
{ required: true, message: this.$t('rules.rightStopPointOffset'), trigger: 'blur' }
],
destinationCode: [
{ required: true, message: this.$t('rules.destinationCode'), trigger: 'blur' }
],
'destinationCodePoint.x': [
{ required: true, message: this.$t('rules.destinationCodePointX'), trigger: 'blur' }
],
'destinationCodePoint.y': [
{ required: true, message: this.$t('rules.destinationCodePointY'), trigger: 'blur' }
],
'namePosition.x': [
{ required: true, message: this.$t('rules.sectionNamePointX'), trigger: 'blur' }
],
'namePosition.y': [
{ required: true, message: this.$t('rules.sectionNamePointY'), trigger: 'blur' }
],
logicSectionNameSort: [
{ required: true, message: this.$t('rules.logicSectionNameSort'), trigger: 'change' }
],
// offsetLeft: [
// { required: true, message: this.$t('rules.sectionOffsetLeft'), trigger: 'blur' }
// ],
sepTypeLeft: [
{ required: true, message: this.$t('rules.sectionSepTypeLeft'), trigger: 'change' }
],
// offsetRight: [
// { required: true, message: this.$t('rules.sectionOffsetRight'), trigger: 'blur' }
// ],
sepTypeRight: [
{ required: true, message: this.$t('rules.sectionSepTypeRight'), trigger: 'change' }
],
relSwitchCode: [
{ required: true, message: this.$t('rules.sectionRelSwitchCode'), trigger: 'change' }
],
trainPosType: [
{ required: true, message: this.$t('rules.pleaseSelectTrainDir'), trigger: 'change' }
]
};
return rules;
},
PhysicalSectionList() {
let list = [];
if (this.sectionList && this.sectionList.length) {
list = this.sectionList.filter(elem => { return elem.type === '01'; });
}
return list;
},
ReverseSectionList() {
let list = [];
if (this.sectionList && this.sectionList.length) {
list = this.sectionList;
list = list.slice(0, list.length);
list.reverse();
}
return list;
},
DatasCollection() {
const list = [];
if (this.linkList) {
this.linkList.forEach(elem => {
list.push({
label: `${elem.name}(${elem.code})`,
key: elem.code,
pinyin: `${elem.name}(${elem.code})`
});
});
}
return list;
},
// 判断显隐 true 显示 false 隐藏
isParentCode() {
return this.editModel.type == '02' || this.editModel.relSwitchCode;
},
isStationCodeDisabled() {
return this.editModel.type == '02';
},
isSectionType() {
return this.editModel.type !== '03';
},
isPhysicalSection() {
return this.editModel.type == '01';
},
isStationAxleShow() {
return this.editModel.section == '02';
},
isstandTrackNameShow() {
return this.editModel.type !== '03' && this.editModel.isStandTrack;
},
isreentryTrackName() {
return this.editModel.type !== '03' && this.editModel.isReentryTrack;
},
istransferTrackName() {
return this.editModel.type !== '03' && this.editModel.isTransferTrack;
},
isdestinationCode() {
return this.editModel.type !== '03' && (this.editModel.isReentryTrack || this.editModel.isTransferTrack);
},
isStopPointOffset() {
return this.editModel.type !== '03' && (this.editModel.isReentryTrack || this.editModel.isStandTrack || this.editModel.isTransferTrack);
},
isButtonType() {
return this.fieldS == 'relStandCode';
},
isrelStandCode() {
return this.editModel.type !== '03' && this.editModel.isStandTrack && this.editModel.type == '01';
},
isRelSwitchCode() {
return this.editModel.type !== '03' && this.editModel.isSwitchSection;
},
isLogicSectionNameSort() { // 逻辑区段排序 判断
return this.editModel.type == '01' && !this.editModel.isSwitchSection;
},
issegmentationPosition() {
return this.editModel.type !== '03' && this.editModel.isSegmentation;
},
isPointsShow() {
return this.editModel.type !== '03' && this.editModel.points.length > 0;
},
sectionColonShow() {
if (this.$store.state.map.map) {
return this.$store.state.map.map.skinVO.code == '03';
}
return false;
},
isSwitchSectionShow() { // 判断道岔区段不显示
return this.editModel.type !== '03' && !this.editModel.isSwitchSection;
}
},
watch: {
'$store.state.menuOperation.mapDrawSelectCount': function(val) {
this.deviceSelect(this.selected);
}
},
mounted() {
this.$Dictionary.sectionType().then(list => {
this.SectionTypeList = list;
});
this.$Dictionary.sectionSepType().then(list => {
this.SectionSepTypeList = list;
});
this.$Dictionary.trainPositionType().then(list => {
this.TrainPositionTypeList = list;
});
this.regionList = this.$ConstSelect.RegionTypeList;
},
methods: {
// 计算逻辑区段数量列表展示
computedLogicSectionNumList(logicSectionNum) {
this.tableData = [];
this.logicSectionNums = [...logicSectionNum];
var i; var num; var len = this.editModel.points.length;
if (len > 1 && this.editModel.type === '01') {
for (i = 0; i < len - 1; i++) {
num = 0;
if (Array.isArray(this.logicSectionNums) && this.logicSectionNums[i]) {
num = parseInt(this.logicSectionNums[i]);
}
this.tableData.push({ index: i + 1, num: num });
}
if (this.tableData.length <= 0) {
this.tableData.push({ index: i + 1, num: 0 });
}
}
},
deviceChange(code) {
this.$emit('setCenter', code);
this.deviceSelect(this.$store.getters['map/getDeviceByCode'](code));
},
deviceSelect(selected) {
if (!this.fieldS) { // 判断是否激活选择站台
this.$refs.dataform.resetFields();
if (selected && selected._type.toUpperCase() === 'Section'.toUpperCase()) {
this.editModel.points = [];
this.activeName = 'first';
this.editModel = deepAssign(this.editModel, selected);
this.editModel.logicSectionNum = selected.type === '01' ? selected.logicSectionNum : [0];
this.editModel.isSegmentation = selected.isSegmentation || false;
this.editModel.points = JSON.parse(JSON.stringify(selected.points));
this.oldPoint = JSON.parse(JSON.stringify(selected.points));
this.editModel.lengthFact = selected.lengthFact || 0;
this.addModel.splitOffsetMax = Math.sqrt(new JTriangle(selected.points[0], selected.points[selected.points.length - 1]).abspowz);
this.addModel.splitOffset = this.addModel.splitOffsetMax / 2;
this.computedLogicSectionNumList(this.editModel.logicSectionNum);
if (this.field.toUpperCase() === 'splitSection'.toUpperCase()) {
this.addModel.code = selected.code;
this.activeName = 'three';
this.field = '';
this.$emit('fieldSelect', '');
} else if (this.field.toUpperCase() === 'leftSection'.toUpperCase()) {
this.mergeModel.lsectioncode = selected.code;
this.activeName = 'three';
this.field = '';
this.$emit('fieldSelect', '');
} else if (this.field.toUpperCase() === 'rightSection'.toUpperCase()) {
this.mergeModel.rsectioncode = selected.code;
this.activeName = 'three';
this.field = '';
this.$emit('fieldSelect', '');
} else if (this.field.toUpperCase() === 'handleSection'.toUpperCase()) {
this.operationModel.sectionList.push(selected.code);
this.activeName = 'five';
}
}
}
},
handleClick(tab, event) {
if (tab.name != 'first') {
this.fieldS = '';
}
this.questionList = [];
},
hover(field) {
if (field == 'relStandCode') {
this.fieldS = field == this.fieldS ? '' : field;
} else {
this.field = field == this.field ? '' : field;
this.$emit('fieldSelect', this.field);
}
},
handleDelete(index, row) {
row.num = 0;
},
// 逻辑区段模型
addLogicalSection(model, points, index, middleOffset) {
const data = {
_type: 'Section',
code: getUID('Section'),
name: String.fromCharCode(index + 'A'.charCodeAt()),
parentCode: model.code,
axleShow: false,
type: '02',
namePosition: { x: 0, y: 0 },
isStandTrack: false,
standTrackName: model.standTrackName,
standTrackNamePosition: {
x: model.standTrackNamePosition.x,
y: model.standTrackNamePosition.y
},
isReentryTrack: false,
reentryTrackName: model.reentryTrackName,
reentryTrackNamePosition: {
x: model.reentryTrackNamePosition.x,
y: model.reentryTrackNamePosition.y
},
isTransferTrack: false,
transferTrackName: model.transferTrackName,
transferTrackNamePosition: {
x: model.transferTrackNamePosition.x,
y: model.transferTrackNamePosition.y
},
isSegmentation: false,
segmentationPosition: {
x: model.segmentationPosition.x,
y: model.segmentationPosition.y
},
logicSectionNameSort: model.logicSectionNameSort,
isSwitchSection: model.isSwitchSection,
relSwitchCode: model.relSwitchCode,
logicSectionNum: [],
logicSectionShow: model.logicSectionShow,
stationCode: model.stationCode,
linkCode: model.linkCode,
offsetLeft: middleOffset * (index) + model.offsetLeft,
offsetRight: middleOffset * (index + 1) + model.offsetLeft,
sepTypeLeft: '00',
sepTypeRight: '00',
trainPosType: model.trainPosType,
points: points,
isCurve: false,
lengthFact: 0,
kmRangeRight: model.kmRangeRight,
kmRangeLeft: model.kmRangeLeft,
region: model.region
};
return data;
},
// 创建逻辑区段
createLogicalSections(num, beg, end, model, counts) {
const models = [];
const triangle = new JTriangle(beg, end);
const offset = Math.sqrt(triangle.abspowz) / num;
const middleOffset = parseFloat((model.offsetRight - model.offsetLeft) / num);
for (let i = 0; i < num; i++) {
const points = [
{ x: beg.x + triangle.getCos(offset * i), y: beg.y + triangle.getSin(offset * i) },
{ x: beg.x + triangle.getCos(offset * (i + 1)), y: beg.y + triangle.getSin(offset * (i + 1)) }
];
models.push(this.addLogicalSection(model, points, counts + i, middleOffset));
}
return models;
},
// 生成逻辑区段
editSectionNum() {
let models = [];
let counts = 0;
const logicSectionNumList = [];
const sectionPoints = [...this.editModel.points]; // 获取区段点
this.tableData.forEach((ele, index) => {
models = [...models, ...this.createLogicalSections(Number(ele.num), sectionPoints[index], sectionPoints[index + 1], this.editModel, counts)];
logicSectionNumList.push(Number(ele.num));
counts += parseInt(ele.num);
});
this.sectionList.forEach(section => { // 删除之前的逻辑区段
if (section.type === '02' && section.parentCode == this.editModel.code) {
models.push(deepAssign(section, {_dispose: true}));
}
});
this.editModel.logicSectionNum = [...logicSectionNumList];
models.push(this.editModel);
this.activeName = 'first';
this.$emit('updateMapModel', models);
},
addPoint(index) {
const data = { x: 0, y: 0 };
this.editModel.points.splice(index + 1, 0, data);
this.logicSectionNums.splice(index + 1, 0, 1);
},
delPoint(index) {
this.editModel.points.splice(index, 1);
this.logicSectionNums.splice(index, 1);
},
// 一键创建区段 检测link是否规范
checkLinkList() {
this.questionList = [];
this.linkList.forEach(item => {
if (item.leftFdCode) {
if (item.leftSdCode) {
item.create = true;
} else {
const selected = this.$store.getters['map/getDeviceByCode'](item.leftFdCode);
if (selected.rightFdCode && selected.rightSdCode) {
item.create = true;
} else {
const string = `link ${item.name} ${this.$t('tip.incidenceRelation')}`;
this.questionList.push(string);
}
}
} else if (item.rightFdCode) {
if (item.rightSdCode) {
item.create = true;
} else {
const selected = this.$store.getters['map/getDeviceByCode'](item.rightFdCode);
if (selected.leftFdCode && selected.leftSdCode) {
item.create = true;
} else {
const string = `link ${item.name} ${this.$t('tip.incidenceRelation')}`;
this.questionList.push(string);
}
}
}
});
return !this.questionList.length;
},
// 一键生成区段
create() {
const models = [];
if (this.checkLinkList()) {
this.linkList.forEach(link => {
let count = 0;
this.sectionList.forEach(setction => {
count++;
if (setction.linkCode == link.code) {
count = 0;
}
});
if (count == this.sectionList.length) {
const uid = getUID('Section');
const uname = 'Section_' + link.name.replace('Link_', '');
const model = {
_type: 'Section',
code: uid,
name: uname,
type: '01',
axleShow: false,
isStandTrack: false,
standTrackName: '',
standTrackNamePosition: { x: 0, y: 0 },
isReentryTrack: false,
reentryTrackName: '',
reentryTrackNamePosition: { x: 0, y: 0 },
isTransferTrack: false,
transferTrackName: '',
transferTrackNamePosition: { x: 0, y: 0 },
isSwitchSection: false, // 是否道岔管理区段
isSegmentation: false,
segmentationPosition: { x: 0, y: 0 },
relSwitchCode: '',
kmRangeRight: '',
kmRangeLeft: '',
region: '',
namePosition: { x: 0, y: 0 },
logicSectionNum: [0],
logicSectionShow: true,
logicSectionNameSort: true,
linkCode: link.code,
sepTypeLeft: '01', // 分隔符类型
offsetLeft: 0,
sepTypeRight: '01',
trainPosType: '', // 默认不填写 列车所在方向
offsetRight: link.lengthFact,
lengthFact: 0,
parentCode: '',
relStandCode: '',
rightStopPointOffset: 0,
leftStopPointOffset: 0,
destinationCode: '',
destinationCodePoint: { x: 0, y: 0 },
points: [
{ x: link.lp.x, y: link.lp.y },
{ x: link.rp.x, y: link.rp.y }
],
isCurve: false
};
// 判断左分隔符类型
if (!link.leftFdCode && !link.leftSdcode) {
model.sepTypeLeft = '03';
} else if (link.leftFdCode && link.leftSdCode) {
model.sepTypeLeft = '00';
} else if (link.leftFdCode) {
const node = this.findLinkData(link.leftFdCode);
if (node && node.rightFdCode && node.rightSdCode) {
model.sepTypeLeft = '00';
}
}
// 判断右分隔符类型
if (!link.rightFdCode && !link.rightSdCode) {
model.sepTypeRight = '03';
} else if (link.rightFdCode && link.rightSdCode) {
model.sepTypeRight = '00';
} else if (link.rightFdCode) {
const node = this.findLinkData(link.rightFdCode);
if (node && node.leftFdCode && node.leftSdCode) {
model.sepTypeRight = '00';
}
}
models.push(model);
const sectionList = this.findSectionListDataByLinkCode(link.code);
if (sectionList) {
sectionList.forEach(section => {
models.push(deepAssign({ _type: 'Section', code: section.code }, { _dispose: true }));
if (section.type === '02' && section.parentCode) {
models.push(deepAssign(section, { _dispose: true }));
}
});
}
}
});
const _that = this;
this.$confirm(this.$t('tip.confirmBatchGeneration'), this.$t('tip.hint'), {
confirmButtonText: this.$t('tip.confirm'),
cancelButtonText: this.$t('tip.cancel'),
type: 'warning'
}).then(() => {
if (models.length) {
_that.$emit('updateMapModel', models);
} else {
_that.$message.info(this.$t('tip.allLinkCreate'));
}
}).catch(() => {
this.$message({
type: 'info',
message: this.$t('tip.cancelGeneration')
});
});
} else {
this.$message.info(this.$t('tip.linkCheckList'));
}
},
// 修改区段属性
edit() {
this.$refs['dataform'].validate((valid) => {
if (valid) {
const models = [];
const model = deepAssign(this.editModel, {_type: 'Section'}); // 修改元素model
model.leftStopPointOffset = Number(model.leftStopPointOffset);
model.rightStopPointOffset = Number(model.rightStopPointOffset);
models.push(model);
this.sectionList.forEach(section => {
if (section.parentCode == model.code) {
const copySection = deepAssign({}, section);
copySection.logicSectionShow = model.logicSectionShow;
copySection.trainPosType = model.trainPosType;
models.push(copySection);
}
if (section.linkCode == model.linkCode && model.code != section.code && section.type == '01') {
const lastIndex = this.oldPoint.length - 1;
const copySection = deepAssign({}, section);
if (this.oldPoint[0].x == section.points[section.points.length - 1].x && this.oldPoint[0].y == section.points[section.points.length - 1].y) {
copySection.points[copySection.points.length - 1].x = model.points[0].x;
copySection.points[copySection.points.length - 1].y = model.points[0].y;
copySection.offsetRight = model.offsetLeft;
}
if (this.oldPoint[lastIndex].x == section.points[0].x && this.oldPoint[lastIndex].y == section.points[0].y) {
copySection.points[0].x = model.points[model.points.length - 1].x;
copySection.points[0].y = model.points[model.points.length - 1].y;
copySection.offsetLeft = model.offsetRight;
}
models.push(copySection);
}
});
this.fieldS = '';
this.$emit('updateMapModel', models);
this.oldPoint = JSON.parse(JSON.stringify(model.points));
}
});
},
// 删除对象
deleteObj() {
const models = [];
const selected = this.$store.getters['map/getDeviceByCode'](this.editModel.code);
if (selected && selected._type.toUpperCase() === 'Section'.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(() => {
models.push(deepAssign(selected, { _dispose: true }));
_that.$emit('updateMapModel', models);
_that.deviceSelect();
}).catch(() => {
_that.$message.info(this.$t('tip.cancelledDelete'));
});
}
},
// 拆分区段
split() {
this.$refs['oprt'].validate((valid) => {
if (valid) {
const selected = this.$store.getters['map/getDeviceByCode'](this.addModel.code);
if (selected && selected._type === 'Section' && selected.type === '01') {
const models = [];
const modelX = (selected.points[selected.points.length - 1].x - selected.points[0].x) / this.addModel.splitNumber; // x 平均值
const modelY = (selected.points[selected.points.length - 1].y - selected.points[0].y) / this.addModel.splitNumber; // y 平均值
for (let index = 1; index <= this.addModel.splitNumber; index++) {
const model = {
_type: 'Section',
code: getUID('Section'),
name: `${selected.name}_${index}`,
type: '01',
parentCode: '',
axleShow: selected.axleShow,
isStandTrack: false,
kmRangeRight: '',
kmRangeLeft: '',
region: '',
standTrackName: '',
standTrackNamePosition: { x: 0, y: 0 },
isReentryTrack: false,
reentryTrackName: '',
reentryTrackNamePosition: { x: 0, y: 0 },
isTransferTrack: false,
transferTrackName: '',
transferTrackNamePosition: { x: 0, y: 0 },
isSwitchSection: false,
isSegmentation: false,
segmentationPosition: { x: 0, y: 0 },
relSwitchCode: '',
logicSectionNameSort: selected.logicSectionNameSort,
logicSectionNum: selected.logicSectionNum,
logicSectionShow: selected.logicSectionShow,
sepTypeLeft: index == 0 ? selected.sepTypeLeft : '01', // 左侧分隔符类型 (起始左侧按原来区段类型走 其余 默认 01)
offsetLeft: selected.offsetLeft,
sepTypeRight: index == this.addModel.splitNumber ? selected.sepTypeRight : '01', // 右侧分隔符类型 (终点右侧按原来区段类型走 其余 默认 01)
offsetRight: selected.offsetRight,
linkCode: selected.linkCode,
trainPosType: this.addModel.trainPosType,
isCurve: selected.isCurve,
lengthFact: 0,
points: [
{
x: selected.points[0].x + ((index - 1) * modelX),
y: selected.points[0].y + ((index - 1) * modelY)
},
{
x: selected.points[0].x + (index * modelX),
y: selected.points[0].y + (index * modelY)
}
],
namePosition: { x: 0, y: 0 }
};
models.push(model);
}
models.push(deepAssign(selected, { _dispose: true }));
this.$emit('updateMapModel', models); // 添加新增拆分区段
}
}
});
},
// 合并区段
merge() {
this.$refs['oprt1'].validate((valid) => {
if (valid) {
if (this.mergeModel.lsectioncode != this.mergeModel.rsectioncode) {
const models = [];
let rsection = null;
let lsection = null;
this.PhysicalSectionList.forEach(section => {
if (section.code === this.mergeModel.lsectioncode) {
lsection = section;
}
if (section.code === this.mergeModel.rsectioncode) {
rsection = section;
}
});
if (!rsection || !lsection) {
this.$messageBox(this.$t('tip.cannotMerged'));
return;
}
if (rsection && lsection) {
if (lsection.linkCode !== rsection.linkCode) {
this.$messageBox(this.$t('tip.linkCannotMerged'));
return;
}
const uid = getUID('Section');
const model = {
_type: 'Section',
code: uid,
parentCode: '',
name: uid,
type: '01',
linkCode: lsection.linkCode,
isStandTrack: false,
standTrackName: '',
standTrackNamePosition: { x: 0, y: 0 },
isSegmentation: false,
segmentationPosition: { x: 0, y: 0 },
isReentryTrack: false,
reentryTrackName: '',
reentryTrackNamePosition: { x: 0, y: 0 },
isTransferTrack: false,
transferTrackName: '',
transferTrackNamePosition: { x: 0, y: 0 },
isSwitchSection: false,
relSwitchCode: '',
isCurve: false,
kmRangeRight: '',
kmRangeLeft: '',
region: ''
};
models.push(deepAssign(this.$store.getters['map/getDeviceByCode'](lsection.code), { _dispose: true }));
models.push(deepAssign(this.$store.getters['map/getDeviceByCode'](rsection.code), { _dispose: true }));
if (lsection.points[lsection.points.length - 1].x == rsection.points[0].x && lsection.points[lsection.points.length - 1].y == rsection.points[0].y) {
model.axleShow = lsection.axleShow;
model.logicSectionNum = lsection.logicSectionNum;
model.logicSectionShow = lsection.logicSectionShow;
model.trainPosType = lsection.trainPosType;
model.sepTypeLeft = lsection.sepTypeLeft;
model.offsetLeft = lsection.offsetLeft;
model.sepTypeRight = rsection.sepTypeRight;
model.offsetRight = lsection.offsetRight + rsection.offsetRight;
model.isCurve = lsection.isCurve;
model.points = [
{ x: lsection.points[0].x, y: lsection.points[0].y },
{ x: rsection.points[rsection.points.length - 1].x, y: rsection.points[rsection.points.length - 1].y }
];
model.logicSectionNameSort = lsection.logicSectionNameSort;
model.namePosition = { x: 0, y: 0 };
model.lengthFact = Number(lsection.lengthFact) + Number(rsection.lengthFact);
models.push(model);
this.$emit('updateMapModel', models);
}
if (lsection.points[0].x == rsection.points[rsection.points.length - 1].x && lsection.points[0].y == rsection.points[rsection.points.length - 1].y) {
model.axleShow = rsection.axleShow;
model.logicSectionNum = rsection.logicSectionNum;
model.logicSectionShow = rsection.logicSectionShow;
model.trainPosType = rsection.trainPosType;
model.sepTypeLeft = rsection.sepTypeLeft;
model.offsetLeft = rsection.offsetLeft;
model.sepTypeRight = lsection.sepTypeRight;
model.offsetRight = lsection.offsetRight + rsection.offsetRight;
model.isCurve = rsection.isCurve;
model.points = [
{ x: rsection.points[0].x, y: rsection.points[0].y },
{ x: lsection.points[lsection.points.length - 1].x, y: lsection.points[lsection.points.length - 1].y }
];
model.logicSectionNameSort = rsection.logicSectionNameSort;
model.namePosition = { x: 0, y: 0 };
model.lengthFact = Number(lsection.lengthFact) + Number(rsection.lengthFact);
models.push(model);
this.$emit('updateMapModel', models);
}
}
this.PhysicalSectionList.forEach(lsection => {
if (lsection.code === this.mergeModel.lsectioncode) {
this.PhysicalSectionList.forEach(rsection => {
});
}
});
}
}
});
},
findLinkData(code) {
const linkList = this.linkList;
if (linkList && linkList.length) {
for (var i = 0; i < linkList.length; i++) {
if (code === linkList[i].code) {
return linkList[i];
}
}
}
return null;
},
findSectionListDataByLinkCode(linkCode) {
const remove = [];
const sectionList = this.PhysicalSectionList;
if (sectionList && sectionList.length) {
for (var i = 0; i < sectionList.length; i++) {
if (sectionList[i].linkCode === linkCode) {
const section = JSON.parse(JSON.stringify(sectionList[i]));
remove.push(section);
}
}
}
return remove;
},
// 按link批量删除区段
delRelevanceSection() {
const models = [];
this.linkCodeList.forEach(code => {
this.sectionList.forEach(section => {
if (section.linkCode == code) {
models.push({...section, _dispose: true });
}
});
});
this.$confirm(this.$t('tip.confirmDeletion'), this.$t('tip.hint'), {
confirmButtonText: this.$t('tip.confirm'),
cancelButtonText: this.$t('tip.cancel'),
type: 'warning'
}).then(async () => {
// this.delSectionSwitch(switchList, models);
this.$emit('updateMapModel', models);
this.deviceSelect();
this.linkCodeList = [];
}).catch(() => {
this.$message.info(this.$t('tip.cancelledDelete'));
});
},
// 多选区段设置集中站
handleScetionStationCode() {
this.$refs['operationModel'].validate((valid) => {
if (valid) {
const models = [];
this.operationModel.sectionList.forEach(sectionCode => {
const section = deepAssign({}, this.$store.getters['map/getDeviceByCode'](sectionCode));
section.stationCode = this.operationModel.stationCode;
models.push(section);
});
this.$emit('updateMapModel', models);
this.$refs['operationModel'].resetFields();
}
});
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
.view-control {
overflow-y: auto;
height: 100%;
}
.flex_box{
display: flex;
justify-content: center;
}
.card {
height: 100%;
}
.box-card {
width: calc(100% - 80px);
margin: 20px auto 0;
padding: 0 20px;
.text {
font-size: 14px;
}
.item {
padding: 18px 0;
}
}
.link_box_select{
padding: 10px 20px;
.title{
width: 100px;
display: block;
float: left;
text-align: right;
line-height: 28px;
font-weight: 700;
font-size: 14px;
color: #606266;
}
}
</style>