济南项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

747 lines
26 KiB

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 * as moment from 'moment';
import { TaskDetailsComponent } from './task-details/task-details.component';
import { CreateTaskComponent } from './create-task/create-task.component';
import { differenceInCalendarDays, setHours } from 'date-fns'
import { PlanAdjustmentComponent } from '../da-oneself-plan/plan-adjustment/plan-adjustment.component';
import { MethodService } from 'src/app/service/method.service';
import { NewTaskMessageService } from 'src/app/service/new-task-message.service';
@Component({
selector: 'app-station-weekly-plan',
templateUrl: './station-weekly-plan.component.html',
styleUrls: ['./station-weekly-plan.component.scss']
})
export class StationWeeklyPlanComponent implements OnInit {
constructor(private http: HttpClient, private modal: NzModalService, private message: NzMessageService, private viewContainerRef: ViewContainerRef, public methodService: MethodService, private newTaskMessage: NewTaskMessageService) { }
OrganizationId
userId
isSupervisor
today = new Date();
disabledDate = (current: Date): boolean => differenceInCalendarDays(current, this.today) <= 0;
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 = 2022
selectedTime
selectMonth(item) {
this.selectedMonth = item.id
this.initializeData()
this.getTuesdayThursdayNum()
this.getTaskList()
this.getTaskListPass(this.stationData[0])
}
selectYear(e) {
this.selectedYear = e
this.initializeData()
this.getTuesdayThursdayNum()
this.getTaskList()
this.getTaskListPass(this.stationData[0])
}
//当月有几个周二周四
TuesdayThursdayNum = 0
getTuesdayThursdayNum() {
let selectedTime = this.selectedYear + '-' + this.selectedMonth + '-' + '01'
this.http.get(`/api/TaskTargets/GetTargetCount/${selectedTime}`).subscribe((data: any) => {
console.log('最大日期', data)
this.TuesdayThursdayNum = data
})
}
isExpand = true
expand() {
this.isExpand = !this.isExpand
}
formatOne = (percent: number): string => `${percent}%\n完成率`;
openDetails(data, type) {
data.isDetails = type
data.badgeNum = 0
}
radioChange(e, i, element) {
element.isLoading = true
let body = {
isSpread: e
}
this.http.patch(`/api/PlanTasks/${i.id}`, body).subscribe({
next: (data) => {
this.message.create('success', e ? '宣传通知已发出' : '取消宣传');
element.isLoading = false
},
error: (err) => {
this.message.create('warning', '发送失败');
element.isLoading = false
}
})
}
checkTime(e, i, element) {
if (e) {
i.planTime = moment(e).format('yyyy-MM-DD')
} else {
i.planTime = null
}
element.isLoading = true
let body = {
planTime: i.planTime
}
this.http.patch(`/api/PlanTasks/${i.id}`, body).subscribe({
next: (data) => {
this.message.create('success', '检查日期分配成功');
element.isLoading = false
},
error: (err) => {
this.message.create('warning', '检查日期分配失败');
element.isLoading = false
}
})
}
//获得辖区下所有救援站
totalCount: string
allOrList: any
getAllStation() {
let params = {
ContainsChildren: true,
pageSize: 9999
}
this.http.get('/api/Organizations', {
params: params
}).subscribe((data: any) => {
this.totalCount = data.totalCount
data.items = data.items.filter(element => {
return element.level == 'squadron'
});
data.items.forEach(element => {
element.isExpand = false
element.isLoading = false
});
this.stationData = data.items
})
}
cardData = [
{ name: '双随机', badgeNum: 0, isDetails: false, isLoading: false, background: '#1D9DFF', icon: 'suiji.png', passed: 0, inspected: 0, percentage: 0, data: [] },
{ name: '行政许可', badgeNum: 0, isDetails: false, isLoading: false, background: '#42B983', icon: 'xuke.png', passed: 0, inspected: 0, percentage: 0, data: [] },
{ name: '熟悉演练', badgeNum: 0, isDetails: false, isLoading: false, background: '#9D80FF', icon: 'yanlian.png', passed: 0, inspected: 0, percentage: 0, data: [] },
{ name: '联络指导', badgeNum: 0, isDetails: false, isLoading: false, background: '#5483EA', icon: 'zhidao.png', passed: 0, inspected: 0, percentage: 0, data: [] },
{ name: '消防宣传', badgeNum: 0, isDetails: false, isLoading: false, background: '#FF5D2A', icon: 'xuanchuan.png', passed: 0, inspected: 0, percentage: 0, data: [] },
{ name: '投诉举报', badgeNum: 0, isDetails: false, isLoading: false, background: '#5087FF', icon: 'tousu.png', passed: 0, inspected: 0, percentage: 0, data: [] },
{ name: '火灾调查', badgeNum: 0, isDetails: false, isLoading: false, background: '#FF404D', icon: 'huozai.png', passed: 0, inspected: 0, percentage: 0, data: [] }
]
//初始化数据
initializeData() {
this.cardData = [
{ name: '双随机', badgeNum: 0, isDetails: false, isLoading: false, background: '#1D9DFF', icon: 'suiji.png', passed: 0, inspected: 0, percentage: 0, data: [] },
{ name: '行政许可', badgeNum: 0, isDetails: false, isLoading: false, background: '#42B983', icon: 'xuke.png', passed: 0, inspected: 0, percentage: 0, data: [] },
{ name: '熟悉演练', badgeNum: 0, isDetails: false, isLoading: false, background: '#9D80FF', icon: 'yanlian.png', passed: 0, inspected: 0, percentage: 0, data: [] },
{ name: '联络指导', badgeNum: 0, isDetails: false, isLoading: false, background: '#5483EA', icon: 'zhidao.png', passed: 0, inspected: 0, percentage: 0, data: [] },
{ name: '消防宣传', badgeNum: 0, isDetails: false, isLoading: false, background: '#FF5D2A', icon: 'xuanchuan.png', passed: 0, inspected: 0, percentage: 0, data: [] },
{ name: '投诉举报', badgeNum: 0, isDetails: false, isLoading: false, background: '#5087FF', icon: 'tousu.png', passed: 0, inspected: 0, percentage: 0, data: [] },
{ name: '火灾调查', badgeNum: 0, isDetails: false, isLoading: false, background: '#FF404D', icon: 'huozai.png', passed: 0, inspected: 0, percentage: 0, data: [] }
]
this.stationData.forEach(element => {
element.isExpand = true
element.isLoading = false
element.data = []
});
}
isShow(element) {
let isShow = true
if (element.creationType == '申领任务') {
if (this.isSupervisor) {//检查员
if ((element.taskType == '熟悉演练' && element.relatedTaskId != null) ||
(element.taskType == '联络指导' && element.approvalStatus == '待处理' && element.relatedTaskId == null)
) {
isShow = false
}
} else {//消防站
if ((element.taskType == '联络指导' && element.relatedTaskId != null) ||
(element.taskType == '熟悉演练' && element.approvalStatus == '待处理' && element.relatedTaskId == null) ||
(element.taskType == '联络指导' && element.relatedTaskId == null ||
(element.taskType == '双随机' && element.relatedTaskId == null))) {
isShow = false
}
}
}
return isShow
}
isLoading = false
PageNumber = 1
PageSize = 9999
async getTaskList() {
this.cardData.forEach(element => {
element.data = []
element.percentage = 0
element.passed = 0
element.inspected = 0
})
this.isLoading = true
let selectedTime = this.selectedYear + '-' + this.selectedMonth + '-' + '01'
let params = {
Month: selectedTime,
SupervisorId: this.isSupervisor ? this.userId : null,
assistantOrganizationId: this.isSupervisor ? null : this.OrganizationId,
PageNumber: this.PageNumber,
PageSize: this.PageSize,
approvalStatuses: ['待处理', '通过', '驳回', '待检查', '已检查']
}
return await new Promise<void>((resolve, reject) => {
this.http.get('/api/PlanTasks', {
params: params
}).subscribe((data: any) => {
this.isLoading = false
// console.log('任务申请列表', data.items)
data.items.forEach(element => {
if (this.isShow(element)) {
this.cardData.forEach((item, key) => {
element.taskType == item.name ? this.cardData[key].data.push(element) : null
});
}
});
this.cardData.forEach(element => {
element.data.forEach(item => {
item.approvalStatus == '通过' ? element.passed += 1 : null
item.approvalStatus == '已检查' ? element.inspected += 1 : null
})
})
this.cardData.forEach(element => {
element.percentage = Math.round((element.inspected / element.data.length) * 100)
})
resolve(data)
console.log('并入卡片数据', this.cardData)
})
})
}
stationData = [
{ name: '', isExpand: true, isLoading: false, data: [], allUnitsNum: 0, awaitInspect: 0, inspected: 0, percentage: 0 }
]
async getTaskListPass(item) {
let selectedTime = this.selectedYear + '-' + this.selectedMonth + '-' + '01'
let params = {
Month: selectedTime,
approvalStatuses: ['通过', '待检查', '已检查'],
SupervisorId: this.isSupervisor ? this.userId : null,
assistantOrganizationId: this.isSupervisor ? null : this.OrganizationId,
PageNumber: this.PageNumber,
PageSize: this.PageSize,
TaskTypes: this.isSupervisor ? ['双随机', '联络指导'] : ['熟悉演练'],
}
item.isLoading = true
return await new Promise<void>((resolve, reject) => {
this.http.get('/api/PlanTasks', {
params: params
}).subscribe((data: any) => {
item.isLoading = false
let listData = [
{ name: '双随机', background: '#1D9DFF', icon: 'suiji.png', scale: '0/0', data: [], inspected: 0, finished: 0 },
{ name: '行政许可', background: '#42B983', icon: 'xuke.png', scale: '0/0', data: [], inspected: 0, finished: 0 },
{ name: '熟悉演练', background: '#9D80FF', icon: 'yanlian.png', scale: '0/0', data: [], inspected: 0, finished: 0 },
{ name: '联络指导', background: '#5483EA', icon: 'zhidao.png', scale: '0/0', data: [], inspected: 0, finished: 0 },
{ name: '消防宣传', background: '#FF5D2A', icon: 'xuanchuan.png', scale: '0/0', data: [], inspected: 0, finished: 0 },
{ name: '投诉举报', background: '#5087FF', icon: 'tousu.png', scale: '0/0', data: [], inspected: 0, finished: 0 },
{ name: '火灾调查', background: '#FF404D', icon: 'huozai.png', scale: '0/0', data: [], inspected: 0, finished: 0 }
]
data.items.forEach(element => {
if (this.isShow(element)) {
listData.forEach((item, key) => {
element.taskType == item.name ? listData[key].data.push(element) : null
});
}
});
for (let index = 0; index < listData.length; index++) {
const element = listData[index];
if (element.data.length == 0) {
listData.splice(index, 1)
index--
}
}
item.data = listData
console.log('当前登录用户所有通过的任务', item);
item.allUnitsNum = 0
item.awaitInspect = 0
item.inspected = 0
item.finished = 0
item.data.forEach(element => {
item.allUnitsNum += element.data.length
element.data.forEach(i => {
i.approvalStatus == '待检查' ? item.awaitInspect += 1 : null
i.approvalStatus == '已检查' ? item.inspected += 1 : null
i.approvalStatus == '待检查' ? element.inspected += 1 : null
i.approvalStatus == '已检查' ? element.finished += 1 : null
});
});
item.percentage = Math.round((item.inspected / item.allUnitsNum) * 100)
resolve(data)
})
})
}
//接受任务
accept(i, item) {
if (i.approvalStatus == '通过') {
this.message.create('warning', '不能重复接受');
return
}
if (i.approvalStatus == '待检查') {
this.message.create('warning', '任务处于待检查状态,不能再次接受');
return
}
this.modal.confirm({
nzTitle: `确定要接受该任务吗?`,
nzOkText: '确定',
nzOkType: 'default',
nzOnOk: () => {
item.isLoading = true
this.http.post(`/api/PlanTasks/Approval/${i.id}`, null, {
params: {
approvalStatus: '通过'
}
}).subscribe({
next: (data) => {
this.message.create('success', '已接受');
i.approvalStatus = '通过'
item.isLoading = false
item.passed += 1
this.getTaskListPass(this.stationData[0])
},
error: (err) => {
this.message.create('warning', '接受失败');
item.isLoading = false
}
})
},
nzCancelText: '取消'
});
}
//拒绝任务
reject(i, item) {
if (i.approvalStatus == '驳回') {
this.message.create('warning', '不能重复驳回');
return
}
this.modal.confirm({
nzTitle: `确定要拒绝该任务吗?`,
nzOkText: '确定',
nzOkType: 'default',
nzOnOk: () => {
item.isLoading = true
this.http.post(`/api/PlanTasks/Approval/${i.id}`, null, {
params: {
approvalStatus: '驳回'
}
}).subscribe({
next: (data) => {
this.message.create('success', '已拒绝');
i.approvalStatus = '驳回'
item.isLoading = false
item.passed -= 1
this.getTaskListPass(this.stationData[0])
},
error: (err) => {
this.message.create('warning', '拒绝失败');
item.isLoading = false
}
})
},
nzCancelText: '取消'
});
}
userName
organizationName
ngOnInit(): void {
this.OrganizationId = JSON.parse(sessionStorage.getItem('userData')).organizationId
this.userId = JSON.parse(sessionStorage.getItem('userData')).id
this.userName = JSON.parse(sessionStorage.getItem('userData')).name
this.organizationName = JSON.parse(sessionStorage.getItem('userData')).organizationName
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
if (isSupervisor) {
this.stationData[0].name = this.userName
} else {
this.stationData[0].name = this.organizationName
}
this.selectedMonth = new Date().getMonth() + 1
// this.getAllStation()
this.getTaskList()
this.getTaskListPass(this.stationData[0])
this.getTuesdayThursdayNum()
setTimeout(() => {
this.rollStart()
}, 0);
this.newTaskMessage.getMessage().subscribe((data: any) => {
console.log('具体任务信息', data);
if (data.signalRData.content == '您有一条新的一体化任务,请注意查收。') {
this.cardData.forEach((item: any) => {
if (item.name == data.taskType) {
item.data.unshift(data)
if (!item.isDetails) {
item.badgeNum += 1
}
if (data.approvalStatus == '通过') {
item.passed += 1
this.getTaskListPass(this.stationData[0])
}
}
})
}
if (data.signalRData.content == '您参与的任务已取消,请点击查看详情。') {
this.cardData.forEach((item: any) => {
if (item.name == data.taskType) {
for (let index = 0; index < item.data.length; index++) {
const element = item.data[index];
if (element.id == data.signalRData.planTaskId) {
item.data.splice(index, 1)
index--
}
}
if (!item.isDetails) {
item.badgeNum -= 1
}
this.getTaskListPass(this.stationData[0])
}
})
}
});
}
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() {
window.clearInterval(this.timer);
}
mouseleave() {
this.rollStart()
}
ngOnDestroy(): void {
console.log('退出了')
this.mouseEnter()
}
expandcarditem(item) {
item.isExpand = !item.isExpand
}
//获得消防站下的所有任务
getTaskListOfStation(item) {
let selectedTime = this.selectedYear + '-' + this.selectedMonth + '-' + '01'
let params = {
Month: selectedTime,
CompanyOrganizationId: item.id,
PageNumber: this.PageNumber,
approvalStatuses: ['通过', '待检查', '已检查'],
PageSize: this.PageSize
}
item.isLoading = true
this.http.get('/api/PlanTasks', {
params: params
}).subscribe({
next: (data: any) => {
item.isLoading = false
let listData = [
{ name: '双随机', background: '#1D9DFF', icon: 'suiji.png', scale: '0/0', data: [], inspected: 0, finished: 0 },
{ name: '行政许可', background: '#42B983', icon: 'xuke.png', scale: '0/0', data: [], inspected: 0, finished: 0 },
{ name: '熟悉演练', background: '#9D80FF', icon: 'yanlian.png', scale: '0/0', data: [], inspected: 0, finished: 0 },
{ name: '联络指导', background: '#5483EA', icon: 'zhidao.png', scale: '0/0', data: [], inspected: 0, finished: 0 },
{ name: '消防宣传', background: '#FF5D2A', icon: 'xuanchuan.png', scale: '0/0', data: [], inspected: 0, finished: 0 },
{ name: '投诉举报', background: '#5087FF', icon: 'tousu.png', scale: '0/0', data: [], inspected: 0, finished: 0 },
{ name: '火灾调查', background: '#FF404D', icon: 'huozai.png', scale: '0/0', data: [], inspected: 0, finished: 0 }
]
data.items.forEach(element => {
listData.forEach((item, key) => {
element.taskType == item.name ? listData[key].data.push(element) : null
});
});
for (let index = 0; index < listData.length; index++) {
const element = listData[index];
if (element.data.length == 0) {
listData.splice(index, 1)
index--
}
}
item.data = listData
console.log('当前登录用户所有通过的任务', item);
item.allUnitsNum = 0
item.awaitInspect = 0
item.inspected = 0
item.finished = 0
item.data.forEach(element => {
item.allUnitsNum += element.data.length
element.data.forEach(i => {
i.approvalStatus == '待检查' ? item.awaitInspect += 1 : null
i.approvalStatus == '已检查' ? item.inspected += 1 : null
i.approvalStatus == '待检查' ? element.inspected += 1 : null
i.approvalStatus == '已检查' ? element.finished += 1 : null
});
});
item.percentage = Math.round(item.inspected / item.allUnitsNum) * 100
},
error: (err) => {
this.message.create('warning', '获取数据失败');
item.isLoading = false
}
})
}
taskDetails(item) {
// console.log(item)
const modal = this.modal.create({
nzTitle: item.name,
nzContent: TaskDetailsComponent,
nzViewContainerRef: this.viewContainerRef,
nzWidth: 900,
nzMaskClosable: false,
nzFooter: null,
nzComponentParams: {
data: item,
parent: this
}
});
const instance = modal.getContentComponent();
modal.afterOpen.subscribe(() => console.log('[afterOpen] emitted!'));
modal.afterClose.subscribe(result => {
// item
// this.getTaskList()
this.getTaskListPass(this.stationData[0])
});
}
apply(item) {
const modal = this.modal.create({
nzTitle: '新增' + item.name + '任务',
nzContent: CreateTaskComponent,
nzViewContainerRef: this.viewContainerRef,
nzWidth: 660,
nzMaskClosable: false,
nzComponentParams: {
title: item.name,
},
nzOnOk: async () => {
console.log(instance.validateForm.value)
if (instance.validateForm.valid) {
await new Promise((resolve, reject) => {
let selectedMonth = this.selectedMonth < 10 ? "0" + this.selectedMonth : this.selectedMonth;
let selectedTime = this.selectedYear + '-' + selectedMonth + '-' + '01'
let body = {
month: selectedTime,
taskName: instance.validateForm.value.taskname,
taskType: instance.validateForm.value.taskname,
companyId: instance.validateForm.value.unitname.id,
organizationId: this.OrganizationId,
supervisorIds: this.isSupervisor ? [this.userId] : [],
assistantOrganizationIds: this.isSupervisor ? [] : [this.OrganizationId],
creationType: '自主任务',
approvalStatus: '通过'
}
this.http.post('/api/PlanTasks', body).subscribe({
next: (data: any) => {
console.log(item)
data.company = instance.validateForm.value.unitname
item.data.push(data)
item.passed += 1
// this.getTaskList()
this.getTaskListPass(this.stationData[0])
this.message.create('success', '创建成功');
resolve(data)
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));
}
createTask(element) {
console.log(element)
let taskIds = []
element.data.forEach(item => {
item.data.forEach(i => {
i.planTime && i.approvalStatus != '已检查' ? taskIds.push(i.id) : null
});
});
let params = {
ids: taskIds,
approvalStatus: '待检查'
}
this.http.post('/api/PlanTasks/ApprovalMany', null, { params: params }).subscribe({
next: (data: any) => {
this.getTaskListPass(this.stationData[0])
this.message.create('success', '发布成功');
},
error: (err) => {
this.message.create('warning', '发布失败');
}
})
}
adjustment(item) {
let selectedTime = this.selectedYear + '-' + this.selectedMonth + '-' + '01'
const modal = this.modal.create({
nzTitle: "任务调整",
nzContent: PlanAdjustmentComponent,
nzViewContainerRef: this.viewContainerRef,
nzWidth: 900,
nzFooter: null,
nzComponentParams: {
data: JSON.parse(JSON.stringify(item)),
time: selectedTime,
level: '非大队'
}
});
const instance = modal.getContentComponent();
modal.afterClose.subscribe(result => {
this.getTaskList()
this.getTaskListPass(this.stationData[0])
});
}
allPass(item) {
console.log(item)
this.modal.confirm({
nzTitle: `确定要全部接受该模块下所有任务吗?`,
nzOkText: '确定',
nzOkType: 'default',
nzOnOk: () => {
let ids = []
item.data.forEach(element => {
if (element.approvalStatus == '待处理' || element.approvalStatus == '驳回')
ids.push(element.id)
});
this.http.post(`/api/PlanTasks/ApprovalMany`, null, {
params: {
ids: ids,
approvalStatus: '通过'
}
}).subscribe({
next: (data) => {
this.message.create('success', '成功');
item.data.forEach(element => {
element.approvalStatus = '通过'
});
this.getTaskListPass(this.stationData[0])
},
error: (err) => {
this.message.create('warning', '失败');
item.isLoading = false
}
})
},
nzCancelText: '取消'
});
}
ischat = false
taskId
openchat(item) {
console.log(item)
this.taskId = item.id
this.ischat = true
}
closechat() {
this.ischat = false
}
}