绘图相关调整_(批量创建车站,区段添加激活)

This commit is contained in:
fan 2019-12-04 15:33:08 +08:00
parent 30bab42bbf
commit f5a5d20ebb
2 changed files with 58 additions and 39 deletions

View File

@ -372,8 +372,8 @@ export default {
{ prop: 'namePosition.y', firstLevel: 'namePosition', secondLevel: 'y', label: 'y:', 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}, { prop: 'type', label: this.$t('map.sectionType'), type: 'select', optionLabel: 'name', optionValue: 'code', options: this.SectionTypeList},
{ prop: 'leftSectionCode', label: this.$t('map.leftAssociatedSection'), type: 'select', optionLabel: 'name&&code', optionValue: 'code', clearable: true, options: this.AssociateSectionList}, { prop: 'leftSectionCode', label: this.$t('map.leftAssociatedSection'), type: 'selectHover', optionLabel: 'name&&code', optionValue: 'code', clearable: true, options: this.AssociateSectionList, hover: this.hover, buttonType: 'leftSection', buttonShowType: this.isLeftSectionButtonShow},
{ prop: 'rightSectionCode', label: this.$t('map.rightAssociatedSection'), type: 'select', optionLabel: 'name&&code', optionValue: 'code', clearable: true, options: this.AssociateSectionList}, { prop: 'rightSectionCode', label: this.$t('map.rightAssociatedSection'), type: 'selectHover', optionLabel: 'name&&code', optionValue: 'code', clearable: true, options: this.AssociateSectionList},
{ 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: '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.isStandTrackShow }, // 1 { prop: 'isStandTrack', label: this.$t('map.isStandTrack'), type: 'checkbox', isHidden: !this.isStandTrackShow }, // 1
@ -445,7 +445,7 @@ export default {
rules() { rules() {
var validateLeftSection = (rule, value, callback) => { var validateLeftSection = (rule, value, callback) => {
const leftSection = value ? this.$store.getters['map/getDeviceByCode'](value) : ''; const leftSection = value ? this.$store.getters['map/getDeviceByCode'](value) : '';
if (leftSection && (leftSection.points[1].x !== this.selected.points[0].x || leftSection.points[1].y !== this.selected.points[0].y )) { if (leftSection && (leftSection.points[1].x !== this.editModel.points[0].x || leftSection.points[1].y !== this.editModel.points[0].y )) {
callback(new Error(this.$t('rules.theLeftEndOfTheSelectedAssociatedSectionIsNotAdjacent'))); callback(new Error(this.$t('rules.theLeftEndOfTheSelectedAssociatedSectionIsNotAdjacent')));
} else { } else {
callback(); callback();
@ -453,7 +453,7 @@ export default {
}; };
var validateRightSection = (rule, value, callback) => { var validateRightSection = (rule, value, callback) => {
const rightSection = value ? this.$store.getters['map/getDeviceByCode'](value) : ''; const rightSection = value ? this.$store.getters['map/getDeviceByCode'](value) : '';
if (rightSection && (rightSection.points[0].x !== this.selected.points[1].x || rightSection.points[0].y !== this.selected.points[1].y )) { if (rightSection && (rightSection.points[0].x !== this.editModel.points[1].x || rightSection.points[0].y !== this.editModel.points[1].y )) {
callback(new Error(this.$t('rules.theRightEndOfTheSelectedAssociatedSectionIsNotAdjacent'))); callback(new Error(this.$t('rules.theRightEndOfTheSelectedAssociatedSectionIsNotAdjacent')));
} else { } else {
callback(); callback();
@ -595,6 +595,9 @@ export default {
}, },
isStandTrackShow() { isStandTrackShow() {
return this.editModel.type !== '04' && this.editModel.type !== '03' && !this.editModel.isSwitchSection; return this.editModel.type !== '04' && this.editModel.type !== '03' && !this.editModel.isSwitchSection;
},
isLeftSectionButtonShow() {
return this.field === 'leftSection';
} }
}, },
watch: { watch: {
@ -642,8 +645,21 @@ export default {
deviceSelect(selected) { deviceSelect(selected) {
this.AssociateSectionList = this.sectionList.filter(item => { return item.type === '01' && item.code !== selected.code; }); this.AssociateSectionList = this.sectionList.filter(item => { return item.type === '01' && item.code !== selected.code; });
if (!this.fieldS) { // if (!this.fieldS) { //
this.$refs.dataform.resetFields();
if (selected && selected._type.toUpperCase() === 'Section'.toUpperCase()) { if (selected && selected._type.toUpperCase() === 'Section'.toUpperCase()) {
if (this.field === 'leftSection') {
this.editModel.leftSectionCode = selected.code;
this.activeName = 'first';
this.field = '';
this.$emit('fieldSelect', '');
return;
} else if (this.field === 'rightSection') {
this.editModel.rightSectionCode = selected.code;
this.activeName = 'first';
this.field = '';
this.$emit('fieldSelect', '');
return;
}
this.$refs.dataform.resetFields();
this.editModel.points = []; this.editModel.points = [];
this.activeName = 'first'; this.activeName = 'first';
this.editModel = deepAssign(this.editModel, selected); this.editModel = deepAssign(this.editModel, selected);

View File

@ -18,7 +18,7 @@
<el-scrollbar wrap-class="scrollbar-wrapper"> <el-scrollbar wrap-class="scrollbar-wrapper">
<el-form ref="make" label-width="140px" :model="addModel" size="mini" :rules="mergeRules"> <el-form ref="make" label-width="140px" :model="addModel" size="mini" :rules="mergeRules">
<el-form-item :label="$t('map.physicalSegmentName')" prop="sectionCode"> <el-form-item :label="$t('map.physicalSegmentName')" prop="sectionCode">
<el-select v-model="addModel.sectionCode" filterable> <el-select v-model="addModel.sectionCode" multiple filterable style="width:300px;">
<el-option <el-option
v-for="item in PhysicalSectionList" v-for="item in PhysicalSectionList"
:key="item.code" :key="item.code"
@ -140,7 +140,7 @@ export default {
controlled:false controlled:false
}, },
addModel: { addModel: {
sectionCode: '' sectionCode: []
}, },
skins: [], skins: [],
mergeRules: { mergeRules: {
@ -254,7 +254,7 @@ export default {
} }
if (selected && selected._type.toUpperCase() === 'Section'.toUpperCase() && this.field.toUpperCase() === 'selectStationCode'.toUpperCase()) { if (selected && selected._type.toUpperCase() === 'Section'.toUpperCase() && this.field.toUpperCase() === 'selectStationCode'.toUpperCase()) {
if (selected.type == '01') { if (selected.type == '01') {
this.addModel.sectionCode = selected.code; this.addModel.sectionCode.push(selected.code);
this.activeName = 'second'; this.activeName = 'second';
this.field = ''; this.field = '';
this.$emit('stationSectionCode', ''); this.$emit('stationSectionCode', '');
@ -333,7 +333,9 @@ export default {
create() { create() {
this.$refs['make'].validate((valid) => { this.$refs['make'].validate((valid) => {
if (valid) { if (valid) {
if (this.addModel.sectionCode) { if (this.addModel.sectionCode.length) {
const models = [];
this.addModel.sectionCode.forEach((item) => {
const uid = getUID('Station'); const uid = getUID('Station');
const model = { const model = {
_type: 'Station', _type: 'Station',
@ -353,18 +355,19 @@ export default {
chargeStationCodeList:[] chargeStationCodeList:[]
}; };
this.sectionList.forEach(elem => { this.sectionList.forEach(elem => {
if (elem.code === this.addModel.sectionCode) { if (elem.code === item) {
const l = 0; const l = 0;
const r = elem.points.length - 1; const r = elem.points.length - 1;
model.name = 'Station_' + elem.name.replace('Station_', ''); model.name = 'Station_' + elem.name.replace('Station_', '');
model.position = { model.position = {
x: elem.points[l].x + (elem.points[r].x - elem.points[l].x) / 2, x: elem.points[l].x + (elem.points[r].x - elem.points[l].x) / 2,
y: elem.points[l].y y: elem.points[l].y - 100
}; };
} }
}); });
models.push(model);
this.$emit('updateMapModel', model); });
this.$emit('updateMapModel', models);
} }
} }
}); });