调整绘图区段关联关系校验

This commit is contained in:
fan 2019-12-02 13:50:13 +08:00
parent 438e633ec4
commit 3d192fe447

View File

@ -224,19 +224,6 @@ export default {
}
},
data() {
var validateLeftSection = (rule, value, callback) => {
if (value === '') {
callback(new Error('请选择做关联区段'));
} else {
const leftSection = this.$store.getters['map/getDeviceByCode'](value);
if (leftSection.point[0] !== this.selected.point[0]) {
callback(new Error('所选择关联区段不相邻!'));
} else {
callback();
}
}
};
return {
questionList: [],
activeName: 'first',
@ -395,9 +382,9 @@ export default {
{ 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},
{ prop: 'leftSection', label: '左关联区段', type: 'select', optionLabel: 'name', optionValue: 'code', options: this.PhysicalSectionList},
{ prop: 'rightSection', label: '右关联区段', type: 'select', optionLabel: 'name', optionValue: 'code', options: this.PhysicalSectionList},
{ prop: 'type', label: this.$t('map.sectionType'), type: 'select', optionLabel: 'name', optionValue: 'code', options: this.SectionTypeList},
{ 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
@ -467,6 +454,22 @@ export default {
return form;
},
rules() {
var validateLeftSection = (rule, value, callback) => {
const leftSection = 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 )) {
callback(new Error('所选择关联区段不相邻!'));
} else {
callback();
}
};
var validateRightSection = (rule, value, callback) => {
const rightSection = 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 )) {
callback(new Error('所选择关联区段不相邻!'));
} else {
callback();
}
};
const rules = {
code: [
{ required: true, message: this.$t('rules.selectEquipment'), trigger: 'change' }
@ -517,10 +520,10 @@ export default {
{ required: true, message: this.$t('rules.pleaseSelectTrainDir'), trigger: 'change' }
],
leftSection: [
{ required: this.editModel.type === '01', message: '请选择左关联区段', trigger: 'change' }
{ required: this.editModel.type === '01', validator: validateLeftSection, trigger: 'change' }
],
rightSection: [
{ required: this.editModel.type === '01', message: '请选择右关联区段', trigger: 'change'}
{ required: this.editModel.type === '01', validator: validateRightSection, trigger: 'change'}
]
};
return rules;
@ -530,7 +533,6 @@ export default {
if (this.sectionList && this.sectionList.length) {
list = this.sectionList.filter(elem => { return elem.type === '01'; });
}
list.unshift({code: '', name: '无'});
return list;
},
ReverseSectionList() {