|
|
|
@ -8,6 +8,7 @@ import { IsLoginService } from '../../is-login.service'
|
|
|
|
|
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; |
|
|
|
|
import {UploadFilesComponent} from '../upload-files/upload-files.component' |
|
|
|
|
import { ComponentServiceService } from '../../component-service.service' |
|
|
|
|
import { element } from 'protractor'; |
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-all-file', |
|
|
|
|
templateUrl: './all-file.component.html', |
|
|
|
@ -705,59 +706,79 @@ export class AllFileComponent {
|
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
isTrueDelete:any = ['基础知识','装备','技战术','消防设施','资料库']; //匹配内置一级目录 是否被选择删除
|
|
|
|
|
// 删除文件
|
|
|
|
|
deleteFiles(){ |
|
|
|
|
if (this.selection.selected.length != 0) { |
|
|
|
|
let isDelete = confirm('您确定要删除选中文件吗') |
|
|
|
|
let arr = [] |
|
|
|
|
if (isDelete) { |
|
|
|
|
this.selection.selected.forEach( async (element,index) => { |
|
|
|
|
|
|
|
|
|
let result = await new Promise((result,reject)=>{ |
|
|
|
|
if(element.isDir){ //如果是文件夹
|
|
|
|
|
// let lastIndex = element.key.lastIndexOf("/")
|
|
|
|
|
// let prefix = element.key.substring(0,lastIndex)
|
|
|
|
|
let paramsdata:any = { |
|
|
|
|
prefix : element.key, |
|
|
|
|
recursive : true |
|
|
|
|
} |
|
|
|
|
this.http.delete(`/api/Objects/drives`,{ |
|
|
|
|
params:paramsdata |
|
|
|
|
}).subscribe(data=>{ |
|
|
|
|
arr.push("删除成功了") |
|
|
|
|
if (arr.length == this.selection.selected.length) { |
|
|
|
|
this.getALLFileList(this.selectedDataBank) |
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('删除文件成功','确定',config); |
|
|
|
|
this.selection.clear() |
|
|
|
|
this.isDelete = false |
|
|
|
|
} |
|
|
|
|
result(data) |
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
}else{ |
|
|
|
|
this.http.delete(`/api/Objects/drives/${element.key}`).subscribe(data=>{ |
|
|
|
|
arr.push("删除成功了") |
|
|
|
|
if (arr.length == this.selection.selected.length) { |
|
|
|
|
this.getALLFileList(this.selectedDataBank) |
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('删除文件成功','确定',config); |
|
|
|
|
this.selection.clear() |
|
|
|
|
this.isDelete = false |
|
|
|
|
let notDelete = [] //所有要删除文件 的 一级目录
|
|
|
|
|
let arrList = [] //匹配到 禁止删除的 目录
|
|
|
|
|
this.selection.selected.forEach((element)=>{ |
|
|
|
|
let data = element.key.split("/"); |
|
|
|
|
notDelete.push(data[2]) |
|
|
|
|
}) |
|
|
|
|
this.isTrueDelete.forEach(element => { |
|
|
|
|
notDelete.forEach(elements=>{ |
|
|
|
|
if (element==elements) { arrList.push('true') } |
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
if (arrList.length) { |
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('内置文件夹不允许删除','确定',config); |
|
|
|
|
} else { |
|
|
|
|
this.selection.selected.forEach( async (element,index) => { |
|
|
|
|
|
|
|
|
|
let result = await new Promise((result,reject)=>{ |
|
|
|
|
if(element.isDir){ //如果是文件夹
|
|
|
|
|
// let lastIndex = element.key.lastIndexOf("/")
|
|
|
|
|
// let prefix = element.key.substring(0,lastIndex)
|
|
|
|
|
let paramsdata:any = { |
|
|
|
|
prefix : element.key, |
|
|
|
|
recursive : true |
|
|
|
|
} |
|
|
|
|
result(data) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
this.http.delete(`/api/Objects/drives`,{ |
|
|
|
|
params:paramsdata |
|
|
|
|
}).subscribe(data=>{ |
|
|
|
|
arr.push("删除成功了") |
|
|
|
|
if (arr.length == this.selection.selected.length) { |
|
|
|
|
this.getALLFileList(this.selectedDataBank) |
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('删除文件成功','确定',config); |
|
|
|
|
this.selection.clear() |
|
|
|
|
this.isDelete = false |
|
|
|
|
} |
|
|
|
|
result(data) |
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
}else{ |
|
|
|
|
this.http.delete(`/api/Objects/drives/${element.key}`).subscribe(data=>{ |
|
|
|
|
arr.push("删除成功了") |
|
|
|
|
if (arr.length == this.selection.selected.length) { |
|
|
|
|
this.getALLFileList(this.selectedDataBank) |
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('删除文件成功','确定',config); |
|
|
|
|
this.selection.clear() |
|
|
|
|
this.isDelete = false |
|
|
|
|
} |
|
|
|
|
result(data) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
} // if arrList
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|