|
@@ -0,0 +1,329 @@
|
|
|
+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 { DatePipe } from '@angular/common';
|
|
|
+import { ProjectManageArchivesService } from 'app/services/project-manage-archives/project-manage-archives.service';
|
|
|
+import { BaseArchivesCollectionLineService } from 'app/services/basedata/base-archives-collection-line.service';
|
|
|
+import { InvoiceManagePurchaseService } from 'app/services/invoice-management/invoice-manage-purchase.service';
|
|
|
+import { I18NService } from '@core';
|
|
|
+import { InvoiceManagePurchase } from 'app/entity/invoice-management/invoice-manage-purchase';
|
|
|
+import { ProjectManageArchives } from 'app/entity/project-manage-archives/project-manage-archives';
|
|
|
+
|
|
|
+@Component({
|
|
|
+ selector: 'app-invoice-management-invoice-sales-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 InvoiceManagementInvoiceSalesUpdateComponent implements OnInit {
|
|
|
+ constructor(
|
|
|
+ private fb: FormBuilder,
|
|
|
+ private settingsService: SettingsService,
|
|
|
+ private datePipe: DatePipe,
|
|
|
+ private projectManageArchivesService: ProjectManageArchivesService,
|
|
|
+ private baseArchivesCollectionLineService: BaseArchivesCollectionLineService,
|
|
|
+ private nzNotificationService: NzNotificationService,
|
|
|
+ private drawerRef: NzDrawerRef,
|
|
|
+ private invoiceManagePurchaseService: InvoiceManagePurchaseService,
|
|
|
+ private i18NService: I18NService,
|
|
|
+ ) {}
|
|
|
+
|
|
|
+ ngOnInit(): void {
|
|
|
+
|
|
|
+ this.validateForm = this.fb.group({
|
|
|
+ proArchivesId: [null, [Validators.required]],
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ this.isLoadingSave = true;
|
|
|
+
|
|
|
+ this.queryById()
|
|
|
+ .then(() => {
|
|
|
+
|
|
|
+ return this.getProList();
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ this.isLoadingSave = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ validateForm!: FormGroup;
|
|
|
+ invoiceManagePurchase: InvoiceManagePurchase = {};
|
|
|
+ isLoadingSave = false;
|
|
|
+ proList = [];
|
|
|
+ itemDataList = [];
|
|
|
+ coArchivesList = [];
|
|
|
+ id = '';
|
|
|
+
|
|
|
+ queryById() {
|
|
|
+ return new Promise(resolve => {
|
|
|
+ this.invoiceManagePurchaseService.queryById(this.id).then(response => {
|
|
|
+ if (response.success) {
|
|
|
+ this.invoiceManagePurchase = response.result;
|
|
|
+ this.itemDataList = response.result.detailList;
|
|
|
+
|
|
|
+ this.itemDataList.forEach(element => {
|
|
|
+ this.coArchivesChange(element);
|
|
|
+
|
|
|
+ element.uncoPriceMax = JSON.parse(JSON.stringify(element.uncoPrice));
|
|
|
+
|
|
|
+ element.oneCoPrice = JSON.parse(JSON.stringify(element.coPrice));
|
|
|
+ });
|
|
|
+ if (this.itemDataList) {
|
|
|
+
|
|
|
+ this.sort = this.itemDataList.length + 1;
|
|
|
+ }
|
|
|
+ resolve();
|
|
|
+ } else {
|
|
|
+ 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.invoiceManagePurchase.proCode = project.proCode;
|
|
|
+ this.invoiceManagePurchase.proName = project.proName;
|
|
|
+
|
|
|
+ this.getLineList();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ getLineList() {
|
|
|
+
|
|
|
+ let projectManageArchives = { proArchivesId: this.invoiceManagePurchase.proArchivesId, planType: '1' };
|
|
|
+ this.projectManageArchivesService.getLineList(projectManageArchives).then(response => {
|
|
|
+ if (response.success) {
|
|
|
+ this.coArchivesList = response.result;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 条线下拉选择事件
|
|
|
+ * 获取名称和里程碑下拉数据
|
|
|
+ */
|
|
|
+ coArchivesChange(data) {
|
|
|
+ if (data.coArchivesId) {
|
|
|
+
|
|
|
+ this.coArchivesList.forEach(element => {
|
|
|
+ if (data.coArchivesId === element.id) {
|
|
|
+ data.coArchivesName = element.planName;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ let where = { businessId: data.coArchivesId };
|
|
|
+ this.projectManageArchivesService.getMileNameById(where).then(response => {
|
|
|
+ if (response.success) {
|
|
|
+ data.proBusinessList = response.result;
|
|
|
+
|
|
|
+ if (data.proBusinessId) {
|
|
|
+ this.proBusinessChange(data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ *
|
|
|
+ * 获取名称和金额
|
|
|
+ */
|
|
|
+ uncoPrice = 0;
|
|
|
+ proBusinessChange(data) {
|
|
|
+ if (data.proBusinessId) {
|
|
|
+ data.proBusinessList.forEach(element => {
|
|
|
+ if (element.mileId === data.proBusinessId) {
|
|
|
+ data.proArchivesMilestone = element.mileName;
|
|
|
+ data.price = element.price;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 里程碑选择事件
|
|
|
+ */
|
|
|
+ proBusinessIdChange(data) {
|
|
|
+ if (data.proBusinessId) {
|
|
|
+ this.proBusinessChange(data);
|
|
|
+
|
|
|
+ let where = { coArchivesId: data.coArchivesId, proBusinessId: data.proBusinessId };
|
|
|
+
|
|
|
+ this.invoiceManagePurchaseService.getChildrenList(where).then(response => {
|
|
|
+ if (response.success) {
|
|
|
+ if (response.result.uncoPrice) {
|
|
|
+ data.uncoPrice = response.result.uncoPrice;
|
|
|
+ data.uncoPriceMax = Number(response.result.uncoPrice);
|
|
|
+ } else {
|
|
|
+ data.uncoPrice = JSON.parse(JSON.stringify(data.price));
|
|
|
+ data.uncoPriceMax = Number(JSON.parse(JSON.stringify(data.price)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 收票输入事件
|
|
|
+ */
|
|
|
+ coPriceKeyUp(data) {
|
|
|
+ if (data.coPrice) {
|
|
|
+ if (data.id) {
|
|
|
+
|
|
|
+ data.uncoPrice = data.uncoPriceMax - (Number(data.coPrice) - Number(data.oneCoPrice));
|
|
|
+ }else{
|
|
|
+
|
|
|
+ data.uncoPrice=data.uncoPriceMax-Number(data.coPrice);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 增行按钮
|
|
|
+ */
|
|
|
+ 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('$ ', '');
|
|
|
+
|
|
|
+
|
|
|
+ * 提交保存按钮
|
|
|
+ */
|
|
|
+ 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.invoiceManagePurchase.type = '2';
|
|
|
+ this.invoiceManagePurchase.pkOrg = sessionStorage.getItem('pkOrg');
|
|
|
+
|
|
|
+ if (this.itemDataList && this.itemDataList.length > 0) {
|
|
|
+ this.itemDataList.forEach(element => {
|
|
|
+
|
|
|
+ if (element.coArchivesId) {
|
|
|
+ this.coArchivesList.forEach(coArchives => {
|
|
|
+ if (coArchives.id == element.coArchivesId) {
|
|
|
+ element.coArchivesName = coArchives.name;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ element.coArchivesName = '';
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+
|
|
|
+ this.nzNotificationService.warning('填写明细数据', '');
|
|
|
+ this.isLoadingSave = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.invoiceManagePurchase.detailList = this.itemDataList;
|
|
|
+ this.invoiceManagePurchaseService.update(this.invoiceManagePurchase).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();
|
|
|
+ }
|
|
|
+}
|