修改道岔生成逻辑
This commit is contained in:
parent
103e8c9c49
commit
5793355e20
@ -3,10 +3,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.3.5:9000'; // 袁琪
|
||||
// BASE_API = 'http://192.168.3.6:9000'; // 旭强
|
||||
BASE_API = 'http://192.168.3.41:9000'; // 张赛
|
||||
// BASE_API = 'http://192.168.3.41:9000'; // 张赛
|
||||
// BASE_API = 'http://192.168.3.82:9000'; // 杜康
|
||||
} else {
|
||||
BASE_API = process.env.VUE_APP_BASE_API;
|
||||
|
@ -169,8 +169,10 @@ export default {
|
||||
this.linkList.forEach(link => {
|
||||
if (link && link.leftFdCode && link.leftSdCode) { // 左侧同时都有关联link
|
||||
linkObj[`${link.code}`] = { name: '', num: 0 };
|
||||
linkObj[`${link.leftSdCode}`] = { name: '', num: 0 };
|
||||
} else if (link && link.rightFdCode && link.rightSdCode) { // 右侧同时都有关联link
|
||||
linkObj[`${link.code}`] = { name: '', num: 0 };
|
||||
linkObj[`${link.rightSdCode}`] = { name: '', num: 0 };
|
||||
} else if (link && link.leftFdCode && !link.leftSdCode && link.rightFdCode && !link.rightSdCode) { // 左右正向link关联,侧向link不关联检测
|
||||
linkObj[`${link.code}`] = { name: '', num: 0 };
|
||||
}
|
||||
@ -277,8 +279,9 @@ export default {
|
||||
createArr.push(item);
|
||||
}
|
||||
} else {
|
||||
console.log(linkObj, item, sectionC, linkObj[sectionC.linkCode]);
|
||||
this.questionList.push(`${this.$t('map.section')}${linkObj[sectionA.linkCode].name}${this.$t('tip.linkNoneSplit')}, ${this.$t('tip.createSwitchPortion')}`);
|
||||
this.questionList.push(`${this.$t('map.section')}${linkObj[sectionC.linkCode].name}${this.$t('tip.linkNoneSplit')}, ${this.$t('tip.createSwitchPortion')}`);
|
||||
// this.questionList.push(`${this.$t('map.section')}${linkObj[sectionC.linkCode].name}${this.$t('tip.linkNoneSplit')}, ${this.$t('tip.createSwitchPortion')}`);
|
||||
}
|
||||
});
|
||||
this.$confirm(this.$t('tip.confirmBatchGeneration'), this.$t('tip.hint'), {
|
||||
|
@ -382,7 +382,7 @@ 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, disabled: true },
|
||||
{ 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.isSwitchSectionShow }, // 1
|
||||
|
@ -162,135 +162,94 @@ export default {
|
||||
this.editModel = deepAssign(this.editModel, selected);
|
||||
}
|
||||
},
|
||||
findSectionA(pointX, pointY) {
|
||||
const list = [];
|
||||
this.sectionList.forEach(item => {
|
||||
if (item.point[0].x == pointX && item.point[0].y == pointY) {
|
||||
list.push(item);
|
||||
}
|
||||
});
|
||||
return list;
|
||||
},
|
||||
findSectionB(pointX, pointY) {
|
||||
const list = [];
|
||||
this.sectionList.forEach(item => {
|
||||
if (item.point[item.point.length - 1].x == pointX && item.point[item.point.length - 1].y == pointY) {
|
||||
list.push(item);
|
||||
}
|
||||
});
|
||||
return list;
|
||||
},
|
||||
create() { // 一键生成道岔
|
||||
this.questionList = []; // 有问题区段列表
|
||||
const models = [];
|
||||
const linkObj = {};
|
||||
this.linkList.forEach(link => {
|
||||
if (link && link.leftFdCode && link.leftSdCode) { // 左侧同时都有关联link
|
||||
linkObj[`${link.code}`] = { name: '', num: 0 };
|
||||
} else if (link && link.rightFdCode && link.rightSdCode) { // 右侧同时都有关联link
|
||||
linkObj[`${link.code}`] = { name: '', num: 0 };
|
||||
} else if (link && link.leftFdCode && !link.leftSdCode && link.rightFdCode && !link.rightSdCode) { // 左右正向link关联,侧向link不关联检测
|
||||
linkObj[`${link.code}`] = { name: '', num: 0 };
|
||||
}
|
||||
});
|
||||
// this.questionList = []; // 有问题区段列表
|
||||
// const models = [];
|
||||
const createArr = []; // 创建model列表
|
||||
this.sectionList.forEach(section => {
|
||||
for (const link in linkObj) {
|
||||
if (section.linkCode == link) {
|
||||
linkObj[link].num++;
|
||||
linkObj[link].name = section.name;
|
||||
}
|
||||
}
|
||||
const uname = 'switch_' + section.name.replace('section_', '');
|
||||
const link = this.findLinkData(section.linkCode);
|
||||
if (link && link.leftFdCode && link.leftSdCode) {
|
||||
const node = this.findLinkData(link.leftSdCode); // 寻找 侧段link
|
||||
if (node) {
|
||||
const lFdSection = this.findSectionDataByLinkCodeAndPoint(link.leftFdCode, section.points[0]);
|
||||
const lSdSection = this.findSectionDataByLinkCodeAndPoint(link.leftSdCode, section.points[0]);
|
||||
|
||||
if (lFdSection && lSdSection) {
|
||||
const model = {
|
||||
_type: 'Switch',
|
||||
code: getUID('Switch'),
|
||||
name: uname,
|
||||
nameShow: true,
|
||||
timeoutShow: true,
|
||||
sectionACode: section.code,
|
||||
sectionBCode: lFdSection.code,
|
||||
sectionCCode: lSdSection.code,
|
||||
namePosition: { x: 0, y: 0 },
|
||||
turnTime: 3,
|
||||
tp: { x: 0, y: 0 },
|
||||
lp: {
|
||||
x: lFdSection.points[lFdSection.points.length - 1].x,
|
||||
y: lFdSection.points[lFdSection.points.length - 1].y
|
||||
},
|
||||
rp: {
|
||||
x: lSdSection.points[lSdSection.points.length - 2].x,
|
||||
y: lSdSection.points[lSdSection.points.length - 2].y
|
||||
},
|
||||
intersection: {
|
||||
x: section.points[0].x,
|
||||
y: section.points[0].y
|
||||
},
|
||||
skew: {
|
||||
x: lSdSection.points[lSdSection.points.length - 2].x,
|
||||
y: lSdSection.points[lSdSection.points.length - 2].y
|
||||
}
|
||||
};
|
||||
const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode);
|
||||
!swch && models.push(model); // 已有的道岔不在创建
|
||||
if (!section.rightSectionCode && section.type == '03') { // 右侧关联关系为空 且 道岔区段
|
||||
const list = this.findSectionA(section.point[section.point.length - 1].x, section.point[section.point.length - 1].y);
|
||||
let sectionB = {};
|
||||
let sectionC = {};
|
||||
list.forEach(item => {
|
||||
if (item.point[1].y == section.point[section.point.length - 1].y) { // 是否水平拿第二个点判断
|
||||
sectionB = item;
|
||||
} else {
|
||||
sectionC = item;
|
||||
}
|
||||
}
|
||||
});
|
||||
const uname = 'switch_' + section.name.replace('section_', '');
|
||||
const model = {
|
||||
_type: 'Switch',
|
||||
code: getUID('Switch'),
|
||||
name: uname,
|
||||
nameShow: true,
|
||||
timeoutShow: true,
|
||||
sectionACode: section.code,
|
||||
sectionBCode: sectionB.code,
|
||||
sectionCCode: sectionC.code,
|
||||
namePosition: { x: 0, y: 0 },
|
||||
turnTime: 3,
|
||||
tp: { x: 0, y: 0 }
|
||||
};
|
||||
const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode);
|
||||
!swch && createArr.push(model); // 已有的道岔不在创建
|
||||
}
|
||||
|
||||
if (link && link.rightFdCode && link.rightSdCode) {
|
||||
const node = this.findLinkData(link.rightSdCode);
|
||||
if (node) {
|
||||
const rFdSection = this.findSectionDataByLinkCodeAndPoint(link.rightFdCode, section.points[section.points.length - 1]);
|
||||
const rSdSection = this.findSectionDataByLinkCodeAndPoint(link.rightSdCode, section.points[section.points.length - 1]);
|
||||
if (rFdSection && rSdSection) {
|
||||
const model = {
|
||||
_type: 'Switch',
|
||||
code: getUID('Switch'),
|
||||
name: uname,
|
||||
nameShow: true,
|
||||
timeoutShow: true,
|
||||
sectionACode: section.code,
|
||||
sectionBCode: rFdSection.code,
|
||||
sectionCCode: rSdSection.code,
|
||||
namePosition: { x: 0, y: 0 },
|
||||
turnTime: 3,
|
||||
tp: { x: 0, y: 0 },
|
||||
lp: {
|
||||
x: rFdSection.points[0].x,
|
||||
y: rFdSection.points[0].y
|
||||
},
|
||||
rp: {
|
||||
x: rSdSection.points[1].x,
|
||||
y: rSdSection.points[1].y
|
||||
},
|
||||
intersection: {
|
||||
x: section.points[section.points.length - 1].x,
|
||||
y: section.points[section.points.length - 1].y
|
||||
},
|
||||
skew: {
|
||||
x: rSdSection.points[1].x,
|
||||
y: rSdSection.points[1].y
|
||||
}
|
||||
};
|
||||
const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode);
|
||||
!swch && models.push(model);
|
||||
if (!section.leftSectionCode && section.type == '03') { // 左侧关联关系为空 且 道岔区段
|
||||
const list = this.findSectionB(section.point[0].x, section.point[0].y);
|
||||
let sectionB = {};
|
||||
let sectionC = {};
|
||||
list.forEach(item => {
|
||||
if (item.point[item.point.length - 2].y == section.point[0].y) { // 是否水平拿倒数第二个点判断
|
||||
sectionB = item;
|
||||
} else {
|
||||
sectionC = item;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
const createArr = [];
|
||||
models.forEach((item) => {
|
||||
const sectionA = this.$store.getters['map/getDeviceByCode'](item.sectionACode);
|
||||
// const sectionB = this.$store.getters['map/getDeviceByCode'](item.sectionBCode);
|
||||
const sectionC = this.$store.getters['map/getDeviceByCode'](item.sectionCCode);
|
||||
if (linkObj[sectionA.linkCode] && linkObj[sectionC.linkCode]) {
|
||||
if (linkObj[sectionA.linkCode].num > 1 && linkObj[sectionC.linkCode].num > 1 ) {
|
||||
createArr.push(item);
|
||||
}
|
||||
} else {
|
||||
this.questionList.push(`${this.$t('map.section')}${linkObj[sectionA.linkCode].name}${this.$t('tip.linkNoneSplit')}, ${this.$t('tip.createSwitchPortion')}`);
|
||||
this.questionList.push(`${this.$t('map.section')}${linkObj[sectionC.linkCode].name}${this.$t('tip.linkNoneSplit')}, ${this.$t('tip.createSwitchPortion')}`);
|
||||
});
|
||||
const uname = 'switch_' + section.name.replace('section_', '');
|
||||
const model = {
|
||||
_type: 'Switch',
|
||||
code: getUID('Switch'),
|
||||
name: uname,
|
||||
nameShow: true,
|
||||
timeoutShow: true,
|
||||
sectionACode: section.code,
|
||||
sectionBCode: sectionB.code,
|
||||
sectionCCode: sectionC.code,
|
||||
namePosition: { x: 0, y: 0 },
|
||||
turnTime: 3,
|
||||
tp: { x: 0, y: 0 }
|
||||
};
|
||||
const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode);
|
||||
!swch && createArr.push(model); // 已有的道岔不在创建
|
||||
}
|
||||
});
|
||||
console.log(createArr, '生成的道岔');
|
||||
|
||||
this.$confirm(this.$t('tip.confirmBatchGeneration'), this.$t('tip.hint'), {
|
||||
confirmButtonText: this.$t('tip.confirm'),
|
||||
cancelButtonText: this.$t('tip.cancel'),
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
for (const link in linkObj) {
|
||||
if (linkObj[link].num == 1) {
|
||||
this.questionList.push(`${this.$t('map.section')}${linkObj[link].name}${this.$t('tip.linkNoneSplit')}, ${this.$t('tip.createSwitchPortion')}`);
|
||||
}
|
||||
}
|
||||
|
||||
const models = this.createSwitchSection(createArr);
|
||||
models.forEach(item => {
|
||||
createArr.push(item);
|
||||
@ -309,6 +268,8 @@ export default {
|
||||
if (valid) {
|
||||
const data = Object.assign({_type: 'Switch'}, this.editModel);
|
||||
this.$emit('updateMapModel', data);
|
||||
} else {
|
||||
this.$message('还有属性未填写,修改未生效!');
|
||||
}
|
||||
});
|
||||
},
|
||||
@ -333,31 +294,20 @@ export default {
|
||||
handleDelete(selected) {
|
||||
const models = [];
|
||||
this.sectionList.forEach(elem => {
|
||||
if (elem.type == '03' && elem.relSwitchCode == selected.code) {
|
||||
if (elem.type == '04' && elem.relSwitchCode == selected.code) { // 删除道岔计轴区段
|
||||
models.push(deepAssign({ _type: 'Section', code: elem.code }, { _dispose: true }));
|
||||
}
|
||||
if (elem.relSwitchCode == selected.code && elem.type != '03') {
|
||||
elem.relSwitchCode = '';
|
||||
elem.isSwitchSection = false;
|
||||
models.push(elem);
|
||||
if (elem.relSwitchCode == selected.code && elem.type == '03') { // 删除道岔区段关联关系
|
||||
const section = deepAssign({}, this.$store.getters['map/getDeviceByCode'](elem.code));
|
||||
section.relSwitchCode = '';
|
||||
section.parentCode = '';
|
||||
section.isSwitchSection = false;
|
||||
models.push(section);
|
||||
}
|
||||
});
|
||||
models.push(deepAssign(selected, { _dispose: true }));
|
||||
this.$emit('updateMapModel', models);
|
||||
},
|
||||
findLinkData(code) {
|
||||
var rtn = null;
|
||||
var linkList = this.linkList;
|
||||
if (linkList && linkList.length) {
|
||||
for (var i = 0; i < linkList.length; ++i) {
|
||||
if (code === linkList[i].code) {
|
||||
rtn = linkList[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return rtn;
|
||||
},
|
||||
findSectionDataByLinkCodeAndPoint(code, point) {
|
||||
var rtn = null;
|
||||
var sectionList = this.sectionList;
|
||||
@ -386,37 +336,51 @@ export default {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return rtn;
|
||||
},
|
||||
// 一键删除道岔区段
|
||||
removeSwitchSection() {
|
||||
const models = [];
|
||||
if (this.sectionList && this.sectionList.length) {
|
||||
this.sectionList.forEach(elem => {
|
||||
// 删除 道岔区段/ 恢复道岔绑定关系
|
||||
if (elem.type === '03' && !elem.parentCode) {
|
||||
models.push(deepAssign({ _type: 'Section', code: elem.code }, { _dispose: true }));
|
||||
}
|
||||
if (elem.relSwitchCode) {
|
||||
elem.relSwitchCode = '';
|
||||
elem.isSwitchSection = false;
|
||||
models.push(elem);
|
||||
}
|
||||
});
|
||||
this.$emit('updateMapModel', models);
|
||||
}
|
||||
},
|
||||
// 一键生成道岔区段
|
||||
// 一键生成道岔计轴区段
|
||||
createSwitchSection(list) {
|
||||
const models = [];
|
||||
if (list && list.length && this.sectionList && this.sectionList.length) {
|
||||
const sectionList = [];
|
||||
list.forEach(elem => {
|
||||
const sectionb = deepAssign({}, this.$store.getters['map/getDeviceByCode'](elem.sectionBCode));
|
||||
const sectiona = deepAssign({}, this.$store.getters['map/getDeviceByCode'](elem.sectionACode));
|
||||
const sectionc = deepAssign({}, this.$store.getters['map/getDeviceByCode'](elem.sectionCCode));
|
||||
if (sectiona && sectionb && sectionc) {
|
||||
const uid = getUID('Section');
|
||||
elem['uid'] = uid;
|
||||
list.forEach(ele => {
|
||||
const sectiona1 = deepAssign({}, this.$store.getters['map/getDeviceByCode'](ele.sectionACode));
|
||||
const sectionb1 = deepAssign({}, this.$store.getters['map/getDeviceByCode'](ele.sectionBCode));
|
||||
if (sectionb.points[0] == sectionb1.points[sectionb1.points.length - 1]) {
|
||||
sectionList.push(elem);
|
||||
}
|
||||
if (sectiona1.points[0] == sectiona.points[sectiona.points.length - 1]) {
|
||||
sectionList.push(elem);
|
||||
}
|
||||
});
|
||||
sectiona.parentCode = uid;
|
||||
sectionb.parentCode = uid;
|
||||
sectionc.parentCode = uid;
|
||||
sectiona.relSwitchCode = elem.code;
|
||||
sectionb.relSwitchCode = elem.code;
|
||||
sectionc.relSwitchCode = elem.code;
|
||||
sectiona.isSwitchSection = true;
|
||||
sectionb.isSwitchSection = true;
|
||||
sectionc.isSwitchSection = true;
|
||||
models.push(sectiona);
|
||||
models.push(sectionb);
|
||||
models.push(sectionc);
|
||||
}
|
||||
});
|
||||
console.log(sectionList, '生成道岔计轴区段');
|
||||
sectionList.forEach(elem => {
|
||||
const sectiona = deepAssign({}, this.$store.getters['map/getDeviceByCode'](elem.sectionACode));
|
||||
const sectionb = deepAssign({}, this.$store.getters['map/getDeviceByCode'](elem.sectionBCode));
|
||||
const sectionc = deepAssign({}, this.$store.getters['map/getDeviceByCode'](elem.sectionCCode));
|
||||
if (sectiona && sectionb && sectionc) {
|
||||
const uid = getUID('Section');
|
||||
let point = {
|
||||
x: sectiona.points[sectiona.points.length - 1].x,
|
||||
y: sectiona.points[sectiona.points.length - 1].y
|
||||
@ -426,9 +390,9 @@ export default {
|
||||
}
|
||||
models.push({
|
||||
_type: 'Section',
|
||||
code: uid,
|
||||
name: sectiona.name || sectionb.name || sectionc.name,
|
||||
type: '03',
|
||||
code: elem.uid,
|
||||
name: sectiona.name,
|
||||
type: '04',
|
||||
axleShow: false,
|
||||
namePosition: point,
|
||||
isStandTrack: false,
|
||||
@ -457,21 +421,9 @@ export default {
|
||||
parentCode: '',
|
||||
stationCode: sectiona.stationCode,
|
||||
trainPosType: sectiona.trainPosType,
|
||||
isCurve: false,
|
||||
linkCode: '0'
|
||||
isCurve: false
|
||||
});
|
||||
sectiona.parentCode = uid;
|
||||
sectiona.relSwitchCode = elem.code;
|
||||
sectiona.isSwitchSection = true;
|
||||
sectionb.parentCode = uid;
|
||||
sectionb.relSwitchCode = elem.code;
|
||||
sectionb.isSwitchSection = true;
|
||||
sectionc.parentCode = uid;
|
||||
sectionc.relSwitchCode = elem.code;
|
||||
sectionc.isSwitchSection = true;
|
||||
models.push(sectiona);
|
||||
models.push(sectionb);
|
||||
models.push(sectionc);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user