-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.html
379 lines (373 loc) · 18.8 KB
/
index.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>后台管理系统</title>
<link rel="stylesheet" type="text/css" href="./assets/iview/iview-3.1.0/styles/iview.css" />
<link rel="stylesheet" type="text/css" href="./css/index.css" />
<script src="./assets/vue/vue-2.5.17.min.js"></script>
<script src="./assets/iview/iview-3.1.0/iview.min.js"></script>
<script src="./assets/axios/axios.min.js"></script>
</head>
<body>
<div id="app">
<div class="layout">
<Layout>
<Sider ref="side1" hide-trigger collapsible :collapsed-width="80" v-model="isCollapsed">
<div class="sider-logo">
<span class="sider-logo-text">后台管理系统</span>
<Icon class="sider-logo-icon" type="md-home" size="24"></Icon>
</div>
<i-menu id="sider_menu" ref="myMenu" :active-name="currentTab.name" theme="dark" width="auto"
:open-names="menuState.openNames" accordion :class="menuitemClasses" :style="{height:menuState.height+'px'}">
<template v-for="submenu in menu" :key="submenu.name">
<submenu :name="submenu.name">
<template slot="title">
<Icon :type="submenu.icon"></Icon>
<span :title="submenu.title">{{submenu.title}}</span>
</template>
<template v-for="item in submenu.menuItem">
<menu-item :name="item.name" @click.native="handleMenuClick(item)" :style="{paddingLeft:(!isCollapsed?43:25)+'px'}">
<Icon :type="item.icon"></Icon>
<span :title="item.label">{{item.label}}</span>
</menu-item>
</template>
</submenu>
</template>
</i-menu>
</Sider>
<Layout>
<i-header :style="{position: 'fixed', width: '100%'}" class="layout-header-bar">
<i-menu mode="horizontal" theme="dark" active-name="1">
<div class="layout-logo">
<Icon @click.native="collapsedSider" class="menu-toggle" :class="rotateIcon" :style="{margin: '0'}"
type="md-menu" size="24"></Icon>
</div>
<div class="layout-nav" :style="{width: (isCollapsed ? 390 : 500) + 'px'}">
<menu-item name="1" title="内容管理">
内容管理
</menu-item>
<menu-item name="2">
用户管理
</menu-item>
<menu-item name="4">
综合设置
</menu-item>
<Submenu name="3">
<template slot="title">
我的
</template>
<menu-group title="使用">
<menu-item name="3-1">新增和启动</menu-item>
<menu-item name="3-2">活跃分析</menu-item>
<menu-item name="3-3">时段分析</menu-item>
</menu-group>
<menu-group title="留存">
<menu-item name="3-4">用户留存</menu-item>
<menu-item name="3-5">流失用户</menu-item>
</menu-group>
</Submenu>
</div>
</i-menu>
</i-header>
<i-content :style="mainContentHeight">
<tabs :type="tab.type" closable v-show="tabs.length>0" :value="currentTab.name" :animated="true"
@on-click="handleTabClicked" @on-tab-remove="handleTabRemoved">
<Dropdown style="margin-left: 20px" placement="bottom-end" transfer="true" slot="extra"
@on-click="handleTabDropdownClick">
<i-button type="text" style="height:30px;">
<Icon type="ios-arrow-down"></Icon>
</i-button>
<dropdown-menu slot="list">
<dropdown-item name="close-all">
<Icon type="md-close"></Icon> 关闭全部
</dropdown-item>
<dropdown-item name="close-current">
<Icon type="ios-arrow-forward"></Icon> 关闭当前
</dropdown-item>
<dropdown-item name="close-others">
<Icon type="md-arrow-forward"></Icon> 关闭其他
</dropdown-item>
<dropdown-item name="switch-tab-type" divided>
<Icon type="md-swap"></Icon> 切换模式
</dropdown-item>
</dropdown-menu>
</Dropdown>
<tab-pane v-for="(tab,index) in tabs" :key="tab" :label="tab.label" :icon="tab.icon" :name="tab.name"
:closable="tab.closable">
<iframe :src="tab.href" style="border:none;width:100%;" frameborder="0" :height="frameHeight"
marginheight="0" scrolling="auto" marginwidth="0"></iframe>
</tab-pane>
</tabs>
</i-content>
</Layout>
</Layout>
</div>
</div>
<script type="text/javascript">
//检查是否已登录
var token = localStorage.getItem("dnc_token");
if (!token) {
window.location.href = "login.html";
}
Vue.prototype.$Message.config({
top: 10,
duration: 3
});
var vm = new Vue({
el: '#app',
data: {
windowHeight: 0,
frameHeight: 0,
menuState: {
openMenus: [],
height: 300
},
tab: {
type: "line" //可选值:line,card
},
currentTab: {
index: 0,
name: "",
closable: true
},
isCollapsed: false,
menu: [
{
title: "用户及授权", name: "1", icon: "logo-apple", menuItem: [
{ label: "用户管理", name: "1-1", href: "pages/account/user/list.html", icon: "logo-apple", closable: false },
{ label: "资源管理", name: "1-2", href: "pages/account/resource/list.html", icon: "logo-windows", closable: true },
{ label: "角色管理", name: "1-3", href: "pages/account/role/list.html", icon: "logo-tux", closable: true }
]
},
{
title: "系统管理", name: "2", icon: "logo-windows", menuItem: [
{ label: "权限管理", name: "2-1", href: "pages/basic/settings/index.html", icon: "logo-apple", closable: true },
{ label: "组织机构", name: "2-2", href: "pages/basic/settings/evn.html", icon: "logo-windows", closable: true },
{ label: "角色管理", name: "2-3", href: "pages/basic/settings/index.html", icon: "logo-apple", closable: true },
{ label: "基础设置", name: "2-4", href: "pages/basic/settings/evn.html", icon: "logo-windows", closable: true },
{ label: "指标类别", name: "2-5", href: "pages/basic/settings/index.html", icon: "logo-apple", closable: true },
{ label: "用户管理", name: "2-6", href: "pages/basic/settings/evn.html", icon: "logo-windows", closable: true },
{ label: "模块管理", name: "2-7", href: "pages/basic/settings/index.html", icon: "logo-apple", closable: true },
{ label: "人员导入", name: "2-8", href: "pages/basic/settings/evn.html", icon: "logo-windows", closable: true },
{ label: "流程申请", name: "2-9", href: "pages/basic/settings/index.html", icon: "logo-apple", closable: true },
{ label: "流程监管", name: "2-10", href: "pages/basic/settings/evn.html", icon: "logo-windows", closable: true },
{ label: "发布消息", name: "2-11", href: "pages/basic/settings/index.html", icon: "logo-apple", closable: true },
{ label: "职位管理", name: "2-12", href: "pages/basic/settings/evn.html", icon: "logo-windows", closable: true },
{ label: "系数管理", name: "2-13", href: "pages/basic/settings/index.html", icon: "logo-apple", closable: true },
{ label: "系统环境", name: "2-14", href: "pages/basic/settings/evn.html", icon: "logo-windows", closable: true }
]
},
{
title: "统计分析", name: "3", icon: "logo-tux", menuItem: [
{ label: "用户活跃度", name: "3-1", href: "pages/statistics/user/active.html", icon: "logo-apple", closable: true },
{ label: "销售报表", name: "3-2", href: "pages/statistics/sales/order.html", icon: "logo-windows", closable: true }
]
}
],
tabs: [
]
},
computed: {
rotateIcon() {
return [
'menu-icon',
this.isCollapsed ? 'rotate-icon' : ''
];
},
menuitemClasses() {
return [
'menu-item',
this.isCollapsed ? 'collapsed-menu' : ''
];
},
mainContentHeight() {
var docHeight = this.windowHeight - 65;
return { margin: '50px 2px 0', background: '#fff', height: '100%', minHeight: docHeight + 15 + 'px' };
}
},
ready: function () {
},
beforeDestroy: function () {
window.removeEventListener('resize', this.handleResize)
},
mounted() {
this.init();
window.addEventListener('resize', this.handleResize);
this.handleMenuClick({ label: "首页", name: "1-0", href: "./pages/default.html", icon: "md-home", closable: false });
},
methods: {
init: function () {
this.calcFrameHeight();
this.calcSiderMenuHeight();
},
calcFrameHeight: function () {
this.windowHeight = (document.documentElement.scrollHeight || document.body.scrollHeight);
this.frameHeight = this.windowHeight - 95;
},
calcSiderMenuHeight: function () {
this.menuState.height = this.windowHeight - 50;
},
setCurrentTab: function (name) {
var tab = this.getTab(name);
var tabIndex = this.getTabIndex(name);
if (tab) {
this.currentTab.index = tabIndex;
this.currentTab.name = tab.name;
this.currentTab.closable = tab.closable;
}
},
handleMenuClick(menu) {
var tab = { label: menu.label, href: menu.href, icon: menu.icon, name: menu.name, closable: menu.closable };
if (this.tabs.map(x => x.name).indexOf(menu.name) === -1) {
this.tabs.push(tab);
}
this.setCurrentTab(tab.name);
},
handleMenuSelected(name) {
var menu = this.menu.menuItem;
},
collapsedSider() {
this.$refs.side1.toggleCollapse();
},
getTab: function (name) {
for (var i = 0; i < this.tabs.length; i++) {
if (this.tabs[i].name == name) {
return this.tabs[i];
}
}
return null;
},
getTabIndex: function (name) {
for (var i = 0; i < this.tabs.length; i++) {
if (this.tabs[i].name == name) {
return i;
}
}
return -1;
},
handleTabClicked: function (name) {
this.setCurrentTab(name);
var openNames = name.split("-")[0] + "";
this.menuState.openNames = [openNames];
this.$nextTick(function () {
this.$refs["myMenu"].updateOpened();
});
},
handleTabRemoved: function (name) {
var index = this.getTabIndex(name);
this.doRemoveTab(index);
},
handleResize: function () {
this.calcFrameHeight();
this.calcSiderMenuHeight();
},
handleTabDropdownClick: function (name) {
switch (name) {
case "close-all":
this.doCloseTabAll();
break;
case "close-current":
this.doCloseTabCurrent();
break;
case "close-others":
this.doCloseTabOthers();
break;
case "switch-tab-type":
this.handleSwitchTabType();
break;
}
},
doRemoveTab: function (index) {
var tab = this.tabs[index];
if (!tab.closable) {
return;
}
this.tabs.splice(index, 1);
},
doCloseTabAll: function () {
for (var i = this.tabs.length - 1; i >= 0; i--) {
var tab = this.tabs[i];
if (tab.closable) {
this.doRemoveTab(i);
}
}
if (this.currentTab.closable) {
var index = this.tabs.length - 1;
this.currentTab.index = index;
this.currentTab.name = this.tabs[index].name;
this.currentTab.closable = this.tabs[index].closable;
}
var target = this;
setTimeout(function () {
target.resetActiveTab();
}, 50);
},
doCloseTabCurrent: function () {
this.handleTabRemoved(this.currentTab.name);
var index = this.currentTab.index - 1;
if (index < 0) {
index = 0;
}
if (this.currentTab.closable) {
this.currentTab.index = index;
this.currentTab.name = this.tabs[index].name;
this.currentTab.closable = this.tabs[index].closable;
}
var target = this;
setTimeout(function () {
target.resetActiveTab();
}, 50);
},
doCloseTabOthers: function () {
var previousRemoveCount = 0;
var count = true;
for (var i = this.tabs.length - 1; i >= 0; i--) {
var tab = this.tabs[i];
if (tab.closable && tab.name != this.currentTab.name) {
this.doRemoveTab(i);
}
if (tab.closable && count) {
previousRemoveCount++;
if (tab.name == this.currentTab.name) {
count = false;
}
}
}
if (previousRemoveCount > 0) {
this.currentTab.index = this.getTabIndex(this.currentTab.name);
}
},
resetActiveTab: function () {
var target = this;
setTimeout(function () {
var name = target.currentTab.name;
target.setCurrentTab(name);
target.handleTabClicked(name);
}, 100);
},
handleSwitchTabType: function () {
this.tab.type = this.tab.type === "line" ? "card" : "line";
},
findNextTabIndex: function () {
var index = this.currentTab.index - 1;
if (index < 0) {
index = 0;
}
return index;
},
findNextTabName: function () {
var index = this.findNextTabIndex();
return this.tabs[index].name;
},
findNextTab: function () {
var index = this.findNextTabIndex();
return this.tabs[index];
}
}
});
</script>
</body>
</html>