|
@@ -0,0 +1,227 @@
|
|
|
+import { Component, OnInit } from '@angular/core';
|
|
|
+import { NzModalRef, NzMessageService, NzNotificationService, NzDrawerRef } from 'ng-zorro-antd';
|
|
|
+import { _HttpClient, SettingsService } from '@delon/theme';
|
|
|
+import { InvoiceManagePurchase } from 'app/entity/invoice-management/invoice-manage-purchase';
|
|
|
+import { FormBuilder, Validators, FormGroup } from '@angular/forms';
|
|
|
+import { DatePipe } from '@angular/common';
|
|
|
+import { ProjectManageArchives } from 'app/entity/project-manage-archives/project-manage-archives';
|
|
|
+import { ProjectManageArchivesService } from 'app/services/project-manage-archives/project-manage-archives.service';
|
|
|
+import { BaseArchivesCollectionLine } from 'app/entity/basedata/base-archives-collection-line';
|
|
|
+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';
|
|
|
+
|
|
|
+@Component({
|
|
|
+ selector: 'app-invoice-management-invoice-manage-purchase-add',
|
|
|
+ templateUrl: './add.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 InvoiceManagementInvoiceManagePurchaseAddComponent 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.getProList().then(() => {
|
|
|
+ return this.getCoArchivesList();
|
|
|
+ }).then(()=>{
|
|
|
+ this.isLoadingSave = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ validateForm!: FormGroup;
|
|
|
+ invoiceManagePurchase: InvoiceManagePurchase = {
|
|
|
+ currentUser: this.settingsService.user.realname,
|
|
|
+ createTime: this.datePipe.transform(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
|
|
+ };
|
|
|
+ isLoadingSave = false;
|
|
|
+ proList = [];
|
|
|
+ itemDataList=[];
|
|
|
+ coArchivesList=[];
|
|
|
+
|
|
|
+
|
|
|
+ * 获取项目下拉数据
|
|
|
+ */
|
|
|
+ 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();
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 获取条线下拉数据
|
|
|
+ */
|
|
|
+ getCoArchivesList(){
|
|
|
+ return new Promise(resolve => {
|
|
|
+ let baseArchivesCollectionLine = new BaseArchivesCollectionLine();
|
|
|
+ baseArchivesCollectionLine.pageSize = 20000;
|
|
|
+ baseArchivesCollectionLine.pkOrg = sessionStorage.getItem('pkOrg');
|
|
|
+ this.baseArchivesCollectionLineService.getList(baseArchivesCollectionLine).then(response => {
|
|
|
+ if (response.result.records) {
|
|
|
+ this.coArchivesList = 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;
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 获取里程碑下拉数据
|
|
|
+ */
|
|
|
+ proBusinessList=[];
|
|
|
+ getBusinessList(){
|
|
|
+
|
|
|
+ let business={id:this.invoiceManagePurchase.proArchivesId,planType:"1"}
|
|
|
+ this.projectManageArchivesService.getBusinessList(business).then((response)=>{
|
|
|
+ if(response.success){
|
|
|
+ this.proBusinessList=response.result;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 增行按钮
|
|
|
+ */
|
|
|
+ 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="1";
|
|
|
+ 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.add(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();
|
|
|
+ }
|
|
|
+}
|