-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshowOne.html
100 lines (99 loc) · 3.37 KB
/
showOne.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>数据看板</title>
<!-- 自定义css -->
<link rel="stylesheet" type="text/css" href="layui/css/layui.css"/>
<link rel="stylesheet" type="text/css" href="css/showPage.css" />
</head>
<body>
<!-- 动态生成报表和数据 -->
<div class="layui-carousel" id="jinggongkb-main-container">
<div carousel-item id="jinggongkb-main-wrapper">
</div>
</div>
<div id="pageContainer"></div>
</body>
<script src="js/jquery-3.3.1.min.js"></script>
<script src="layui/layui.js"></script>
<script src="js/echarts.min.js"></script>
<script src="js/socket.io.js"></script>
<script src="js/app.js"></script>
<script src="js/pageUtil.js"></script>
<script src="js/showPage.js"></script>
<script type="text/javascript">
layui.use(['carousel', 'element'], function() {
var carousel = layui.carousel
var element = layui.element
//根据看板组ID获取全部看板,为每一个看板设置一个div作为容器
window.dbs = {}
callAjax('dbs/byid', {id: getQueryString('id')}, function(res) {
var page = $('#jinggongkb-main-wrapper')[0]
for (var x = 0; x < res.dbList.length; x++) {
if (res.dbList[x].checked) {
var config = JSON.parse(res.dbList[x].config)
dbs[res.dbList[x].id] = {
title: res.dbList[x].title,
config: config
}
//如果看板存在Echart主题,则全局注册主题
if (config.chartTheme) {
echarts.registerTheme(res.dbList[x].id, config.chartTheme)
}
//设置对象并插入父元素(双层DIV解决尺寸)
var outDiv = document.createElement('div')
var innerDiv = document.createElement('div')
innerDiv.setAttribute('id', 'db_' + res.dbList[x].id)
innerDiv.setAttribute('class', 'my_db')
innerDiv.style.width = config.width + 'px'
innerDiv.style.height = config.height + 'px'
outDiv.appendChild(innerDiv)
page.appendChild(outDiv)
//设置看板的背景色
if (config.backgroundColor) {
innerDiv.style.backgroundColor = config.backgroundColor
} else if (config.backgroundImg) {
innerDiv.style.backgroundImage = 'url(' + config.backgroundImg + ')'
innerDiv.style.backgroundRepeat = 'no-repeat'
innerDiv.style.backgroundSize = '100% 100%'
}
}
}
//循环每一个看板,向其中添加数据
for (var x = 0; x < Object.keys(dbs).length; x++) {
//因为要讲看板id带进入,所以搞一个闭包
(function(dbId) {
//所有元素都是平级,所以按顺序填充即可
//首先处理html
callAjax('html/list', {db_id: dbId}, function(res) {
loadHtml(dbId, res.data)
})
//处理chart
callAjax('chart/list', {db_id: dbId}, function(res) {
loadChart(dbId, res.data)
})
//处理table
callAjax('table/list', {db_id: dbId}, function(res) {
loadTable(dbId, res.data)
})
//处理image
callAjax('img/list', {db_id: dbId}, function(res) {
loadImage(dbId, res.data)
})
})(Object.keys(dbs)[x])
}
//建造轮播实例,先放那放着
carousel.render({
elem: '#jinggongkb-main-container',
width: '100%',
height: '100%',
full: true,
arrow: 'none',
interval: 1000 * 20
})
})
});
</script>
</html>