Skip to content

Commit

Permalink
文件策略重新加载时,隐藏空节点状态还原
Browse files Browse the repository at this point in the history
  • Loading branch information
qichangjun committed Jul 28, 2021
1 parent 0f99974 commit 2e5919f
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion projects/recordinfo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "recordinfo",
"version": "1.4.228",
"version": "1.4.231",
"repository": {
"type": "git",
"url": "https://github.com/qichangjun/ad-record-info"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
</mat-radio-group>
</div>
<div class="select--node--upload--box">
<nz-switch
*ngIf="currentPolicy!='default'"
nzCheckedChildren="隐藏空节点" nzUnCheckedChildren="显示空节点"
[(ngModel)]="hideEmptyNode" (ngModelChange)="toggleShowType($event)"></nz-switch>

<div
[ngClass]="{hasData : ((currentPolicy=='default' && defaultFileLists.length > 0) || (currentPolicy!='default' && policyInfo.children.length>0))}"
class="head" class="head">电子文件:</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export class addElectronicDocumentComponent implements OnInit, OnChanges {
relativePath: any//上传时候的relativePath
hasNoFileBlock: boolean = false
firstInitServerFilesFinished: boolean = false
hideEmptyNode : boolean = true
currentFile : string = ''
path:path
@ViewChild('fileTree') fileTree : any
Expand Down Expand Up @@ -179,6 +180,7 @@ export class addElectronicDocumentComponent implements OnInit, OnChanges {
// 若有,则调用formatPoolicyInfo方法,把jsonData中的文件集合初始化到policy的json中
async getPolicyInfo() {
let policyInfo
this.hideEmptyNode = true
this.firstInitServerFilesFinished = false
this.policyLists = await this.getPolicyInfoPomise(this.metadataSchemeId)
let block = JSONPath.JSONPath({ path: this.fileJsonPath, json: this.jsonMetadataTemplate, resultType: 'all' })
Expand Down Expand Up @@ -699,6 +701,38 @@ export class addElectronicDocumentComponent implements OnInit, OnChanges {
}
}

toggleShowType(e?){
this.fileTree.nzNodes.forEach((node:NzTreeNode)=>{
this.toggleNodeDisplay(node)
})
}

toggleNodeDisplay(node){
let result = this.checkHasFileNode(node)
if(!result){
node.component.elRef.nativeElement.style.display =
node.component.elRef.nativeElement.style.display == 'none' ? '' : 'none'
}
node.getChildren().forEach(child=>{
this.toggleNodeDisplay(child)
})
}

checkHasFileNode(node:NzTreeNode):boolean{
let hasFileNode : boolean = false
function checkChildren(child:NzTreeNode){
if(child.origin.type == 'file'){
hasFileNode = true
return
}
child.getChildren().forEach(s_children => {
checkChildren(s_children)
});
}
checkChildren(node)
return hasFileNode
}

/**
* 根据key找到文件资料节点
* @param key 节点的key,不传时默认查当前节点的key
Expand Down
2 changes: 2 additions & 0 deletions projects/recordinfo/src/lib/recordinfo.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { NzIconModule } from 'ng-zorro-antd';
import { NzProgressModule } from 'ng-zorro-antd';
import { NzPopoverModule } from 'ng-zorro-antd';

import { NzSwitchModule } from 'ng-zorro-antd';
import { registerLocaleData } from '@angular/common';
import zh from '@angular/common/locales/zh';
registerLocaleData(zh);
Expand All @@ -49,6 +50,7 @@ registerLocaleData(zh);
NzInputModule,
FileUploadModule,
NzTreeSelectModule,
NzSwitchModule,
NzSelectModule,
MatProgressSpinnerModule,
MatDialogModule,
Expand Down
1 change: 1 addition & 0 deletions src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }
@import "~ng-zorro-antd/progress/style/index.min.css"; /* 下拉 */

@import "~ng-zorro-antd/popover/style/index.min.css"; /* 折叠板 */
@import "~ng-zorro-antd/switch/style/index.min.css"; /* 折叠板 */
.drag-over-gap-bottom{
border-bottom:2px solid #1890ff;
}
Expand Down

0 comments on commit 2e5919f

Please sign in to comment.