Newer
Older
import {Component, EventEmitter, OnInit, Output, ViewChild} from '@angular/core';
import {WorkService} from '../../work.service';
import {NzMessageService, UploadFile} from 'ng-zorro-antd';
import {SelectPersonComponent} from '../../../modal/select-person/select-person.component';
@Component({
selector: 'smart-plan-modal',
templateUrl: './plan-modal.component.html',
styles: []
})
export class PlanModalComponent implements OnInit {
@ViewChild('smartSelectPerson') smartSelectPerson: SelectPersonComponent;
constructor(private workSer: WorkService, private message: NzMessageService,
}
ngOnInit() {
this.initForm();
this.getPlanType();
}
initForm() {
startTime: [null, [Validators.required]],
endTime: [null, [Validators.required]],
principals: [null, [Validators.required]], //负责人
participants: [null, [Validators.required]], //参与人
}
beforeUpload = (file: UploadFile): boolean => {
const isLt5M = file.size / 1024 < 5000;
if (!isLt5M) {
this.message.error(' 文件必须小于5M!');
} else {
}
return false;
};
showAddModal() {
this.title = '添加计划';
}
showEditModal(id) {
this.title = '编辑计划';
this.planId = id;
(res) => {
res.data.number += '';
res.data.cycleNum += '';
this.participantsList = res.data.participants;
this.principalsList = res.data.principals;
startTime: new Date(res.data.startTime),
endTime: new Date(res.data.endTime),
this.validateForm.patchValue({
principals: this.principalsList.length == 0 ? null : this.principalsList,
participants: this.participantsList.length == 0 ? null : this.participantsList,
startTime: this.datePipe.transform(this.validateForm.value.startTime, 'yyyy-MM-dd HH:mm:ss'),
endTime: this.datePipe.transform(this.validateForm.value.endTime, 'yyyy-MM-dd HH:mm:ss'),
});
for (let i in this.validateForm.controls) {
this.validateForm.controls[i].markAsDirty();
this.validateForm.controls[i].updateValueAndValidity();
}
this.update();
}
}
create() {
let formData = new FormData();
this.fileList.forEach((file: any) => {
formData.append('file', file);
});
formData.append('json', JSON.stringify(this.validateForm.value));
this.workSer.createPlan(formData).subscribe(
let formData = new FormData();
this.fileList.forEach((file: any) => {
formData.append('file', file);
});
(res) => {
if (res.errCode == 10000) {
this.message.success('修改计划成功');
e.forEach(res => {
const data = {
username: res.name,
userId: res.id
};
arr.push(data);
if (this.modalTitle == '选择参与人') {
this.participantsList = arr;
}
if (this.modalTitle == '选择负责人') {
this.principalsList = arr;
}
}
//删除参与人