请求状态等通知提示抽取
This commit is contained in:
@@ -4,7 +4,6 @@ import { Component } from '@angular/core';
|
|||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
template: `
|
template: `
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
<toast-box toastAnimation="fancy" toastPosition="toast-top-right"></toast-box>
|
|
||||||
`,
|
`,
|
||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent {
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ import { AppComponent } from './app.component';
|
|||||||
import { HttpService } from './services/http.service'
|
import { HttpService } from './services/http.service'
|
||||||
import { HttpClientService } from './services/http-client.service'
|
import { HttpClientService } from './services/http-client.service'
|
||||||
|
|
||||||
/* 消息提示 */
|
|
||||||
import { ToastModule } from './components/toast/toast.module'
|
|
||||||
|
|
||||||
/* 预加载策略 */
|
/* 预加载策略 */
|
||||||
import { SelectivePreloadingStrategy } from './preloading-strategy';
|
import { SelectivePreloadingStrategy } from './preloading-strategy';
|
||||||
@@ -40,7 +38,6 @@ import { OperateSpinServiceService } from './services/operate-spin-service.servi
|
|||||||
BrowserAnimationsModule,
|
BrowserAnimationsModule,
|
||||||
CommonModule,
|
CommonModule,
|
||||||
HttpClientModule,
|
HttpClientModule,
|
||||||
ToastModule,
|
|
||||||
NgZorroAntdModule,
|
NgZorroAntdModule,
|
||||||
AppRoutingModule
|
AppRoutingModule
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -2,9 +2,7 @@ import { Component, OnInit } from '@angular/core';
|
|||||||
import { FormGroup, FormBuilder, Validators } from '@angular/forms'
|
import { FormGroup, FormBuilder, Validators } from '@angular/forms'
|
||||||
|
|
||||||
import { Router, ActivatedRoute } from '@angular/router'
|
import { Router, ActivatedRoute } from '@angular/router'
|
||||||
|
import { NzMessageService } from 'ng-zorro-antd';
|
||||||
import { ToastService } from '../components/toast/toast.service';
|
|
||||||
import { ToastConfig, ToastType } from '../components/toast/toast-model';
|
|
||||||
|
|
||||||
import { HttpClientService } from '../services/http-client.service';
|
import { HttpClientService } from '../services/http-client.service';
|
||||||
import { HttpHeaders } from '@angular/common/http';
|
import { HttpHeaders } from '@angular/common/http';
|
||||||
@@ -21,7 +19,7 @@ export class LoginComponent implements OnInit {
|
|||||||
private router: Router,
|
private router: Router,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private httpClient: HttpClientService,
|
private httpClient: HttpClientService,
|
||||||
private toastService: ToastService,
|
private message: NzMessageService
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
loginForm: FormGroup = this.formBuilder.group({
|
loginForm: FormGroup = this.formBuilder.group({
|
||||||
@@ -41,15 +39,13 @@ export class LoginComponent implements OnInit {
|
|||||||
console.log(xhr);
|
console.log(xhr);
|
||||||
if (xhr.is_success) {
|
if (xhr.is_success) {
|
||||||
sessionStorage.setItem('userInfo', JSON.stringify(xhr.body));
|
sessionStorage.setItem('userInfo', JSON.stringify(xhr.body));
|
||||||
const toastCfg = new ToastConfig(ToastType.SUCCESS, '', '登录成功!', 3000);
|
this.message.success('登录成功!');
|
||||||
this.toastService.toast(toastCfg);
|
|
||||||
this.router.navigate(['../app/main'], { relativeTo: this.route });
|
this.router.navigate(['../app/main'], { relativeTo: this.route });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
const toastCfg = new ToastConfig(ToastType.ERROR, '', '登录失败!', 3000);
|
this.message.error('登录失败!');
|
||||||
this.toastService.toast(toastCfg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -10,11 +10,6 @@
|
|||||||
padding: 5px 10px 5px 20px;
|
padding: 5px 10px 5px 20px;
|
||||||
p{
|
p{
|
||||||
margin: 0;
|
margin: 0;
|
||||||
label{
|
|
||||||
// width: 120px;
|
|
||||||
font-weight: bolder;
|
|
||||||
// text-align: right;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -201,7 +201,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td style="min-width:165px">{{airline_row['renderFlight']['FLID']}}</td>
|
<td style="min-width:165px">{{airline_row['renderFlight']['FLID']}}</td>
|
||||||
<td *ngFor="let airline_col of render_col_lists" [ngClass]="getPosition(airline_col.COL_CODE,airline_row)"
|
<td *ngFor="let airline_col of render_col_lists" [ngClass]="getPosition(airline_col.COL_CODE,airline_row)"
|
||||||
[ngStyle]="getColor(airline_col.COL_CODE,airline_row,airline_col.COL_WIDTH)" [title]="airline_row['renderFlight'][airline_col.COL_CODE]">{{airline_row['renderFlight'][airline_col.COL_CODE]}}</td>
|
[ngStyle]="getColor(airline_col.COL_CODE,airline_row,airline_col.COL_WIDTH)">{{airline_row['renderFlight'][airline_col.COL_CODE]}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@@ -228,4 +228,5 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<toast-box toastAnimation="fancy" toastPosition="toast-top-right"></toast-box>
|
||||||
</div>
|
</div>
|
||||||
@@ -413,8 +413,6 @@ export class MainComponent implements OnInit {
|
|||||||
})
|
})
|
||||||
this.combined_data = combined_data;
|
this.combined_data = combined_data;
|
||||||
this.doSequence(this.combined_data);
|
this.doSequence(this.combined_data);
|
||||||
// const toastCfg = new ToastConfig(ToastType.SUCCESS, '', '刷新成功!', 3000);
|
|
||||||
// this.toastService.toast(toastCfg);
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||||
import { NgZorroAntdModule } from 'ng-zorro-antd'
|
import { NgZorroAntdModule } from 'ng-zorro-antd';
|
||||||
|
/* 消息提示 */
|
||||||
|
import { ToastModule } from '../../components/toast/toast.module'
|
||||||
|
|
||||||
import { MainComponent } from './main.component';
|
import { MainComponent } from './main.component';
|
||||||
import { MainRoutingModule } from './main-routing.module';
|
import { MainRoutingModule } from './main-routing.module';
|
||||||
@@ -17,7 +19,8 @@ import { SpecialTabComponent } from './special-tab/special-tab.component';
|
|||||||
FormsModule,
|
FormsModule,
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
NgZorroAntdModule,
|
NgZorroAntdModule,
|
||||||
MainRoutingModule
|
MainRoutingModule,
|
||||||
|
ToastModule
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
MainComponent,
|
MainComponent,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ const pagesRoutes: Routes = [
|
|||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
component: PagesComponent,
|
component: PagesComponent,
|
||||||
|
data: { preload: false, reuse: false },
|
||||||
children:[
|
children:[
|
||||||
{
|
{
|
||||||
path:'',
|
path:'',
|
||||||
|
|||||||
@@ -3,9 +3,7 @@ import { Router, NavigationEnd, ActivatedRoute } from '@angular/router';
|
|||||||
import { BasicDataService } from '../services/basic-data-service';
|
import { BasicDataService } from '../services/basic-data-service';
|
||||||
import { OperateSpinServiceService } from '../services/operate-spin-service.service';
|
import { OperateSpinServiceService } from '../services/operate-spin-service.service';
|
||||||
import { HttpClientService } from '../services/http-client.service';
|
import { HttpClientService } from '../services/http-client.service';
|
||||||
|
import { NzMessageService } from 'ng-zorro-antd';
|
||||||
import { ToastService } from '../components/toast/toast.service';
|
|
||||||
import { ToastConfig, ToastType } from '../components/toast/toast-model';
|
|
||||||
|
|
||||||
import { filter } from 'rxjs/operators';
|
import { filter } from 'rxjs/operators';
|
||||||
// import 'rxjs/add/operator/map';
|
// import 'rxjs/add/operator/map';
|
||||||
@@ -196,7 +194,7 @@ export class PagesComponent implements OnInit {
|
|||||||
private basicDataService: BasicDataService,
|
private basicDataService: BasicDataService,
|
||||||
private operateSpinService: OperateSpinServiceService,
|
private operateSpinService: OperateSpinServiceService,
|
||||||
private httpClient: HttpClientService,
|
private httpClient: HttpClientService,
|
||||||
private toastService: ToastService,
|
private message: NzMessageService
|
||||||
) {
|
) {
|
||||||
this.operateSpinService.spinSubject.subscribe(
|
this.operateSpinService.spinSubject.subscribe(
|
||||||
val => this.isSpinning = val
|
val => this.isSpinning = val
|
||||||
@@ -259,8 +257,7 @@ export class PagesComponent implements OnInit {
|
|||||||
sessionStorageMsg.forEach(element => {
|
sessionStorageMsg.forEach(element => {
|
||||||
sessionStorage.removeItem(element)
|
sessionStorage.removeItem(element)
|
||||||
})
|
})
|
||||||
const toastCfg = new ToastConfig(ToastType.SUCCESS, '', '退出系统成功!', 3000);
|
this.message.success('退出系统成功!');
|
||||||
this.toastService.toast(toastCfg);
|
|
||||||
this.router.navigate(['/login']);
|
this.router.navigate(['/login']);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ import { Router } from '@angular/router';
|
|||||||
import { HttpClient, HttpRequest, HttpHeaders, HttpParams } from '@angular/common/http';
|
import { HttpClient, HttpRequest, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||||
import { HttpObserve } from '@angular/common/http/src/client';
|
import { HttpObserve } from '@angular/common/http/src/client';
|
||||||
import { OperateSpinServiceService } from './operate-spin-service.service';
|
import { OperateSpinServiceService } from './operate-spin-service.service';
|
||||||
import { ToastService } from '../components/toast/toast.service';
|
import { NzMessageService } from 'ng-zorro-antd';
|
||||||
import { ToastConfig, ToastType } from '../components/toast/toast-model';
|
|
||||||
|
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
@@ -18,7 +17,7 @@ export class HttpClientService {
|
|||||||
private router: Router,
|
private router: Router,
|
||||||
private httpClient: HttpClient,
|
private httpClient: HttpClient,
|
||||||
private operateSpinServiceService: OperateSpinServiceService,
|
private operateSpinServiceService: OperateSpinServiceService,
|
||||||
private toastService: ToastService,
|
private message: NzMessageService
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
header: HttpHeaders = new HttpHeaders().set('x-requested-with', 'XMLHttpRequest')
|
header: HttpHeaders = new HttpHeaders().set('x-requested-with', 'XMLHttpRequest')
|
||||||
@@ -136,8 +135,7 @@ export class HttpClientService {
|
|||||||
};
|
};
|
||||||
case 500: {
|
case 500: {
|
||||||
this.operateSpinServiceService.hideSpin();
|
this.operateSpinServiceService.hideSpin();
|
||||||
const toastCfg = new ToastConfig(ToastType.ERROR, '', '数据请求失败!', 5000);
|
this.message.error('数据请求失败!')
|
||||||
this.toastService.toast(toastCfg);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user