Browse Source

[合并]合并代码

develop
邵佳豪 5 years ago
parent
commit
0ad2eab0af
  1. 2
      package.json
  2. 14
      src/app/app-routing.module.ts
  3. 37
      src/app/app.component.ts
  4. 12
      src/app/http-interceptors/base-interceptor.ts
  5. 6
      src/app/http-interceptors/cache-token.service.ts
  6. 67
      src/app/pages/login/login.component.html
  7. 146
      src/app/pages/login/login.component.scss
  8. 52
      src/app/pages/login/login.component.ts
  9. 129
      src/app/pages/register/register.component.html
  10. 128
      src/app/pages/register/register.component.scss
  11. 39
      src/app/pages/register/register.component.ts
  12. 4
      src/app/tabbar/tabbar.component.html
  13. 23
      src/app/tabbar/tabbar.component.ts
  14. 2
      src/app/ui/changepassword/changepassword.component.ts
  15. 1
      src/app/ui/ui-routing.module.ts
  16. 51
      src/app/ui/userdata/edituserdata.component.html
  17. 34
      src/app/ui/userdata/userdata.component.html
  18. 32
      src/app/ui/userdata/userdata.component.scss
  19. 116
      src/app/ui/userdata/userdata.component.ts
  20. 2
      src/index.html

2
package.json

@ -3,7 +3,7 @@
"version": "0.0.0", "version": "0.0.0",
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
"start": "ng serve --proxy-config proxy.config.json --open ", "start": "ng serve --proxy-config proxy.config.json --open --port 4000 ",
"build": "ng build", "build": "ng build",
"test": "ng test", "test": "ng test",
"lint": "ng lint", "lint": "ng lint",

14
src/app/app-routing.module.ts

@ -9,6 +9,7 @@ import { LockscreenComponent } from './pages/lockscreen/lockscreen.component';
import {AuthGuard} from './auth.guard' import {AuthGuard} from './auth.guard'
const routes: Routes = [ const routes: Routes = [
{path:'',redirectTo:'login',pathMatch:'full'}, {path:'',redirectTo:'login',pathMatch:'full'},
{ {
@ -18,17 +19,16 @@ const routes: Routes = [
children:[ children:[
{path:'datacollection',loadChildren:() => import('./ui/ui.module').then(m => m.UiModule)} {path:'datacollection',loadChildren:() => import('./ui/ui.module').then(m => m.UiModule)}
]}, ]},
{path:'login', {path:'login',
component:LoginComponent}, component:LoginComponent}, //登录页
{path:'register', {path:'register',
component:RegisterComponent, component:RegisterComponent,}, //注册页
canActivate: [AuthGuard],},//守卫验证
{path:'lockscreen', // {path:'lockscreen',
component:LockscreenComponent, // component:LockscreenComponent,
canActivate: [AuthGuard],}//守卫验证 // canActivate: [AuthGuard],}//守卫验证
]; ];
@NgModule({ @NgModule({

37
src/app/app.component.ts

@ -3,44 +3,25 @@ import { HttpClient } from '@angular/common/http'
import { Data } from './interface' import { Data } from './interface'
import { Router,ActivatedRoute } from '@angular/router' import { Router,ActivatedRoute } from '@angular/router'
import {CacheTokenService} from './http-interceptors/cache-token.service'//引入服务 import {CacheTokenService} from './http-interceptors/cache-token.service'//引入服务
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
templateUrl: './app.component.html', templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'] styleUrls: ['./app.component.scss']
}) })
export class AppComponent { export class AppComponent {
title = '数字化预案编制管理平台'; title = '数据采集管理平台';
constructor(private http:HttpClient,private router:Router,public token:CacheTokenService) { } constructor(private http:HttpClient,private router:Router,public token:CacheTokenService) { }
ngOnInit(): void {
var isnologin = localStorage.getItem("isnologin") ngOnInit(): void {
//七天免登录
if(isnologin){
var token = localStorage.getItem("token");
var refreshToken = localStorage.getItem("refreshToken");
this.http.post(
'/api/Account/RefreshToken',
{
token: token,
refreshToken: refreshToken
}
).subscribe(
(data: Data) => {
sessionStorage.setItem("token",data.token);
sessionStorage.setItem("refreshToken",data.refreshToken);
this.token.getmenus()
this.token.startUp()
this.router.navigate(['/ui/person'])
console.log('已自动登录')
}
)
}else{
var token = sessionStorage.getItem("token"); var token = sessionStorage.getItem("token");
var refreshToken = sessionStorage.getItem("refreshToken"); var refreshToken = sessionStorage.getItem("refreshToken");
if(token && refreshToken) { if(token && refreshToken) {
this.http.post( this.http.post(
'/api/Account/RefreshToken', '/api/CompanyAccount/RefreshToken',
{ {
token: token, token: token,
refreshToken: refreshToken refreshToken: refreshToken
@ -49,15 +30,13 @@ export class AppComponent {
(data: Data) => { (data: Data) => {
sessionStorage.setItem("token",data.token); sessionStorage.setItem("token",data.token);
sessionStorage.setItem("refreshToken",data.refreshToken); sessionStorage.setItem("refreshToken",data.refreshToken);
this.token.getmenus()
this.token.startUp() this.token.startUp()
console.log('已重启定时器') console.log('已重启定时器')
} }
) )
}
} }
} }
} }

12
src/app/http-interceptors/base-interceptor.ts

@ -8,6 +8,7 @@ import { catchError, retry } from 'rxjs/operators';
import { Router,ActivatedRoute } from '@angular/router' import { Router,ActivatedRoute } from '@angular/router'
import {CacheTokenService} from './cache-token.service' import {CacheTokenService} from './cache-token.service'
import { MatSnackBar } from '@angular/material/snack-bar';
//baseurl //baseurl
// const baseurl = 'http://39.106.78.171:8008'; // const baseurl = 'http://39.106.78.171:8008';
@ -15,7 +16,8 @@ import {CacheTokenService} from './cache-token.service'
@Injectable() @Injectable()
export class BaseInterceptor implements HttpInterceptor { export class BaseInterceptor implements HttpInterceptor {
constructor(private http:HttpClient,private router:Router,private route:ActivatedRoute,public token:CacheTokenService) {} constructor(private http:HttpClient,private router:Router,private route:ActivatedRoute,public token:CacheTokenService,
public snackBar: MatSnackBar) {}
intercept(req, next: HttpHandler) { intercept(req, next: HttpHandler) {
@ -47,11 +49,15 @@ export class BaseInterceptor implements HttpInterceptor {
this.token.delete() this.token.delete()
sessionStorage.clear() sessionStorage.clear()
window.localStorage.clear() window.localStorage.clear()
alert('用户认证信息过期,请重新登录') this.snackBar.open('用户认证信息过期,请重新登录', '确定', {
duration: 3000
});
this.router.navigate(['/login']) this.router.navigate(['/login'])
} }
if (error.status === 403) { if (error.status === 403) {
alert('对不起,您无此权限') this.snackBar.open('对不起,您无此权限!', '确定', {
duration: 3000
});
} }
if (error.error instanceof ErrorEvent) { if (error.error instanceof ErrorEvent) {

6
src/app/http-interceptors/cache-token.service.ts

@ -15,13 +15,12 @@ export class CacheTokenService {
startUp = ():void=>{ startUp = ():void=>{
// this.getmenus(); // this.getmenus();
this.timer = window.setInterval( this.timer = window.setInterval(
()=>{ ()=>{
window.clearInterval(this.settime) window.clearInterval(this.settime)
var token = sessionStorage.getItem("token"); var token = sessionStorage.getItem("token");
var refreshToken = sessionStorage.getItem("refreshToken"); var refreshToken = sessionStorage.getItem("refreshToken");
this.http.post( this.http.post(
'/api/Account/RefreshToken', '/api/CompanyAccount/RefreshToken',
{ {
token: token, token: token,
refreshToken: refreshToken refreshToken: refreshToken
@ -40,8 +39,7 @@ export class CacheTokenService {
//删除定时器 //删除定时器
delete = ():void=> { delete = ():void=> {

67
src/app/pages/login/login.component.html

@ -1,51 +1,42 @@
<div class="login"> <div class="login">
<div class="loginbox"> <div class="loginBox">
<div class="intro"> <div>
<p>用户信息采集平台</p> <div class="card">
<!-- <span>
数字化预案编制管理应用平台集重点单位的数字化预案资源的管理、分析及调用为一体,可实现辖区内预案使用的高效化、集约化、统一化、标准化管理。同时,可将消防现有的三维预案、图片式预案、卡片式预案、二维预案、视频预案等接入至系统中进行更加全面、真实、直观、生动的展示各项单位预案数据,方便进行预案资源调用,更好的服务实战指挥。
</span> -->
</div>
<div class="card">
<div class="loginImg">
<img src="../../../assets/images/login.gif">
<p class="cardheader">登录</p>
</div>
<mat-card>
<span class="cardheader">数据采集管理平台</span>
<form (ngSubmit)="onSubmit(form.value)" #form="ngForm" class="example-container"> <form (ngSubmit)="onSubmit(form.value)" #form="ngForm" class="example-container">
<mat-icon class="icon">account_box</mat-icon>
<mat-icon class="icon2">lock</mat-icon>
<mat-form-field>
<input matInput id="name" name="name"
required
ngModel #name="ngModel" placeholder="请输入账号">
</mat-form-field>
<mat-form-field> <div class="input">
<input matInput id="password" name="password" type='password' <label class="position"><mat-icon>account_box</mat-icon></label>
required minlength="8" <mat-form-field>
ngModel #password="ngModel" placeholder="请输入密码"> <input matInput id="name" name="name"
</mat-form-field> required type="text"
ngModel #name="ngModel" placeholder="请输入账号">
</mat-form-field>
</div>
<div class="input">
<label class="position"><mat-icon>lock</mat-icon></label>
<mat-form-field>
<input matInput id="password" name="password" type='password'
required
ngModel #password="ngModel" placeholder="请输入密码">
</mat-form-field>
</div>
<div *ngIf="errmsg" class="alert-danger"> <div *ngIf="errmsg" class="alert-danger input">
{{errmsg}} {{errmsg}}
</div> </div>
<a href="javascript:void(0);" (click)='open()'> <div class="register">
忘记密码? <a href="javascript:void(0);" (click)='open()'>忘记密码?</a>
</a> <a href="javascript:void(0);" (click)='toRegister()'>快速注册</a>
<button type="submit" [disabled]="!form.form.valid" class="loginbtn"mat-button>登录</button> </div>
</form>
<div class="website"> <button type="submit" [disabled]="!form.form.valid" class="loginbtn" mat-button>登录</button>
<p>北京安信科创有限公司提供技术支持和维护</p> </form>
</div>
</mat-card> </div>
</div> </div>
</div> </div>

146
src/app/pages/login/login.component.scss

@ -1,115 +1,73 @@
.login { .login {
width: 100%; width: 100%;
height: 100%; height: 100%;
background: url('../../../assets/images/bg_login.jpg'); background: url('../../../assets/images/bg_login.jpg');
.loginbox {
width: 100%;
height: 100%;
background-color: #000;
background: rgba(0,0,0,0.5);/*盒子背景透明*/
position: relative;
}
.intro {
width: 35%;
position: fixed;
top:35%;
left: 15%;
p {
font-size: 36px;
color:white;
margin-bottom: 35px;
}
span {
font-size: 16px;
color:white;
opacity: 0.5;
}
}
.card{
width: 460px;
height: 100%;
background-color: #fff;
position: absolute;
right: 0;
}
} }
.loginBox {
.example-container {
display: flex;
flex-direction: column;
width: 100%; width: 100%;
} height: 100%;
.loginbtn { background-color: #000;
margin-top: 25px; background: rgba(0,0,0,0.5);/*盒子背景透明*/
height: 35px; display: flex;
background-color:#039be5; /*!*flex-direction: column;*!可写可不写*/
border-radius: 15px; justify-content: center;
color: #fff;; align-items: center;
}
.mat-card {
box-shadow: 0 0 0;
margin-top: 140px;
}
.applyfor {
font-size: 16px;
a {
color: #039be5;
}
} }
.website { .card {
font-size: 14px; width: 500px;
height: 355px;
border-radius: 10px;
padding-top: 25px;
background-color: hsla(0,0%,100%,.8);
text-align: center; text-align: center;
margin-top: 60px; box-shadow:0px 0px 10px 5px #333;
}
.alert-danger {
font-size: 14px;
color: red;
} }
.cardheader{ .cardheader{
margin-bottom: 10px;
font-size: 26px; font-size: 26px;
font-weight: 500; font-weight: 500;
margin-top: 20px;
}
.mat-card {
margin-top: 10px;
padding-left: 20px;
}
.mat-form-field {
padding-left: 20px;;
}
.loginImg {
margin-top: 90px;
text-align: center;
} }
.mat-input-element {
.input {
margin: 15px auto;
position: relative; position: relative;
} }
.mat-card .example-container .icon { .mat-form-field {
width: 24px; width: 300px;
color: #666;
font-size: 24px;
position: absolute;
top:36px;
left: 15px;
} }
.mat-card .example-container .icon2 { .position {
width: 24px; margin-top: 5px;
color: #666;
font-size: 24px;
position: absolute; position: absolute;
top:100px; top: 15px;
left: 15px; left: 75px;
} }
a {
.alert-danger {
text-align-last: left;
margin-left: 100px;
font-size: 14px; font-size: 14px;
color: #0066FF; color: red;
margin-left: 250px; }
.register {
text-align: left;
a {
font-size: 14px;
color: #0066FF;
}
:first-child {
margin-left: 100px;
}
:last-child {
margin-left: 180px;
}
}
.loginbtn {
margin-top: 25px;
height: 30px;
line-height: 30px;
width: 280px;
background-color:#039be5;
border-radius: 15px;
color: #fff;
} }

52
src/app/pages/login/login.component.ts

@ -2,9 +2,11 @@ import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http' import { HttpClient } from '@angular/common/http'
import { Data } from '../../interface' import { Data } from '../../interface'
import { Router,ActivatedRoute } from '@angular/router' import { Router,ActivatedRoute } from '@angular/router'
import {CacheTokenService} from '../../http-interceptors/cache-token.service'//引入服务 import {CacheTokenService} from '../../http-interceptors/cache-token.service'//引入服务
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
@Component({ @Component({
selector: 'app-login', selector: 'app-login',
templateUrl: './login.component.html', templateUrl: './login.component.html',
@ -13,54 +15,44 @@ import { MatSnackBar } from '@angular/material/snack-bar';
}) })
export class LoginComponent implements OnInit { export class LoginComponent implements OnInit {
constructor(private http:HttpClient,private router:Router,private route:ActivatedRoute,public token:CacheTokenService,public snackBar: MatSnackBar) { } constructor(private http:HttpClient,private router:Router,private route:ActivatedRoute,public token:CacheTokenService,
public snackBar: MatSnackBar) { }
ngOnInit() { ngOnInit() {}
} errmsg :string = ''; //错误信息
errmsg :string = ''
//提交登录表单
onSubmit(e){ onSubmit(e){
this.http.post( this.http.post('/api/CompanyAccount/SignIn',{
'/api/Account/SignIn',
{
name: e.name, name: e.name,
password: e.password password: e.password}).subscribe(
}
).subscribe(
(data: Data) => (data: Data) =>
{ {
sessionStorage.setItem("token",data.token); sessionStorage.setItem("token",data.token);
sessionStorage.setItem("refreshToken",data.refreshToken); sessionStorage.setItem("refreshToken",data.refreshToken);
this.router.navigate(['/datacollection/userdata']) this.router.navigate(['/datacollection/basicinfo'])
if(e.notlogin){
console.log("true")
localStorage.setItem("isnologin","true")
localStorage.setItem("token",data.token)
localStorage.setItem("refreshToken",data.refreshToken)
}else{
console.log("false")
}
//调用服务中的function刷新token //调用服务中的function刷新token
this.token.startUp() this.token.startUp()
//调用服务中的function获取菜单
this.token.getmenus()
}, },
(err) => (err) =>
{this.errmsg = err} {this.errmsg = err}
) )
} }
//打开弹窗 //跳转注册页面
toRegister () {
this.router.navigate(['/register'])
}
//打开忘记密码弹窗
open () { open () {
this.snackBar.open('请联系管理员', '确定', { this.snackBar.open('请联系管理员: 1391111111', '确定', {
duration: 3000 duration: 3000
}); });
} }
} }

129
src/app/pages/register/register.component.html

@ -1,80 +1,87 @@
<div class="login"> <div class="login">
<div class="loginbox"> <div class="loginBox">
<div class="intro"> <div>
<p>北京安信科创有限公司</p> <div class="card">
<span>北京安信科创软件有限公司作为中国应急服务领跑者,于2006年进入消防救援领域,是一家专注于应急领域仿真培训演练与应急数据预判领域的软件服务供应商。安信主要利用大数据与虚拟现实技术实现对消防、公安、机场相关安防人员与企业安全监管人员的仿真培训与考核,致力于为我国应急产业的发展构建更美好的未来。目前,安信的业务遍布全国20多个省份和地区,服务全国将近四分之一以上的人口
</span>
</div>
<div class="card">
<mat-card>
<p class="cardheader">注册</p>
<p>Please register first</p>
<span class="cardheader">数据采集管理平台</span>
<form (ngSubmit)="onSubmit(form.value)" #form="ngForm" class="example-container"> <form (ngSubmit)="onSubmit(form.value)" #form="ngForm" class="example-container">
<mat-form-field> <div class="input">
<input matInput id="name" name="name" <label class="position"><mat-icon>group</mat-icon></label>
required <mat-form-field>
ngModel #name="ngModel" placeholder="请输入账号"> <input matInput id="companyName" name="companyName"
</mat-form-field> required ngModel placeholder="请输入单位名称">
</mat-form-field>
</div>
<!-- <div *ngIf="name.invalid && (name.dirty || name.touched)" <div class="input">
class="alert-danger"> <label class="position"><mat-icon>dns</mat-icon></label>
<div *ngIf="name.errors.required"> <mat-form-field>
账号不能为空 <input matInput id="usci" name="usci" #usci="ngModel"
pattern="^[0-9A-HJ-NP-RTUW-Y]{2}\d{6}[0-9A-HJ-NP-RTUW-Y]{10}$"
required ngModel placeholder="请输入统一社会信用代码">
</mat-form-field>
</div>
<div *ngIf="usci.invalid && (usci.dirty || usci.touched)" class="alert-danger">
<div *ngIf="usci.errors.pattern">
统一社会信用代码格式不正确
</div> </div>
</div> --> </div>
<mat-form-field> <div class="input">
<input matInput id="email" name="email" <label class="position"><mat-icon>phone</mat-icon></label>
required pattern="^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$" <mat-form-field>
ngModel #email="ngModel" placeholder="请输入邮箱"> <input matInput id="phone" name="phone" #tel="ngModel"
</mat-form-field> required pattern="^^(?:\+?86)?1(?:3\d{3}|5[^4\D]\d{2}|8\d{3}|7(?:[35-8]\d{2}|4(?:0\d|1[0-2]|9\d))|9[0135-9]\d{2}|66\d{2})\d{6}$"
<!-- ngModel placeholder="请输入联系电话">
<div *ngIf="email.invalid && (email.dirty || email.touched)" </mat-form-field>
class="alert-danger"> </div>
<div *ngIf="email.errors.required"> <div *ngIf="tel.invalid && (tel.dirty || tel.touched)" class="alert-danger">
邮箱不能为空 <div *ngIf="tel.errors.pattern">
</div> 电话号码格式不正确
<div *ngIf="email.errors.pattern">
邮箱格式不正确
</div> </div>
</div> --> </div>
<mat-form-field> <div class="input">
<input matInput id="password" name="password" type='password' <label class="position"><mat-icon>account_box</mat-icon></label>
required minlength="8" <mat-form-field>
ngModel #password="ngModel" placeholder="请输入密码"> <input matInput id="name" name="name" #name="ngModel" pattern="^[a-zA-Z][a-zA-Z0-9_]{4,19}$"
</mat-form-field> required ngModel placeholder="请输入账号">
</mat-form-field>
<!-- <div *ngIf="password.invalid && (password.dirty || password.touched)" </div>
class="alert-danger"> <div *ngIf="name.invalid && (name.dirty || name.touched)" class="alert-danger">
<div *ngIf="password.errors.required"> <div *ngIf="name.errors.pattern">
密码不能为空 登录账号格式为5-19位字母+数字
</div> </div>
<div *ngIf="password.errors.minlength"> </div>
密码最少8位
<div class="input">
<label class="position"><mat-icon>lock</mat-icon></label>
<mat-form-field>
<input matInput id="password" name="password" type='password' #password="ngModel"
required pattern="^(?=.*[a-zA-Z])(?=.*[0-9])[A-Za-z0-9]{8,20}$"
ngModel placeholder="请输入密码">
</mat-form-field>
</div>
<div *ngIf="password.invalid && (password.dirty || password.touched)" class="alert-danger">
<div *ngIf="password.errors.pattern">
登录密码格式为8-20位字母+数字
</div> </div>
</div> --> </div>
<mat-checkbox style="margin-top: 25px;">请同意不扩散核武器条约条约</mat-checkbox> <div *ngIf="errmsg" class="alert-danger">
{{errmsg}}
</div>
<div class="register">
<a href="javascript:void(0);" (click)='toLogin()'>已有账号,去登陆</a>
<a href="javascript:void(0);" (click)='open()'>注册失败?</a>
</div>
<button type="submit" [disabled]="!form.form.valid" class="loginbtn"mat-button>注册</button> <button type="submit" [disabled]="!form.form.valid" class="loginbtn" mat-button>注册</button>
</form> </form>
<div class="applyfor"> </div>
<p>已有账号?去<a href="/login">登录</a></p>
</div>
<div class="website">
<p>WEBSITE BY AnXin</p>
<p>© 2020. All RIGHT RESERVED.</p>
</div>
</mat-card>
</div> </div>
</div> </div>

128
src/app/pages/register/register.component.scss

@ -2,87 +2,71 @@
width: 100%; width: 100%;
height: 100%; height: 100%;
background: url('../../../assets/images/bg_login.jpg'); background: url('../../../assets/images/bg_login.jpg');
.loginbox {
width: 100%;
height: 100%;
background-color: #000;
background: rgba(0,0,0,0.5);/*盒子背景透明*/
// opacity: 0.5;
position: relative;
}
.intro {
width: 650px;
// height: 350px;
position: fixed;
top:35%;
left: 15%;
p {
font-size: 36px;
color:white;
margin-bottom: 35px;
}
span {
font-size: 16px;
color:white;
opacity: 0.5;
}
}
.card{
width: 460px;
height: 100%;
padding-left: 20px;
background-color: #fff;
position: absolute;
right: 0;
p {
width: 100%;
margin: 18px 0;
}
.cardheader{
font-size: 26px;
font-weight: 500;
}
}
} }
.loginBox {
.example-container { width: 100%;
height: 100%;
background-color: #000;
background: rgba(0,0,0,0.5);/*盒子背景透明*/
display: flex; display: flex;
flex-direction: column; /*!*flex-direction: column;*!可写可不写*/
justify-content: center;
align-items: center;
} }
.example-container > * { .card {
width: 100%; width: 500px;
} border-radius: 10px;
.loginbtn { padding-top: 25px;
margin-top: 18px; background-color: hsla(0,0%,100%,.8);
height: 35px; text-align: center;
background-color:#039be5; box-shadow:0px 0px 10px 5px #333;
border-radius: 15px;
color: #fff;;
} }
.mat-card { .cardheader{
box-shadow: 0 0 0; margin-bottom: 10px;
margin-top: 70px; font-size: 26px;
font-weight: 500;
} }
.applyfor { .input {
font-size: 16px; margin: 0 auto;
a { position: relative;
color: #039be5;
}
} }
.mat-form-field {
.website { width: 300px;
font-size: 14px;
text-align: center;
margin-top: 50px;
} }
.position {
margin-top: 5px;
position: absolute;
top: 15px;
left: 75px;
}
.alert-danger { .alert-danger {
font-size: 14px; margin-bottom: 5px;
text-align: left;
padding-left: 100px;
font-size: 12px;
color: red; color: red;
}
.register {
padding-left: 100px;
text-align: left;
a {
font-size: 14px;
color: #0066FF;
}
:last-child {
margin-left: 135px;
}
}
.loginbtn {
margin-top: 25px;
margin-bottom: 25px;
height: 30px;
line-height: 30px;
width: 280px;
background-color:#039be5;
border-radius: 15px;
color: #fff;
} }

39
src/app/pages/register/register.component.ts

@ -1,4 +1,7 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Router, ActivatedRoute } from '@angular/router';
import { MatSnackBar } from '@angular/material/snack-bar';
@Component({ @Component({
selector: 'app-register', selector: 'app-register',
@ -7,13 +10,41 @@ import { Component, OnInit } from '@angular/core';
}) })
export class RegisterComponent implements OnInit { export class RegisterComponent implements OnInit {
constructor() { } constructor(private http:HttpClient,private router:Router,private route:ActivatedRoute,public snackBar: MatSnackBar) { }
ngOnInit() { ngOnInit() {}
errmsg:any; //错误信息
//提交注册表单
onSubmit(e){
this.http.post('/api/CompanyAccount/SignUp',{
companyName: e.companyName,
name:e.name,
password:e.password,
phone:e.phone,
usci:e.usci
}).subscribe(data=>{
this.snackBar.open('注册成功,请登录!', '确定', {
duration: 3000
});
this.router.navigate(['/login'])
},(err)=>{
this.errmsg = err
})
} }
onSubmit(e){ //跳转登陆页面
console.log(e) toLogin () {
this.router.navigate(['/login'])
}
//打开注册失败弹窗
open () {
this.snackBar.open('若信息输入正确无法注册,请联系管理员: 13911111111', '确定', {
duration: 3000
});
} }
} }

4
src/app/tabbar/tabbar.component.html

@ -1,6 +1,6 @@
<mat-toolbar [color]="theme?'primary':'accent'"> <mat-toolbar [color]="theme?'primary':'accent'">
<!-- <mat-toolbar> --> <!-- <mat-toolbar> -->
<h1>用户信息采集平台</h1> <h1>{{companyName}}</h1>
<!-- 全屏 --> <!-- 全屏 -->
<button mat-button (click)="!isfullscreen?fullscreenToggle():closefullscreen()" class="fullscreen"> <button mat-button (click)="!isfullscreen?fullscreenToggle():closefullscreen()" class="fullscreen">
@ -24,7 +24,7 @@
<mat-icon>account_circle</mat-icon> <mat-icon>account_circle</mat-icon>
</button> </button>
<mat-menu #appMenu="matMenu"> <mat-menu #appMenu="matMenu">
<button mat-menu-item [routerLink]="['/ui/userdata']" > <button mat-menu-item [routerLink]="['/datacollection/userdata']" >
<mat-icon>perm_identity</mat-icon> <mat-icon>perm_identity</mat-icon>
<span>修改资料</span> <span>修改资料</span>
</button> </button>

23
src/app/tabbar/tabbar.component.ts

@ -5,6 +5,10 @@ import { Router,ActivatedRoute } from '@angular/router'
import {CacheTokenService} from '../http-interceptors/cache-token.service'//引入服务 import {CacheTokenService} from '../http-interceptors/cache-token.service'//引入服务
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import {ChangepasswordComponent} from '../ui/changepassword/changepassword.component' import {ChangepasswordComponent} from '../ui/changepassword/changepassword.component'
import { MatSnackBar } from '@angular/material/snack-bar';
@Component({ @Component({
selector: 'app-tabbar', selector: 'app-tabbar',
templateUrl: './tabbar.component.html', templateUrl: './tabbar.component.html',
@ -25,9 +29,12 @@ export class TabbarComponent implements OnInit {
onChange(eventValue: boolean){ onChange(eventValue: boolean){
this.toggleDarkTheme.emit(eventValue); this.toggleDarkTheme.emit(eventValue);
} }
constructor(private http:HttpClient,private router:Router,private route:ActivatedRoute,public token:CacheTokenService,public dialog: MatDialog) { } constructor(private http:HttpClient,private router:Router,private route:ActivatedRoute,public token:CacheTokenService,public dialog: MatDialog,public snackBar: MatSnackBar) { }
ngOnInit() { ngOnInit() {
this.getCompany()
} }
boxed(css){ boxed(css){
const Element = document.body; const Element = document.body;
Element.style.width = '1200px' Element.style.width = '1200px'
@ -76,16 +83,26 @@ export class TabbarComponent implements OnInit {
this.isfullscreen = false; this.isfullscreen = false;
} }
companyName:any; //企业name
//获取当前登录企业信息
getCompany () {
this.http.get('/api/CompanyAccount/Profiles').subscribe((data:any)=>{
this.companyName = data.companyName
})
}
//退出系统 //退出系统
signOut = () => { signOut = () => {
let out = confirm("您确定要退出吗") let out = confirm("您确定要退出吗")
if(out) { if(out) {
this.http.post('/api/Account/SignOut',{}).subscribe( this.http.post('/api/CompanyAccount/SignOut',{}).subscribe(
data=> { data=> {
this.token.delete() this.token.delete()
sessionStorage.clear() sessionStorage.clear()
window.localStorage.clear() window.localStorage.clear()
alert('成功退出') this.snackBar.open('成功退出', '确定', {
duration: 3000
});
this.router.navigate(['/login']) this.router.navigate(['/login'])
} }
) )

2
src/app/ui/changepassword/changepassword.component.ts

@ -19,7 +19,7 @@ export class ChangepasswordComponent implements OnInit {
onSubmit(e){ onSubmit(e){
this.http.put( this.http.put(
'/api/Account/Password', '/api/CompanyAccount/Password',
{ {
newPassword: e.newPassword, newPassword: e.newPassword,
password: e.password password: e.password

1
src/app/ui/ui-routing.module.ts

@ -9,6 +9,7 @@ import { KeySiteComponent } from './key-site/key-site.component';
import { FunctionDivisionComponent } from './function-division/function-division.component'; import { FunctionDivisionComponent } from './function-division/function-division.component';
import { RealisticPictureComponent } from './realistic-picture/realistic-picture.component'; import { RealisticPictureComponent } from './realistic-picture/realistic-picture.component';
import { UploadingCADComponent } from './uploading-cad/uploading-cad.component'; import { UploadingCADComponent } from './uploading-cad/uploading-cad.component';
const routes: Routes = [ const routes: Routes = [
{ path: '', component:UserdataComponent }, { path: '', component:UserdataComponent },
{ path: 'userdata', component:UserdataComponent }, { path: 'userdata', component:UserdataComponent },

51
src/app/ui/userdata/edituserdata.component.html

@ -1,13 +1,42 @@
<form (ngSubmit)="onSubmit(form.value)" #form="ngForm" class="example-container"> <h1 mat-dialog-title>修改资料</h1>
<mat-form-field>
<input matInput id="realName" name="realName" type='text' <form (ngSubmit)="onSubmit(form.value)" #form="ngForm">
required minlength="1"
ngModel #realName="ngModel" placeholder="修改真实姓名"> <div>
<mat-form-field>
<input type="text" matInput disabled
[(ngModel)]="data.name" name="name" placeholder="登录账号">
</mat-form-field> </mat-form-field>
</div>
<div>
<mat-form-field>
<input type="text" matInput pattern="^(?:\+?86)?1(?:3\d{3}|5[^4\D]\d{2}|8\d{3}|7(?:[35-8]\d{2}|4(?:0\d|1[0-2]|9\d))|9[0135-9]\d{2}|66\d{2})\d{6}$" required
[(ngModel)]="tel" name="tel" placeholder="联系电话">
</mat-form-field>
</div>
<div>
<mat-form-field>
<input type="text" matInput required
[(ngModel)]="companyName" name="companyName" placeholder="单位名称">
</mat-form-field>
</div>
<div>
<mat-form-field>
<input type="text" matInput required pattern="^[0-9A-HJ-NP-RTUW-Y]{2}\d{6}[0-9A-HJ-NP-RTUW-Y]{10}$"
[(ngModel)]="usci" name="usci" placeholder="统一社会信用代码">
</mat-form-field>
</div>
<div *ngIf="errMsg" class="err"><p>{{errMsg}}</p></div>
<div class="btn"> <div mat-dialog-actions>
<button type="submit" class="savebtn" mat-raised-button color="primary" [disabled]='form.invalid'>确认</button> <button mat-raised-button color="primary" type="submit"
<button type="button" mat-button (click)="onNoClick()" mat-raised-button color="primary">取消</button> [disabled]="!form.form.valid">
</div> 确定
</button>
</form> <button mat-raised-button mat-dialog-close>取消</button>
</div>
</form>

34
src/app/ui/userdata/userdata.component.html

@ -1,11 +1,27 @@
<mat-card> <mat-card>
<mat-card-title>账号:{{userdata.name}}</mat-card-title> <mat-list role="list" class="userList">
<mat-card-content> <mat-list-item role="listitem">
<h1>真实姓名:{{userdata.realName}}</h1> <label>登录账号:</label> {{userInfo.name}}
<h1>创建时间:{{userdata.creationTime | date:'yyyy-MM-dd'}}</h1> </mat-list-item>
<h1>组织机构名称:{{userdata.organizationName }}</h1> <mat-list-item role="listitem">
</mat-card-content> <label>联系电话:</label> {{userInfo.phone}}
<mat-card-actions> </mat-list-item>
<button mat-raised-button color="primary" (click)="edit()">修改信息</button> <mat-list-item role="listitem">
</mat-card-actions> <label>单位名称:</label> {{userInfo.companyName}}
</mat-list-item>
<mat-list-item role="listitem">
<label>账号状态:</label>
<span *ngIf="userInfo.enabled">正常</span>
<span *ngIf="!userInfo.enabled">禁用</span>
</mat-list-item>
<mat-list-item role="listitem">
<label>注册时间:</label> {{userInfo.creationTime|date:'yyyy-MM-dd'}}
</mat-list-item>
<mat-list-item role="listitem">
<label>统一社会信用代码:</label> {{userInfo.usci}}
</mat-list-item>
<mat-list-item role="listitem">
<button mat-raised-button color="primary" (click)='edit()'>修改资料</button>
</mat-list-item>
</mat-list>
</mat-card> </mat-card>

32
src/app/ui/userdata/userdata.component.scss

@ -1,21 +1,15 @@
mat-card{ .userList {
padding-left: 40%; padding-left: 35%;
h1{ label {
margin: 10px 0; font-weight: 500;
} margin-right: 10px;
mat-card-actions{ }
padding-left: 10%;
}
} }
form{ .mat-form-field {
text-align: center; width: 200px;
button{
margin: 0 8px;
margin-top: 8px;
}
.mat-checkbox{
display: block;
text-align: left;
}
} }
.err {
width: 350px;
font-size: 16px;
color: red;
}

116
src/app/ui/userdata/userdata.component.ts

@ -1,18 +1,9 @@
import { Component, OnInit, ViewChild, Inject } from '@angular/core'; import { Component, OnInit, ViewChild, Inject } from '@angular/core';
import {MatPaginator} from '@angular/material/paginator';
import {MatTableDataSource} from '@angular/material/table';
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog'; import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog';
import {FormControl} from '@angular/forms';
import { HttpClient,HttpHeaders } from '@angular/common/http'; import { HttpClient,HttpHeaders } from '@angular/common/http';
import format from 'date-fns/format';
export interface userdata {
name: string,//名称
realName: string,//身份
enabled: boolean,//是否已启用
creationTime: string,//创建时间
organizationId: null//机构编号,
}
//总页面
@Component({ @Component({
selector: 'app-userdata', selector: 'app-userdata',
templateUrl: './userdata.component.html', templateUrl: './userdata.component.html',
@ -22,68 +13,71 @@ export class UserdataComponent implements OnInit {
constructor(private http: HttpClient,public dialog: MatDialog) { } constructor(private http: HttpClient,public dialog: MatDialog) { }
userdata: any = {} userInfo:any={}; // 用户信息
ngOnInit() { ngOnInit() {
this.http.get("/api/Account/Profiles").subscribe( this.getUserInfo()
data=>{
if(!data['organizationName']){
data['organizationName'] = '无'
}
this.userdata = data
}
)
} }
edit(){
const dialogRef = this.dialog.open(EditUser, {//调用open方法打开对话框并且携带参数过去 //获取用户信息
width: '260px', getUserInfo () {
data: {} this.http.get('/api/CompanyAccount/Profiles').subscribe(data=>{
}); this.userInfo = data
dialogRef.afterClosed().subscribe( })
data=>{ }
this.http.get("/api/Account/Profiles").subscribe(
data=>{ //修改资料弹窗
this.userdata = data edit () {
} let data = this.userInfo
) let dialogRef = this.dialog.open(EditUser,{'width':'500px',data});
} dialogRef.afterClosed().subscribe(
); (data)=>{
if (data) {this.getUserInfo()}
}
);
} }
} }
@Component({ @Component({
selector: 'edituserdata', selector: 'edituserdata',
templateUrl: './edituserdata.component.html', templateUrl: './edituserdata.component.html',
styleUrls: ['./userdata.component.scss'] styleUrls: ['./userdata.component.scss']
}) })
export class EditUser { export class EditUser {
myControl = new FormControl();
constructor(private http: HttpClient,public dialogRef: MatDialogRef<EditUser>,@Inject(MAT_DIALOG_DATA) public data) {} constructor(private http: HttpClient,public dialogRef: MatDialogRef<EditUser>,@Inject(MAT_DIALOG_DATA) public data) {}
onNoClick(): void {
this.dialogRef.close(); ngOnInit() {
this.tel = this.data.phone
this.companyName = this.data.companyName
this.usci = this.data.usci
} }
onSubmit(value){
tel:any; //联系电话
let headers = new HttpHeaders({ companyName:any; //单位名称
'Content-Type': 'text/json' usci:any; //统一社会信用代码
}); errMsg:any; //错误信息
let options = {
headers //提交表单修改信息
}; onSubmit (e) {
let body = JSON.stringify(value.realName); this.http.put('/api/CompanyAccount/Profiles',{
this.http.put<any>( name:this.data.name,
"/api/Account/Profiles", phone:e.tel,
body, enabled:this.data.enabled,
options creationTime:this.data.creationTime,
).subscribe( usci:e.usci,
data=>{ companyId:this.data.companyId,
alert("修改成功") companyName:e.companyName
this.dialogRef.close(); }).subscribe(data=>{
}, this.dialogRef.close('success')
err=>{ },(err) =>
alert("修改失败") {this.errMsg = err})
this.dialogRef.close();
}
)
} }
} }

2
src/index.html

@ -2,7 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>字化预案编制管理平台</title> <title>据采集管理平台</title>
<base href="/"> <base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico"> <link rel="icon" type="image/x-icon" href="favicon.ico">

Loading…
Cancel
Save