Compare commits

...

2 Commits

  1. 2
      package.json
  2. 4
      src/app/system-management/organization/change-or/change-or.component.html
  3. 4
      src/app/system-management/organization/change-or/change-or.component.scss
  4. 25
      src/app/system-management/organization/change-or/change-or.component.spec.ts
  5. 55
      src/app/system-management/organization/change-or/change-or.component.ts
  6. 3
      src/app/system-management/organization/organization.component.html
  7. 46
      src/app/system-management/organization/organization.component.ts
  8. 2
      src/app/system-management/system-management.module.ts

2
package.json

@ -3,7 +3,7 @@
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.config.json --open --port 1234 ",
"start": "ng serve --proxy-config proxy.config.json --open --port 1234 --host 192.168.1.82",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"

4
src/app/system-management/organization/change-or/change-or.component.html

@ -0,0 +1,4 @@
<div class="box">
<nz-tree #nzTreeComponent [nzSelectedKeys]="defaultSelectedKeys" [nzData]="nodes"
[nzExpandedKeys]="defaultExpandedKeys"></nz-tree>
</div>

4
src/app/system-management/organization/change-or/change-or.component.scss

@ -0,0 +1,4 @@
.box {
max-height: 500px;
overflow-y: auto;
}

25
src/app/system-management/organization/change-or/change-or.component.spec.ts

@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ChangeOrComponent } from './change-or.component';
describe('ChangeOrComponent', () => {
let component: ChangeOrComponent;
let fixture: ComponentFixture<ChangeOrComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ChangeOrComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ChangeOrComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

55
src/app/system-management/organization/change-or/change-or.component.ts

@ -0,0 +1,55 @@
import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { HttpClient } from '@angular/common/http';
import { TreeService } from 'src/app/service/tree.service';
import { NzTreeComponent } from 'ng-zorro-antd/tree';
@Component({
selector: 'app-change-or',
templateUrl: './change-or.component.html',
styleUrls: ['./change-or.component.scss'],
})
export class ChangeOrComponent implements OnInit {
@Input() data?: any;
@ViewChild('nzTreeComponent', { static: false })
nzTreeComponent!: NzTreeComponent;
constructor(
private modal: NzModalRef,
private fb: FormBuilder,
private http: HttpClient,
private toTree: TreeService
) {}
defaultExpandedKeys = [];
defaultSelectedKeys = [];
ngOnInit(): void {
this.getAllOrganization();
// this.nzTreeComponent.getCheckedNodeList()
}
allOrList: any;
nodes: any;
getAllOrganization() {
let params = {
ContainsChildren: true,
pageSize: 9999,
};
this.http
.get('/api/Organizations', {
params: params,
})
.subscribe((data: any) => {
data.items.forEach((element) => {
element.key = element.id;
element.title = element.name;
});
this.allOrList = data.items.filter((v) => !v.isGasStation);
this.nodes = [...this.toTree.toTree(this.allOrList)];
});
}
destroyModal(): void {
this.modal.destroy({ data: 'this the result data' });
}
}

3
src/app/system-management/organization/organization.component.html

@ -17,13 +17,14 @@
</div>
<nz-tree [nzHideUnMatched]='true' [nzSearchValue]="searchValue" #nzTreeComponent [nzData]="nodes"
[nzExpandAll]="nzExpandAll" [nzExpandedKeys]="defaultExpandedKeys" nzDraggable nzBlockNode
(nzOnDrop)="nzEvent($event)" [nzBeforeDrop]="beforeDrop">
(nzOnDrop)="nzEvent($event)" [nzBeforeDrop]="beforeDrop" [nzTreeTemplate]="nzTreeTemplate">
</nz-tree>
<ng-template #nzTreeTemplate let-node let-origin="origin">
<div class="nodebox">
<span class="name">{{ node.title }}</span>
<span class="operation">
<span class="blue" (click)="addOr(node)" *ngIf="!node.origin.isGasStation">新增</span>
<span class="blue" (click)="changeOr(node)">修改所属机构</span>
<span class="blue" (click)="editOr(node)">编辑</span>
<span class="red" (click)="deleteOr(node)">删除</span>
</span>

46
src/app/system-management/organization/organization.component.ts

@ -22,6 +22,7 @@ import { NzFormatBeforeDropEvent } from 'ng-zorro-antd/tree';
import { Observable, of } from 'rxjs';
import { delay } from 'rxjs/operators';
import { CustomReuseStrategy } from 'src/app/CustomReuseStrategy';
import { ChangeOrComponent } from './change-or/change-or.component';
@Component({
selector: 'app-organization',
templateUrl: './organization.component.html',
@ -84,10 +85,7 @@ export class OrganizationComponent implements OnInit {
allOrList: any;
getAllOrganization() {
let OrganizationUnitId = '';
let params = {
// OrganizationUnitId: OrganizationUnitId,
// IsContainsChildren: "true"
ContainsChildren: true,
pageSize: 9999,
};
@ -193,6 +191,48 @@ export class OrganizationComponent implements OnInit {
});
const instance = modal.getContentComponent();
}
changeOr(node) {
console.log(node);
const modal = this.modal.create({
nzTitle: '修改所属组织机构',
nzContent: ChangeOrComponent,
nzViewContainerRef: this.viewContainerRef,
nzWidth: 500,
nzComponentParams: {
data: this.allOrList,
},
nzOnOk: async () => {
let selectedNode =
instance.nzTreeComponent.getSelectedNodeList()[0].key;
if (selectedNode) {
await new Promise((resolve) => {
let body = {
parentId: selectedNode,
isGasStation: node.origin.isGasStation,
};
this.http
.put(`/api/Organizations/${node.origin.id}`, body)
.subscribe((data) => {
resolve(data);
this.message.create('success', '修改成功!');
this.nzTreeComponent.getExpandedNodeList().forEach((item) => {
this.defaultExpandedKeys.push(item.key);
});
this.getAllOrganization();
return true;
});
});
} else {
this.message.create('warning', '请选择机构!');
return false;
}
},
});
const instance = modal.getContentComponent();
}
deleteOr(item) {
console.log(item);
if (item.origin.children && item.origin.children.length != 0) {

2
src/app/system-management/system-management.module.ts

@ -52,6 +52,7 @@ import { AnxinConfigComponent } from './host-config/anxin-config/anxin-config.co
import { DragDropModule } from '@angular/cdk/drag-drop';
import { IframeComponent } from './iframe/iframe.component';
import { WorkerTagComponent } from './analysis-of-the-host/worker-tag/worker-tag.component';
import { ChangeOrComponent } from './organization/change-or/change-or.component';
@NgModule({
declarations: [
OrganizationComponent,
@ -84,6 +85,7 @@ import { WorkerTagComponent } from './analysis-of-the-host/worker-tag/worker-tag
AnxinConfigComponent,
IframeComponent,
WorkerTagComponent,
ChangeOrComponent,
],
imports: [
CommonModule,

Loading…
Cancel
Save