新版地图保存

This commit is contained in:
zyy 2019-12-02 14:09:50 +08:00
parent 829d1b7e0c
commit d0a986e8bf
6 changed files with 132 additions and 120 deletions

View File

@ -59,6 +59,15 @@ export function saveMap(data) {
}); });
} }
/** 保存新草稿地图*/
export function saveNewMap(data) {
return request({
url: `/api/mapBuild/${data.mapId}/saveNewElements`,
method: 'post',
data: data
});
}
/** 草稿地图另存为*/ /** 草稿地图另存为*/
export function saveAsMap(data) { export function saveAsMap(data) {
return request({ return request({

View File

@ -20,27 +20,7 @@ function queryDeleteModels(map, device, dict) {
setDisPose(device, dict); setDisPose(device, dict);
switch (device._type) { switch (device._type) {
// 查询ink关联项 // 移除区段关联项
case deviceType.Link:
// 查询Link关联的区段
if (map.sectionList && map.sectionList.length) {
map.sectionList.forEach(elem => {
if (elem.linkCode === device.code) {
queryDeleteModels(map, elem, dict);
}
});
}
// 查询Link关联的信号机
if (map.signalList && map.signalList.length) {
map.signalList.forEach(elem => {
if (elem.linkCode === device.code) {
setDisPose(elem, dict);
}
});
}
break;
// 移除区段关联项
case deviceType.Section: case deviceType.Section:
// 删除所属逻辑区段 // 删除所属逻辑区段
if (map.sectionList && map.sectionList.length && device.type == '01') { if (map.sectionList && map.sectionList.length && device.type == '01') {
@ -63,13 +43,14 @@ function queryDeleteModels(map, device, dict) {
break; break;
case deviceType.Switch: case deviceType.Switch:
map.sectionList.forEach(elem => { map.sectionList.forEach(elem => {
if (elem.type == '03' && elem.relSwitchCode == device.code) { if (elem.type == '04' && elem.relSwitchCode == device.code) {
setDisPose(elem, dict); setDisPose(elem, dict);
} }
if (elem.relSwitchCode == device.code && elem.type != '03') { if (elem.relSwitchCode == device.code && elem.type != '04') {
if (!dict[elem.code] || !dict[elem.code]._dispose) { if (!dict[elem.code] || !dict[elem.code]._dispose) {
const copyModel = deepAssign({}, elem); const copyModel = deepAssign({}, elem);
copyModel.relSwitchCode = ''; copyModel.relSwitchCode = '';
copyModel.parentCode = '';
copyModel.isSwitchSection = false; copyModel.isSwitchSection = false;
dict[elem.code] = copyModel; dict[elem.code] = copyModel;
} }

View File

@ -3,11 +3,11 @@ export function getBaseUrl() {
let BASE_API; let BASE_API;
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
// BASE_API = 'https://joylink.club/jlcloud'; // 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.5:9000'; // 袁琪
// BASE_API = 'http://192.168.3.6: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'; // 杜康 BASE_API = 'http://192.168.3.82:9000'; // 杜康
} else { } else {
BASE_API = process.env.VUE_APP_BASE_API; BASE_API = process.env.VUE_APP_BASE_API;
} }

View File

@ -145,6 +145,7 @@ export default {
this.$refs['newForm'].validate((valid) => { this.$refs['newForm'].validate((valid) => {
if (valid) { if (valid) {
this.loading = true; this.loading = true;
this.newModel['drawWay'] = '1';
newMap(this.newModel).then(response => { newMap(this.newModel).then(response => {
this.loading = false; this.loading = false;
this.$emit('refresh'); this.$emit('refresh');

View File

@ -48,7 +48,7 @@
</transition> </transition>
</template> </template>
<script> <script>
import { saveMap, getMapDetail, verifyMap, postBuildMapImport } from '@/api/jmap/mapdraft'; import { saveNewMap, getMapDetail, verifyMap, postBuildMapImport } from '@/api/jmap/mapdraft';
import { ViewMode, TrainingMode, getDeviceMenuByDeviceType } from '@/scripts/ConstDic'; import { ViewMode, TrainingMode, getDeviceMenuByDeviceType } from '@/scripts/ConstDic';
import { checkLoginLine } from '@/api/login'; import { checkLoginLine } from '@/api/login';
import JlmapVisual from '@/views/newMap/jlmapNew/index'; import JlmapVisual from '@/views/newMap/jlmapNew/index';
@ -236,7 +236,7 @@ export default {
if (this.verifySectionPoint(map)) { if (this.verifySectionPoint(map)) {
this.mapSaveing = true; this.mapSaveing = true;
this.$store.dispatch('map/saveMapDeviceDefaultRelations').then(() => { this.$store.dispatch('map/saveMapDeviceDefaultRelations').then(() => {
saveMap(Object.assign(map, { mapId: this.$route.params.mapId })).then(response => { saveNewMap(Object.assign(map, { mapId: this.$route.params.mapId })).then(response => {
this.$message.success(this.$t('tip.saveSuccessfully')); this.$message.success(this.$t('tip.saveSuccessfully'));
this.mapSaveing = false; this.mapSaveing = false;
this.initAutoSaveTask(); this.initAutoSaveTask();

View File

@ -165,7 +165,7 @@ export default {
findSectionA(pointX, pointY) { findSectionA(pointX, pointY) {
const list = []; const list = [];
this.sectionList.forEach(item => { this.sectionList.forEach(item => {
if (item.point[0].x == pointX && item.point[0].y == pointY) { if (item.points[0].x == pointX && item.points[0].y == pointY) {
list.push(item); list.push(item);
} }
}); });
@ -174,7 +174,7 @@ export default {
findSectionB(pointX, pointY) { findSectionB(pointX, pointY) {
const list = []; const list = [];
this.sectionList.forEach(item => { this.sectionList.forEach(item => {
if (item.point[item.point.length - 1].x == pointX && item.point[item.point.length - 1].y == pointY) { if (item.points[item.points.length - 1].x == pointX && item.points[item.points.length - 1].y == pointY) {
list.push(item); list.push(item);
} }
}); });
@ -186,60 +186,80 @@ export default {
const createArr = []; // model const createArr = []; // model
this.sectionList.forEach(section => { this.sectionList.forEach(section => {
if (!section.rightSectionCode && section.type == '03') { // if (!section.rightSectionCode && section.type == '03') { //
const list = this.findSectionA(section.point[section.point.length - 1].x, section.point[section.point.length - 1].y); const list = this.findSectionA(section.points[section.points.length - 1].x, section.points[section.points.length - 1].y);
let sectionB = {}; let sectionB = {};
let sectionC = {}; let sectionC = {};
list.forEach(item => { if (list.length >= 2) {
if (item.point[1].y == section.point[section.point.length - 1].y) { // list.forEach(item => {
sectionB = item; if (item.points[1].y == section.points[section.points.length - 1].y) { //
} else { sectionB = item;
sectionC = item; } else {
} sectionC = item;
}); }
const uname = 'switch_' + section.name.replace('section_', ''); });
const model = { const uname = 'switch_' + section.name.replace('section_', '');
_type: 'Switch', const model = {
code: getUID('Switch'), _type: 'Switch',
name: uname, code: getUID('Switch'),
nameShow: true, name: uname,
timeoutShow: true, nameShow: true,
sectionACode: section.code, timeoutShow: true,
sectionBCode: sectionB.code, sectionACode: section.code,
sectionCCode: sectionC.code, sectionBCode: sectionB.code,
namePosition: { x: 0, y: 0 }, sectionCCode: sectionC.code,
turnTime: 3, namePosition: { x: 0, y: 0 },
tp: { x: 0, y: 0 } turnTime: 3,
}; tp: { x: 0, y: 0 },
const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode); intersection: {
!swch && createArr.push(model); // x: section.points[section.points.length - 1].x,
y: section.points[section.points.length - 1].y
},
skew: {
x: sectionC.points[1].x,
y: sectionC.points[1].y
}
};
const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode);
!swch && createArr.push(model); //
}
} }
if (!section.leftSectionCode && section.type == '03') { // if (!section.leftSectionCode && section.type == '03') { //
const list = this.findSectionB(section.point[0].x, section.point[0].y); const list = this.findSectionB(section.points[0].x, section.points[0].y);
let sectionB = {}; let sectionB = {};
let sectionC = {}; let sectionC = {};
list.forEach(item => { if (list.length >= 2) {
if (item.point[item.point.length - 2].y == section.point[0].y) { // list.forEach(item => {
sectionB = item; if (item.points[item.points.length - 2].y == section.points[0].y) { //
} else { sectionB = item;
sectionC = item; } else {
} sectionC = item;
}); }
const uname = 'switch_' + section.name.replace('section_', ''); });
const model = { const uname = 'switch_' + section.name.replace('section_', '');
_type: 'Switch', const model = {
code: getUID('Switch'), _type: 'Switch',
name: uname, code: getUID('Switch'),
nameShow: true, name: uname,
timeoutShow: true, nameShow: true,
sectionACode: section.code, timeoutShow: true,
sectionBCode: sectionB.code, sectionACode: section.code,
sectionCCode: sectionC.code, sectionBCode: sectionB.code,
namePosition: { x: 0, y: 0 }, sectionCCode: sectionC.code,
turnTime: 3, namePosition: { x: 0, y: 0 },
tp: { x: 0, y: 0 } turnTime: 3,
}; tp: { x: 0, y: 0 },
const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode); intersection: {
!swch && createArr.push(model); // x: section.points[0].x,
y: section.points[0].y
},
skew: {
x: sectionC.points[sectionC.points.length - 2].x,
y: sectionC.points[sectionC.points.length - 2].y
}
};
const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode);
!swch && createArr.push(model); //
}
} }
}); });
console.log(createArr, '生成的道岔'); console.log(createArr, '生成的道岔');
@ -275,6 +295,7 @@ export default {
}, },
// //
deleteObj() { deleteObj() {
const models = [];
const selected = this.$store.getters['map/getDeviceByCode'](this.editModel.code); const selected = this.$store.getters['map/getDeviceByCode'](this.editModel.code);
if (selected && selected._type.toUpperCase() === 'Switch'.toUpperCase()) { if (selected && selected._type.toUpperCase() === 'Switch'.toUpperCase()) {
const _that = this; const _that = this;
@ -283,7 +304,9 @@ export default {
cancelButtonText: this.$t('tip.cancel'), cancelButtonText: this.$t('tip.cancel'),
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
_that.handleDelete(selected); // _that.handleDelete(selected);
models.push(deepAssign(selected, { _dispose: true }));
_that.$emit('updateMapModel', models);
_that.deviceSelect(); _that.deviceSelect();
}).catch(() => { }).catch(() => {
_that.$message.info(this.$t('tip.cancelGeneration')); _that.$message.info(this.$t('tip.cancelGeneration'));
@ -292,21 +315,21 @@ export default {
}, },
// / // /
handleDelete(selected) { handleDelete(selected) {
const models = []; // const models = [];
this.sectionList.forEach(elem => { // this.sectionList.forEach(elem => {
if (elem.type == '04' && elem.relSwitchCode == selected.code) { // // if (elem.relSwitchCode == selected.code && elem.type == '04') { //
models.push(deepAssign({ _type: 'Section', code: elem.code }, { _dispose: true })); // models.push(deepAssign({ _type: 'Section', code: elem.code }, { _dispose: true }));
} // }
if (elem.relSwitchCode == selected.code && elem.type == '03') { // // if (elem.relSwitchCode == selected.code && elem.type == '03') { //
const section = deepAssign({}, this.$store.getters['map/getDeviceByCode'](elem.code)); // const section = deepAssign({}, this.$store.getters['map/getDeviceByCode'](elem.code));
section.relSwitchCode = ''; // section.relSwitchCode = '';
section.parentCode = ''; // section.parentCode = '';
section.isSwitchSection = false; // section.isSwitchSection = false;
models.push(section); // models.push(section);
} // }
}); // });
models.push(deepAssign(selected, { _dispose: true })); // models.push(deepAssign(selected, { _dispose: true }));
this.$emit('updateMapModel', models); // this.$emit('updateMapModel', models);
}, },
findSectionDataByLinkCodeAndPoint(code, point) { findSectionDataByLinkCodeAndPoint(code, point) {
var rtn = null; var rtn = null;
@ -348,32 +371,30 @@ export default {
const sectionb = deepAssign({}, this.$store.getters['map/getDeviceByCode'](elem.sectionBCode)); const sectionb = deepAssign({}, this.$store.getters['map/getDeviceByCode'](elem.sectionBCode));
const sectiona = deepAssign({}, this.$store.getters['map/getDeviceByCode'](elem.sectionACode)); const sectiona = deepAssign({}, this.$store.getters['map/getDeviceByCode'](elem.sectionACode));
const sectionc = deepAssign({}, this.$store.getters['map/getDeviceByCode'](elem.sectionCCode)); const sectionc = deepAssign({}, this.$store.getters['map/getDeviceByCode'](elem.sectionCCode));
if (sectiona && sectionb && sectionc) { const uid = getUID('Section');
const uid = getUID('Section'); elem['uid'] = uid;
elem['uid'] = uid; list.forEach(ele => {
list.forEach(ele => { const sectiona1 = deepAssign({}, this.$store.getters['map/getDeviceByCode'](ele.sectionACode));
const sectiona1 = deepAssign({}, this.$store.getters['map/getDeviceByCode'](ele.sectionACode)); const sectionb1 = deepAssign({}, this.$store.getters['map/getDeviceByCode'](ele.sectionBCode));
const sectionb1 = deepAssign({}, this.$store.getters['map/getDeviceByCode'](ele.sectionBCode)); if (sectionb1.points[0].x == sectionb.points[sectionb.points.length - 1].x && sectionb1.points[0].y == sectionb.points[sectionb.points.length - 1].y) {
if (sectionb.points[0] == sectionb1.points[sectionb1.points.length - 1]) { sectionList.push(elem);
sectionList.push(elem); }
} if (sectiona1.points[0].x == sectiona.points[sectiona.points.length - 1].x && sectiona1.points[0].y == sectiona.points[sectiona.points.length - 1].y) {
if (sectiona1.points[0] == sectiona.points[sectiona.points.length - 1]) { sectionList.push(elem);
sectionList.push(elem); }
} });
}); sectiona.parentCode = uid;
sectiona.parentCode = uid; sectionb.parentCode = uid;
sectionb.parentCode = uid; sectionc.parentCode = uid;
sectionc.parentCode = uid; sectiona.relSwitchCode = elem.code;
sectiona.relSwitchCode = elem.code; sectionb.relSwitchCode = elem.code;
sectionb.relSwitchCode = elem.code; sectionc.relSwitchCode = elem.code;
sectionc.relSwitchCode = elem.code; sectiona.isSwitchSection = true;
sectiona.isSwitchSection = true; sectionb.isSwitchSection = true;
sectionb.isSwitchSection = true; sectionc.isSwitchSection = true;
sectionc.isSwitchSection = true; models.push(sectiona);
models.push(sectiona); models.push(sectionb);
models.push(sectionb); models.push(sectionc);
models.push(sectionc);
}
}); });
console.log(sectionList, '生成道岔计轴区段'); console.log(sectionList, '生成道岔计轴区段');
sectionList.forEach(elem => { sectionList.forEach(elem => {