123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- import { Component, OnInit, Output, EventEmitter } from '@angular/core';
- import { NzModalRef, NzMessageService, NzModalService } from 'ng-zorro-antd';
- import { _HttpClient } from '@delon/theme';
- import { ContractFileProduct } from 'app/entity/contract-management/contract-file-product';
- import { ContractFileModular } from 'app/entity/contract-management/contract-file-modular';
- import { ContractFile } from 'app/entity/contract-management/contract-file';
- import { RoutesSharedModalProdutSelectComponent } from 'app/routes/shared/modal/produt-select/produt-select.component';
- @Component({
- selector: 'app-contract-management-contract-file-add-product-module',
- templateUrl: './product-module.component.html',
- })
- export class ContractManagementContractFileAddProductModuleComponent implements OnInit {
- constructor(
- private modalService:NzModalService
- ) {}
- ngOnInit(): void {}
- productList: ContractFileProduct[] = []; //产品数据
- // moduleList:ContractFileModular[]=[];//模块数据
- formatterDollar = (value: number): string => `¥ ${value}`;
- parserDollar = (value: string): string => value.replace('¥ ', '');
- /**
- * 产品新增行
- */
- prouctI = 0;
- productAddRow() {
- this.productList = [
- ...this.productList,
- {
- id: `${this.prouctI}`,
- code: '',
- name: '',
- discountRate: 0,
- standardQuotation: 0,
- unitPriceAfterDiscount: 0,
- standardAmount: 0,
- amountAfterDiscount: 0,
- costUnitPrice: 0,
- costAmount: 0,
- contractFileModularList: [],
- },
- ];
- this.prouctI++;
- }
- /**
- * 产品删除行
- */
- productDeleteRow(id) {
- this.productList = this.productList.filter(d => d.id !== id);
- }
- /**
- * 模块新增行
- */
- moduleI = 0;
- moduleAddRow(product) {
- product.contractFileModularList = [
- ...product.contractFileModularList,
- {
- id: `${this.moduleI}`,
- code: '',
- name: '',
- standardQuotation: 0,
- purchasePrice: 0,
- },
- ];
- this.moduleI++;
- }
- /**
- * 模块删除行
- */
- moduleDeleteRow(product, id) {
- product.contractFileModularList = product.contractFileModularList.filter(d => d.id !== id);
- }
- /**
- * 模块标准报价键盘弹起事件
- * @param product 产品对象
- */
- standardQuotationModuleKeyUp(product) {
- //判断当前产品下是否存在模块
- if (product && product.contractFileModularList) {
- let standardQuotationTotal = 0.0; //定义模块中标准报价总计
- //循环模块
- product.contractFileModularList.forEach(element => {
- //判断标准报价是否为数字
- if (!isNaN(Number(element.standardQuotation))) {
- //累加
- standardQuotationTotal = standardQuotationTotal + Number(element.standardQuotation);
- }
- });
- //把模块标准报价总和赋值给产品的标准报价
- product.standardQuotation = standardQuotationTotal;
- //获取品总标准报价并传入基本信息
- this.getContractFileStandardQuotationTotal();
- }
- }
- /**
- * 获取合同总共的标准报价
- */
- getContractFileStandardQuotationTotal() {
- if (this.productList) {
- let standardQuotationProductTotal = 0.0; //定义产品中标准报价总计
- this.productList.forEach(element => {
- //判断标准报价是否为数字
- if (!isNaN(Number(element.standardQuotation))) {
- //累加
- standardQuotationProductTotal = standardQuotationProductTotal + Number(element.standardQuotation);
- }
- });
- //把产品的总标准报价给合同标准报价
- this.contractFile.standardQuotation = standardQuotationProductTotal;
- //传给基本信息
- this.outContractFileObject();
- }
- }
- contractFile: ContractFile = {}; //合同的对象
- /**
- * 获取当前页面的相关信息传个父级页面
- */
- @Output() contractFileObject = new EventEmitter<{}>();
- outContractFileObject() {
- this.contractFileObject.emit(this.contractFile);
- }
- /**
- * 选择产品事件
- */
- selectProdutModal(data) {
- const modalRef = this.modalService.create({
- nzTitle: '选择产品',
- nzContent: RoutesSharedModalProdutSelectComponent,
- nzWidth: 1400,
- nzFooter: [
- {
- label: '关闭',
- type: 'default',
- onClick: addModel => {
- addModel.close();
- },
- },
- {
- label: '确定',
- type: 'primary',
- onClick: addModel => {
- addModel.save().then(()=>{
- data.code=addModel.selectObj[0].code
- data.name=addModel.selectObj[0].name
- data.baseMaterialFileProductId=addModel.selectObj[0].id
- });
- },
- },
- ],
- });
- }
- close() {}
- }
|