|
@@ -0,0 +1,212 @@
|
|
|
+import { Component, OnInit } from '@angular/core';
|
|
|
+import { NzModalRef, NzMessageService, NzNotificationService, NzDrawerRef } from 'ng-zorro-antd';
|
|
|
+import { _HttpClient } from '@delon/theme';
|
|
|
+import { ProjectManageArchivesService } from 'app/services/project-manage-archives/project-manage-archives.service';
|
|
|
+import { FormBuilder, Validators, FormGroup } from '@angular/forms';
|
|
|
+import { ManagerPaymentAndReceiptSlipService } from 'app/services/down-payment-management/manager-payment-and-receipt-slip.service';
|
|
|
+import { I18NService } from '@core';
|
|
|
+import { ManagerPaymentAndReceiptSlip } from 'app/entity/down-payment-management/manager-payment-and-receipt-slip';
|
|
|
+import { ProjectManageArchives } from 'app/entity/project-manage-archives/project-manage-archives';
|
|
|
+
|
|
|
+@Component({
|
|
|
+ selector: 'app-down-payment-management-receipt-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 DownPaymentManagementReceiptUpdateComponent implements OnInit {
|
|
|
+ constructor(private fb: FormBuilder, private projectManageArchivesService: ProjectManageArchivesService,
|
|
|
+ private managerPaymentAndReceiptSlipService:ManagerPaymentAndReceiptSlipService,
|
|
|
+ private nzNotificationService:NzNotificationService,
|
|
|
+ private i18NService:I18NService,
|
|
|
+ private drawerRef:NzDrawerRef) {}
|
|
|
+
|
|
|
+ ngOnInit(): void {
|
|
|
+
|
|
|
+ this.validateForm = this.fb.group({
|
|
|
+ proId: [null, [Validators.required]],
|
|
|
+ });
|
|
|
+ this.isLoadingSave = true;
|
|
|
+
|
|
|
+ this.getProList().then(()=>{
|
|
|
+ return this.getById();
|
|
|
+ }).then(() => {
|
|
|
+ this.isLoadingSave = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ id="";
|
|
|
+ validateForm!: FormGroup;
|
|
|
+ managerPaymentAndReceiptSlip: ManagerPaymentAndReceiptSlip = {};
|
|
|
+ isLoadingSave = false;
|
|
|
+ proList = [];
|
|
|
+ proArchivesList = [];
|
|
|
+ coArchivesList = [];
|
|
|
+ invoiceIdList=[];
|
|
|
+
|
|
|
+ formatterDollar = (value: number) => {
|
|
|
+ if (value) {
|
|
|
+ return `$ ${value}`;
|
|
|
+ } else {
|
|
|
+ return `$ `;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ parserDollar = (value: string) => value.replace('$ ', '');
|
|
|
+
|
|
|
+
|
|
|
+ * 根据id查询
|
|
|
+ */
|
|
|
+ getById(){
|
|
|
+ return new Promise(resolve => {
|
|
|
+ this.managerPaymentAndReceiptSlipService.queryById(this.id).then((response)=>{
|
|
|
+ if(response.success){
|
|
|
+ this.managerPaymentAndReceiptSlip=response.result;
|
|
|
+ this.itemDataList=response.result.detailList;
|
|
|
+ if(this.itemDataList){
|
|
|
+ this.sort=this.itemDataList.length+1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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();
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 项目下拉选择事件
|
|
|
+ */
|
|
|
+ proChange(event) {
|
|
|
+ if (event) {
|
|
|
+
|
|
|
+ this.projectManageArchivesService.getListById(event).then(response => {
|
|
|
+ if (response.success) {
|
|
|
+ let project = JSON.parse(JSON.stringify(response.result));
|
|
|
+ this.managerPaymentAndReceiptSlip.proCode = project.proCode;
|
|
|
+ this.managerPaymentAndReceiptSlip.proName = project.proName;
|
|
|
+ this.managerPaymentAndReceiptSlip.cusId = project.cusId;
|
|
|
+ this.managerPaymentAndReceiptSlip.cusCode = project.cusCode;
|
|
|
+ this.managerPaymentAndReceiptSlip.cusName = project.cusName;
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
+
|
|
|
+ this.getCoPrviceTotal();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 金额填写事件
|
|
|
+ */
|
|
|
+ coPrviceKeyUp(){
|
|
|
+
|
|
|
+ this.getCoPrviceTotal();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 获取收款金额合计
|
|
|
+ */
|
|
|
+ getCoPrviceTotal(){
|
|
|
+
|
|
|
+ if(!this.itemDataList){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ let coPrviceTotal=0;
|
|
|
+ this.itemDataList.forEach(element => {
|
|
|
+ if(element.coPrvice&&!isNaN(Number(element.coPrvice))){
|
|
|
+ coPrviceTotal=coPrviceTotal+Number(element.coPrvice);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.managerPaymentAndReceiptSlip.totalPrice=coPrviceTotal;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 保存提交
|
|
|
+ */
|
|
|
+ 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.managerPaymentAndReceiptSlip.type="1";
|
|
|
+ this.managerPaymentAndReceiptSlip.pkOrg=sessionStorage.getItem("pkOrg");
|
|
|
+ this.managerPaymentAndReceiptSlip.detailList=this.itemDataList;
|
|
|
+ this.managerPaymentAndReceiptSlipService.add(this.managerPaymentAndReceiptSlip).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();
|
|
|
+ }
|
|
|
+}
|