Browse Source

[新增]测试新建文件夹接口

master
邵佳豪 5 years ago
parent
commit
a6ae1ad807
  1. 4
      src/app/ui/all-file/all-file.component.html
  2. 8
      src/app/ui/all-file/all-file.component.scss
  3. 61
      src/app/ui/all-file/all-file.component.ts
  4. 15
      src/app/ui/all-file/folderdalog.html
  5. 4
      src/app/ui/ui.module.ts

4
src/app/ui/all-file/all-file.component.html

@ -17,9 +17,9 @@
</div>
</div>
</div>
<!-- <div class="newFile" (click)="yyy()" *ngIf="downloadFile.isLogin">
<div class="newFile" (click)="createFolder()" *ngIf="downloadFile.isLogin">
<mat-icon>create_new_folder</mat-icon> <span>新建文件夹</span>
</div> -->
</div>
<div class="newFile" style="width: 88px;" *ngIf="isDelete" (click)='downLoadFile()'>
<mat-icon>save_alt</mat-icon> <span>下载</span>
</div>

8
src/app/ui/all-file/all-file.component.scss

@ -193,4 +193,12 @@
}
}
}
}
.btn{
width: 100%;
text-align: center;
button{
margin: 0 5px;
}
}

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

@ -233,7 +233,7 @@ export class AllFileComponent implements OnInit {
fileArr:any
//文件夹
//上传文件夹
selectFiles (e) {
this.fileArr = e.target.files || null //上传的文件
console.log(this.fileArr.length)
@ -247,7 +247,27 @@ export class AllFileComponent implements OnInit {
this.downloadFile.startUploading(f,adddress)
}
}
//新建文件夹
createFolder(){
const dialogRef = this.dialog.open(FolderDialog, {//调用open方法打开对话框并且携带参数过去
// width: '1600px',
// height:'900px',
data: {}
});
dialogRef.afterClosed().subscribe((data)=>{
if(data){
console.log(data)
//创建空文件夹
this.http.post(`/api/Objects/drives/${this.selectedDataBank}/`,"").subscribe(data=>{
this.getALLFileList(this.selectedDataBank)
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('新建文件夹成功','确定',config)
})
}
});
}
@ -401,7 +421,7 @@ export class AllFileComponent implements OnInit {
}
//查看图片大图和视频
@Component({
selector: 'viewdetails',
templateUrl: './viewdetails.html',
@ -421,4 +441,39 @@ export class ViewDetails {
}
}
@Component({
selector: 'folderdalog',
templateUrl: './folderdalog.html',
styleUrls: ['./all-file.component.scss']
})
export class FolderDialog {
// myControl = new FormControl();
//注入MatDialogRef,可以用来关闭对话框
//要访问对话框组件中的数据,必须使用MAT_DIALOG_DATA注入令牌
constructor(private http: HttpClient,public dialogRef: MatDialogRef<FolderDialog>,@Inject(MAT_DIALOG_DATA) public data) {}
newFolderName:string
onNoClick(): void {
this.dialogRef.close();
}
ngOnInit(): void {
var myDate = new Date();
var year = myDate.getFullYear();
var month = myDate.getMonth();
var day = myDate.getDate();
var hour = myDate.getHours(); //获取当前小时数(0-23)
var minutes = myDate.getMinutes(); //获取当前分钟数(0-59)
var seconds = myDate.getSeconds(); //获取当前秒数(0-59)
var data = year + '' + month + day + hour + minutes + seconds
this.newFolderName = "新建文件夹_" + data;
}
onSubmit(value){
this.dialogRef.close(value);
}
}

15
src/app/ui/all-file/folderdalog.html

@ -0,0 +1,15 @@
<form (ngSubmit)="onSubmit(form.value)" #form="ngForm" class="example-container">
<mat-form-field>
<input matInput id="name" name="name" type='text'
required
style="font-size: 12px;"
[(ngModel)]="newFolderName" placeholder="创建新文件夹名称">
</mat-form-field>
<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>取消</button>
</div>
</form>

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

@ -50,12 +50,12 @@ import { ChangepasswordComponent } from './changepassword/changepassword.compone
import { SizePipe , NamePipe} from '../pipes/size.pipe';
import {ConfirmpswDirective} from './changepassword/equal-validator.directive';
import { FileUploadModule } from 'ng2-file-upload'
import { AllFileComponent, ViewDetails } from './all-file/all-file.component';
import { AllFileComponent, ViewDetails, FolderDialog } from './all-file/all-file.component';
import { ChangeuserdataComponent } from './changeuserdata/changeuserdata.component';
import { LoginComponent } from './login/login.component';
@NgModule({
declarations: [ViewDetails,PersonaldataComponent, ChangepasswordComponent,SizePipe,NamePipe,ConfirmpswDirective, AllFileComponent, ChangeuserdataComponent, LoginComponent],
declarations: [FolderDialog,ViewDetails,PersonaldataComponent, ChangepasswordComponent,SizePipe,NamePipe,ConfirmpswDirective, AllFileComponent, ChangeuserdataComponent, LoginComponent],
imports: [
CommonModule,

Loading…
Cancel
Save