Skip to content

Commit 131fcaf

Browse files
author
黄大超
committed
.
1 parent 0e94ade commit 131fcaf

File tree

8 files changed

+74
-21
lines changed

8 files changed

+74
-21
lines changed

src/app/common/http-params.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { URLSearchParams } from '@angular/http';
2+
export class HttpParams {
3+
static toUrlParams(data: any): URLSearchParams {
4+
let params = new URLSearchParams();
5+
for (let key in data) {
6+
if (data.hasOwnProperty(key) && data[key]) {
7+
params.set(key, data[key]);
8+
}
9+
}
10+
return params;
11+
}
12+
13+
static toFormParams(data: any) {
14+
15+
}
16+
}

src/app/common/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from './json-page.model';
2+
export * from './http-params';

src/app/modules/department/department.service.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Injectable } from '@angular/core';
2-
import { Http, URLSearchParams } from '@angular/http';
3-
import * as formUrlencoded from 'form-urlencoded';
2+
import { Http } from '@angular/http';
3+
import { HttpParams } from '../../common';
44

55
import 'rxjs/add/operator/toPromise';
66
import { Department } from './department.model';
@@ -15,14 +15,7 @@ export class DepartmentService {
1515
}
1616

1717
getDepartments(query: any): Promise<JsonPage<Department>> {
18-
let params = new URLSearchParams();
19-
for (let key in query) {
20-
if (query.hasOwnProperty(key)) {
21-
params.set(key, query[key]);
22-
}
23-
}
24-
25-
return this.http.get(this.departmentUrl, {search: params}).toPromise()
18+
return this.http.get(this.departmentUrl, {search: HttpParams.toUrlParams(query)}).toPromise()
2619
.then(response => {
2720
let json = response.json();
2821
if (!json.result) {

src/app/modules/department/edit/department-edit.component.html

Whitespace-only changes.

src/app/modules/department/edit/department-edit.component.ts

Whitespace-only changes.

src/app/modules/department/list/department-list.component.html

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
<div class="p-10 clearfix">
2-
<h4 class="m-0 pull-left"><i class="fa fa-sitemap text-primary m-r-10"></i>部门管理</h4>
3-
<div class="pull-right">
4-
<span class="btn btn-primary"><i class="fa fa-plus"></i> 添加部门</span>
5-
</div>
6-
</div>
71

8-
<div class="card card-block no-border">
2+
3+
<div class="search-block">
4+
<div class="search-header">
5+
<h4 class="m-0 pull-left" style="line-height: 33px;"><i class="fa fa-sitemap text-primary m-r-10"></i>部门管理</h4>
6+
<div class="pull-right">
7+
<span class="btn btn-primary"><i class="fa fa-plus"></i> 添加部门</span>
8+
</div>
9+
</div>
910
<div class="row">
1011
<div class="col-sm-3">
1112
<div class="input-group">
@@ -36,7 +37,7 @@ <h4 class="m-0 pull-left"><i class="fa fa-sitemap text-primary m-r-10"></i>部
3637
</div>
3738
</div>
3839
</div>
39-
<div class="row m-t-10">
40+
<div class="row m-t-10 m-b-10">
4041
<div class="col-sm-12 text-xs-right">
4142
<button class="btn btn-warning" (click)="resetQueryParams()">重置</button>
4243
<button class="btn btn-primary m-l-5" (click)="getDepartments()">查询</button>
@@ -50,6 +51,7 @@ <h4 class="m-0 pull-left"><i class="fa fa-sitemap text-primary m-r-10"></i>部
5051
<thead>
5152
<tr>
5253
<th>#</th>
54+
<th>操作</th>
5355
<th>名称</th>
5456
<th>机构码</th>
5557
<th>顶级机构</th>
@@ -62,6 +64,17 @@ <h4 class="m-0 pull-left"><i class="fa fa-sitemap text-primary m-r-10"></i>部
6264
<tbody>
6365
<tr *ngFor="let department of departments; let i = index" data-id="{{department.id}}">
6466
<th>{{i + 1}}</th>
67+
<td>
68+
<div ngbDropdown class="d-inline-block">
69+
<button class="btn btn-sm btn-outline-primary" ngbDropdownToggle>
70+
<i class="fa fa-pencil">&nbsp;</i>
71+
</button>
72+
<div class="dropdown-menu">
73+
<button class="dropdown-item">编辑</button>
74+
<button class="dropdown-item">删除</button>
75+
</div>
76+
</div>
77+
</td>
6578
<td>{{department.name}}</td>
6679
<td>{{department.orgCode}}</td>
6780
<td>{{department.rootCode}}</td>
@@ -73,7 +86,7 @@ <h4 class="m-0 pull-left"><i class="fa fa-sitemap text-primary m-r-10"></i>部
7386
</tbody>
7487
</table>
7588
</div>
76-
<div class="container-fluid">
89+
<div class="row">
7790
<div class="col-sm-3">
7891
<div class="input-group">
7992
<label class="input-group-addon">每页大小</label>

src/assets/style/_bootstrap.scss

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// bootstrap 常量定义
22
@import 'variables';
3+
$enable-shadows: true;
4+
$enable-gradients: true;
5+
$enable-transitions: true;
36
$font-size-root: 14px;
47
$input-border-radius: 0;
58
$input-border-radius-lg: 0;
@@ -13,7 +16,6 @@ $custom-select-border-radius: 0;
1316
.dropdown.open {
1417
.dropdown-menu {
1518
margin-top: 0;
16-
border-color: $color-border-light;
1719
}
1820
}
1921

@@ -35,6 +37,14 @@ select {
3537
padding: 0.4rem;
3638
}
3739

40+
.table-responsive {
41+
overflow: visible;
42+
}
43+
3844
.pagination {
3945
margin: 0;
46+
}
47+
48+
.dropdown-menu {
49+
border-radius: 0;
4050
}

src/assets/style/app.scss

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ html, body {
3333
background-color: $bg-lighter;
3434
}
3535

36+
.bg-white {
37+
background-color: #FFF;
38+
}
39+
3640
.bg-black {
3741
color: #7793a7;
3842
background-color: $bg-black;
@@ -49,12 +53,28 @@ html, body {
4953
padding: 3px 6px;
5054
}
5155

56+
.search-block {
57+
padding: 0 15px;
58+
background-color: #FFF;
59+
border-bottom: 1px solid $color-border-light;
60+
margin: 0 0 10px 0;
61+
62+
.search-header {
63+
height: 50px;
64+
border-bottom: 1px solid $color-border-light;
65+
background-color: $bg-lighter;
66+
margin: 0 -15px 20px -15px;
67+
padding: 10px 15px;
68+
@include clearfix;
69+
}
70+
}
71+
5272
.app-page-title {
5373
border-bottom: 1px solid $color-border-light;
5474
padding: 15px;
5575
margin-bottom: 15px;
5676
background-color: $bg-lighter;
57-
@include clearfix();
77+
@include clearfix;
5878
.btn {
5979
font-size: 16px;
6080
}

0 commit comments

Comments
 (0)