|
@@ -0,0 +1,255 @@
|
|
|
+import { Component, OnInit } from '@angular/core';
|
|
|
+import { NzModalRef, NzMessageService, NzNotificationService, NzDrawerRef } from 'ng-zorro-antd';
|
|
|
+import { _HttpClient, SettingsService } from '@delon/theme';
|
|
|
+import { FormBuilder, Validators, FormGroup } from '@angular/forms';
|
|
|
+import { PersonnelService } from 'app/services/basedata/personnel.service';
|
|
|
+import { ProjectManageArchivesService } from 'app/services/project-manage-archives/project-manage-archives.service';
|
|
|
+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';
|
|
|
+import { ReExpenseSlip } from 'app/entity/expense-reimbursement/re-expense-slip';
|
|
|
+import { recursiveQuery } from '@shared';
|
|
|
+import { ProjectManageArchives } from 'app/entity/project-manage-archives/project-manage-archives';
|
|
|
+import { BaseArchivesCost } from 'app/entity/basedata/base-archives-cost';
|
|
|
+
|
|
|
+@Component({
|
|
|
+ selector: 'app-expense-reimbursement-expense-reimbursement-form-update',
|
|
|
+ templateUrl: './update.component.html',
|
|
|
+ styles: [
|
|
|
+ `
|
|
|
+ .base {
|
|
|
+ position: absolute;
|
|
|
+ bottom: 0px;
|
|
|
+ width: 100%;
|
|
|
+ border-top: 1px solid rgb(232, 232, 232);
|
|
|
+ padding: 6px 16px;
|
|
|
+ text-align: right;
|
|
|
+ left: 0px;
|
|
|
+ background: #fff;
|
|
|
+ z-index: 99;
|
|
|
+ }
|
|
|
+ `,
|
|
|
+ ],
|
|
|
+})
|
|
|
+export class ExpenseReimbursementExpenseReimbursementFormUpdateComponent implements OnInit {
|
|
|
+ constructor(
|
|
|
+ private fb: FormBuilder,
|
|
|
+ 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 {
|
|
|
+
|
|
|
+ this.validateForm = this.fb.group({
|
|
|
+ proId: [null, [Validators.required]],
|
|
|
+ date: [null, [Validators.required]],
|
|
|
+ personId: [null, [Validators.required]],
|
|
|
+ });
|
|
|
+ this.isLoadingSave=true;
|
|
|
+
|
|
|
+ this.getPersonnelList().then(() => {
|
|
|
+ return this.getProList();
|
|
|
+ }).then(()=>{
|
|
|
+ return this.getCostIdList();
|
|
|
+ }).then(()=>{
|
|
|
+ return this.getListById();
|
|
|
+ }).then(()=>{
|
|
|
+ this.isLoadingSave=false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ isLoadingSave = false;
|
|
|
+ validateForm!: FormGroup;
|
|
|
+ reExpenseSlip: ReExpenseSlip = {
|
|
|
+ producer: this.settingsService.user.realname,
|
|
|
+ };
|
|
|
+ proList = [];
|
|
|
+ personnelList = [];
|
|
|
+ id="";
|
|
|
+
|
|
|
+
|
|
|
+ * 根据id查询主子表数据
|
|
|
+ */
|
|
|
+ getListById(){
|
|
|
+ return new Promise((resolve)=>{
|
|
|
+ this.reExpenseSlipService.getListById(this.id).then((response)=>{
|
|
|
+ this.reExpenseSlip=response.result;
|
|
|
+ this.itemDataList=response.result.detailList;
|
|
|
+ if(this.itemDataList){
|
|
|
+ this.sort=this.itemDataList.length+1;
|
|
|
+ }
|
|
|
+ resolve();
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 获取人员下拉数据到各个页签中
|
|
|
+ */
|
|
|
+ getPersonnelList() {
|
|
|
+ return new Promise(resolve => {
|
|
|
+ this.personnelService.queryApprover(sessionStorage.getItem('pkOrg')).then(response => {
|
|
|
+
|
|
|
+ this.personnelList = JSON.parse(JSON.stringify(response.result));
|
|
|
+ recursiveQuery(this.personnelList);
|
|
|
+ resolve();
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 获取项目下拉数据
|
|
|
+ */
|
|
|
+ getProList() {
|
|
|
+ return new Promise(resolve => {
|
|
|
+
|
|
|
+ let projectManageArchives = new ProjectManageArchives();
|
|
|
+ projectManageArchives.pageSize = 20000;
|
|
|
+ projectManageArchives.pkOrg = sessionStorage.getItem('pkOrg');
|
|
|
+
|
|
|
+ this.projectManageArchivesService.getList(projectManageArchives).then(response => {
|
|
|
+ if (response.result.records) {
|
|
|
+ this.proList = response.result.records;
|
|
|
+ }
|
|
|
+ resolve();
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 增行按钮
|
|
|
+ */
|
|
|
+ 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();
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 保存提交
|
|
|
+ */
|
|
|
+ submitForm(): any {
|
|
|
+ return new Promise(resolve => {
|
|
|
+ for (const i in this.validateForm.controls) {
|
|
|
+ this.validateForm.controls[i].markAsDirty();
|
|
|
+ this.validateForm.controls[i].updateValueAndValidity();
|
|
|
+ }
|
|
|
+ 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.update(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() {
|
|
|
+ this.drawerRef.close();
|
|
|
+ }
|
|
|
+}
|