修正格式

This commit is contained in:
ival 2019-07-08 09:38:39 +08:00
parent 4e6d971797
commit 266ea1a44a
7 changed files with 80 additions and 56 deletions

View File

@ -25,6 +25,7 @@
"nprogress": "0.2.0",
"path-to-regexp": "2.4.0",
"qrcode.vue": "^1.6.2",
"sessionstorage": "^0.1.0",
"stompjs": "^2.3.3",
"storejs": "^1.0.25",
"vue": "2.6.10",

View File

@ -0,0 +1,11 @@
import deviceType from './deviceType';
const deviceRender = {};
/** link状态配置*/
deviceRender[deviceType.Link] = {
zlevel: 1,
progressive: 1,
};
export default deviceRender;

View File

@ -1,3 +1,4 @@
import * as zrUtil from 'zrender/src/core/util';
import Painter from './painter';
import ProxyHandle from './proxyHandle';
import deviceState from './config/deviceState';
@ -43,14 +44,21 @@ class Jmap {
// 加载皮肤
this.styleDict = this.loadStyle(skinStyle);
console.log('开始解析');
// 解析地图数据
this.mapDevice = parser(data, this.defaultStateDict);
console.log('解析数据完成');
// 生成代理对象
this.proxyData = new Proxy(this.mapDevice, new ProxyHandle(this));
console.log('数据加载完成: dataLoaded');
// 初次渲染视图
this.$painter.repaint(this.mapDevice, this.styleDict);
console.log('状态加载完成: stateLoaded');
}
loadStyle(skinStyle) {
@ -60,12 +68,12 @@ class Jmap {
loaddefaultState() {
const defaultStateDict = {};
Object.keys(deviceState).forEach(type => {
zrUtil.each(Object.keys(deviceState), (type) => {
defaultStateDict[type] = {};
Object.keys(deviceState[type] || {}).forEach(state => {
zrUtil.each(Object.keys(deviceState[type] || {}), (state) => {
defaultStateDict[type][state] = deviceState[type][state].Default;
});
});
})
})
return defaultStateDict;
}
@ -102,7 +110,7 @@ class Jmap {
device = this.proxyData[code] = Object.assign(device, { model });
}
this.syncData(model);
// this.syncData(model);
})
}

View File

@ -1,10 +1,11 @@
import zrender from 'zrender';
import * as zrUtil from 'zrender/src/core/util';
import Group from 'zrender/src/container/Group';
import deviceType from './config/deviceType';
import shapefactory from './shape/factory';
import TransformController from './transformController';
const renderer = 'svg';
const renderer = 'canvas';
const devicePixelRatio = 2;
class Painter {
@ -45,7 +46,7 @@ class Painter {
this.$zr.add(this.parentLevel);
// 添加子级图层
Object.values(deviceType).forEach(type => {
zrUtil.each(Object.values(deviceType), (type) => {
const level = new Group({ name: `__${type}__` });
this.viewLevelMap[type] = level;
this.parentLevel.add(level);
@ -141,9 +142,9 @@ class Painter {
this.viewInstance = {};
// 清空图层
Object.values(this.viewLevelMap).forEach(level => {
zrUtil.each(Object.values(this.viewLevelMap), (level) => {
level && level.removeAll();
});
})
this.refresh();
}

View File

@ -13,8 +13,8 @@ class transformController {
this.$zr = painter.$zr;
this.parentLevel = painter.parentLevel;
this.zoom = {scale: 1, offsetX: 0, offsetY: 0};
this.rect = {x:0, y:0, width: this.$zr.getWidth(), height: this.$zr.getHeight()};
this.zoom = { scale: 1, offsetX: 0, offsetY: 0 };
this.rect = { x: 0, y: 0, width: this.$zr.getWidth(), height: this.$zr.getHeight() };
this.transform = getTransform(this.zoom);
}
@ -31,7 +31,7 @@ class transformController {
view.hide();
}
view.dirty();
// view.dirty();
}
transformView(view) {
@ -44,7 +44,7 @@ class transformController {
return view;
}
transformAll () {
transformAll() {
this.parentLevel.eachChild((level) => {
level.eachChild((view) => {
this.transformView(view);

View File

@ -1,20 +1,21 @@
import * as zrUtil from 'zrender/src/core/util';
import deviceType from '../config/deviceType';
import deviceRender from '../config/deviceRender';
export function deviceFactory(type, defaultStateDict, elem) {
return {
zlevel: 1,
return Object.assign({
_type: type,
_code: elem.code,
model: elem,
state: Object.assign({}, defaultStateDict[type])
};
}, deviceRender[type]);
}
export function parser(data, defaultStateDict) {
const mapDevice = {};
if (data) {
(data.linkList || []).forEach(elem => {
zrUtil.each(data.linkList || [], (elem) => {
mapDevice[elem.code] = deviceFactory(deviceType.Link, defaultStateDict, elem);
});
}

View File

@ -14,24 +14,26 @@
jmaps: null
};
},
mounted() {
created() {
this.jmaps = new Jmaps();
},
mounted() {
this.jmap = this.jmaps.init({
id: this.id,
config: {
renderer: 'svg',
renderer: 'canvas',
width: document.documentElement.clientWidth,
height: document.documentElement.clientHeight
}
});
let list = [
{ code: '1', beg: { x: 20 , y: 50}, end: { x: 120, y: 50 } }
{ code: '1', beg: { x: 20, y: 50 }, end: { x: 120, y: 50 } }
];
for (var i = 1; i < 10; i++) {
for (var j = 1; j < 6000; j++) {
list.push({ code: `${i}${j}`, beg: { x: i * 120 + 50, y: j * 20 + 50}, end: { x: i * 120 + 150, y: j * 20 + 50 } });
for (var j = 1; j < 5000; j++) {
list.push({ code: `_00${i}${j}`, beg: { x: i * 120 + 50, y: j * 20 + 50 }, end: { x: i * 120 + 150, y: j * 20 + 50 } });
}
}