|
|
|
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, HttpHeaders } from '@angular/common/http';
|
|
|
|
import { TreeService } from 'src/app/service/tree.service';
|
|
|
|
import { ThisReceiver } from '@angular/compiler';
|
|
|
|
import { MethodService } from 'src/app/service/method.service';
|
|
|
|
import { UploadComponent } from './upload/upload.component';
|
|
|
|
import { Router } from '@angular/router';
|
|
|
|
@Component({
|
|
|
|
selector: 'app-station-task-execution',
|
|
|
|
templateUrl: './station-task-execution.component.html',
|
|
|
|
styleUrls: ['./station-task-execution.component.scss']
|
|
|
|
})
|
|
|
|
export class StationTaskExecutionComponent implements OnInit {
|
|
|
|
|
|
|
|
validateForm!: FormGroup;
|
|
|
|
constructor(private router: Router, public methodService: MethodService, private fb: FormBuilder, private modal: NzModalService, private viewContainerRef: ViewContainerRef, private message: NzMessageService, private http: HttpClient, private toTree: TreeService) { }
|
|
|
|
searchForm = {
|
|
|
|
taskname: '',
|
|
|
|
unitname: '',
|
|
|
|
unitlevel: '',
|
|
|
|
or: ''
|
|
|
|
}
|
|
|
|
OrganizationId
|
|
|
|
|
|
|
|
isSupervisor: boolean //是否为检查员
|
|
|
|
|
|
|
|
months = [
|
|
|
|
{ id: 1, name: '1月', isable: true },
|
|
|
|
{ id: 2, name: '2月', isable: true },
|
|
|
|
{ id: 3, name: '3月', isable: true },
|
|
|
|
{ id: 4, name: '4月', isable: true },
|
|
|
|
{ id: 5, name: '5月', isable: true },
|
|
|
|
{ id: 6, name: '6月', isable: true },
|
|
|
|
{ id: 7, name: '7月', isable: true },
|
|
|
|
{ id: 8, name: '8月', isable: true },
|
|
|
|
{ id: 9, name: '9月', isable: true },
|
|
|
|
{ id: 10, name: '10月', isable: true },
|
|
|
|
{ id: 11, name: '11月', isable: true },
|
|
|
|
{ id: 12, name: '12月', isable: true }
|
|
|
|
]
|
|
|
|
selectedMonth
|
|
|
|
selectedYear = 2023
|
|
|
|
selectedTime
|
|
|
|
selectMonth(item) {
|
|
|
|
this.selectedMonth = item.id
|
|
|
|
this.getTaskList()
|
|
|
|
}
|
|
|
|
selectYear(e) {
|
|
|
|
this.selectedYear = e
|
|
|
|
this.getTaskList()
|
|
|
|
}
|
|
|
|
|
|
|
|
cancel(item) {
|
|
|
|
this.modal.confirm({
|
|
|
|
nzTitle: `确定要驳回该任务吗?`,
|
|
|
|
nzOkText: '确定',
|
|
|
|
nzOkType: 'default',
|
|
|
|
nzOnOk: () => {
|
|
|
|
item.isLoading = true
|
|
|
|
this.http.post(`/api/PlanTasks/Approval/${item.id}`, null, {
|
|
|
|
params: {
|
|
|
|
approvalStatus: '驳回'
|
|
|
|
}
|
|
|
|
}).subscribe({
|
|
|
|
next: (data) => {
|
|
|
|
this.getTaskList()
|
|
|
|
this.message.create('success', '已驳回');
|
|
|
|
},
|
|
|
|
error: (err) => {
|
|
|
|
this.message.create('warning', '驳回失败');
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
nzCancelText: '取消'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
delete(item) {
|
|
|
|
console.log(item)
|
|
|
|
this.modal.confirm({
|
|
|
|
nzTitle: `确定要删除该任务吗?`,
|
|
|
|
nzOkText: '确定',
|
|
|
|
nzOkType: 'primary',
|
|
|
|
nzOnOk: () => {
|
|
|
|
this.http.delete(`/api/PlanTasks/${item.id}`).subscribe(data => {
|
|
|
|
|
|
|
|
for (let index = 0; index < this.taskLIst.length; index++) {
|
|
|
|
const element = this.taskLIst[index];
|
|
|
|
if (element.id == item.id) {
|
|
|
|
this.taskLIst.splice(index, 1)
|
|
|
|
index--
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.message.create('success', '删除成功!');
|
|
|
|
|
|
|
|
})
|
|
|
|
},
|
|
|
|
nzCancelText: '取消',
|
|
|
|
nzOnCancel: () => {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
isloading = false
|
|
|
|
totalCount
|
|
|
|
PageNumber = 1
|
|
|
|
PageSize = 10
|
|
|
|
taskLIst = []
|
|
|
|
getTaskList() {
|
|
|
|
this.isloading = true
|
|
|
|
let selectedTime = this.selectedYear + '-' + this.selectedMonth + '-' + '01'
|
|
|
|
let params = {
|
|
|
|
Month: selectedTime,
|
|
|
|
// OrganizationId: this.OrganizationId,
|
|
|
|
TaskTypes: this.isSupervisor ? ['双随机', '联络指导'] : ['熟悉演练'],
|
|
|
|
TaskName: this.searchForm.taskname,
|
|
|
|
CompanyName: this.searchForm.unitname,
|
|
|
|
SupervisorId: this.isSupervisor ? this.userId : null,
|
|
|
|
AssistantOrganizationId: this.isSupervisor ? null : this.OrganizationId,
|
|
|
|
approvalStatuses: ['待检查', '已检查'],
|
|
|
|
PageNumber: this.PageNumber,
|
|
|
|
PageSize: this.PageSize
|
|
|
|
}
|
|
|
|
this.http.get('/api/PlanTasks', {
|
|
|
|
params: params
|
|
|
|
}).subscribe((data: any) => {
|
|
|
|
this.isloading = 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
|
|
|
|
//获取所有组织机构
|
|
|
|
organizationList: any
|
|
|
|
organizationListAll: any
|
|
|
|
nodes: any = []
|
|
|
|
async getAllOrganization() {
|
|
|
|
let params = {
|
|
|
|
ContainsChildren: "true",
|
|
|
|
PageNumber: 1,
|
|
|
|
PageSize: 9999
|
|
|
|
}
|
|
|
|
var p = 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.disableCheckbox = true
|
|
|
|
element.selectable = false
|
|
|
|
});
|
|
|
|
this.organizationListAll = JSON.parse(JSON.stringify(data.items))
|
|
|
|
this.organizationList = JSON.parse(JSON.stringify(data.items)).filter(item => {
|
|
|
|
return item.level != 'squadron'
|
|
|
|
})
|
|
|
|
resolve(data)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return p
|
|
|
|
}
|
|
|
|
|
|
|
|
//获得所有检查员
|
|
|
|
supervisorList = []
|
|
|
|
mainsupervisorList = []
|
|
|
|
assitantsupervisorList = []
|
|
|
|
async getSupervisor() {
|
|
|
|
var p = new Promise<void>((resolve, reject) => {
|
|
|
|
this.http.get('/api/Users/Inspectors').subscribe((data: any) => {
|
|
|
|
console.log('检查员列表', data)
|
|
|
|
data.forEach(element => {
|
|
|
|
element.key = element.id
|
|
|
|
element.title = element.name
|
|
|
|
element.parentId = element.organizationId
|
|
|
|
});
|
|
|
|
this.supervisorList = data
|
|
|
|
resolve(data)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return p
|
|
|
|
}
|
|
|
|
|
|
|
|
//获得除了检查员的其他用户
|
|
|
|
users
|
|
|
|
async getUsers() {
|
|
|
|
var p = new Promise<void>((resolve, reject) => {
|
|
|
|
let params = {
|
|
|
|
OrganizationId: this.OrganizationId,
|
|
|
|
OrganizationLevel: 'squadron',
|
|
|
|
ContainsChildren: true,
|
|
|
|
PageNumber: 1,
|
|
|
|
PageSize: 9999
|
|
|
|
}
|
|
|
|
this.http.get('/api/Users', {
|
|
|
|
params: params
|
|
|
|
}).subscribe((data: any) => {
|
|
|
|
console.log('用户列表', data.items)
|
|
|
|
data.items.forEach(element => {
|
|
|
|
element.key = element.id
|
|
|
|
element.title = element.name
|
|
|
|
element.parentId = element.organizationId
|
|
|
|
});
|
|
|
|
this.users = data.items
|
|
|
|
resolve(data)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return p
|
|
|
|
}
|
|
|
|
|
|
|
|
userId
|
|
|
|
|
|
|
|
time1
|
|
|
|
time2
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
this.userId = JSON.parse(sessionStorage.getItem('userData')).id
|
|
|
|
this.OrganizationId = JSON.parse(sessionStorage.getItem('userData')).organizationId
|
|
|
|
this.userId = JSON.parse(sessionStorage.getItem('userData')).id
|
|
|
|
let roles = JSON.parse(sessionStorage.getItem('userData')).roles
|
|
|
|
let isSupervisor = roles.find(item => {
|
|
|
|
return item.name.indexOf('检查') != -1
|
|
|
|
})
|
|
|
|
isSupervisor ? this.isSupervisor = true : this.isSupervisor = false
|
|
|
|
this.selectedMonth = new Date().getMonth() + 1
|
|
|
|
this.getTaskList()
|
|
|
|
Promise.all([this.getAllOrganization(), this.getSupervisor(), this.getUsers()])
|
|
|
|
.then((results) => {
|
|
|
|
if (this.isSupervisor) {
|
|
|
|
let arr = [...this.users, ...this.organizationListAll]
|
|
|
|
this.nodes = this.toTree.toTree(JSON.parse(JSON.stringify(arr)))
|
|
|
|
} else {
|
|
|
|
let arr = [...this.supervisorList, ...this.organizationList]
|
|
|
|
this.nodes = this.toTree.toTree(JSON.parse(JSON.stringify(arr)))
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
this.rollStart()
|
|
|
|
}, 0);
|
|
|
|
|
|
|
|
|
|
|
|
let t1 = new Date().getTime()
|
|
|
|
|
|
|
|
let date = '2022-9-10'
|
|
|
|
let t2 = Date.parse(date)
|
|
|
|
// this.methodService.countdown(t1, t2, (res) => {
|
|
|
|
// // console.log(666, res)
|
|
|
|
// this.time1 = res.day + '天' + res.hour + '小时'
|
|
|
|
// })
|
|
|
|
}
|
|
|
|
|
|
|
|
timer
|
|
|
|
rollStart() {
|
|
|
|
var ROLL_SPEED = 100
|
|
|
|
var noticeList1 = document.getElementById('notice-list');
|
|
|
|
var noticeList2 = document.getElementById('notice-list-2');
|
|
|
|
var listWrapper = document.getElementById('list-wrapper');
|
|
|
|
noticeList2.innerHTML = noticeList1.innerHTML;
|
|
|
|
this.timer = setInterval(rollStart, ROLL_SPEED);
|
|
|
|
|
|
|
|
function rollStart() {
|
|
|
|
if (Math.abs(_subStr(listWrapper.style.top)) >= noticeList1.clientHeight) {
|
|
|
|
listWrapper.style.top = '0px'
|
|
|
|
} else {
|
|
|
|
var top = listWrapper.style.top
|
|
|
|
listWrapper.style.top = _subStr(top) - 1 + 'px'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 截取px前数值
|
|
|
|
function _subStr(str) {
|
|
|
|
var index = str.indexOf('px');
|
|
|
|
if (index > -1) {
|
|
|
|
return parseFloat(str.substr(0, index + 1))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mouseEnter() {
|
|
|
|
// console.log('进入了')
|
|
|
|
window.clearInterval(this.timer);
|
|
|
|
}
|
|
|
|
mouseleave() {
|
|
|
|
|
|
|
|
this.rollStart()
|
|
|
|
|
|
|
|
}
|
|
|
|
ngOnDestroy(): void {
|
|
|
|
console.log('退出了')
|
|
|
|
this.mouseEnter()
|
|
|
|
|
|
|
|
this.methodService.cleartimer()
|
|
|
|
}
|
|
|
|
apply() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
look(item) {
|
|
|
|
console.log(item)
|
|
|
|
if (item.approvalStatus == '待检查') {
|
|
|
|
this.message.create('warning', '该单位未检查');
|
|
|
|
return
|
|
|
|
}
|
|
|
|
this.router.navigate(['/task/taskexecution/taskdetails'], { queryParams: { id: item.id, company: item.company.companyName, organization: item.organization.name, legalPersonName: item.company.legalPersonName ? item.company.legalPersonName : '' } })
|
|
|
|
}
|
|
|
|
|
|
|
|
complete(item) {
|
|
|
|
const modal = this.modal.create({
|
|
|
|
nzTitle: '完成任务',
|
|
|
|
nzContent: UploadComponent,
|
|
|
|
nzViewContainerRef: this.viewContainerRef,
|
|
|
|
nzWidth: 450,
|
|
|
|
nzMaskClosable: false,
|
|
|
|
nzComponentParams: {
|
|
|
|
data: item,
|
|
|
|
},
|
|
|
|
nzOnOk: async () => {
|
|
|
|
if (instance.validateForm.valid) {
|
|
|
|
await new Promise((resolve, reject) => {
|
|
|
|
let body = {
|
|
|
|
inspectionResult: instance.validateForm.value.result,
|
|
|
|
resultAttachment: instance.fileList
|
|
|
|
}
|
|
|
|
this.http.patch(`/api/PlanTasks/${item.id}`, body).subscribe({
|
|
|
|
next: (data) => {
|
|
|
|
this.message.create('success', '已完成');
|
|
|
|
this.getTaskList()
|
|
|
|
resolve(data)
|
|
|
|
},
|
|
|
|
error: (err) => {
|
|
|
|
this.message.create('warning', '完成失败');
|
|
|
|
reject(err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
} 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));
|
|
|
|
}
|
|
|
|
|
|
|
|
ischat = false
|
|
|
|
taskId
|
|
|
|
openchat(item) {
|
|
|
|
console.log(item)
|
|
|
|
this.taskId = item.id
|
|
|
|
this.ischat = true
|
|
|
|
}
|
|
|
|
closechat() {
|
|
|
|
this.ischat = false
|
|
|
|
}
|
|
|
|
}
|