- {{ $t('map.createSwitch') }}
+ {{ $t('map.createSwitch') }}
一键删除道岔
@@ -21,248 +21,248 @@ export default {
])
},
methods:{
- create() { // 一键生成道岔
- const createArr = []; // 创建model列表
- // const changeSectionLists = [];
- // const changeSectionList = this.changeSectionsAttr(); // 找道岔中心点
- const changeSectionList = this.changeSectionAttr(); // 找道岔中心点
- changeSectionList.forEach(section => {
- if (section['typeModel'] && section['typeModel'] == 'start') { // 右侧关联关系为空 且 道岔区段
- const list = this.findSectionA(section.points[section.points.length - 1].x, section.points[section.points.length - 1].y, changeSectionList, section.code);
- let sectionB = {};
- let sectionC = {};
- if (list.length >= 2) {
- list.forEach(item => {
- let sectionEnd;
- if (this.handleResetPoint(item.points)) {
- sectionEnd = item.points.length == 2 ? item.points[item.points.length - 1] : item.points[1];
- } else {
- sectionEnd = item.points.length == 2 ? item.points[0] : item.points[item.points.length - 2];
- }
- if ((sectionEnd.y == section.points[section.points.length - 1].y) || (sectionEnd.x == section.points[section.points.length - 1].x)) { // 是否水平拿第二个点判断
- sectionB = item;
- } else {
- sectionC = item;
- }
- });
- if (section.code && sectionB.code && sectionC.code) {
- const uname = 'W' + section.name.replace('T', '');
- const switchModel = getModel('Switch');
- let intersection;
- if (this.handleResetPoint(section.points)) {
- intersection = section.points.length == 2 ? section.points[section.points.length - 1] : section.points[1];
- } else {
- intersection = section.points.length == 2 ? section.points[0] : section.points[section.points.length - 2];
- }
- let skew;
- if (this.handleResetPoint(sectionC.points)) {
- skew = sectionC.points[sectionC.points.length - 1];
- } else {
- skew = sectionC.points.length == 2 ? sectionC.points[0] : sectionC.points[sectionC.points.length - 2];
- }
- const data = {
- code: getUID('W', [...this.switchList, ...createArr]),
- name: uname,
- nameShow: true,
- timeoutShow: true,
- sectionACode: section.code,
- sectionBCode: sectionB.code,
- sectionCCode: sectionC.code,
- turnTime: 3,
- intersection: {
- x: intersection.x,
- y: intersection.y
- },
- skew: {
- x: skew.x,
- y: skew.y
- },
- pos: 'N', // 默认状态定位
- // N-定位 R-反位 NO-无(失表) EX-挤叉
- throat: ''
- };
- const model = Object.assign(switchModel, data);
- const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode);
- !swch && createArr.push(model); // 已有的道岔不在创建
- }
- }
- }
- if (section['typeModel'] && section['typeModel'] == 'end') { // 左侧关联关系为空 且 道岔区段
- const list = this.findSectionB(section.points[0].x, section.points[0].y, changeSectionList, section.code);
- let sectionB = {};
- let sectionC = {};
- if (list.length >= 2) {
- list.forEach(item => {
- let sectionStart;
- if (this.handleResetPoint(item.points)) {
- sectionStart = item.points.length == 2 ? item.points[0] : item.points[item.points.length - 2];
- } else {
- sectionStart = item.points.length == 2 ? item.points[item.points.length - 1] : item.points[1];
- }
- const dy = section.points[1].y - section.points[0].y;
- const dx = section.points[1].x - section.points[0].x;
- const startDx = sectionStart.x - section.points[0].x;
- const startDy = sectionStart.y - section.points[0].y;
- if ((sectionStart.y == section.points[0].y) || (sectionStart.x == section.points[0].x) ||
- (dy * startDx == dx * startDy)) { // 是否水平拿倒数第二个点判断
- sectionB = item;
- } else {
- sectionC = item;
- }
- });
- if (section.code && sectionB.code && sectionC.code) {
- const uname = 'W' + section.name.replace('T', '');
- const switchModel = getModel('Switch');
- let intersection;
- if (this.handleResetPoint(section.points)) {
- intersection = section.points.length == 2 ? section.points[0] : section.points[section.points.length - 1];
- } else {
- intersection = section.points.length == 2 ? section.points[section.points.length - 1] : section.points[0];
- }
- let skew;
- if (this.handleResetPoint(sectionC.points)) {
- skew = sectionC.points.length == 2 ? sectionC.points[0] : sectionC.points[sectionC.points.length - 2];
- } else {
- skew = sectionC.points[sectionC.points.length - 1];
- }
- const data = {
- code: getUID('W', [...this.switchList, ...createArr]),
- name: uname,
- nameShow: true,
- timeoutShow: true,
- sectionACode: section.code,
- sectionBCode: sectionB.code,
- sectionCCode: sectionC.code,
- turnTime: 3,
- intersection: {
- x: intersection.x,
- y: intersection.y
- },
- skew: {
- x: skew.x,
- y: skew.y
- },
- pos: 'N', // 默认状态定位
- // N-定位 R-反位 NO-无(失表) EX-挤叉
- throat: ''
- };
- const model = Object.assign(switchModel, data);
- const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode);
- !swch && createArr.push(model); // 已有的道岔不在创建
- }
- }
- // if (item['typeModel'] == 'start') { // 右侧关联关系为空 且 道岔区段
- // const section = item.A;
- // const sectionB = item.B;
- // const sectionC = item.C;
- // if (section.code && sectionB.code && sectionC.code) {
- // const uname = 'W' + section.name.replace('T', '');
- // const switchModel = getModel('Switch');
- // let intersection;
- // if (this.handleResetPoint(section.points)) {
- // intersection = section.points[section.points.length - 1];
- // } else {
- // intersection = section.points.length == 2 ? section.points[0] : section.points[section.points.length - 2];
- // }
- // let skew;
- // if (this.handleResetPoint(sectionC.points)) {
- // skew = sectionC.points[sectionC.points.length - 1];
- // } else {
- // skew = sectionC.points.length == 2 ? sectionC.points[0] : sectionC.points[sectionC.points.length - 2];
- // }
- // const data = {
- // code: getUID('W', [...this.switchList, ...createArr]),
- // name: uname,
- // nameShow: true,
- // timeoutShow: true,
- // sectionACode: section.code,
- // sectionBCode: sectionB.code,
- // sectionCCode: sectionC.code,
- // turnTime: 3,
- // intersection: {
- // x: intersection.x,
- // y: intersection.y
- // },
- // skew: {
- // x: skew.x,
- // y: skew.y
- // },
- // normalPosition: 1 // 默认状态定位
- // };
- // const model = Object.assign(switchModel, data);
- // const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode);
- // !swch && createArr.push(model); // 已有的道岔不在创建
- // }
- // }
- // if (item['typeModel'] == 'end') { // 左侧关联关系为空 且 道岔区段
- // const section = item.A;
- // const sectionB = item.B;
- // const sectionC = item.C;
- // if (section.code && sectionB.code && sectionC.code) {
- // const uname = 'W' + section.name.replace('T', '');
- // const switchModel = getModel('Switch');
- // let intersection;
- // if (this.handleResetPoint(section.points)) {
- // intersection = section.points.length == 2 ? section.points[0] : section.points[section.points.length - 2];
- // } else {
- // intersection = section.points[section.points.length - 1];
- // }
- // let skew;
- // if (this.handleResetPoint(sectionC.points)) {
- // skew = sectionC.points.length == 2 ? sectionC.points[0] : sectionC.points[sectionC.points.length - 2];
- // } else {
- // skew = sectionC.points[sectionC.points.length - 1];
- // }
- // const data = {
- // code: getUID('W', [...this.switchList, ...createArr]),
- // name: uname,
- // nameShow: true,
- // timeoutShow: true,
- // sectionACode: section.code,
- // sectionBCode: sectionB.code,
- // sectionCCode: sectionC.code,
- // turnTime: 3,
- // intersection: {
- // x: intersection.x,
- // y: intersection.y
- // },
- // skew: {
- // x: skew.x,
- // y: skew.y
- // },
- // normalPosition: 1 // 默认状态定位
- // };
- // const model = Object.assign(switchModel, data);
- // const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode);
- // !swch && createArr.push(model); // 已有的道岔不在创建
- // }
- // }
- }
- });
- this.$confirm(this.$t('tip.confirmBatchGeneration'), this.$t('tip.hint'), {
- confirmButtonText: this.$t('tip.confirm'),
- cancelButtonText: this.$t('tip.cancel'),
- type: 'warning'
- }).then((res) => {
- const modelsList = this.createSwitchSection(createArr, changeSectionList);
- modelsList.forEach(item => {
- createArr.push(item);
- });
- this.$emit('updateMapModel', createArr);
- }).catch((error) => {
- this.$message( this.$t('tip.cancelGeneration'));
- });
- },
- findArr(arr) {
- if (arr[0].slope !== arr[1].slope && arr[0].slope !== arr[2].slope) {
- return arr[0];
- }
- for (var i = 0, len = arr.length; i < len; i++) {
- if (arr[i].slope !== arr[0].slope) {
- return arr[i];
- }
- }
- },
+ // create() { // 一键生成道岔
+ // const createArr = []; // 创建model列表
+ // // const changeSectionLists = [];
+ // // const changeSectionList = this.changeSectionsAttr(); // 找道岔中心点
+ // const changeSectionList = this.changeSectionAttr(); // 找道岔中心点
+ // changeSectionList.forEach(section => {
+ // if (section['typeModel'] && section['typeModel'] == 'start') { // 右侧关联关系为空 且 道岔区段
+ // const list = this.findSectionA(section.points[section.points.length - 1].x, section.points[section.points.length - 1].y, changeSectionList, section.code);
+ // let sectionB = {};
+ // let sectionC = {};
+ // if (list.length >= 2) {
+ // list.forEach(item => {
+ // let sectionEnd;
+ // if (this.handleResetPoint(item.points)) {
+ // sectionEnd = item.points[1];
+ // } else {
+ // sectionEnd = item.points.length == 2 ? item.points[0] : item.points[item.points.length - 2];
+ // }
+ // if ((sectionEnd.y == section.points[section.points.length - 1].y) || (sectionEnd.x == section.points[section.points.length - 1].x)) { // 是否水平拿第二个点判断
+ // sectionB = item;
+ // } else {
+ // sectionC = item;
+ // }
+ // });
+ // if (section.code && sectionB.code && sectionC.code) {
+ // const uname = 'W' + section.name.replace('T', '');
+ // const switchModel = getModel('Switch');
+ // let intersection;
+ // if (this.handleResetPoint(section.points)) {
+ // intersection = section.points[1];
+ // } else {
+ // intersection = section.points.length == 2 ? section.points[0] : section.points[section.points.length - 2];
+ // }
+ // let skew;
+ // if (this.handleResetPoint(sectionC.points)) {
+ // skew = sectionC.points[sectionC.points.length - 1];
+ // } else {
+ // skew = sectionC.points.length == 2 ? sectionC.points[0] : sectionC.points[sectionC.points.length - 2];
+ // }
+ // const data = {
+ // code: getUID('W', [...this.switchList, ...createArr]),
+ // name: uname,
+ // nameShow: true,
+ // timeoutShow: true,
+ // sectionACode: section.code,
+ // sectionBCode: sectionB.code,
+ // sectionCCode: sectionC.code,
+ // turnTime: 3,
+ // intersection: {
+ // x: intersection.x,
+ // y: intersection.y
+ // },
+ // skew: {
+ // x: skew.x,
+ // y: skew.y
+ // },
+ // pos: 'N', // 默认状态定位
+ // // N-定位 R-反位 NO-无(失表) EX-挤叉
+ // throat: ''
+ // };
+ // const model = Object.assign(switchModel, data);
+ // const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode);
+ // !swch && createArr.push(model); // 已有的道岔不在创建
+ // }
+ // }
+ // }
+ // if (section['typeModel'] && section['typeModel'] == 'end') { // 左侧关联关系为空 且 道岔区段
+ // const list = this.findSectionB(section.points[0].x, section.points[0].y, changeSectionList, section.code);
+ // let sectionB = {};
+ // let sectionC = {};
+ // if (list.length === 2) {
+ // list.forEach(item => {
+ // let sectionStart;
+ // if (this.handleResetPoint(item.points)) {
+ // sectionStart = item.points.length == 2 ? item.points[0] : item.points[item.points.length - 2];
+ // } else {
+ // sectionStart = item.points[1];
+ // }
+ // const dy = section.points[1].y - section.points[0].y;
+ // const dx = section.points[1].x - section.points[0].x;
+ // const startDx = sectionStart.x - section.points[0].x;
+ // const startDy = sectionStart.y - section.points[0].y;
+ // if ((sectionStart.y == section.points[0].y) || (sectionStart.x == section.points[0].x) ||
+ // (dy * startDx == dx * startDy)) { // 是否水平拿倒数第二个点判断
+ // sectionB = item;
+ // } else {
+ // sectionC = item;
+ // }
+ // });
+ // if (section.code && sectionB.code && sectionC.code) {
+ // const uname = 'W' + section.name.replace('T', '');
+ // const switchModel = getModel('Switch');
+ // let intersection;
+ // if (this.handleResetPoint(section.points)) {
+ // intersection = section.points.length == 2 ? section.points[0] : section.points[section.points.length - 1];
+ // } else {
+ // intersection = section.points.length == 2 ? section.points[section.points.length - 1] : section.points[0];
+ // }
+ // let skew;
+ // if (this.handleResetPoint(sectionC.points)) {
+ // skew = sectionC.points.length == 2 ? sectionC.points[0] : sectionC.points[sectionC.points.length - 2];
+ // } else {
+ // skew = sectionC.points[sectionC.points.length - 1];
+ // }
+ // const data = {
+ // code: getUID('W', [...this.switchList, ...createArr]),
+ // name: uname,
+ // nameShow: true,
+ // timeoutShow: true,
+ // sectionACode: section.code,
+ // sectionBCode: sectionB.code,
+ // sectionCCode: sectionC.code,
+ // turnTime: 3,
+ // intersection: {
+ // x: intersection.x,
+ // y: intersection.y
+ // },
+ // skew: {
+ // x: skew.x,
+ // y: skew.y
+ // },
+ // pos: 'N', // 默认状态定位
+ // // N-定位 R-反位 NO-无(失表) EX-挤叉
+ // throat: ''
+ // };
+ // const model = Object.assign(switchModel, data);
+ // const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode);
+ // !swch && createArr.push(model); // 已有的道岔不在创建
+ // }
+ // }
+ // // if (item['typeModel'] == 'start') { // 右侧关联关系为空 且 道岔区段
+ // // const section = item.A;
+ // // const sectionB = item.B;
+ // // const sectionC = item.C;
+ // // if (section.code && sectionB.code && sectionC.code) {
+ // // const uname = 'W' + section.name.replace('T', '');
+ // // const switchModel = getModel('Switch');
+ // // let intersection;
+ // // if (this.handleResetPoint(section.points)) {
+ // // intersection = section.points[section.points.length - 1];
+ // // } else {
+ // // intersection = section.points.length == 2 ? section.points[0] : section.points[section.points.length - 2];
+ // // }
+ // // let skew;
+ // // if (this.handleResetPoint(sectionC.points)) {
+ // // skew = sectionC.points[sectionC.points.length - 1];
+ // // } else {
+ // // skew = sectionC.points.length == 2 ? sectionC.points[0] : sectionC.points[sectionC.points.length - 2];
+ // // }
+ // // const data = {
+ // // code: getUID('W', [...this.switchList, ...createArr]),
+ // // name: uname,
+ // // nameShow: true,
+ // // timeoutShow: true,
+ // // sectionACode: section.code,
+ // // sectionBCode: sectionB.code,
+ // // sectionCCode: sectionC.code,
+ // // turnTime: 3,
+ // // intersection: {
+ // // x: intersection.x,
+ // // y: intersection.y
+ // // },
+ // // skew: {
+ // // x: skew.x,
+ // // y: skew.y
+ // // },
+ // // normalPosition: 1 // 默认状态定位
+ // // };
+ // // const model = Object.assign(switchModel, data);
+ // // const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode);
+ // // !swch && createArr.push(model); // 已有的道岔不在创建
+ // // }
+ // // }
+ // // if (item['typeModel'] == 'end') { // 左侧关联关系为空 且 道岔区段
+ // // const section = item.A;
+ // // const sectionB = item.B;
+ // // const sectionC = item.C;
+ // // if (section.code && sectionB.code && sectionC.code) {
+ // // const uname = 'W' + section.name.replace('T', '');
+ // // const switchModel = getModel('Switch');
+ // // let intersection;
+ // // if (this.handleResetPoint(section.points)) {
+ // // intersection = section.points.length == 2 ? section.points[0] : section.points[section.points.length - 2];
+ // // } else {
+ // // intersection = section.points[section.points.length - 1];
+ // // }
+ // // let skew;
+ // // if (this.handleResetPoint(sectionC.points)) {
+ // // skew = sectionC.points.length == 2 ? sectionC.points[0] : sectionC.points[sectionC.points.length - 2];
+ // // } else {
+ // // skew = sectionC.points[sectionC.points.length - 1];
+ // // }
+ // // const data = {
+ // // code: getUID('W', [...this.switchList, ...createArr]),
+ // // name: uname,
+ // // nameShow: true,
+ // // timeoutShow: true,
+ // // sectionACode: section.code,
+ // // sectionBCode: sectionB.code,
+ // // sectionCCode: sectionC.code,
+ // // turnTime: 3,
+ // // intersection: {
+ // // x: intersection.x,
+ // // y: intersection.y
+ // // },
+ // // skew: {
+ // // x: skew.x,
+ // // y: skew.y
+ // // },
+ // // normalPosition: 1 // 默认状态定位
+ // // };
+ // // const model = Object.assign(switchModel, data);
+ // // const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode);
+ // // !swch && createArr.push(model); // 已有的道岔不在创建
+ // // }
+ // // }
+ // }
+ // });
+ // this.$confirm(this.$t('tip.confirmBatchGeneration'), this.$t('tip.hint'), {
+ // confirmButtonText: this.$t('tip.confirm'),
+ // cancelButtonText: this.$t('tip.cancel'),
+ // type: 'warning'
+ // }).then((res) => {
+ // const modelsList = this.createSwitchSection(createArr, changeSectionList);
+ // modelsList.forEach(item => {
+ // createArr.push(item);
+ // });
+ // this.$emit('updateMapModel', createArr);
+ // }).catch((error) => {
+ // this.$message( this.$t('tip.cancelGeneration'));
+ // });
+ // },
+ // findArr(arr) {
+ // if (arr[0].slope !== arr[1].slope && arr[0].slope !== arr[2].slope) {
+ // return arr[0];
+ // }
+ // for (var i = 0, len = arr.length; i < len; i++) {
+ // if (arr[i].slope !== arr[0].slope) {
+ // return arr[i];
+ // }
+ // }
+ // },
// 修改区段属性
// changeSectionsAttr() {
// const pointMap = {};
@@ -379,48 +379,48 @@ export default {
// var BC = Math.sqrt(Math.pow(B.x - C.x, 2) + Math.pow(B.y - C.y, 2));
// return Math.pow(AB, 2) + Math.pow(BC, 2) > Math.pow(AC, 2);
// },
- findSectionA(pointX, pointY, lists, code) {
- const list = [];
- lists.forEach(item => {
- if (item.code != code) {
- if (this.handleResetPoint(item.points)) {
- if (item.points[0].x == pointX && item.points[0].y == pointY) {
- list.push(item);
- }
- } else {
- if (item.points[item.points.length - 1].x == pointX && item.points[item.points.length - 1].y == pointY) {
- list.push(item);
- }
- }
- }
- });
- return list;
- },
- findSectionB(pointX, pointY, lists, code) {
- const list = [];
- lists.forEach(item => {
- if (item.code != code) {
- if (this.handleResetPoint(item.points)) {
- if (item.points[item.points.length - 1].x == pointX && item.points[item.points.length - 1].y == pointY) {
- list.push(item);
- }
- } else {
- if (item.points[0].x == pointX && item.points[0].y == pointY) {
- list.push(item);
- }
- }
- }
- });
- return list;
- },
+ // findSectionA(pointX, pointY, lists, code) {
+ // const list = [];
+ // lists.forEach(item => {
+ // if (item.code != code) {
+ // if (this.handleResetPoint(item.points)) {
+ // if (item.points[0].x == pointX && item.points[0].y == pointY) {
+ // list.push(item);
+ // }
+ // } else {
+ // if (item.points[item.points.length - 1].x == pointX && item.points[item.points.length - 1].y == pointY) {
+ // list.push(item);
+ // }
+ // }
+ // }
+ // });
+ // return list;
+ // },
+ // findSectionB(pointX, pointY, lists, code) {
+ // const list = [];
+ // lists.forEach(item => {
+ // if (item.code != code) {
+ // if (this.handleResetPoint(item.points)) {
+ // if (item.points[item.points.length - 1].x == pointX && item.points[item.points.length - 1].y == pointY && list.findIndex(elem => elem.code === item.code) === -1) {
+ // list.push(item);
+ // }
+ // } else {
+ // if (item.points[0].x == pointX && item.points[0].y == pointY && list.findIndex(elem => elem.code === item.code) === -1) {
+ // list.push(item);
+ // }
+ // }
+ // }
+ // });
+ // return list;
+ // },
findSwitchData(sectionACode, sectionBCode, sectionCCode) {
var rtn = null;
var switchList = this.switchList;
if (switchList && switchList.length) {
for (var i = 0; i < switchList.length; ++i) {
if (sectionACode === switchList[i].sectionACode &&
- sectionBCode === switchList[i].sectionBCode &&
- sectionCCode === switchList[i].sectionCCode) {
+ sectionBCode === switchList[i].sectionBCode &&
+ sectionCCode === switchList[i].sectionCCode) {
rtn = switchList[i];
break;
}
@@ -429,75 +429,239 @@ export default {
return rtn;
},
// 重置坐标点
- handleResetPoint(points) {
- return points[points.length - 1].x >= points[points.length - 2].x;
- },
- // 修改区段属性
- changeSectionAttr() {
- const changeSectionList = []; // 改变的区段列表
+ // handleResetPoint(points) {
+ // return points[points.length - 1].x >= points[points.length - 2].x;
+ // },
+ findSwitchSection() {
+ const pointMap = new Map();
this.sectionList.forEach(section => {
- if (section.type == '01' || section.type == '03') {
- const oneSection = section.points[section.points.length - 1];
- const oneSectionStar = section.points[0];
- let countA = 0;
- let countB = 0;
- this.sectionList.forEach(elem => {
- if ((elem.type == '01' || section.type == '03') && section.code != elem.code) {
- let twoSection, twoSectionEnd;
- if (this.handleResetPoint(elem.points)) {
- twoSection = elem.points[0];
- twoSectionEnd = elem.points[elem.points.length - 1];
- } else {
- twoSection = elem.points[elem.points.length - 1];
- twoSectionEnd = elem.points[0];
- }
- if (oneSection.x == twoSection.x && oneSection.y == twoSection.y) {
- countA++;
- if (countA >= 2) {
- // if (!this.checkAddListA(oneSection, section.code)) { // 右侧关系清空
- const sectionModel = deepAssign({}, section);
- sectionModel.rightSectionCode = '';
- sectionModel.sepTypeRight = '00'; // 分隔符
- sectionModel.type = '03';
- const list = this.findSectionA(sectionModel.points[sectionModel.points.length - 1].x, sectionModel.points[sectionModel.points.length - 1].y, this.sectionList, sectionModel.code);
- list.forEach(elem => {
- const sectionModelElem = deepAssign({}, elem);
- sectionModelElem.leftSectionCode = '';
- sectionModelElem.sepTypeLeft = '00';
- sectionModelElem.type = '03';
- changeSectionList.push(sectionModelElem);
- });
- sectionModel['typeModel'] = 'start';
- changeSectionList.push(sectionModel);
- // }
- }
- } else if (oneSectionStar.x == twoSectionEnd.x && oneSectionStar.y == twoSectionEnd.y) {
- countB++;
- if (countB >= 2) {
- // if (!this.checkAddListB(oneSectionStar, section.code)) { // 左侧关系清空
- const sectionModel = deepAssign({}, section);
- sectionModel.leftSectionCode = '';
- sectionModel.sepTypeLeft = '00';
- sectionModel.type = '03';
- const list = this.findSectionB(sectionModel.points[0].x, sectionModel.points[0].y, this.sectionList, sectionModel.code);
- list.forEach(elem => {
- const sectionModelElem = deepAssign({}, elem);
- sectionModelElem.rightSectionCode = '';
- sectionModelElem.sepTypeRight = '00'; // 分隔符
- sectionModelElem.type = '03';
- changeSectionList.push(sectionModelElem);
- });
- sectionModel['typeModel'] = 'end';
- changeSectionList.push(sectionModel);
- // }
- }
- }
- }
- });
+ if (section.type === '01') {
+ const startP = `${section.points[0].x}_${section.points[0].y}`;
+ const endP = `${section.points[section.points.length - 1].x}_${section.points[section.points.length - 1].y}`;
+ if (pointMap.get(startP)) {
+ const value = pointMap.get(startP);
+ value.count++;
+ value.sections.push({ device: section, type: 'start' });
+ } else {
+ pointMap.set(startP, { count: 1, sections: [{ device: section, type: 'start' }] });
+ }
+ if (pointMap.get(endP)) {
+ const value = pointMap.get(endP);
+ value.count++;
+ value.sections.push({ device: section, type: 'end' });
+ } else {
+ pointMap.set(endP, { count: 1, sections: [{device: section, type: 'end'}] });
+ }
}
});
- return changeSectionList;
+ const switchSectionGroups = [];
+ pointMap.forEach((value, key) => {
+ if (value.count === 3) {
+ const switchSectionGroup = [];
+ value.sections.forEach(item => {
+ const sectionModelElem = deepAssign({}, item.device);
+ sectionModelElem.type = '03';
+ if (item.type === 'start') {
+ sectionModelElem.rightSectionCode = '';
+ sectionModelElem.sepTypeRight = '00';
+ } else if (item.type === 'end') {
+ sectionModelElem.leftSectionCode = '';
+ sectionModelElem.sepTypeLeft = '00';
+ }
+ switchSectionGroup.push({ sectionModel:sectionModelElem, type: item.type });
+ });
+ switchSectionGroups.push(switchSectionGroup);
+ }
+ });
+ return switchSectionGroups;
},
+ getAngle(x1, y1, x2, y2) {
+ const dot = x1 * x2 + y1 * y2;
+ const det = x1 * y2 + x2 * y1;
+ const angle = Math.atan2(det, dot) / Math.PI * 180;
+ return (angle + 360) % 360;
+ },
+ isLine(p1, p2, p) {
+ const k1 = ((p2.y - p1.y) / (p2.x - p1.x)).toFixed(3);
+ const k2 = ((p.y - p1.y) / (p.x - p1.x)).toFixed(3);
+ const error = Math.abs(k2 - k1);
+ return error - 0.001 < Number.EPSILON;
+ },
+ createSwitch() {
+ const createArr = []; // 创建model列表
+ const changeSectionList = [];
+ const switchSectionGroups = this.findSwitchSection();
+ switchSectionGroups.forEach(group => {
+ let sectionA, sectionB, sectionC;
+ let skew;
+ const coreP = group[0].type === 'start' ? group[0].sectionModel.points[0] : group[0].sectionModel.points[group[0].sectionModel.points.length - 1];
+ const p0 = group[0].type === 'start' ? group[0].sectionModel.points[1] : group[0].sectionModel.points[group[0].sectionModel.points.length - 2];
+ const p1 = group[1].type === 'start' ? group[1].sectionModel.points[1] : group[1].sectionModel.points[group[1].sectionModel.points.length - 2];
+ const p2 = group[2].type === 'start' ? group[2].sectionModel.points[1] : group[2].sectionModel.points[group[2].sectionModel.points.length - 2];
+ if (this.isLine(p0, p1, coreP)) {
+ sectionC = group[2].sectionModel;
+ skew = p2;
+ const angle = this.getAngle(p0.x - coreP.x, p0.y - coreP.y, p2.x - coreP.x, p2.y - coreP.y);
+ if (angle > 90 && angle < 270) {
+ sectionA = group[0].sectionModel;
+ sectionB = group[1].sectionModel;
+ } else {
+ sectionA = group[1].sectionModel;
+ sectionB = group[0].sectionModel;
+ }
+ // 特殊处理 大铁线路(B端水平, A、C端在同一条直线)
+ if (p2.y === coreP.y) {
+ sectionC = sectionB;
+ sectionB = group[2].sectionModel;
+ skew = angle > 90 && angle < 270 ? p1 : p0;
+ }
+ } else if (this.isLine(p1, p2, coreP)) {
+ sectionC = group[0].sectionModel;
+ skew = p0;
+ const angle = this.getAngle(p1.x - coreP.x, p1.y - coreP.y, p0.x - coreP.x, p0.y - coreP.y);
+ if (angle > 90 && angle < 270) {
+ sectionA = group[1].sectionModel;
+ sectionB = group[2].sectionModel;
+ } else {
+ sectionA = group[2].sectionModel;
+ sectionB = group[1].sectionModel;
+ }
+ // 特殊处理 大铁线路(B端水平, A、C端在同一条直线)
+ if (p0.y === coreP.y) {
+ sectionC = sectionB;
+ sectionB = group[0].sectionModel;
+ skew = angle > 90 && angle < 270 ? p2 : p1;
+ }
+ } else if (this.isLine(p0, p2, coreP)) {
+ sectionC = group[1].sectionModel;
+ skew = p1;
+ const angel = this.getAngle(p2.x - coreP.x, p2.y - coreP.y, p1.x - coreP.x, p1.y - coreP.y);
+ if (angel > 90 && angel < 270) {
+ sectionA = group[2].sectionModel;
+ sectionB = group[0].sectionModel;
+ } else {
+ sectionA = group[0].sectionModel;
+ sectionB = group[2].sectionModel;
+ }
+ // 特殊处理 大铁线路(B端水平, A、C端在同一条直线)
+ if (p1.y === coreP.y) {
+ sectionC = sectionB;
+ sectionB = group[1].sectionModel;
+ skew = angel > 90 && angel < 270 ? p0 : p2;
+ }
+ }
+ if (sectionA && sectionB && sectionC) {
+ changeSectionList.push(sectionA);
+ changeSectionList.push(sectionB);
+ changeSectionList.push(sectionC);
+ const uname = 'W' + sectionA.name.replace('T', '');
+ const switchModel = getModel('Switch');
+ const data = {
+ code: getUID('W', [...this.switchList, ...createArr]),
+ name: uname,
+ nameShow: true,
+ timeoutShow: true,
+ sectionACode: sectionA.code,
+ sectionBCode: sectionB.code,
+ sectionCCode: sectionC.code,
+ turnTime: 3,
+ intersection: {
+ x: coreP.x,
+ y: coreP.y
+ },
+ skew: {
+ x: skew.x,
+ y: skew.y
+ },
+ pos: 'N', // 默认状态定位
+ // N-定位 R-反位 NO-无(失表) EX-挤叉
+ throat: ''
+ };
+ const model = Object.assign(switchModel, data);
+ const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode);
+ !swch && createArr.push(model); // 已有的道岔不在创建
+ }
+ });
+ this.$confirm(this.$t('tip.confirmBatchGeneration'), this.$t('tip.hint'), {
+ confirmButtonText: this.$t('tip.confirm'),
+ cancelButtonText: this.$t('tip.cancel'),
+ type: 'warning'
+ }).then((res) => {
+ const modelsList = this.createSwitchSection(createArr, changeSectionList);
+ modelsList.forEach(item => {
+ createArr.push(item);
+ });
+ this.$emit('updateMapModel', createArr);
+ }).catch(() => {
+ this.$message( this.$t('tip.cancelGeneration'));
+ });
+ },
+ // 修改区段属性
+ // changeSectionAttr() {
+ // const changeSectionList = []; // 改变的区段列表
+ // this.sectionList.forEach(section => {
+ // if (section.type == '01' || section.type == '03') {
+ // const oneSection = section.points[section.points.length - 1];
+ // const oneSectionStar = section.points[0];
+ // let countA = 0;
+ // let countB = 0;
+ // this.sectionList.forEach(elem => {
+ // if ((elem.type == '01' || section.type == '03') && section.code != elem.code) {
+ // let twoSection, twoSectionEnd;
+ // if (this.handleResetPoint(elem.points)) {
+ // twoSection = elem.points[0];
+ // twoSectionEnd = elem.points[elem.points.length - 1];
+ // } else {
+ // twoSection = elem.points[elem.points.length - 1];
+ // twoSectionEnd = elem.points[0];
+ // }
+ // if (oneSection.x == twoSection.x && oneSection.y == twoSection.y) {
+ // countA++;
+ // if (countA === 2) {
+ // // if (!this.checkAddListA(oneSection, section.code)) { // 右侧关系清空
+ // const sectionModel = deepAssign({}, section);
+ // sectionModel.rightSectionCode = '';
+ // sectionModel.sepTypeRight = '00'; // 分隔符
+ // sectionModel.type = '03';
+ // const list = this.findSectionA(sectionModel.points[sectionModel.points.length - 1].x, sectionModel.points[sectionModel.points.length - 1].y, this.sectionList, sectionModel.code);
+ // list.forEach(elem => {
+ // const sectionModelElem = deepAssign({}, elem);
+ // sectionModelElem.leftSectionCode = '';
+ // sectionModelElem.sepTypeLeft = '00';
+ // sectionModelElem.type = '03';
+ // changeSectionList.push(sectionModelElem);
+ // });
+ // sectionModel['typeModel'] = 'start';
+ // changeSectionList.push(sectionModel);
+ // // }
+ // }
+ // } else if (oneSectionStar.x == twoSectionEnd.x && oneSectionStar.y == twoSectionEnd.y) {
+ // countB++;
+ // if (countB === 2) {
+ // // if (!this.checkAddListB(oneSectionStar, section.code)) { // 左侧关系清空
+ // const sectionModel = deepAssign({}, section);
+ // sectionModel.leftSectionCode = '';
+ // sectionModel.sepTypeLeft = '00';
+ // sectionModel.type = '03';
+ // const list = this.findSectionB(sectionModel.points[0].x, sectionModel.points[0].y, this.sectionList, sectionModel.code);
+ // list.forEach(elem => {
+ // const sectionModelElem = deepAssign({}, elem);
+ // sectionModelElem.rightSectionCode = '';
+ // sectionModelElem.sepTypeRight = '00'; // 分隔符
+ // sectionModelElem.type = '03';
+ // changeSectionList.push(sectionModelElem);
+ // });
+ // sectionModel['typeModel'] = 'end';
+ // changeSectionList.push(sectionModel);
+ // // }
+ // }
+ // }
+ // }
+ // });
+ // }
+ // });
+ // return changeSectionList;
+ // },
// checkAddListA(points, code) { // 判断是否添加list (暂时不用)
// let flag = false;
// this.sectionList.forEach(section => {
@@ -645,8 +809,8 @@ export default {
};
diff --git a/src/views/system/deviceManage/index.vue b/src/views/system/deviceManage/index.vue
index d73089b4c..ce1f709bc 100644
--- a/src/views/system/deviceManage/index.vue
+++ b/src/views/system/deviceManage/index.vue
@@ -207,7 +207,7 @@ export default {
getDeviceDetail(row.id).then(res=>{
if (res.data) {
let url = '';
- url = `${window.location.protocol}//${window.location.host}/cbtc/login?project=${row.project.toLowerCase().replace(/_/, '')}&projectDevice=${row.code}&type=${row.type}`;
+ url = `${window.location.protocol}//${window.location.host}/cbtc/login?project=${row.project.toLowerCase().replaceAll('_', '')}&projectDevice=${row.code}&type=${row.type}`;
this.url = url;
this.$messageBox();
this.$confirm(`登录路径:${url}`, '登录路径', {