|
|
|
@ -5,6 +5,7 @@ import { HttpClient } from '@angular/common/http';
|
|
|
|
|
import { TreeService } from 'src/app/service/tree.service'; |
|
|
|
|
import { Observable, of } from 'rxjs'; |
|
|
|
|
import { catchError, map } from 'rxjs/operators'; |
|
|
|
|
import { NzMessageService } from 'ng-zorro-antd/message'; |
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-apply', |
|
|
|
|
templateUrl: './apply.component.html', |
|
|
|
@ -18,72 +19,169 @@ export class ApplyComponent implements OnInit {
|
|
|
|
|
@Input() users?: any; |
|
|
|
|
|
|
|
|
|
validateForm!: FormGroup; |
|
|
|
|
constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient, private toTree: TreeService) { } |
|
|
|
|
constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient, private toTree: TreeService, private message: NzMessageService) { } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
newTree |
|
|
|
|
ngOnInit(): void { |
|
|
|
|
this.validateForm = this.fb.group({ |
|
|
|
|
taskname: [null, [Validators.required]], |
|
|
|
|
unitname: [null, [Validators.required]], |
|
|
|
|
organization: [null, [Validators.required]] |
|
|
|
|
}); |
|
|
|
|
// let arr = [...this.supervisorList, ...this.organizationList]
|
|
|
|
|
// this.newTree = this.toTree.toTree(arr)
|
|
|
|
|
this.newTree = this.nodes |
|
|
|
|
} |
|
|
|
|
this.newTree = this.nodes |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Promise.all([this.getCompanies(), this.getAllOrganization()]) |
|
|
|
|
.then((results) => { |
|
|
|
|
|
|
|
|
|
destroyModal(): void { |
|
|
|
|
this.modal.destroy({ data: 'this the result data' }); |
|
|
|
|
let arr = [...JSON.parse(JSON.stringify(this.allOrList)), ...JSON.parse(JSON.stringify(this.unitList))] |
|
|
|
|
console.log(789456, this.allOrList) |
|
|
|
|
console.log(789456, this.unitList) |
|
|
|
|
let nodes = [...this.toTree.toTree(arr)] |
|
|
|
|
this.unitPopover.nodes = JSON.parse(JSON.stringify(nodes)) |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
optionList = []; |
|
|
|
|
selectedUser = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isLoading = false; |
|
|
|
|
|
|
|
|
|
PageNumber = 0 |
|
|
|
|
PageSize = 50 |
|
|
|
|
totalCount |
|
|
|
|
loadMore(): Promise<void> { |
|
|
|
|
if (this.optionList.length >= this.totalCount) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
this.PageNumber += 1 |
|
|
|
|
this.isLoading = true; |
|
|
|
|
this.getCompanies() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
search(value: string) { |
|
|
|
|
this.optionList = [] |
|
|
|
|
this.PageNumber = 1 |
|
|
|
|
this.isLoading = true; |
|
|
|
|
this.getCompanies(value) |
|
|
|
|
} |
|
|
|
|
allOrList: any |
|
|
|
|
|
|
|
|
|
async getCompanies(CompanyName?: string) { |
|
|
|
|
async getAllOrganization() { |
|
|
|
|
let params = { |
|
|
|
|
CompanyName: CompanyName, |
|
|
|
|
ContainsChildren: true, |
|
|
|
|
pageSize: 9999 |
|
|
|
|
} |
|
|
|
|
return new Promise<void>((resolve, reject) => { |
|
|
|
|
this.http.get('/api/Organizations', { |
|
|
|
|
params: params |
|
|
|
|
}).subscribe((data: any) => { |
|
|
|
|
data.items.forEach(element => { |
|
|
|
|
element.key = element.id |
|
|
|
|
element.title = element.name |
|
|
|
|
element.selectable = false |
|
|
|
|
element.disableCheckbox = true |
|
|
|
|
}); |
|
|
|
|
this.allOrList = JSON.parse(JSON.stringify(data.items)) |
|
|
|
|
this.allOrList.length == 1 ? this.allOrList[0].parentId = null : null |
|
|
|
|
resolve(data) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
unitList |
|
|
|
|
async getCompanies(incomingData?: any) { |
|
|
|
|
let params = { |
|
|
|
|
CompanyName: incomingData ? incomingData.search1 : '', |
|
|
|
|
OrganizationId: JSON.parse(sessionStorage.getItem('userData')).organizationId, |
|
|
|
|
PageNumber: this.PageNumber, |
|
|
|
|
PageSize: this.PageSize |
|
|
|
|
PageNumber: 1, |
|
|
|
|
PageSize: 9999 |
|
|
|
|
} |
|
|
|
|
await new Promise<void>((resolve, reject) => { |
|
|
|
|
return new Promise<void>((resolve, reject) => { |
|
|
|
|
this.http.get('/api/Companies', { |
|
|
|
|
params: params |
|
|
|
|
}).subscribe((data: any) => { |
|
|
|
|
this.totalCount = data.totalCount |
|
|
|
|
this.isLoading = false; |
|
|
|
|
this.optionList = [...this.optionList, ...data.items]; |
|
|
|
|
let map = new Map(); |
|
|
|
|
for (let item of this.optionList) { |
|
|
|
|
if (!map.has(item.id)) { |
|
|
|
|
map.set(item.id, item); |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
this.optionList = [...map.values()]; |
|
|
|
|
data.items.forEach(element => { |
|
|
|
|
element.label = element.companyName |
|
|
|
|
element.value = element.id |
|
|
|
|
element.parentId = element.organizationId |
|
|
|
|
element.key = element.id |
|
|
|
|
element.title = element.companyName |
|
|
|
|
element.level = 4 |
|
|
|
|
}); |
|
|
|
|
this.unitList = data.items |
|
|
|
|
|
|
|
|
|
this.unitPopover.unitList = JSON.parse(JSON.stringify(this.unitList)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resolve(data) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
selectedUnitData = { |
|
|
|
|
name: '', |
|
|
|
|
id: '' |
|
|
|
|
} |
|
|
|
|
selectedUnit(data, e?: any) { |
|
|
|
|
e ? e.stopPropagation() : null |
|
|
|
|
let arr = [...data.search1Value, ...data.search2Value] |
|
|
|
|
let arrSet = [...new Set(arr)] |
|
|
|
|
|
|
|
|
|
if (arrSet.length > 1) { |
|
|
|
|
this.message.create('warning', '只能选择一个单位'); |
|
|
|
|
return |
|
|
|
|
} else { |
|
|
|
|
this.unitList.forEach(element => { |
|
|
|
|
if (element.id == arrSet[0]) { |
|
|
|
|
this.selectedUnitData.name = element.companyName |
|
|
|
|
this.selectedUnitData.id = element.id |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
console.log(this.selectedUnitData) |
|
|
|
|
console.log(this.unitPopover) |
|
|
|
|
this.unitPopover.isPopover = false |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//
|
|
|
|
|
unitPopover = { |
|
|
|
|
allocated: 0, |
|
|
|
|
isExpand: true,//卡片展开
|
|
|
|
|
isPopover: false,//选择单位气泡卡片
|
|
|
|
|
isLoading: false, |
|
|
|
|
search1: '',//选择单位气泡卡片---单位选择列表
|
|
|
|
|
search1Value: [], |
|
|
|
|
search2: '',//选择单位气泡卡片---组织选择列表
|
|
|
|
|
search2Value: [], |
|
|
|
|
searchAll: [], |
|
|
|
|
selectedMenu: 1,//选择单位气泡卡片
|
|
|
|
|
data: [ |
|
|
|
|
],//表格数据
|
|
|
|
|
nodes: [], |
|
|
|
|
unitList: [] |
|
|
|
|
} |
|
|
|
|
isPopover(data, e?: any) { |
|
|
|
|
e ? e.stopPropagation() : null |
|
|
|
|
console.log(data) |
|
|
|
|
data.isPopover = !data.isPopover |
|
|
|
|
// data.unitList.forEach(element => {
|
|
|
|
|
// element.checked = false
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
// 弹出 tab
|
|
|
|
|
popoverMenuSelect(data, type) { |
|
|
|
|
data.selectedMenu = type |
|
|
|
|
} |
|
|
|
|
//搜索框提交
|
|
|
|
|
submitForm(data): void { |
|
|
|
|
console.log(data) |
|
|
|
|
data.unitList = [] |
|
|
|
|
this.getCompanies(data) |
|
|
|
|
} |
|
|
|
|
log(data) { |
|
|
|
|
let arr = [] |
|
|
|
|
data.unitList.forEach(item => { |
|
|
|
|
item.checked ? arr.push(item.id) : null |
|
|
|
|
}); |
|
|
|
|
data.search1Value = arr |
|
|
|
|
} |
|
|
|
|
orcheckbox(data, $event, node) { |
|
|
|
|
if ($event) { |
|
|
|
|
data.search2Value.push(node.origin.id) |
|
|
|
|
} else { |
|
|
|
|
for (let index = 0; index < data.search2Value.length; index++) { |
|
|
|
|
const element = data.search2Value[index]; |
|
|
|
|
if (element == node.origin.id) { |
|
|
|
|
data.search2Value.splice(index, 1) |
|
|
|
|
index-- |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
console.log(data.search2Value) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|