Skip to content

Commit 949e6cd

Browse files
committed
修复tabbug;完善Readme
1 parent 52da1a0 commit 949e6cd

File tree

9 files changed

+82
-19
lines changed

9 files changed

+82
-19
lines changed

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,43 @@ ng serve
2626

2727
### angular4基本功能的使用
2828
### 带管理功能可切换的tab
29+
- tab可管理;
30+
- 自定义路由重用机制
2931
### 一个增改查删的Demo(见人员管理)
30-
### 集成一些插件(文本编辑器、图表、地图、弹出框、流程图、树目录等)
32+
- 增改查删的实现
33+
- 多种表单控件
34+
### 集成一些插件
35+
- 文本编辑器
36+
- 图表
37+
- 地图
38+
- 弹出框
39+
- 流程图
40+
- 树目录
41+
- 日程安排
3142
### 与后台交互使用Rxjs
43+
- 异步编程使用Rxjs
3244
### 集成Material Design风格和Bootstrap风格的UI
3345

3446
如果喜欢,还请挪一下鼠标给我一个star~~
3547

3648
# 效果图
3749

50+
![person-list](http://oqtn5nfde.bkt.clouddn.com/person-list.png)
51+
52+
![tab](http://oqtn5nfde.bkt.clouddn.com/tab.png)
53+
54+
![alert](http://oqtn5nfde.bkt.clouddn.com/alert.png)
55+
56+
![calendar](http://oqtn5nfde.bkt.clouddn.com/calendar.png)
57+
58+
![echarts](http://oqtn5nfde.bkt.clouddn.com/echarts.png)
59+
60+
![jsplumb](http://oqtn5nfde.bkt.clouddn.com/jsplumb.png)
61+
62+
![ztree](http://oqtn5nfde.bkt.clouddn.com/ztree.png)
63+
64+
![amap](http://oqtn5nfde.bkt.clouddn.com/amap.png)
65+
3866
PS: 个人项目,一些琐碎的细节没有实现;与后台交互使用的是mock-data,增删改也是模拟成功返回;
3967

4068

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.copy-right {
2+
text-align: center;
3+
margin-left: -12%;
4+
padding-top: 10px;
5+
}
6+
7+
.copy-right-link {
8+
cursor: pointer;
9+
color: #F38181;
10+
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<div class="app-body">
22
<router-outlet></router-outlet>
33
</div>
4-
<div class="body-footer"></div>
4+
<div class="body-footer">
5+
<p class="copy-right">Copyright&nbsp;&copy;&nbsp;weihome 2017
6+
<a class="copy-right-link" target="_blank" href="http://rulifun.com">http://rulifun.com</a>
7+
</p>
8+
</div>

src/app/layout/header/header.component.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
}
1414

1515
.header-user {
16-
margin-top: 15px;
16+
margin-top: 5px;
1717
}
1818

1919
.header-user .mdl-button {

src/app/layout/header/tab/tab.component.css

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ md2-tabs {
1717
margin: 0;
1818
padding: 0;
1919
list-style: none;
20-
-webkit-user-select: none;
21-
-moz-user-select: none;
22-
-ms-user-select: none;
2320
user-select: none;
2421
}
2522

@@ -45,7 +42,7 @@ md2-tabs {
4542
}
4643

4744
.md2-next-button {
48-
right: 0;
45+
right: -30px;
4946
}
5047

5148
.md2-prev-button.disabled,
@@ -64,17 +61,17 @@ md2-tabs {
6461
border-style: solid;
6562
border-radius: 1px;
6663
transform: rotate(45deg);
67-
margin: 6px;
64+
margin: 4px 10px;
6865
}
6966

7067
.md2-next-button .next-icon {
71-
border-width: 2px 2px 0 0;
68+
border-width: 4px 4px 0 0;
7269
}
7370

7471
.md2-tabs-canvas {
7572
position: relative;
7673
height: 100%;
77-
overflow: hidden;
74+
/*overflow: hidden;*/
7875
display: block;
7976
outline: none;
8077
}
@@ -196,6 +193,11 @@ md2-tab.active {
196193
margin-left: -4px;
197194
}
198195

196+
.fixed-manage-btn {
197+
position: fixed;
198+
right: 30px;
199+
}
200+
199201
#tab_manage_btn .fa-lg {
200202
vertical-align: initial;
201203
}

src/app/layout/header/tab/tab.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ export class TabComponent implements OnInit {
1717
private md2Tabs: Md2Tabs;
1818
constructor(
1919
private tabControlService: TabControlService
20-
) { }
20+
) { }
2121

2222
ngOnInit(): void {
2323
this.tabsModel = this.tabControlService.tabsModel;
2424
}
2525

26-
goToTab(menuTab){
26+
goToTab(menuTab) {
2727
this.tabControlService.goToTab(menuTab);
2828
}
2929

src/app/layout/header/tab/tabControl.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export class TabControlService {
8383
link;
8484
if (~nowLink.indexOf(';')) {
8585
link = nowLink.substr(0, nowLink.indexOf(';'));
86-
}else {
86+
} else {
8787
link = nowLink;
8888
}
8989
if (~nowLink.indexOf('foo')) {
@@ -97,6 +97,7 @@ export class TabControlService {
9797
closeAll() {
9898
this.tabs.length = 1;
9999
this.tabsModel.activeTab = 0;
100+
100101
this.router.navigate(['/home']);
101102
}
102103

src/app/layout/header/tab/tabs.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import { TabControlServiceModal } from './TabControlServiceModal';
2626
import { TabControlService } from './tabControl.service';
2727
import { Menu } from '../../nav/menu';
2828

29+
declare var $;
30+
2931
export class Md2TabChangeEvent {
3032
index: number;
3133
tab: Md2Tab;
@@ -87,7 +89,7 @@ export class Md2TabLabel {
8789
[class.disabled]="tab.disabled" (click)="goToTab(tab.reallyTab)">
8890
<span [md2Transclude]="tab.labelRef">{{tab.label}}</span>
8991
</div>
90-
<button mdl-button #btn1="mdlButton" (click)="m1.toggle($event, btn1)" id="tab_manage_btn" mdl-ripple>
92+
<button mdl-button #btn1="mdlButton" (click)="toggle(m1, $event, btn1)" id="tab_manage_btn" mdl-ripple>
9193
<i class="fa fa-sort-down fa-lg white"></i>
9294
</button>
9395
<mdl-menu #m1="mdlMenu" mdl-menu-position="bottom-left">
@@ -315,17 +317,33 @@ export class Md2Tabs implements OnInit, AfterContentInit {
315317
canvasWidth -= tab.offsetWidth;
316318
});
317319
this.shouldPaginate = canvasWidth < 0;
318-
// TODO: need improve
319-
if (this.tabsModel.tabs.length <= 6) {
320-
this.shouldPaginate = false;
320+
321+
const manageBtn = $('#tab_manage_btn'),
322+
canvas = $('.md2-tabs-canvas');
323+
if (this.shouldPaginate) {
324+
manageBtn.addClass('fixed-manage-btn');
325+
canvas.css('overflow', 'hidden');
326+
} else {
327+
manageBtn.removeClass('fixed-manage-btn');
328+
canvas.css('overflow', '');
329+
}
330+
}
331+
332+
toggle(target, $event, btn1) {
333+
target.toggle(event, btn1);
334+
const menuContainer = $('.mdl-menu__container');
335+
if (this.shouldPaginate) {
336+
setTimeout(() => menuContainer.css({ 'position': 'fixed', 'left': '', 'right': '0' }));
337+
} else {
338+
setTimeout(() => menuContainer.css({ 'position': '', 'right': '' }));
321339
}
322340
}
323341

324342
/**
325343
* 调整tabs的位移
326344
* @param index
327345
*/
328-
adjustOffset(index: number) {
346+
adjustOffset(index: number = this.tabsModel.activeTab) {
329347
let elements = this.element;
330348
let tabsWidth = 0;
331349
if (!elements.tabs[index]) { return; }

src/app/share/app-jsplumb/app-jsplumb.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<h2>点击线上的标签文字可修改</h2>
1+
<h2>简单流程图</h2>
22
<div class="jtk-demo-canvas canvas-wide flowchart-demo jtk-surface jtk-surface-nopan" id="canvas">
33
<div class="window jtk-node" id="flowchartWindow1"><strong>开始</strong><br/><br/></div>
44
<div class="window jtk-node" id="flowchartWindow2"><strong>提交申请</strong><br/><br/></div>

0 commit comments

Comments
 (0)