Merge branch 'dev' of https://git.qcloud.com/joylink/jl-nclient into dev
This commit is contained in:
commit
791655a50a
@ -20,9 +20,6 @@ class Jlmap {
|
||||
// 鼠标事件
|
||||
this.events = { __Pan: 'pan', __Zoom: 'zoom', Selected: 'selected', Contextmenu: 'contextmenu', DataZoom: 'dataZoom'};
|
||||
|
||||
// 原始数据
|
||||
this.data = {};
|
||||
|
||||
// 皮肤参数
|
||||
this.skinCode = '';
|
||||
|
||||
@ -83,12 +80,10 @@ class Jlmap {
|
||||
this.$options.scaleRate = map.skinVO.scaling || 1;
|
||||
this.$options.offsetX = map.skinVO.origin ? map.skinVO.origin.x : 0;
|
||||
this.$options.offsetY = map.skinVO.origin ? map.skinVO.origin.y : 0;
|
||||
// 更新视图大小
|
||||
this.$painter.updateTransform({ scaleRate: this.$options.scaleRate, offsetX: this.$options.offsetX, offsetY: this.$options.offsetY });
|
||||
}
|
||||
|
||||
// 保存原始数据
|
||||
this.data = map;
|
||||
|
||||
// 解析地图数据
|
||||
this.mapDevice = mapDevice;
|
||||
|
||||
@ -103,7 +98,6 @@ class Jlmap {
|
||||
|
||||
// 视图加载完成 回调
|
||||
if (this.methods.viewLoaded instanceof Function) { this.methods.viewLoaded(this.mapDevice); }
|
||||
|
||||
}
|
||||
|
||||
setDefaultState() {
|
||||
@ -158,7 +152,6 @@ class Jlmap {
|
||||
const type = elem._type;
|
||||
const oDevice = this.mapDevice[code] || deviceFactory(type, elem);
|
||||
const nDevice = Object.assign(oDevice || {}, elem);
|
||||
this.dataSync(nDevice);
|
||||
this.$painter.delete(oDevice);
|
||||
if (!elem._dispose) {
|
||||
this.mapDevice[code] = nDevice;
|
||||
@ -275,52 +268,6 @@ class Jlmap {
|
||||
return payload || {};
|
||||
}
|
||||
|
||||
dataSync(model) {
|
||||
var prop = null;
|
||||
var type = model._type;
|
||||
var code = model.code;
|
||||
|
||||
switch (type) {
|
||||
case deviceType.Link: prop = 'linkList'; break;
|
||||
case deviceType.Section: prop = 'sectionList'; break;
|
||||
case deviceType.Switch: prop = 'switchList'; break;
|
||||
case deviceType.Signal: prop = 'signalList'; break;
|
||||
case deviceType.Station: prop = 'stationList'; break;
|
||||
case deviceType.StationStand: prop = 'stationStandList'; break;
|
||||
case deviceType.StationControl: prop = 'stationControlList'; break;
|
||||
case deviceType.StationCounter: prop = 'stationCounterList'; break;
|
||||
case deviceType.ZcControl: prop = 'zcControlList'; break;
|
||||
case deviceType.StationDelayUnlock: prop = 'stationDelayUnlockList'; break;
|
||||
case deviceType.LcControl: prop = 'lcControlList'; break;
|
||||
case deviceType.ButtonControl: prop = 'buttonList'; break;
|
||||
case deviceType.LimitControl: prop = 'tempSpeedLimitList'; break;
|
||||
case deviceType.ImageControl: prop = 'imageControl'; break;
|
||||
case deviceType.Train: prop = 'trainList'; break;
|
||||
case deviceType.TrainWindow: prop = 'trainWindowList'; break;
|
||||
case deviceType.Line: prop = 'lineList'; break;
|
||||
case deviceType.Text: prop = 'textList'; break;
|
||||
}
|
||||
|
||||
const list = this.data[prop] || [];
|
||||
const idex = list.findIndex(elem => { return elem.code == code; });
|
||||
if (list) {
|
||||
if (model._dispose) {
|
||||
idex >= 0 && list.splice(idex, 1);
|
||||
} else {
|
||||
const elem = list[idex];
|
||||
if (elem) {
|
||||
Object.keys(model).forEach(key => {
|
||||
if (key != 'instance') {
|
||||
elem[key] = model[key];
|
||||
}
|
||||
});
|
||||
} else {
|
||||
list.push(Object.assign({}, model));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getZr() {
|
||||
return this.$zr;
|
||||
}
|
||||
|
@ -191,6 +191,53 @@ function saveMapDeviceDefaultRelations(state) {
|
||||
}
|
||||
}
|
||||
|
||||
// 同步绘制数据到原始数据
|
||||
function dataSync(model, map) {
|
||||
var prop = null;
|
||||
var type = model._type;
|
||||
var code = model.code;
|
||||
|
||||
switch (type) {
|
||||
case deviceType.Link: prop = 'linkList'; break;
|
||||
case deviceType.Section: prop = 'sectionList'; break;
|
||||
case deviceType.Switch: prop = 'switchList'; break;
|
||||
case deviceType.Signal: prop = 'signalList'; break;
|
||||
case deviceType.Station: prop = 'stationList'; break;
|
||||
case deviceType.StationStand: prop = 'stationStandList'; break;
|
||||
case deviceType.StationControl: prop = 'stationControlList'; break;
|
||||
case deviceType.StationCounter: prop = 'stationCounterList'; break;
|
||||
case deviceType.ZcControl: prop = 'zcControlList'; break;
|
||||
case deviceType.StationDelayUnlock: prop = 'stationDelayUnlockList'; break;
|
||||
case deviceType.LcControl: prop = 'lcControlList'; break;
|
||||
case deviceType.ButtonControl: prop = 'buttonList'; break;
|
||||
case deviceType.LimitControl: prop = 'tempSpeedLimitList'; break;
|
||||
case deviceType.ImageControl: prop = 'imageControl'; break;
|
||||
case deviceType.Train: prop = 'trainList'; break;
|
||||
case deviceType.TrainWindow: prop = 'trainWindowList'; break;
|
||||
case deviceType.Line: prop = 'lineList'; break;
|
||||
case deviceType.Text: prop = 'textList'; break;
|
||||
}
|
||||
|
||||
const list = map[prop] || [];
|
||||
const idex = list.findIndex(elem => { return elem.code == code; });
|
||||
if (list) {
|
||||
if (model._dispose) {
|
||||
idex >= 0 && list.splice(idex, 1);
|
||||
} else {
|
||||
const elem = list[idex];
|
||||
if (elem) {
|
||||
Object.keys(model).forEach(key => {
|
||||
if (key != 'instance') {
|
||||
elem[key] = model[key];
|
||||
}
|
||||
});
|
||||
} else {
|
||||
list.push(Object.assign({}, model));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 实训状态数据
|
||||
*/
|
||||
@ -435,7 +482,13 @@ const map = {
|
||||
state.dataZoom = dataZoom;
|
||||
},
|
||||
mapRender: (state, devices) => {
|
||||
Vue.prototype.$jlmap && Vue.prototype.$jlmap.render(devices);
|
||||
if (state.map) {
|
||||
devices.forEach(elem => { dataSync(elem, state.map); });
|
||||
}
|
||||
|
||||
if (Vue.prototype.$jlmap) {
|
||||
Vue.prototype.$jlmap.render(devices);
|
||||
}
|
||||
},
|
||||
setTrainDetails: (state, details) => {
|
||||
state.trainDetails = details;
|
||||
@ -474,14 +527,18 @@ const map = {
|
||||
}
|
||||
});
|
||||
|
||||
Vue.prototype.$jlmap && Vue.prototype.$jlmap.render(trainList);
|
||||
if (Vue.prototype.$jlmap) {
|
||||
Vue.prototype.$jlmap.render(trainList);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
mapClear: (state) => {
|
||||
state.map = null;
|
||||
state.mapDevice = {};
|
||||
Vue.prototype.$jlmap && Vue.prototype.$jlmap.clear();
|
||||
if (Vue.prototype.$jlmap) {
|
||||
Vue.prototype.$jlmap.clear();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user