Browse Source

[新增]学习记录页面基本功能

master
邵佳豪 5 years ago
parent
commit
bb237b08ea
  1. 46
      package-lock.json
  2. 3
      src/app/navigation/navigation.component.html
  3. 1
      src/app/pages/lockscreen/lockscreen.component.scss
  4. 6
      src/app/pipes/size.pipe.ts
  5. 22
      src/app/ui/all-file/all-file.component.ts
  6. 1
      src/app/ui/enterpriseuser/addenterpriseuser.component.ts
  7. 2
      src/app/ui/enterpriseuser/enterpriseuser.component.html
  8. 9
      src/app/ui/enterpriseuser/enterpriseuser.component.ts
  9. 49
      src/app/ui/learning-record-details/learning-record-details.component.html
  10. 43
      src/app/ui/learning-record-details/learning-record-details.component.scss
  11. 143
      src/app/ui/learning-record-details/learning-record-details.component.ts
  12. 4
      src/app/ui/ui-routing.module.ts
  13. 5
      src/app/ui/ui.module.ts
  14. 3
      tsconfig.json

46
package-lock.json generated

@ -15968,7 +15968,8 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"aproba": {
"version": "1.2.0",
@ -16011,7 +16012,8 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"concat-map": {
"version": "0.0.1",
@ -16022,7 +16024,8 @@
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"core-util-is": {
"version": "1.0.2",
@ -16139,7 +16142,8 @@
"inherits": {
"version": "2.0.4",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"ini": {
"version": "1.3.5",
@ -16151,6 +16155,7 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@ -16180,6 +16185,7 @@
"version": "2.9.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@ -16198,6 +16204,7 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
@ -16300,6 +16307,7 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@ -16385,7 +16393,8 @@
"safe-buffer": {
"version": "5.1.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"safer-buffer": {
"version": "2.1.2",
@ -16421,6 +16430,7 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@ -16440,6 +16450,7 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@ -16483,12 +16494,14 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"yallist": {
"version": "3.1.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
}
}
},
@ -16926,7 +16939,8 @@
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"core-util-is": {
"version": "1.0.2",
@ -17043,7 +17057,8 @@
"inherits": {
"version": "2.0.4",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"ini": {
"version": "1.3.5",
@ -17085,6 +17100,7 @@
"version": "2.9.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@ -17103,6 +17119,7 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
@ -17205,6 +17222,7 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@ -17290,7 +17308,8 @@
"safe-buffer": {
"version": "5.1.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"safer-buffer": {
"version": "2.1.2",
@ -17326,6 +17345,7 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@ -17389,12 +17409,14 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"yallist": {
"version": "3.1.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
}
}
},

3
src/app/navigation/navigation.component.html

@ -65,6 +65,9 @@
<li *ngFor="let item of systemManagement" (click)="clickUser(item)" [ngClass]="{'selectedLi': item.id === selectedDataBank}" >{{item.name}}</li>
</ul>
</mat-expansion-panel>
<!-- <ul>
<li [routerLink]="['/home/learningrecorddetails']" routerLinkActive="router-link-active" >学习记录</li>
</ul> -->
</mat-accordion>
</div>
</mat-sidenav>

1
src/app/pages/lockscreen/lockscreen.component.scss

@ -51,6 +51,7 @@
position: fixed;
bottom: 35px;
font-size: 14px;
color: white;
}
.toLogin{
color: #B0B0B0;

6
src/app/pipes/size.pipe.ts

@ -32,4 +32,10 @@ export class NamePipe2 implements PipeTransform {
let nameArr = name.split("/")
return nameArr[nameArr.length - 2]
}
}
@Pipe({name: 'name3'})
export class NamePipe3 implements PipeTransform {
transform(name: string): string {
return name.replace(/\//g,'>').substring(9,name.length)
}
}

22
src/app/ui/all-file/all-file.component.ts

@ -235,25 +235,22 @@ export class AllFileComponent {
goback:any //记录上一级目录
//点击列表每一条的名字
clickName(e,item){
// console.log(item)
console.log(e,item)
e.stopPropagation()
if(item.type == "jpg" || item.type == "png" || item.type == "bmp"|| item.type == "gif" || item.type == "jpeg"&& !item.isDir){
const dialogRef = this.dialog.open(ViewDetails, {//调用open方法打开对话框并且携带参数过去
data: {url:item.key,type:"img"}
});
this.downloadFile.handleData(item.key,"查看")
}else if(item.type == "mp4" || item.type == "MP4" && !item.isDir){
console.log(666,item.key)
const dialogRef = this.dialog.open(ViewDetails, {//调用open方法打开对话框并且携带参数过去
width: '1400px',
height:'800px',
data: {url:item.key,type:"video"}
});
dialogRef.afterClosed().subscribe(
);
dialogRef.afterClosed().subscribe();
this.downloadFile.handleData(item.key,"查看")
}else if(item.type == "mp3" || item.type == "MP3"&& !item.isDir){
const dialogRef = this.dialog.open(ViewDetails, {//调用open方法打开对话框并且携带参数过去
@ -261,13 +258,11 @@ export class AllFileComponent {
height:'108px',
data: {url:item.key,type:"mp3"}
});
dialogRef.afterClosed().subscribe(
);
dialogRef.afterClosed().subscribe();
this.downloadFile.handleData(item.key,"查看")
}else if(item.type == "pdf"){
// console.log(item)
window.open("/api/Objects/drives/" + item.key)
this.downloadFile.handleData(item.key,"查看")
}else if(item.type == "gaopenche"){
window.open("GaoPenChe")
@ -310,6 +305,9 @@ export class AllFileComponent {
config.duration = 3000
this.snackBar.open('该文件类型暂不支持在线查看,请下载查看','确定',config)
}
}
//返回上一级目录
backTominTop(){

1
src/app/ui/enterpriseuser/addenterpriseuser.component.ts

@ -55,6 +55,7 @@ export class AddEnterpriserUser {
creationTime : date,
posts : postsObj
}
// console.log(date)
this.http.post("/api/Users",body).subscribe( data => {
this.dialogRef.close(data);
})

2
src/app/ui/enterpriseuser/enterpriseuser.component.html

@ -48,7 +48,7 @@
<ng-container matColumnDef="operation">
<th mat-header-cell *matHeaderCellDef>操作</th>
<td mat-cell *matCellDef="let element">
<span class="operationSpan"><mat-icon class="icon">assessment</mat-icon><span class="spanbtn blue">查看学习记录</span></span>
<span class="operationSpan"><mat-icon class="icon">assessment</mat-icon><span class="spanbtn blue" (click)="openRecord(element)">查看学习记录</span></span>
<span class="operationSpan"><mat-icon class="icon">cached</mat-icon><span class="spanbtn blue" (click)="reset(element)">重置密码</span></span>
<span class="operationSpan"><mat-icon class="icon">edit</mat-icon><span class="spanbtn blue" (click)="edit(element)">修改</span></span>
<span *ngIf="element.enabled" class="operationSpan"><mat-icon class="icon" style="color: rgb(245, 34, 45);">remove_circle</mat-icon><span class="spanbtn blue" (click)="noEnabled(element)">禁用</span></span>

9
src/app/ui/enterpriseuser/enterpriseuser.component.ts

@ -7,7 +7,7 @@ import { PageEvent } from '@angular/material/paginator';
import { AddEnterpriserUser } from './addenterpriseuser.component'
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
import {FormControl} from '@angular/forms';
import { Router,ActivatedRoute } from '@angular/router'
@Component({
selector: 'app-enterpriseuser',
templateUrl: './enterpriseuser.component.html',
@ -15,7 +15,7 @@ import {FormControl} from '@angular/forms';
})
export class EnterpriseuserComponent implements OnInit {
constructor(public http: HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar) { }
constructor(public http: HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,private router:Router,private route:ActivatedRoute) { }
ngOnInit() {
this.initData()
@ -64,7 +64,6 @@ export class EnterpriseuserComponent implements OnInit {
RoleType: '2',
}
this.http.get('/api/Users',{params:data}).subscribe((data:any)=>{
console.log(666,data)
this.length = data.totalCount
this.pageSize = data.pageSize
this.pageEvent.pageIndex = 0
@ -94,6 +93,10 @@ export class EnterpriseuserComponent implements OnInit {
this.initData()
}
//跳转学习记录
openRecord(e){
this.router.navigate([`/home/statistics?name=${e.realName}&id=${e.name}`])
}
//创建用户
open(){
let dialogRef = this.dialog.open(AddEnterpriserUser, {//调用open方法打开对话框并且携带参数过去

49
src/app/ui/learning-record-details/learning-record-details.component.html

@ -0,0 +1,49 @@
<div style="height: 100%; width: 100%;">
<div class="topbox">
<div class="backtop">
<button type="button" mat-raised-button color="primary">返回</button>
</div>
<div class="datasearch">
<div class="starttime">
<span>开始时间 :</span>
<mat-form-field>
<input matInput [matDatepicker]="dp" disabled [formControl]="startdate">
<mat-datepicker-toggle matSuffix [for]="dp"></mat-datepicker-toggle>
<mat-datepicker #dp disabled="false"></mat-datepicker>
</mat-form-field>
</div>
<div class="endtime">
<span>结束时间 :</span>
<mat-form-field>
<input matInput [matDatepicker]="dp2" disabled [formControl]="enddate">
<mat-datepicker-toggle matSuffix [for]="dp2"></mat-datepicker-toggle>
<mat-datepicker #dp2 disabled="false"></mat-datepicker>
</mat-form-field>
</div>
</div>
<div class="btnbox">
<button type="button" mat-raised-button color="primary" (click)="onSubmit()">查询</button>
<button type="button" mat-raised-button (click)="reset()">重置</button>
</div>
</div>
<mat-divider></mat-divider>
<div class="listbox">
<ul>
<li *ngFor="let item of recordList;let key = index">
<p class="timeTitle" *ngIf="key ==0 || item.time != recordList[key - 1].time">{{item.time}}</p>
<span class="listitem">
<span style="margin-right: 5px;">{{item.time2}}</span>
{{item.operation}} : {{item.target | name3}}
</span>
</li>
</ul>
<mat-paginator
[length]="length"
[pageSize]="pageSize"
(page)="chagePage($event)">
</mat-paginator>
</div>
</div>

43
src/app/ui/learning-record-details/learning-record-details.component.scss

@ -0,0 +1,43 @@
.topbox{
display: flex;
width: 100%;
height:7%;
line-height: 66px;
// border-bottom: 1px solid gray;
justify-content: space-around;
.datasearch{
display: flex;
div{
margin: 0 10px;
span{
margin-right: 5px;
}
mat-form-field{
input{
padding-left: 3px;
}
}
}
}
.btnbox{
button{
margin: 0 10px;
}
}
}
.listbox{
margin-top: 18px;
margin-left: 26%;
height: 82%;
overflow-y: auto;
.timeTitle{
font-weight: 800;
font-size: 18px;
}
.listitem{
margin-left: 80px;
font-size: 16px;
line-height: 30px;
}
}

143
src/app/ui/learning-record-details/learning-record-details.component.ts

@ -0,0 +1,143 @@
import { Component, OnInit ,ViewChild} from '@angular/core';
import {DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE} from '@angular/material/core';
import {MatDatepicker} from '@angular/material/datepicker';
import {FormControl} from '@angular/forms';
import {HttpClient} from '@angular/common/http';
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
import { MatPaginator } from '@angular/material/paginator';
import { PageEvent } from '@angular/material/paginator';
import { Router,ActivatedRoute } from '@angular/router'
@Component({
selector: 'app-learning-record-details',
templateUrl: './learning-record-details.component.html',
styleUrls: ['./learning-record-details.component.scss']
})
export class LearningRecordDetailsComponent implements OnInit {
startdate:any //开始时间
enddate:any //结束时间
constructor(private adapter: DateAdapter<any>,private http:HttpClient,public snackBar: MatSnackBar,private router:Router,private route:ActivatedRoute) { }
lastdate:any //上个月日期
startTime:any //开始时间查询条件
endTime:any //结束时间查询条件
Catalog:any = this.route.snapshot.queryParams.Catalog || "" //目录
PageNumber:any = 1//当前页数
id:any = this.route.snapshot.queryParams.id//身份证
recordList:any//渲染的100条列表
oneMonthDate:number = 30*24*60*60*1000; //一个月的时间戳
//分页
@ViewChild(MatPaginator, {static: true})
pageEvent: PageEvent;
paginator: MatPaginator;
length:any; //共多少条数据
pageSize:any; //每页条数
// pageSizeOptions: number[] = [10] //设置每页条数
pageNumber:number = 1; //第几页
ngOnInit(): void {
this.adapter.setLocale('CH');
let nowdate = new Date().toLocaleDateString() //本月日期 2020/07/11 形式
this.lastdate = new Date(new Date().getTime()-this.oneMonthDate).toLocaleDateString() //上个月日期 2020/06/11 形式
this.startdate = new FormControl(new Date(this.lastdate)); //日历开始时间显示
this.enddate = new FormControl(new Date()); //日历结束时间显示
this.startTime = this.getTIme(new Date(this.lastdate))
this.endTime = this.getTIme(new Date())
this.getAllStudyRecords()
}
//分页切换
chagePage (e) {
this.pageNumber = e.pageIndex+1
let date:any = new Date()
let data = {
Name : this.id,
StartTime : this.startTime,
EndTime : this.endTime,
Catalog : this.Catalog,
PageNumber : String(this.pageNumber),
PageSize:"100"
}
this.http.get("/api/StudyRecords",{params:data}).subscribe((data:any) => {
this.recordList = data.items
this.recordList.forEach((item) => {
item.time = item.creationTime.substring(0,10)
item.time2 = item.creationTime.substring(11,16)
})
this.length = data.totalCount
this.pageSize = data.pageSize
})
}
//传入 new Date()格式 将日期变为 年月日时分秒
getTIme(date){
let year = date.getFullYear(); //年
let month = date.getMonth() + 1; //月
let day = date.getDate(); //日
let hour = date.getHours() //时
let min = date.getMinutes(); //分
let seconds = date.getSeconds(); //秒
return year+'-'+month+'-'+ day + " "+ hour +':'+ min +':'+ seconds;
}
//获得所有学习记录
getAllStudyRecords(){
let date:any = new Date()
let data = {
Name : this.id,
StartTime : this.startTime,
EndTime : this.endTime,
Catalog : this.Catalog || "",
PageNumber : this.PageNumber,
PageSize:"100"
}
this.http.get("/api/StudyRecords",{params:data}).subscribe((data:any) => {
this.recordList = data.items
this.recordList.forEach((item) => {
item.time = item.creationTime.substring(0,10)
item.time2 = item.creationTime.substring(11,16)
})
this.length = data.totalCount
this.pageSize = data.pageSize
this.pageEvent.pageIndex = 0
})
}
//查询
onSubmit(){
if(this.startdate.value > this.enddate.value){
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('起始时间大于结束时间','确定',config);
}
if(this.enddate.value.toLocaleDateString() == new Date().toLocaleDateString() || this.enddate.value > new Date()){
this.enddate.value = new Date()
}
if(this.enddate.value < new Date() && this.enddate.value.toLocaleDateString() != new Date().toLocaleDateString()){
this.enddate.value = new Date(this.enddate.value.getTime() + 24*60*60*1000)
}
this.startTime = this.getTIme(this.startdate.value)
this.endTime = this.getTIme(this.enddate.value)
this.getAllStudyRecords()
}
//重置
reset(){
this.startdate = new FormControl(new Date(this.lastdate)); //日历开始时间显示
this.enddate = new FormControl(new Date()); //日历结束时间显示
this.startTime = this.getTIme(this.startdate.value)
this.endTime = this.getTIme(this.enddate.value)
this.getAllStudyRecords()
}
}

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

@ -3,10 +3,12 @@ import { NgModule } from '@angular/core';
import { AllFileComponent } from './all-file/all-file.component';
import { EnterpriseuserComponent } from './enterpriseuser/enterpriseuser.component';
import { TeacherManagementComponent } from './teacherManagement/enterpriseuser.component';
import { LearningRecordDetailsComponent } from './learning-record-details/learning-record-details.component';
const routes: Routes = [
{ path: '', component:AllFileComponent },
{ path: 'userManagement', component:EnterpriseuserComponent },
{ path: 'teacherManagement', component:TeacherManagementComponent }
{ path: 'teacherManagement', component:TeacherManagementComponent },
{ path: 'learningrecorddetails', component:LearningRecordDetailsComponent }
];
@NgModule({

5
src/app/ui/ui.module.ts

@ -47,7 +47,7 @@ import { MatFormFieldModule } from '@angular/material/form-field';
import { MatPaginatorIntl } from '@angular/material/paginator';
import { PersonaldataComponent } from '../pages/personaldata/personaldata.component';
import { ChangepasswordComponent } from './changepassword/changepassword.component';
import { SizePipe , NamePipe,NamePipe2} from '../pipes/size.pipe';
import { SizePipe , NamePipe,NamePipe2, NamePipe3} from '../pipes/size.pipe';
import {ConfirmpswDirective} from './changepassword/equal-validator.directive';
import { FileUploadModule } from 'ng2-file-upload'
import { AllFileComponent, ViewDetails, FolderDialog } from './all-file/all-file.component';
@ -60,8 +60,9 @@ import {EnterpriseuserComponent,editenterpriseuser,seeenterpriseuser} from './en
import { myPaginator } from "./my-paginator"
import { TeacherManagementComponent, editTeacher, seeTeacher } from './teacherManagement/enterpriseuser.component';
import { AddTeacher } from './teacherManagement/addenterpriseuser.component';
import { LearningRecordDetailsComponent } from './learning-record-details/learning-record-details.component';
@NgModule({
declarations: [FolderDialog,ViewDetails,PersonaldataComponent, ChangepasswordComponent,SizePipe,NamePipe,NamePipe2,ConfirmpswDirective, AllFileComponent, ChangeuserdataComponent, LoginComponent, UploadFilesComponent,AddEnterpriserUser,EnterpriseuserComponent,editenterpriseuser,seeenterpriseuser,TeacherManagementComponent,editTeacher,AddTeacher,seeTeacher],
declarations: [FolderDialog,ViewDetails,PersonaldataComponent, ChangepasswordComponent,SizePipe,NamePipe,NamePipe2,NamePipe3,ConfirmpswDirective, AllFileComponent, ChangeuserdataComponent, LoginComponent, UploadFilesComponent,AddEnterpriserUser,EnterpriseuserComponent,editenterpriseuser,seeenterpriseuser,TeacherManagementComponent,editTeacher,AddTeacher,seeTeacher, LearningRecordDetailsComponent],
imports: [
CommonModule,

3
tsconfig.json

@ -17,7 +17,8 @@
"lib": [
"es2018",
"dom"
]
],
"allowSyntheticDefaultImports": true
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,

Loading…
Cancel
Save