Newer
Older
import {Component, OnInit, ViewChild} from '@angular/core';
import {CostModalComponent} from '../../project-manager/modal/cost-modal/cost-modal.component';
import {opr_cost_type, opr_time_type, project_status} from '../../project-manager/project.constants';
import {pageSize} from '../../app.constants';
import {WorkService} from '../work.service';
import {NzMessageService} from 'ng-zorro-antd';
import {ProjectService} from '../../project-manager/project.service';
import {Router} from '@angular/router';
import {CommonService} from '../../shared/common/common.service';
import {DatePipe} from '@angular/common';
import {PlanConfigComponent} from '../modal/plan-config/plan-config.component';
selector: 'smart-inspect-plan-config',
templateUrl: './inspect-plan-config.component.html',
styles: []
@ViewChild('smartPlanConfig') smartPlanConfig: PlanConfigComponent;
timeFormat = 'yyyy-MM-dd';
statusList = project_status;
timeType = [{label: '全部', value: null}, ...opr_time_plan_type];
time = {
startTime: '',
endTime: '',
type: null
};
searchStr: '', //模糊查询字符
status: '', //计划状态: 0=未开始, 1=进行中, 2=结束
typeId: null, //计划类型ID
nextExecutionStart: null, //开始时间
nextExecutionEnd: null, //结束时间
constructor(private workSer: WorkService, private message: NzMessageService, private projectSer: ProjectService,
private router: Router, private commonSer: CommonService, private datePipe: DatePipe) {
}
//获取列表
getList() {
this.page.isLoading = true;
const obj = {
pageNum: this.page.pageNum,
pageCount: this.page.pageCount,
searchStr: this.obj.searchStr,
typeId: this.obj.typeId,
status: this.obj.status,
nextExecutionStart: this.obj.nextExecutionStart ? new Date(this.obj.nextExecutionStart).getTime() : null, //开始时间
nextExecutionEnd: this.obj.nextExecutionEnd ? new Date(this.obj.nextExecutionEnd).getTime() : null, //结束时间
};
this.workSer.findPlanList(obj).subscribe(
(res) => {
if (res.errCode == 10000) {
this.page.list = res.data.data;
}
);
}
//获取计划分类
getPlanType() {
const data = {
type: 1
};
this.workSer.findByType(data).subscribe(
(res) => {
if (res.errCode == 10000) {
this.planTypeList = res.data;
}
}
);
}
//翻页
change(e) {
if (e > 0) {
this.page.pageNum = e;
this.getList();
}
}
changeTimeType(e) {
if (e == '99') return;
this.time.type = e;
this.obj.nextExecutionStart = this.commonSer.getTimeByType(this.time.type).startTime;
this.obj.nextExecutionEnd = this.commonSer.getTimeByType(this.time.type).endTime;
if (this.time.type == '99') {
this.obj.nextExecutionStart = this.datePipe.transform(this.time.startTime, 'yyyy-MM-dd HH:mm:ss');
this.obj.nextExecutionEnd = this.datePipe.transform(this.time.endTime, 'yyyy-MM-dd HH:mm:ss');
}
//编辑计划
editPlan(id) {
this.smartPlanConfig.showEditModal(id);
}
//删除计划
deletePlan(data) {
this.commonSer.confirmThing('删除', '确认删除该计划吗?', () => {
const arr = {
ids: []
};
arr.ids.push(data.id);
this.workSer.deletePlan(arr).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.success('删除成功');
this.search();
}
}
);
});
}