Newer
Older
import {opr_cost_type, opr_time_type, project_status} from '../project.constants';
import {pageSize} from '../../app.constants';
import {WorkService} from '../../work/work.service';
import {NzMessageService} from 'ng-zorro-antd';
import {ProjectService} from '../project.service';
import {Router} from '@angular/router';
import {CommonService} from '../../shared/common/common.service';
import {DatePipe} from '@angular/common';
import {CostModalComponent} from '../modal/cost-modal/cost-modal.component';
selector: 'app-opr-cost',
templateUrl: './opr-cost.component.html',
styleUrls: ['./opr-cost.component.css']
@ViewChild('smartCostModal') smartCostModal: CostModalComponent;
timeFormat = 'yyyy-MM-dd';
costType = [{label: '全部', value: null}, ...opr_cost_type];
timeType = [{label: '全部', value: null}, ...opr_time_type];
page = {
list: [],
isLoading: false,
pageCount: pageSize,
pageNum: 1,
totalNum: null
};
type: null, //费用类型
startTime: null, //开始时间
endTime: 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 = {
obj: this.obj,
pageNum: this.page.pageNum,
pageCount: this.page.pageCount
};
this.projectSer.findPageCost(obj).subscribe(
(res) => {
if (res.errCode == 10000) {
this.page.list = res.data.data;
this.page.totalNum = res.data.totalNum;
this.page.isLoading = false;
}
}
);
}
this.obj.startTime = this.commonSer.getTimeByType(this.time.type).startTime;
this.obj.endTime = this.commonSer.getTimeByType(this.time.type).endTime;
console.log(this.obj);
this.page.pageNum = 1;
this.getList();
}
if (this.time.type == '99') {
this.obj.startTime = this.datePipe.transform(this.time.startTime, 'yyyy-MM-dd') +' 00:00:00';
this.obj.endTime = this.datePipe.transform(this.time.endTime, 'yyyy-MM-dd') +' 23:59:59';
}
//删除
handleDelete(item) {
this.commonSer.confirmThing('删除', '确定删除该费用记录?', () => {
const data = {
id: item.id
};
this.projectSer.deleteCost(data).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.success('删除成功!');
this.getList();
}
}
);
});
}