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",
"scripts": {
"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",
"test": "ng test",
"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'
const routes: Routes = [
{path:'',redirectTo:'login',pathMatch:'full'},
{
@ -18,17 +19,16 @@ const routes: Routes = [
children:[
{path:'datacollection',loadChildren:() => import('./ui/ui.module').then(m => m.UiModule)}
]},
{path:'login',
component:LoginComponent},
component:LoginComponent}, //登录页
{path:'register',
component:RegisterComponent,
canActivate: [AuthGuard],},//守卫验证
component:RegisterComponent,}, //注册页
{path:'lockscreen',
component:LockscreenComponent,
canActivate: [AuthGuard],}//守卫验证
// {path:'lockscreen',
// component:LockscreenComponent,
// canActivate: [AuthGuard],}//守卫验证
];
@NgModule({

37
src/app/app.component.ts

@ -3,44 +3,25 @@ import { HttpClient } from '@angular/common/http'
import { Data } from './interface'
import { Router,ActivatedRoute } from '@angular/router'
import {CacheTokenService} from './http-interceptors/cache-token.service'//引入服务
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
title = '数字化预案编制管理平台';
title = '数据采集管理平台';
constructor(private http:HttpClient,private router:Router,public token:CacheTokenService) { }
ngOnInit(): void {
var isnologin = localStorage.getItem("isnologin")
//七天免登录
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{
ngOnInit(): void {
var token = sessionStorage.getItem("token");
var refreshToken = sessionStorage.getItem("refreshToken");
if(token && refreshToken) {
this.http.post(
'/api/Account/RefreshToken',
'/api/CompanyAccount/RefreshToken',
{
token: token,
refreshToken: refreshToken
@ -49,15 +30,13 @@ export class AppComponent {
(data: Data) => {
sessionStorage.setItem("token",data.token);
sessionStorage.setItem("refreshToken",data.refreshToken);
this.token.getmenus()
this.token.startUp()
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 {CacheTokenService} from './cache-token.service'
import { MatSnackBar } from '@angular/material/snack-bar';
//baseurl
// const baseurl = 'http://39.106.78.171:8008';
@ -15,7 +16,8 @@ import {CacheTokenService} from './cache-token.service'
@Injectable()
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) {
@ -47,11 +49,15 @@ export class BaseInterceptor implements HttpInterceptor {
this.token.delete()
sessionStorage.clear()
window.localStorage.clear()
alert('用户认证信息过期,请重新登录')
this.snackBar.open('用户认证信息过期,请重新登录', '确定', {
duration: 3000
});
this.router.navigate(['/login'])
}
if (error.status === 403) {
alert('对不起,您无此权限')
this.snackBar.open('对不起,您无此权限!', '确定', {
duration: 3000
});
}
if (error.error instanceof ErrorEvent) {

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

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

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

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

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

@ -1,115 +1,73 @@
.login {
width: 100%;
height: 100%;
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;
}
}
.example-container {
display: flex;
flex-direction: column;
.loginBox {
width: 100%;
}
.loginbtn {
margin-top: 25px;
height: 35px;
background-color:#039be5;
border-radius: 15px;
color: #fff;;
}
.mat-card {
box-shadow: 0 0 0;
margin-top: 140px;
}
.applyfor {
font-size: 16px;
a {
color: #039be5;
}
height: 100%;
background-color: #000;
background: rgba(0,0,0,0.5);/*盒子背景透明*/
display: flex;
/*!*flex-direction: column;*!可写可不写*/
justify-content: center;
align-items: center;
}
.website {
font-size: 14px;
.card {
width: 500px;
height: 355px;
border-radius: 10px;
padding-top: 25px;
background-color: hsla(0,0%,100%,.8);
text-align: center;
margin-top: 60px;
}
.alert-danger {
font-size: 14px;
color: red;
box-shadow:0px 0px 10px 5px #333;
}
.cardheader{
margin-bottom: 10px;
font-size: 26px;
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;
}
.mat-card .example-container .icon {
width: 24px;
color: #666;
font-size: 24px;
position: absolute;
top:36px;
left: 15px;
.mat-form-field {
width: 300px;
}
.mat-card .example-container .icon2 {
width: 24px;
color: #666;
font-size: 24px;
.position {
margin-top: 5px;
position: absolute;
top:100px;
left: 15px;
top: 15px;
left: 75px;
}
a {
.alert-danger {
text-align-last: left;
margin-left: 100px;
font-size: 14px;
color: #0066FF;
margin-left: 250px;
color: red;
}
.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 { Data } from '../../interface'
import { Router,ActivatedRoute } from '@angular/router'
import {CacheTokenService} from '../../http-interceptors/cache-token.service'//引入服务
import { MatSnackBar } from '@angular/material/snack-bar';
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
@ -13,54 +15,44 @@ import { MatSnackBar } from '@angular/material/snack-bar';
})
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){
this.http.post(
'/api/Account/SignIn',
{
this.http.post('/api/CompanyAccount/SignIn',{
name: e.name,
password: e.password
}
).subscribe(
password: e.password}).subscribe(
(data: Data) =>
{
{
sessionStorage.setItem("token",data.token);
sessionStorage.setItem("refreshToken",data.refreshToken);
this.router.navigate(['/datacollection/userdata'])
if(e.notlogin){
console.log("true")
localStorage.setItem("isnologin","true")
localStorage.setItem("token",data.token)
localStorage.setItem("refreshToken",data.refreshToken)
}else{
console.log("false")
}
this.router.navigate(['/datacollection/basicinfo'])
//调用服务中的function刷新token
this.token.startUp()
//调用服务中的function获取菜单
this.token.getmenus()
},
(err) =>
{this.errmsg = err}
)
}
//打开弹窗
//跳转注册页面
toRegister () {
this.router.navigate(['/register'])
}
//打开忘记密码弹窗
open () {
this.snackBar.open('请联系管理员', '确定', {
this.snackBar.open('请联系管理员: 1391111111', '确定', {
duration: 3000
});
}
}

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

@ -1,80 +1,87 @@
<div class="login">
<div class="loginbox">
<div class="loginBox">
<div class="intro">
<p>北京安信科创有限公司</p>
<span>北京安信科创软件有限公司作为中国应急服务领跑者,于2006年进入消防救援领域,是一家专注于应急领域仿真培训演练与应急数据预判领域的软件服务供应商。安信主要利用大数据与虚拟现实技术实现对消防、公安、机场相关安防人员与企业安全监管人员的仿真培训与考核,致力于为我国应急产业的发展构建更美好的未来。目前,安信的业务遍布全国20多个省份和地区,服务全国将近四分之一以上的人口
</span>
</div>
<div class="card">
<mat-card>
<p class="cardheader">注册</p>
<p>Please register first</p>
<div>
<div class="card">
<span class="cardheader">数据采集管理平台</span>
<form (ngSubmit)="onSubmit(form.value)" #form="ngForm" class="example-container">
<mat-form-field>
<input matInput id="name" name="name"
required
ngModel #name="ngModel" placeholder="请输入账号">
</mat-form-field>
<div class="input">
<label class="position"><mat-icon>group</mat-icon></label>
<mat-form-field>
<input matInput id="companyName" name="companyName"
required ngModel placeholder="请输入单位名称">
</mat-form-field>
</div>
<!-- <div *ngIf="name.invalid && (name.dirty || name.touched)"
class="alert-danger">
<div *ngIf="name.errors.required">
账号不能为空
<div class="input">
<label class="position"><mat-icon>dns</mat-icon></label>
<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>
<mat-form-field>
<input matInput id="email" name="email"
required pattern="^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$"
ngModel #email="ngModel" placeholder="请输入邮箱">
</mat-form-field>
<!--
<div *ngIf="email.invalid && (email.dirty || email.touched)"
class="alert-danger">
<div *ngIf="email.errors.required">
邮箱不能为空
</div>
<div *ngIf="email.errors.pattern">
邮箱格式不正确
<div class="input">
<label class="position"><mat-icon>phone</mat-icon></label>
<mat-form-field>
<input matInput id="phone" name="phone" #tel="ngModel"
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="请输入联系电话">
</mat-form-field>
</div>
<div *ngIf="tel.invalid && (tel.dirty || tel.touched)" class="alert-danger">
<div *ngIf="tel.errors.pattern">
电话号码格式不正确
</div>
</div> -->
</div>
<mat-form-field>
<input matInput id="password" name="password" type='password'
required minlength="8"
ngModel #password="ngModel" placeholder="请输入密码">
</mat-form-field>
<!-- <div *ngIf="password.invalid && (password.dirty || password.touched)"
class="alert-danger">
<div *ngIf="password.errors.required">
密码不能为空
<div class="input">
<label class="position"><mat-icon>account_box</mat-icon></label>
<mat-form-field>
<input matInput id="name" name="name" #name="ngModel" pattern="^[a-zA-Z][a-zA-Z0-9_]{4,19}$"
required ngModel placeholder="请输入账号">
</mat-form-field>
</div>
<div *ngIf="name.invalid && (name.dirty || name.touched)" class="alert-danger">
<div *ngIf="name.errors.pattern">
登录账号格式为5-19位字母+数字
</div>
<div *ngIf="password.errors.minlength">
密码最少8位
</div>
<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>
<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>
<div class="applyfor">
<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>

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

@ -2,87 +2,71 @@
width: 100%;
height: 100%;
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;
}
}
}
.example-container {
.loginBox {
width: 100%;
height: 100%;
background-color: #000;
background: rgba(0,0,0,0.5);/*盒子背景透明*/
display: flex;
flex-direction: column;
/*!*flex-direction: column;*!可写可不写*/
justify-content: center;
align-items: center;
}
.example-container > * {
width: 100%;
}
.loginbtn {
margin-top: 18px;
height: 35px;
background-color:#039be5;
border-radius: 15px;
color: #fff;;
.card {
width: 500px;
border-radius: 10px;
padding-top: 25px;
background-color: hsla(0,0%,100%,.8);
text-align: center;
box-shadow:0px 0px 10px 5px #333;
}
.mat-card {
box-shadow: 0 0 0;
margin-top: 70px;
.cardheader{
margin-bottom: 10px;
font-size: 26px;
font-weight: 500;
}
.applyfor {
font-size: 16px;
a {
color: #039be5;
}
.input {
margin: 0 auto;
position: relative;
}
.website {
font-size: 14px;
text-align: center;
margin-top: 50px;
.mat-form-field {
width: 300px;
}
.position {
margin-top: 5px;
position: absolute;
top: 15px;
left: 75px;
}
.alert-danger {
font-size: 14px;
margin-bottom: 5px;
text-align: left;
padding-left: 100px;
font-size: 12px;
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 { HttpClient } from '@angular/common/http';
import { Router, ActivatedRoute } from '@angular/router';
import { MatSnackBar } from '@angular/material/snack-bar';
@Component({
selector: 'app-register',
@ -7,13 +10,41 @@ import { Component, OnInit } from '@angular/core';
})
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> -->
<h1>用户信息采集平台</h1>
<h1>{{companyName}}</h1>
<!-- 全屏 -->
<button mat-button (click)="!isfullscreen?fullscreenToggle():closefullscreen()" class="fullscreen">
@ -24,7 +24,7 @@
<mat-icon>account_circle</mat-icon>
</button>
<mat-menu #appMenu="matMenu">
<button mat-menu-item [routerLink]="['/ui/userdata']" >
<button mat-menu-item [routerLink]="['/datacollection/userdata']" >
<mat-icon>perm_identity</mat-icon>
<span>修改资料</span>
</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 { MatDialog } from '@angular/material/dialog';
import {ChangepasswordComponent} from '../ui/changepassword/changepassword.component'
import { MatSnackBar } from '@angular/material/snack-bar';
@Component({
selector: 'app-tabbar',
templateUrl: './tabbar.component.html',
@ -25,9 +29,12 @@ export class TabbarComponent implements OnInit {
onChange(eventValue: boolean){
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() {
this.getCompany()
}
boxed(css){
const Element = document.body;
Element.style.width = '1200px'
@ -76,16 +83,26 @@ export class TabbarComponent implements OnInit {
this.isfullscreen = false;
}
companyName:any; //企业name
//获取当前登录企业信息
getCompany () {
this.http.get('/api/CompanyAccount/Profiles').subscribe((data:any)=>{
this.companyName = data.companyName
})
}
//退出系统
signOut = () => {
let out = confirm("您确定要退出吗")
if(out) {
this.http.post('/api/Account/SignOut',{}).subscribe(
this.http.post('/api/CompanyAccount/SignOut',{}).subscribe(
data=> {
this.token.delete()
sessionStorage.clear()
window.localStorage.clear()
alert('成功退出')
this.snackBar.open('成功退出', '确定', {
duration: 3000
});
this.router.navigate(['/login'])
}
)

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

@ -19,7 +19,7 @@ export class ChangepasswordComponent implements OnInit {
onSubmit(e){
this.http.put(
'/api/Account/Password',
'/api/CompanyAccount/Password',
{
newPassword: e.newPassword,
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 { RealisticPictureComponent } from './realistic-picture/realistic-picture.component';
import { UploadingCADComponent } from './uploading-cad/uploading-cad.component';
const routes: Routes = [
{ path: '', 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">
<mat-form-field>
<input matInput id="realName" name="realName" type='text'
required minlength="1"
ngModel #realName="ngModel" placeholder="修改真实姓名">
<h1 mat-dialog-title>修改资料</h1>
<form (ngSubmit)="onSubmit(form.value)" #form="ngForm">
<div>
<mat-form-field>
<input type="text" matInput disabled
[(ngModel)]="data.name" name="name" placeholder="登录账号">
</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">
<button type="submit" class="savebtn" mat-raised-button color="primary" [disabled]='form.invalid'>确认</button>
<button type="button" mat-button (click)="onNoClick()" mat-raised-button color="primary">取消</button>
</div>
</form>
<div mat-dialog-actions>
<button mat-raised-button color="primary" type="submit"
[disabled]="!form.form.valid">
确定
</button>
<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-title>账号:{{userdata.name}}</mat-card-title>
<mat-card-content>
<h1>真实姓名:{{userdata.realName}}</h1>
<h1>创建时间:{{userdata.creationTime | date:'yyyy-MM-dd'}}</h1>
<h1>组织机构名称:{{userdata.organizationName }}</h1>
</mat-card-content>
<mat-card-actions>
<button mat-raised-button color="primary" (click)="edit()">修改信息</button>
</mat-card-actions>
<mat-list role="list" class="userList">
<mat-list-item role="listitem">
<label>登录账号:</label> {{userInfo.name}}
</mat-list-item>
<mat-list-item role="listitem">
<label>联系电话:</label> {{userInfo.phone}}
</mat-list-item>
<mat-list-item role="listitem">
<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>

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

@ -1,21 +1,15 @@
mat-card{
padding-left: 40%;
h1{
margin: 10px 0;
}
mat-card-actions{
padding-left: 10%;
}
.userList {
padding-left: 35%;
label {
font-weight: 500;
margin-right: 10px;
}
}
form{
text-align: center;
button{
margin: 0 8px;
margin-top: 8px;
}
.mat-checkbox{
display: block;
text-align: left;
}
.mat-form-field {
width: 200px;
}
.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 {MatPaginator} from '@angular/material/paginator';
import {MatTableDataSource} from '@angular/material/table';
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog';
import {FormControl} from '@angular/forms';
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({
selector: 'app-userdata',
templateUrl: './userdata.component.html',
@ -22,68 +13,71 @@ export class UserdataComponent implements OnInit {
constructor(private http: HttpClient,public dialog: MatDialog) { }
userdata: any = {}
userInfo:any={}; // 用户信息
ngOnInit() {
this.http.get("/api/Account/Profiles").subscribe(
data=>{
if(!data['organizationName']){
data['organizationName'] = '无'
}
this.userdata = data
}
)
this.getUserInfo()
}
edit(){
const dialogRef = this.dialog.open(EditUser, {//调用open方法打开对话框并且携带参数过去
width: '260px',
data: {}
});
dialogRef.afterClosed().subscribe(
data=>{
this.http.get("/api/Account/Profiles").subscribe(
data=>{
this.userdata = data
}
)
}
);
//获取用户信息
getUserInfo () {
this.http.get('/api/CompanyAccount/Profiles').subscribe(data=>{
this.userInfo = data
})
}
//修改资料弹窗
edit () {
let data = this.userInfo
let dialogRef = this.dialog.open(EditUser,{'width':'500px',data});
dialogRef.afterClosed().subscribe(
(data)=>{
if (data) {this.getUserInfo()}
}
);
}
}
@Component({
selector: 'edituserdata',
templateUrl: './edituserdata.component.html',
styleUrls: ['./userdata.component.scss']
})
export class EditUser {
myControl = new FormControl();
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){
let headers = new HttpHeaders({
'Content-Type': 'text/json'
});
let options = {
headers
};
let body = JSON.stringify(value.realName);
this.http.put<any>(
"/api/Account/Profiles",
body,
options
).subscribe(
data=>{
alert("修改成功")
this.dialogRef.close();
},
err=>{
alert("修改失败")
this.dialogRef.close();
}
)
tel:any; //联系电话
companyName:any; //单位名称
usci:any; //统一社会信用代码
errMsg:any; //错误信息
//提交表单修改信息
onSubmit (e) {
this.http.put('/api/CompanyAccount/Profiles',{
name:this.data.name,
phone:e.tel,
enabled:this.data.enabled,
creationTime:this.data.creationTime,
usci:e.usci,
companyId:this.data.companyId,
companyName:e.companyName
}).subscribe(data=>{
this.dialogRef.close('success')
},(err) =>
{this.errMsg = err})
}
}

2
src/index.html

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

Loading…
Cancel
Save