Newer
Older
import {Component, EventEmitter, OnInit, Output, ViewChild} from '@angular/core';
import {SelectPersonComponent} from '../../../modal/select-person/select-person.component';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {WorkService} from '../../../work/work.service';
import {NzMessageService, UploadFile} from 'ng-zorro-antd';
import {DatePipe} from '@angular/common';
import {ProjectService} from '../../project.service';
import {ProjectModalComponent} from '../project-modal/project-modal.component';
import {LocalStorageService} from 'ngx-webstorage';
selector: 'smart-cost-modal',
templateUrl: './cost-modal.component.html',
`
:host ::ng-deep .ant-input-disabled {
color: rgba(0, 0, 0, .65);
@ViewChild('smartProjectModal') smartProjectModal: ProjectModalComponent;
@Output() done = new EventEmitter<any>();
total: 0,
purchasenum: 0,
purchasemoney: 0,
outsourcingnum: 0,
outsourcingmoney: 0,
othernum: 0,
othermoney: 0,
};
constructor(private workSer: WorkService, private message: NzMessageService,
private fb: FormBuilder, private datePipe: DatePipe,
private projectSer: ProjectService,
private $localStorage: LocalStorageService) {
}
ngOnInit() {
this.isDisabled = false;
this.obj.people = this.$localStorage.retrieve('userInfo').userName;
this.obj = {
projectName: null,
projectId: null,
people: '',
total: 0,
purchasenum: 0,
purchasemoney: 0,
outsourcingnum: 0,
outsourcingmoney: 0,
othernum: 0,
othermoney: 0,
costdescribe: '',
time: null
};
}
showAddModal() {
this.title = '添加费用记录';
this.isVisiable = true;
}
showLookModal(data) {
this.title = '费用记录';
this.isVisiable = true;
for (let k in data) {
this.obj[k] = data[k];
}
}
if (!this.obj.projectName || !this.obj.projectId) {
this.message.info('请输入必选项!');
return;
}
this.create();
}
handleCancle() {
this.isVisiable = false;
}
create() {
this.obj.time = new Date().getTime();
this.projectSer.addCost(this.obj).subscribe(
(res) => {
if (res.errCode == 10000) {
this.initForm();
this.isVisiable = false;
this.done.emit();
this.message.success('新增费用记录成功');
}
}
);
}
//选择项目
selectProjectModal() {
this.smartProjectModal.showModal();
}
setProject(e) {
this.obj.projectName = e.name;
this.obj.projectId = e.id;
}
this.obj.total = this.obj.purchasemoney * this.obj.purchasenum +
this.obj.outsourcingnum * this.obj.outsourcingmoney +
this.obj.othernum * this.obj.othermoney;
}