|
@@ -1,12 +1,17 @@
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
-import { NzModalRef, NzMessageService } from 'ng-zorro-antd';
|
|
|
|
|
-import { _HttpClient } from '@delon/theme';
|
|
|
|
|
|
|
+import { NzModalRef, NzMessageService, NzNotificationService, NzDrawerRef } from 'ng-zorro-antd';
|
|
|
|
|
+import { _HttpClient, SettingsService } from '@delon/theme';
|
|
|
import { FormBuilder, Validators, FormGroup } from '@angular/forms';
|
|
import { FormBuilder, Validators, FormGroup } from '@angular/forms';
|
|
|
import { ReExpenseSlip } from 'app/entity/expense-reimbursement/re-expense-slip';
|
|
import { ReExpenseSlip } from 'app/entity/expense-reimbursement/re-expense-slip';
|
|
|
import { PersonnelService } from 'app/services/basedata/personnel.service';
|
|
import { PersonnelService } from 'app/services/basedata/personnel.service';
|
|
|
import { recursiveQuery } from '@shared';
|
|
import { recursiveQuery } from '@shared';
|
|
|
import { ProjectManageArchives } from 'app/entity/project-manage-archives/project-manage-archives';
|
|
import { ProjectManageArchives } from 'app/entity/project-manage-archives/project-manage-archives';
|
|
|
import { ProjectManageArchivesService } from 'app/services/project-manage-archives/project-manage-archives.service';
|
|
import { ProjectManageArchivesService } from 'app/services/project-manage-archives/project-manage-archives.service';
|
|
|
|
|
+import { BaseArchivesCost } from 'app/entity/basedata/base-archives-cost';
|
|
|
|
|
+import { BaseArchivesCostService } from 'app/services/basedata/base-archives-cost.service';
|
|
|
|
|
+import { ReExpenseSlipService } from 'app/services/expense-reimbursement/re-expense-slip.service';
|
|
|
|
|
+import { I18NService } from '@core';
|
|
|
|
|
+import { DatePipe } from '@angular/common';
|
|
|
|
|
|
|
|
@Component({
|
|
@Component({
|
|
|
selector: 'app-expense-reimbursement-expense-reimbursement-form-add',
|
|
selector: 'app-expense-reimbursement-expense-reimbursement-form-add',
|
|
@@ -30,28 +35,42 @@ import { ProjectManageArchivesService } from 'app/services/project-manage-archiv
|
|
|
export class ExpenseReimbursementExpenseReimbursementFormAddComponent implements OnInit {
|
|
export class ExpenseReimbursementExpenseReimbursementFormAddComponent implements OnInit {
|
|
|
constructor(
|
|
constructor(
|
|
|
private fb: FormBuilder,
|
|
private fb: FormBuilder,
|
|
|
- private personnelService:PersonnelService,
|
|
|
|
|
- private projectManageArchivesService:ProjectManageArchivesService
|
|
|
|
|
|
|
+ private personnelService: PersonnelService,
|
|
|
|
|
+ private projectManageArchivesService: ProjectManageArchivesService,
|
|
|
|
|
+ private settingsService: SettingsService,
|
|
|
|
|
+ private baseArchivesCostService: BaseArchivesCostService,
|
|
|
|
|
+ private nzNotificationService:NzNotificationService,
|
|
|
|
|
+ private reExpenseSlipService:ReExpenseSlipService,
|
|
|
|
|
+ private i18NService:I18NService,
|
|
|
|
|
+ private drawerRef:NzDrawerRef,
|
|
|
|
|
+ private datePipe:DatePipe
|
|
|
) {}
|
|
) {}
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
ngOnInit(): void {
|
|
|
//初始化表单
|
|
//初始化表单
|
|
|
this.validateForm = this.fb.group({
|
|
this.validateForm = this.fb.group({
|
|
|
proId: [null, [Validators.required]],
|
|
proId: [null, [Validators.required]],
|
|
|
- date:[null,[Validators.required]],
|
|
|
|
|
- personId:[null,[Validators.required]]
|
|
|
|
|
|
|
+ date: [null, [Validators.required]],
|
|
|
|
|
+ personId: [null, [Validators.required]],
|
|
|
});
|
|
});
|
|
|
|
|
+ this.isLoadingSave=true;
|
|
|
//人员
|
|
//人员
|
|
|
- this.getPersonnelList().then(()=>{
|
|
|
|
|
- return this.getProList();//项目下拉
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ this.getPersonnelList().then(() => {
|
|
|
|
|
+ return this.getProList(); //项目下拉
|
|
|
|
|
+ }).then(()=>{
|
|
|
|
|
+ return this.getCostIdList();//费用项目数据
|
|
|
|
|
+ }).then(()=>{
|
|
|
|
|
+ this.isLoadingSave=false;
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- isLoadingSave=false;
|
|
|
|
|
|
|
+ isLoadingSave = false;
|
|
|
validateForm!: FormGroup;
|
|
validateForm!: FormGroup;
|
|
|
- reExpenseSlip:ReExpenseSlip={};//对象
|
|
|
|
|
- proList=[];//项目集合
|
|
|
|
|
- personnelList=[];//人员集合
|
|
|
|
|
|
|
+ reExpenseSlip: ReExpenseSlip = {
|
|
|
|
|
+ producer: this.settingsService.user.realname,
|
|
|
|
|
+ }; //对象
|
|
|
|
|
+ proList = []; //项目集合
|
|
|
|
|
+ personnelList = []; //人员集合
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取人员下拉数据到各个页签中
|
|
* 获取人员下拉数据到各个页签中
|
|
@@ -86,6 +105,57 @@ export class ExpenseReimbursementExpenseReimbursementFormAddComponent implements
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 增行按钮
|
|
|
|
|
+ */
|
|
|
|
|
+ itemDataList = []; //明细集合
|
|
|
|
|
+ sort = 0;
|
|
|
|
|
+ addRow() {
|
|
|
|
|
+ this.itemDataList = [
|
|
|
|
|
+ ...this.itemDataList,
|
|
|
|
|
+ {
|
|
|
|
|
+ price: '',
|
|
|
|
|
+ uncoPrice: '',
|
|
|
|
|
+ coPrice: '',
|
|
|
|
|
+ sort: this.sort,
|
|
|
|
|
+ },
|
|
|
|
|
+ ];
|
|
|
|
|
+ this.sort++;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 删除行
|
|
|
|
|
+ */
|
|
|
|
|
+ deleteRow(sort) {
|
|
|
|
|
+ this.itemDataList = this.itemDataList.filter(d => d.sort !== sort);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //金额格式化
|
|
|
|
|
+ formatterDollar = (value: number) => {
|
|
|
|
|
+ if (value) {
|
|
|
|
|
+ return `$ ${value}`;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return `$ `;
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ parserDollar = (value: string) => value.replace('$ ', '');
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询费用档案数据
|
|
|
|
|
+ */
|
|
|
|
|
+ costIdList = []; //费用项目下拉数据集合
|
|
|
|
|
+ getCostIdList() {
|
|
|
|
|
+ return new Promise(resolve => {
|
|
|
|
|
+ let baseArchivesCost = new BaseArchivesCost();
|
|
|
|
|
+ baseArchivesCost.pkOrg = sessionStorage.getItem('pkOrg'); //组织
|
|
|
|
|
+ baseArchivesCost.pageSize = 20000;
|
|
|
|
|
+ this.baseArchivesCostService.getList(baseArchivesCost).then(response => {
|
|
|
|
|
+ this.costIdList = response.result.records;
|
|
|
|
|
+ resolve();
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 保存提交
|
|
* 保存提交
|
|
|
*/
|
|
*/
|
|
@@ -96,8 +166,71 @@ export class ExpenseReimbursementExpenseReimbursementFormAddComponent implements
|
|
|
this.validateForm.controls[i].updateValueAndValidity();
|
|
this.validateForm.controls[i].updateValueAndValidity();
|
|
|
}
|
|
}
|
|
|
let valid = this.validateForm.valid;
|
|
let valid = this.validateForm.valid;
|
|
|
|
|
+ if(valid){
|
|
|
|
|
+ this.isLoadingSave=true;
|
|
|
|
|
+ this.reExpenseSlip.pkOrg=sessionStorage.getItem("pkOrg");//组织
|
|
|
|
|
+ //日期
|
|
|
|
|
+ this.reExpenseSlip.date = this.datePipe.transform(this.reExpenseSlip.date, 'yyyy-MM-dd HH:mm:ss');
|
|
|
|
|
+ //人员名称
|
|
|
|
|
+ if (this.reExpenseSlip.personId) {
|
|
|
|
|
+ //循环集合数据获取名称
|
|
|
|
|
+ this.personnelList.forEach(pkOrg => {
|
|
|
|
|
+ pkOrg.children.forEach(depart => {
|
|
|
|
|
+ depart.children.forEach(personnel => {
|
|
|
|
|
+ if (personnel.key === this.reExpenseSlip.personId) {
|
|
|
|
|
+ this.reExpenseSlip.person = personnel.name;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ //项目名称
|
|
|
|
|
+ if(this.reExpenseSlip.proId){
|
|
|
|
|
+ this.proList.forEach(element => {
|
|
|
|
|
+ if(element.id===this.reExpenseSlip.proId){
|
|
|
|
|
+ this.reExpenseSlip.proName=element.proName;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ //明细
|
|
|
|
|
+ if(this.itemDataList){
|
|
|
|
|
+ this.itemDataList.forEach(element => {
|
|
|
|
|
+ //获取明细中下拉选择的费用项目名称
|
|
|
|
|
+ if(element.costId){
|
|
|
|
|
+ this.costIdList.forEach(cost => {
|
|
|
|
|
+ if(cost.id===element.costId){
|
|
|
|
|
+ element.costName=cost.name;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }else{
|
|
|
|
|
+ element.costName="";
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ //获取明细数据
|
|
|
|
|
+ this.reExpenseSlip.detailList=this.itemDataList;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ this.nzNotificationService.warning('费用项目必填', '');
|
|
|
|
|
+ this.isLoadingSave=false;
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.reExpenseSlipService.add(this.reExpenseSlip).then((response)=>{
|
|
|
|
|
+ if (response.success) {
|
|
|
|
|
+ //保存成功
|
|
|
|
|
+ this.isLoadingSave = false;
|
|
|
|
|
+ this.nzNotificationService.success(this.i18NService.fanyi('save.ok'), '');
|
|
|
|
|
+ this.drawerRef.close(true);
|
|
|
|
|
+ resolve();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //保存失败
|
|
|
|
|
+ this.isLoadingSave = false;
|
|
|
|
|
+ this.nzNotificationService.error(this.i18NService.fanyi('save.not'), '');
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- close() {}
|
|
|
|
|
|
|
+ close() {
|
|
|
|
|
+ this.drawerRef.close();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|