From bffeb0ab6369ce65ed3fdec54b430b12abc8cfde Mon Sep 17 00:00:00 2001 From: cpf <1105965053@qq.com> Date: Wed, 15 Jul 2020 11:45:16 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BF=AE=E6=AD=A3]=20=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=B9=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proxy.config.json | 2 +- src/app/ui/all-file/all-file.component.ts | 109 +++++++++++++--------- 2 files changed, 66 insertions(+), 45 deletions(-) diff --git a/proxy.config.json b/proxy.config.json index 482ddf5..4498db3 100644 --- a/proxy.config.json +++ b/proxy.config.json @@ -1,6 +1,6 @@ { "/api": { - "target": "http://192.168.110.109:8100", + "target": "http://121.37.20.190:8100", "secure": false, "changeOrigin": true } diff --git a/src/app/ui/all-file/all-file.component.ts b/src/app/ui/all-file/all-file.component.ts index 0eacd9a..017c49a 100644 --- a/src/app/ui/all-file/all-file.component.ts +++ b/src/app/ui/all-file/all-file.component.ts @@ -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 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 - } - 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 + 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) - - }) - }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) - }) - } + 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();