Skip to content

Commit 5210d23

Browse files
committed
集成常用工具
1 parent 7390274 commit 5210d23

File tree

270 files changed

+1576
-43779
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

270 files changed

+1576
-43779
lines changed

.angular-cli.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
"../node_modules/jquery/dist/jquery.min.js",
2525
"./assets/global/scripts/common.js",
2626
"./assets/global/plugins/sweet-alert/sweetalert.min.js",
27-
"./assets/global/scripts/sweetalert.js"
27+
"./assets/global/scripts/sweetalert.js",
28+
"../node_modules/echarts/dist/echarts.min.js",
29+
"..node_modules/fullcalendar/dist/fullcalendar.js"
2830
],
2931
"environmentSource": "environments/environment.ts",
3032
"environments": {

README.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,41 @@
11
# Angular4Admin
22

3-
基于Angular4和Material Design风格的企业后台管理系统,使用Angular-cli构建。
3+
基于Angular4的后台管理系统,使用Angular-cli构建。
4+
5+
# 使用
6+
7+
```
8+
git clone https://github.com/weihomechen/angular4-admin.git;
9+
```
10+
切换到项目目录,
11+
12+
```
13+
// 如果不能科学上网,请使用cnpm代替npm
14+
// npm i -g cnpm
15+
// 如果未安装angular-cli
16+
// npm i -g @angular/cli
17+
npm install
18+
```
19+
启动开发模式:
20+
```
21+
ng serve
22+
```
23+
如果顺利,项目会运行在本地 http://localhost:4200
24+
25+
# 主要功能点
26+
27+
### angular4基本功能的使用
28+
### 带管理功能可切换的tab
29+
### 一个增改查删的Demo(见人员管理)
30+
### 集成一些插件(文本编辑器、图表、地图、弹出框、流程图、树目录等)
31+
### 与后台交互使用Rxjs
32+
### 集成Material Design风格和Bootstrap风格的UI
33+
34+
如果喜欢,还请挪一下鼠标给我一个star~~
35+
36+
# 效果图
37+
38+
PS: 个人项目,一些琐碎的细节没有实现;与后台交互使用的是mock-data,增删改也是模拟成功返回;
39+
440

541

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,24 @@
1818
"@angular/core": "^4.0.0",
1919
"@angular/forms": "^4.0.0",
2020
"@angular/http": "^4.0.0",
21+
"@angular/material": "^2.0.0-beta.6",
2122
"@angular/platform-browser": "^4.0.0",
2223
"@angular/platform-browser-dynamic": "^4.0.0",
2324
"@angular/router": "^4.0.0",
25+
"@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.26",
2426
"@types/hammerjs": "^2.0.34",
2527
"@types/jquery": "^2.0.45",
2628
"core-js": "^2.4.1",
29+
"echarts": "^3.6.1",
30+
"fullcalendar": "^3.4.0",
2731
"hammerjs": "^2.0.8",
2832
"jquery": "^3.2.1",
2933
"material-design-icons": "^3.0.1",
3034
"material-design-lite": "^1.3.0",
35+
"ng2-ckeditor": "^1.1.7",
36+
"ng2-toastr": "^4.0.1",
3137
"ng2-translate": "^5.0.0",
38+
"ngx-echarts": "^1.2.0",
3239
"rxjs": "^5.1.0",
3340
"zone.js": "^0.8.4"
3441
},

src/app/app.component.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ declare var $: any;
1010
})
1111
export class AppComponent implements OnInit {
1212

13-
constructor(private translate: TranslateService){}
13+
constructor(private translate: TranslateService) { }
1414
ngOnInit() {
1515
const windowWidth = window.innerWidth,
1616
windowHeight = window.innerHeight;
1717
$('.app-body, .body-footer').css('width', windowWidth - 246 + 'px');
18-
$('.app-body').css('height', windowHeight - 121 + 'px');
18+
$('.app-body').css('height', windowHeight - 111 + 'px');
1919

2020

2121
this.translate.addLangs(["zh", "en"]);
22-
this.translate.setDefaultLang('zh');
22+
this.translate.setDefaultLang('zh');
2323

24-
const browserLang = this.translate.getBrowserLang();
25-
console.log("检测到的浏览器语言>" + browserLang);
26-
this.translate.use(browserLang.match(/zh|en/) ? browserLang : 'zh');
24+
const browserLang = this.translate.getBrowserLang();
25+
console.log("检测到的浏览器语言>" + browserLang);
26+
this.translate.use(browserLang.match(/zh|en/) ? browserLang : 'zh');
2727
}
2828
}

src/app/app.module.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ import { AppComponent } from './app.component';
1111
import { routing, CustomReuseStrategy } from './app.routing';
1212

1313
// 第三方模块
14-
// import { MdlModule } from '@angular-mdl/core';
14+
import { MdlModule } from '@angular-mdl/core';
1515
import { TranslateModule, TranslateLoader, TranslateStaticLoader } from 'ng2-translate';
1616
import 'hammerjs';
1717

1818
// 项目内模块
1919
import { LayoutModule } from './layout/layout.module';
20+
import { ShareModule } from './share/share.module';
2021
import { HomeModule } from './home/home.module';
22+
import { BaseDataModule } from './base-data/base-data.module'
2123
import { UserModule } from './user/user.module';
22-
import { ShareModule } from './share/share.module';
2324
import { TabControlService } from './layout/header/tab/tabControl.service';
2425
import { UserService } from './user/user.service';
2526

@@ -38,16 +39,18 @@ export function createTranslateLoader(http: Http) {
3839
FormsModule,
3940
HttpModule,
4041
// 第三方模块
42+
MdlModule,
4143
TranslateModule.forRoot({
4244
provide: TranslateLoader,
4345
useFactory: (createTranslateLoader),
4446
deps: [Http]
4547
}),
4648
// 项目内模块
4749
LayoutModule,
50+
ShareModule,
4851
HomeModule,
52+
BaseDataModule,
4953
UserModule,
50-
ShareModule,
5154
// App模块
5255
routing
5356
],

src/app/app.routing.ts

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,39 @@ import { Routes, RouterModule, RouteReuseStrategy, DetachedRouteHandle, Activate
33
import { AppComponent } from './app.component';
44

55
import { HomeComponent } from './home/home/home.component';
6+
import { PersonAddComponent } from './base-data/person-add/person-add.component';
7+
import { PersonEditComponent } from './base-data/person-edit/person-edit.component';
8+
import { PersonListComponent } from './base-data/person-list/person-list.component';
69
import { UserLoginComponent } from './user/user-login/user-login.component';
710
import { UserRegisterComponent } from './user/user-register/user-register.component';
811
import { UserForgetpwdComponent } from './user/user-forgetpwd/user-forgetpwd.component';
912
import { UserInfoComponent } from './user/user-info/user-info.component';
1013
import { UserChangePwdComponent } from './user/user-change-pwd/user-change-pwd.component';
1114
import { UserService } from './user/user.service';
1215

16+
import { AppCkeditorComponent } from './share/app-ckeditor/app-ckeditor.component';
17+
import { AppChartsComponent } from './share/app-charts/app-charts.component';
18+
import { AmapDemoComponent } from './share/app-amap/amap-demo.component';
19+
import { CalendarDemoComponent } from './share/app-calendar/calendar-demo.component';
20+
1321

1422
const appRoutes: Routes = [
1523
{
1624
path: 'home',
1725
component: HomeComponent,
18-
canActivate: [UserService]
26+
// canActivate: [UserService]
27+
},
28+
{
29+
path: 'person-list',
30+
component: PersonListComponent
31+
},
32+
{
33+
path: 'person-add',
34+
component: PersonAddComponent
1935
},
2036
{
21-
path: 'base-data',
22-
loadChildren: './base-data/base-data.module#BaseDataModule'
37+
path: 'person-edit/:id',
38+
component: PersonEditComponent
2339
},
2440
{
2541
path: 'user-register',
@@ -44,6 +60,22 @@ const appRoutes: Routes = [
4460
path: 'user-change-pwd',
4561
component: UserChangePwdComponent
4662
},
63+
{
64+
path: 'charts',
65+
component: AppChartsComponent
66+
},
67+
{
68+
path: 'ckeditor',
69+
component: AppCkeditorComponent
70+
},
71+
{
72+
path: 'amap',
73+
component: AmapDemoComponent
74+
},
75+
{
76+
path: 'calendar',
77+
component: CalendarDemoComponent
78+
},
4779
{
4880
path: '',
4981
redirectTo: '/home',
@@ -97,6 +129,9 @@ export class CustomReuseStrategy implements RouteReuseStrategy {
97129
}
98130
// 决定是否重用路由
99131
shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean {
132+
if (future.params.reuse === 'false') {
133+
return false;
134+
}
100135
// 在此处可以取得跳转前和跳转后的路由路径
101136
// console.log('CustomReuseStrategy:shouldReuseRoute', future, curr);
102137
return future.routeConfig === curr.routeConfig;

src/app/base-data/base-data.module.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { CommonModule } from '@angular/common';
33
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
44
import { RouterModule } from '@angular/router';
55

6-
import { ShareModule } from '../share/share.module';
6+
import { MaterialModule, MdNativeDateModule } from '@angular/material';
7+
import { MdlModule } from '@angular-mdl/core';
78
import { PersonListComponent } from './person-list/person-list.component';
89
import { PersonAddComponent } from './person-add/person-add.component';
910
import { PersonEditComponent } from './person-edit/person-edit.component';
@@ -14,9 +15,11 @@ import { PersonManageService } from './person-manage.service';
1415
imports: [
1516
CommonModule,
1617
FormsModule,
17-
ShareModule,
18+
MaterialModule,
19+
MdNativeDateModule,
1820
ReactiveFormsModule,
19-
RouterModule.forChild(baseDataRoutes)
21+
MdlModule
22+
// RouterModule.forChild(baseDataRoutes)
2023
],
2124
declarations: [PersonListComponent, PersonAddComponent, PersonEditComponent],
2225
providers: [

src/app/base-data/person-add/person-add.component.html

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,51 @@
1818
<mdl-textfield label="职业*" type="text" formControlName="role" floating-label error-msg="请输入职业"></mdl-textfield>
1919
</div>
2020
<div class="form-inline-item">
21-
<mdl-textfield label="职务*" type="text" formControlName="position" floating-label error-msg="请输入职务"></mdl-textfield>
21+
<md-input-container>
22+
<input mdInput placeholder="请输入职务" [mdAutocomplete]="positionAuto" [formControl]="positionCtrl">
23+
</md-input-container>
24+
25+
<md-autocomplete #positionAuto="mdAutocomplete">
26+
<md-option *ngFor="let position of filteredPositions | async" [value]="position">
27+
{{ position }}
28+
</md-option>
29+
</md-autocomplete>
2230
</div>
2331

2432
<div class="form-inline-item">
25-
<mdl-textfield label="凑数目的" type="text" floating-label></mdl-textfield>
33+
<md-select placeholder="请选择性别" formControlName="sex" name="sex">
34+
<md-option *ngFor="let gender of genders" [value]="gender.value">
35+
{{gender.viewValue}}
36+
</md-option>
37+
</md-select>
2638
</div>
39+
2740
<div class="form-inline-item">
28-
<mdl-textfield label="凑数目的" type="text" floating-label></mdl-textfield>
41+
<md-input-container>
42+
<input mdInput placeholder="自动匹配" [mdAutocomplete]="auto" [formControl]="stateCtrl">
43+
</md-input-container>
44+
45+
<md-autocomplete #auto="mdAutocomplete">
46+
<md-option *ngFor="let state of filteredStates | async" [value]="state">
47+
{{ state }}
48+
</md-option>
49+
</md-autocomplete>
2950
</div>
3051

3152
<div class="form-inline-item">
32-
33-
性别:<br/>
34-
<mdl-radio value="" formControlName="sex" mdl-ripple></mdl-radio>
35-
<mdl-radio value="" formControlName="sex" mdl-ripple></mdl-radio>
53+
<md-input-container>
54+
<input mdInput [mdDatepicker]="picker" placeholder="请选择注册日期" [formControl]="registerDateCtrl">
55+
<button mdSuffix [mdDatepickerToggle]="picker"></button>
56+
</md-input-container>
57+
<md-datepicker #picker></md-datepicker>
3658
</div>
3759

60+
<div class="form-inline-item">
61+
<mdl-textfield label="凑数目的" type="text" floating-label></mdl-textfield>
62+
</div>
63+
<div class="form-inline-item">
64+
<mdl-textfield label="凑数目的" type="text" floating-label></mdl-textfield>
65+
</div>
3866

3967
</form>
4068
<div class="diaplay-from-footer">

src/app/base-data/person-add/person-add.component.ts

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,46 @@ export class PersonAddComponent implements OnInit {
2121
public sex = new FormControl('');
2222
public account = new FormControl('', Validators.required);
2323
public role = new FormControl('', Validators.required);
24-
public position = new FormControl('');
24+
public registerDateCtrl = new FormControl('', Validators.required);
2525
public genders = [
2626
{ value: '0', viewValue: '男' },
2727
{ value: '1', viewValue: '女' }
2828
];
2929

30+
public positionCtrl = new FormControl();
31+
filteredPositions: any;
32+
positions = [
33+
'队长',
34+
'副队长',
35+
'队员',
36+
'替补'
37+
];
38+
39+
public stateCtrl = new FormControl();
40+
filteredStates: any;
41+
states = [
42+
'a',
43+
'ab',
44+
'abc',
45+
'abcd',
46+
'e',
47+
'f',
48+
'g',
49+
'h',
50+
'i',
51+
'j',
52+
'k',
53+
'l',
54+
'm',
55+
'n',
56+
'o',
57+
'p',
58+
'q',
59+
'r',
60+
's',
61+
't'
62+
];
63+
3064
constructor(private fb: FormBuilder,
3165
private tabControlService: TabControlService,
3266
private personManageService: PersonManageService
@@ -37,18 +71,39 @@ export class PersonAddComponent implements OnInit {
3771
'sex': this.sex,
3872
'account': this.account,
3973
'role': this.role,
40-
'position': this.position
74+
'registerDate': this.registerDateCtrl,
75+
'position': this.positionCtrl,
76+
'state': this.stateCtrl
4177
});
78+
this.filteredStates = this.stateCtrl.valueChanges
79+
.startWith(null)
80+
.map(name => this.filterStates(name));
81+
this.filteredPositions = this.positionCtrl.valueChanges
82+
.startWith(null)
83+
.map(position => this.filterPositions(position));
4284
}
43-
4485
ngOnInit() {
4586
}
4687

88+
filterStates(val: string) {
89+
return val ? this.states.filter(s => new RegExp(`^${val}`, 'gi').test(s))
90+
: this.states;
91+
}
92+
93+
filterPositions(val: string) {
94+
return val ? this.positions.filter(p => new RegExp(`^${val}`, 'gi').test(p))
95+
: this.positions;
96+
}
97+
4798
// 确认
4899
public onSubmit() {
49100
console.log(this.form);
50-
this.personManageService.addPerson(this.form).subscribe(() => SweetAlert.alert('新增人员成功'));
101+
this.personManageService.addPerson(this.form).subscribe({
102+
next: () => SweetAlert.alert('新增人员成功'),
103+
error: () => SweetAlert.warning('发生错误')
104+
});
51105
}
106+
52107
// 取消
53108
cancel() {
54109
this.tabControlService.closeTab();

0 commit comments

Comments
 (0)