|
|
|
import { Component, OnInit, TemplateRef, ViewContainerRef } from '@angular/core';
|
|
|
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
|
|
|
import { NzFormatEmitEvent, NzTreeComponent, NzTreeNodeOptions } 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 { ApplyComponent } from './apply/apply.component';
|
|
|
|
import { ApplyLookComponent } from './apply-look/apply-look.component';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-station-task-apply',
|
|
|
|
templateUrl: './station-task-apply.component.html',
|
|
|
|
styleUrls: ['./station-task-apply.component.scss']
|
|
|
|
})
|
|
|
|
export class StationTaskApplyComponent implements OnInit {
|
|
|
|
|
|
|
|
validateForm!: FormGroup;
|
|
|
|
constructor(private fb: FormBuilder, private modal: NzModalService, private viewContainerRef: ViewContainerRef, private message: NzMessageService, private http: HttpClient, private toTree: TreeService) { }
|
|
|
|
searchForm = {
|
|
|
|
taskname: '',
|
|
|
|
unitname: '',
|
|
|
|
unitlevel: '',
|
|
|
|
or: ''
|
|
|
|
}
|
|
|
|
OrganizationId
|
|
|
|
ngOnInit(): void {
|
|
|
|
this.OrganizationId = JSON.parse(sessionStorage.getItem('userData')).organizationId
|
|
|
|
this.getAllOrganization()
|
|
|
|
this.getTaskList()
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cancel(item, type) {
|
|
|
|
|
|
|
|
}
|
|
|
|
delete(item) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
nzLoading = false
|
|
|
|
totalCount
|
|
|
|
PageNumber = 1
|
|
|
|
PageSize = 10
|
|
|
|
taskLIst = []
|
|
|
|
getTaskList() {
|
|
|
|
this.nzLoading = true
|
|
|
|
let params = {
|
|
|
|
OrganizationId: this.OrganizationId,
|
|
|
|
TaskName: this.searchForm.taskname,
|
|
|
|
CompanyName: this.searchForm.unitname,
|
|
|
|
AssitantOrganizationId: this.searchForm.or,
|
|
|
|
PageNumber: this.PageNumber,
|
|
|
|
PageSize: this.PageSize
|
|
|
|
}
|
|
|
|
this.http.get('/api/PlanTasks', {
|
|
|
|
params: params
|
|
|
|
}).subscribe((data: any) => {
|
|
|
|
this.nzLoading = false
|
|
|
|
console.log('任务申请列表', data);
|
|
|
|
this.totalCount = data.totalCount
|
|
|
|
this.taskLIst = [...data.items]
|
|
|
|
})
|
|
|
|
}
|
|
|
|
pageChange($event) {
|
|
|
|
this.PageNumber = $event
|
|
|
|
this.getTaskList()
|
|
|
|
}
|
|
|
|
search() {
|
|
|
|
this.PageNumber = 1
|
|
|
|
this.getTaskList()
|
|
|
|
}
|
|
|
|
reset() {
|
|
|
|
this.PageNumber = 1
|
|
|
|
this.searchForm = {
|
|
|
|
taskname: '',
|
|
|
|
unitname: '',
|
|
|
|
unitlevel: '',
|
|
|
|
or: ''
|
|
|
|
}
|
|
|
|
this.getTaskList()
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
expandKeys
|
|
|
|
defaultOrId: string
|
|
|
|
//获取所有组织机构
|
|
|
|
nodes: any = []
|
|
|
|
getAllOrganization() {
|
|
|
|
let params = {
|
|
|
|
PageNumber: 1,
|
|
|
|
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.nodes = [...this.toTree.toTree(data.items)]
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
apply() {
|
|
|
|
if (this.nodes.length == 0) {
|
|
|
|
this.message.create('warning', '组织机构初始化中,请稍后重试');
|
|
|
|
return
|
|
|
|
}
|
|
|
|
const modal = this.modal.create({
|
|
|
|
nzTitle: '申请',
|
|
|
|
nzContent: ApplyComponent,
|
|
|
|
nzViewContainerRef: this.viewContainerRef,
|
|
|
|
nzWidth: 660,
|
|
|
|
nzMaskClosable: false,
|
|
|
|
nzComponentParams: {
|
|
|
|
title: "熟悉演练",
|
|
|
|
nodes: this.nodes,
|
|
|
|
},
|
|
|
|
nzOnOk: async () => {
|
|
|
|
if (instance.validateForm.valid) {
|
|
|
|
await new Promise((resolve, reject) => {
|
|
|
|
let body = {
|
|
|
|
organizationId: this.OrganizationId,
|
|
|
|
taskName: "熟悉演练",
|
|
|
|
companyId: instance.validateForm.value.unitname,
|
|
|
|
assitantOrganizationId: instance.validateForm.value.organization,
|
|
|
|
}
|
|
|
|
this.http.post('/api/PlanTasks', body).subscribe({
|
|
|
|
next: (data) => {
|
|
|
|
this.message.create('success', '创建成功');
|
|
|
|
resolve(data)
|
|
|
|
this.getTaskList()
|
|
|
|
return true
|
|
|
|
},
|
|
|
|
error: (err) => {
|
|
|
|
this.message.create('warning', '创建失败');
|
|
|
|
reject(err)
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
this.message.create('warning', '请填写完整!');
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
const instance = modal.getContentComponent();
|
|
|
|
modal.afterOpen.subscribe(() => console.log('[afterOpen] emitted!'));
|
|
|
|
modal.afterClose.subscribe(result => console.log('[afterClose] The result is:', result));
|
|
|
|
}
|
|
|
|
look(item) {
|
|
|
|
const modal = this.modal.create({
|
|
|
|
nzTitle: '详情',
|
|
|
|
nzContent: ApplyLookComponent,
|
|
|
|
nzViewContainerRef: this.viewContainerRef,
|
|
|
|
nzWidth: 660,
|
|
|
|
nzMaskClosable: false,
|
|
|
|
nzComponentParams: {
|
|
|
|
data: item,
|
|
|
|
},
|
|
|
|
nzFooter: null,
|
|
|
|
nzOnOk: async () => {
|
|
|
|
if (instance.validateForm.valid) {
|
|
|
|
await new Promise(resolve => {
|
|
|
|
let roleNames = [...instance.validateForm.value.role, ...instance.validateForm.value.role2]
|
|
|
|
let body = {
|
|
|
|
userName: instance.validateForm.value.account,
|
|
|
|
name: instance.validateForm.value.name,
|
|
|
|
organizationUnitId: Number(instance.validateForm.value.organization),
|
|
|
|
roleNames: roleNames,
|
|
|
|
phoneNumber: instance.validateForm.value.phonenum,
|
|
|
|
isActive: true
|
|
|
|
}
|
|
|
|
// this.http.post(this.addUrl, body).subscribe(data => {
|
|
|
|
// resolve(data)
|
|
|
|
// this.message.create('success', '创建成功!');
|
|
|
|
// this.SkipCount = 0
|
|
|
|
// this.getAllUsers()
|
|
|
|
// return true
|
|
|
|
// }, err => {
|
|
|
|
// resolve(err)
|
|
|
|
// this.message.create('warning', err.error.error.message);
|
|
|
|
// return false
|
|
|
|
// })
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
this.message.create('warning', '请填写完整!');
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
const instance = modal.getContentComponent();
|
|
|
|
modal.afterOpen.subscribe(() => console.log('[afterOpen] emitted!'));
|
|
|
|
modal.afterClose.subscribe(result => console.log('[afterClose] The result is:', result));
|
|
|
|
}
|
|
|
|
}
|