新版地图保存

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) {
return request({

View File

@ -20,26 +20,6 @@ function queryDeleteModels(map, device, dict) {
setDisPose(device, dict);
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:
// 删除所属逻辑区段
@ -63,13 +43,14 @@ function queryDeleteModels(map, device, dict) {
break;
case deviceType.Switch:
map.sectionList.forEach(elem => {
if (elem.type == '03' && elem.relSwitchCode == device.code) {
if (elem.type == '04' && elem.relSwitchCode == device.code) {
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) {
const copyModel = deepAssign({}, elem);
copyModel.relSwitchCode = '';
copyModel.parentCode = '';
copyModel.isSwitchSection = false;
dict[elem.code] = copyModel;
}

View File

@ -3,11 +3,11 @@ 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.82:9000'; // 杜康
BASE_API = 'http://192.168.3.82:9000'; // 杜康
} else {
BASE_API = process.env.VUE_APP_BASE_API;
}

View File

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

View File

@ -48,7 +48,7 @@
</transition>
</template>
<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 { checkLoginLine } from '@/api/login';
import JlmapVisual from '@/views/newMap/jlmapNew/index';
@ -236,7 +236,7 @@ export default {
if (this.verifySectionPoint(map)) {
this.mapSaveing = true;
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.mapSaveing = false;
this.initAutoSaveTask();

View File

@ -165,7 +165,7 @@ export default {
findSectionA(pointX, pointY) {
const list = [];
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);
}
});
@ -174,7 +174,7 @@ export default {
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) {
if (item.points[item.points.length - 1].x == pointX && item.points[item.points.length - 1].y == pointY) {
list.push(item);
}
});
@ -186,11 +186,12 @@ export default {
const createArr = []; // model
this.sectionList.forEach(section => {
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 sectionC = {};
if (list.length >= 2) {
list.forEach(item => {
if (item.point[1].y == section.point[section.point.length - 1].y) { //
if (item.points[1].y == section.points[section.points.length - 1].y) { //
sectionB = item;
} else {
sectionC = item;
@ -208,17 +209,27 @@ export default {
sectionCCode: sectionC.code,
namePosition: { x: 0, y: 0 },
turnTime: 3,
tp: { x: 0, y: 0 }
tp: { x: 0, y: 0 },
intersection: {
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') { //
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 sectionC = {};
if (list.length >= 2) {
list.forEach(item => {
if (item.point[item.point.length - 2].y == section.point[0].y) { //
if (item.points[item.points.length - 2].y == section.points[0].y) { //
sectionB = item;
} else {
sectionC = item;
@ -236,11 +247,20 @@ export default {
sectionCCode: sectionC.code,
namePosition: { x: 0, y: 0 },
turnTime: 3,
tp: { x: 0, y: 0 }
tp: { x: 0, y: 0 },
intersection: {
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, '生成的道岔');
@ -275,6 +295,7 @@ export default {
},
//
deleteObj() {
const models = [];
const selected = this.$store.getters['map/getDeviceByCode'](this.editModel.code);
if (selected && selected._type.toUpperCase() === 'Switch'.toUpperCase()) {
const _that = this;
@ -283,7 +304,9 @@ export default {
cancelButtonText: this.$t('tip.cancel'),
type: 'warning'
}).then(() => {
_that.handleDelete(selected);
// _that.handleDelete(selected);
models.push(deepAssign(selected, { _dispose: true }));
_that.$emit('updateMapModel', models);
_that.deviceSelect();
}).catch(() => {
_that.$message.info(this.$t('tip.cancelGeneration'));
@ -292,21 +315,21 @@ export default {
},
// /
handleDelete(selected) {
const models = [];
this.sectionList.forEach(elem => {
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') { //
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);
// const models = [];
// this.sectionList.forEach(elem => {
// if (elem.relSwitchCode == selected.code && elem.type == '04') { //
// models.push(deepAssign({ _type: 'Section', code: elem.code }, { _dispose: true }));
// }
// 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);
},
findSectionDataByLinkCodeAndPoint(code, point) {
var rtn = null;
@ -348,16 +371,15 @@ export default {
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]) {
if (sectionb1.points[0].x == sectionb.points[sectionb.points.length - 1].x && sectionb1.points[0].y == sectionb.points[sectionb.points.length - 1].y) {
sectionList.push(elem);
}
if (sectiona1.points[0] == sectiona.points[sectiona.points.length - 1]) {
if (sectiona1.points[0].x == sectiona.points[sectiona.points.length - 1].x && sectiona1.points[0].y == sectiona.points[sectiona.points.length - 1].y) {
sectionList.push(elem);
}
});
@ -373,7 +395,6 @@ export default {
models.push(sectiona);
models.push(sectionb);
models.push(sectionc);
}
});
console.log(sectionList, '生成道岔计轴区段');
sectionList.forEach(elem => {