Browse Source

[完善]新建文件夹功能基本完成

master
陈鹏飞 5 years ago
parent
commit
2952e2c484
  1. 3
      src/app/ui/all-file/all-file.component.html
  2. 57
      src/app/ui/all-file/all-file.component.ts

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

@ -56,7 +56,7 @@
</ng-container>
<ng-template #elseTemplate>
<div class="titleleft">
<span class="goBack">返回上一级</span>
<span class="goBack" (click)='backToTop()' *ngIf="selectedDataBank.includes('/')">返回顶级目录</span>
<span style="margin: 0 3px;color: #c5d8f3;">|</span>
<span class="allFile" (click)="allFile()">全部文件</span>
</div>
@ -99,6 +99,7 @@
<img *ngIf="element.type == 'bmp'" src="../../../assets/images/bmp.png" alt="">
<img *ngIf="element.type == 'txt'" src="../../../assets/images/txt.png" alt="">
<img *ngIf="element.type == 'pptx'" src="../../../assets/images/ppt.png" alt="">
<img *ngIf="element.isDir" src="../../../assets/images/file.png" alt="">
<i class="iconfont icon-mp"></i>
<span class="filename" (click)="clickName($event,element)">
{{element.key | name}}

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

@ -74,7 +74,8 @@ export class AllFileComponent implements OnInit {
getALLFileList(name){
this.selectedDataBank = name
let paramsdata = {
prefix : this.selectedDataBank
prefix : this.selectedDataBank + "/",
delimiter : "/"
}
this.http.get(`/api/Objects/drives`,{
params:paramsdata
@ -249,26 +250,28 @@ export class AllFileComponent implements OnInit {
}
//新建文件夹
createFolder(){
const dialogRef = this.dialog.open(FolderDialog, {//调用open方法打开对话框并且携带参数过去
// width: '1600px',
// height:'900px',
data: {}
});
const dialogRef = this.dialog.open(FolderDialog);
dialogRef.afterClosed().subscribe((data)=>{
if(data){
console.log(data)
console.log(data,this.selectedDataBank)
//创建空文件夹
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)
this.http.post(`/api/Objects/drives/${this.selectedDataBank}/${data.name}/`,{}).subscribe(data=>{
console.log(data)
// this.getALLFileList(this.selectedDataBank)
// const config = new MatSnackBarConfig();
// config.verticalPosition = 'top';
// config.duration = 3000
// this.snackBar.open('新建文件夹成功','确定',config)
})
}
} //if
});
}
//返回顶级目录
backToTop () {
console.log(this.selectedDataBank,'返回')
}
//上传文件
@ -451,24 +454,25 @@ export class ViewDetails {
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;
// 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){
@ -476,4 +480,5 @@ export class FolderDialog {
}
}
Loading…
Cancel
Save