import { Component, OnInit, TemplateRef, ViewChild, ViewContainerRef, } from "@angular/core"; import { FormBuilder, FormGroup } from "@angular/forms"; import { NzFormatEmitEvent } from "ng-zorro-antd/tree"; import { NzModalService } from "ng-zorro-antd/modal"; import { NzMessageService } from "ng-zorro-antd/message"; import { HttpClient } from "@angular/common/http"; import { TreeService } from "src/app/service/tree.service"; import { NzNotificationService } from "ng-zorro-antd/notification"; import { OrBindingModelComponent } from "./or-binding-model/or-binding-model.component"; // import { BindingComponent } from "./binding/binding.component"; @Component({ selector: "app-or-binding", templateUrl: "./or-binding.component.html", styleUrls: ["./or-binding.component.scss"], }) export class OrBindingComponent implements OnInit { validateForm!: FormGroup; constructor( private fb: FormBuilder, private http: HttpClient, private toTree: TreeService, private modal: NzModalService, private message: NzMessageService, private viewContainerRef: ViewContainerRef ) {} ngOnInit(): void { this.validateForm = this.fb.group({ search: [null], }); this.getAllOr(); // this.getAllOrganization(); } listConfig = { loading: false, usersLIst: [], totalCount: 0, IsContainsChildren: true, searchValue: "", OrganizationUnitId: "", IsBindingLocal: true, }; getAllOr() { this.listConfig.loading = true; let params = { Keyword: this.validateForm.value.search ? this.validateForm.value.search : "", SkipCount: String(this.SkipCount), MaxResultCount: String(this.MaxResultCount), // OrganizationUnitId: this.OrganizationUnitId, IsBindingLocal: this.listConfig.IsBindingLocal, // IsActive:true, // IsContainsChildren: String(this.listConfig.IsContainsChildren), }; this.http .get(this.getAllUrl, { params: params, }) .subscribe((data: any) => { console.log("中台组织机构列表", data); data.result.items.forEach((element) => { element.detail = JSON.parse(element.detail); }); this.listConfig.usersLIst = data.result.items; this.listConfig.totalCount = data.result.totalCount; this.listConfig.loading = false; }); } SkipCount: number = 0; //0 16 32 48 MaxResultCount: number = 16; pageChange($event) { this.SkipCount = ($event - 1) * this.MaxResultCount; this.getAllOr(); } getAllUrl = "/api/services/app/Organization/GetSinochemOrgs"; //搜索框提交 submitForm(): void { for (const i in this.validateForm.controls) { this.validateForm.controls[i].markAsDirty(); this.validateForm.controls[i].updateValueAndValidity(); } this.getAllOr(); } getOrganType(type) { let obj = { "00": "总公司", "01": "省公司", "05": "管理部门", "06": "大区公司", "07": "模块", "08": "管理区域", "09": "省子公司", "10": "油站网点/线上商城", "11": "油库", }; return obj[type]; } binding(data) { const modal = this.modal.create({ nzTitle: "绑定本地机构", nzContent: OrBindingModelComponent, nzViewContainerRef: this.viewContainerRef, nzWidth: 1500, nzFooter: null, nzMaskClosable: false, nzComponentParams: { data: JSON.parse(JSON.stringify(data)), }, }); const instance = modal.getContentComponent(); modal.afterClose.subscribe((result) => this.getAllOr()); } // sync() { // this.http // .post("/api/services/app/OrganizationSync/AutoSinochemOrgRelate", null) // .subscribe((data: any) => { // this.message.create("success", "同步成功"); // }); // } syncOr() { this.http .post("/api/services/app/OrganizationSync/SyncOrgFromSinochem", null) .subscribe(() => { this.http .post( "/api/services/app/OrganizationSync/AutoSinochemOrgRelate", null ) .subscribe(() => { this.message.create("success", "同步成功"); }); }); } syncUser() { this.http .post("/api/services/app/OrganizationSync/SyncUserFromSinochem", null) .subscribe(() => { this.message.create("success", "同步成功"); }); } }