diff --git a/src/app/pages/order/order-form/order-form.component.html b/src/app/pages/order/order-form/order-form.component.html index f5daa15..5c6f1f3 100644 --- a/src/app/pages/order/order-form/order-form.component.html +++ b/src/app/pages/order/order-form/order-form.component.html @@ -145,6 +145,7 @@ + @@ -159,11 +160,11 @@
- + - {{user.productName }}({{user.skuId }} ) + {{user.productName }}({{user.skuId }} ) @@ -192,10 +193,11 @@ - + + - +
diff --git a/src/app/pages/order/order-form/order-form.component.ts b/src/app/pages/order/order-form/order-form.component.ts index df8151a..16072b9 100644 --- a/src/app/pages/order/order-form/order-form.component.ts +++ b/src/app/pages/order/order-form/order-form.component.ts @@ -39,7 +39,7 @@ export class OrderFormComponent implements OnInit { { label: 'Item 2', quantity: 0 }, { label: 'Item 3', quantity: 0 } ]; -fieldTitle:any =' New Order' +fieldTitle:any ='New Order' minimize = false; maximize = false; fullScreen = true; @@ -60,7 +60,7 @@ fieldTitle:any =' New Order' delArr:any=[] selectedProductId: number | undefined = null; addFormBtn: any; - constructor(private dialogService: NbDialogService,private route :ActivatedRoute,private router: Router,public _api:PageapiService,private toastrService: NbToastrService,private service: SmartTableData ,private windowService: NbWindowService) { + constructor(private dialogService: NbDialogService,private route :ActivatedRoute,private router: Router,public _api:PageapiService,private toastrService: NbToastrService,private service: SmartTableData ,private windowService: NbWindowService) { this._api.orderDetails_observable$.subscribe((res) => { console.log('booked', res); @@ -193,15 +193,33 @@ fieldTitle:any =' New Order' } getProductlistApi(param){ - let data ={type : param} - this.getProductlistApi2( param) + console.log(this.fieldTitle, param) + let data + if(this.fieldTitle != 'New Order'){ + data ={} + }else { + data ={type : param} + } + console.log(data) + this.getProductlistApi2(param) this._api.getProducts(data).subscribe(res => { console.log(res) if(res.status == 200){ - let passData = res.data - let product = passData -console.log(product) + let passData = res.data + let product + if(this.fieldTitle != 'New Order'){ + + let UniqueProducts = this.getUniqueProducts(passData, 'productName'); + let filteredProducts = UniqueProducts.filter(product => product.productCategory === param); + product = filteredProducts + + } else{ + product = passData + } + + + console.log(product) product.forEach((element:any, index) => { element.index = index +1 element.qty = 0; @@ -210,6 +228,8 @@ console.log(product) }); this.product = product + + console.log(this.product) // this.productfull = product if(this.setData != undefined){ if( Object.keys(this.setData).length != 0){ @@ -230,6 +250,20 @@ console.log(product) }) } + getUniqueProducts(products: any[], propertyName: string): any[] { + const uniqueProducts = []; + const seen = new Set(); + + for (const product of products) { + const value = product[propertyName]; + if (!seen.has(value)) { + seen.add(value); + uniqueProducts.push(product); + } + } + + return uniqueProducts; + } getProductlistApi2(param){ let data ={type : param} @@ -357,7 +391,7 @@ console.log(product) this.inputFieldGroups.forEach((element:any) => { - + delete element.isNew; this.product.forEach(e => { @@ -403,6 +437,7 @@ this.invoice.products =[]; // console.log(mixedProductGas) const filteredItems = this.inputFieldGroups.filter(item => item.name === 'Mixed Gas' && item.productSpec === ''); +console.log(filteredItems) if (filteredItems.length > 0) { this.showToast('warning', 'Please Fill Mixed Gas Fields...!', ''); return; @@ -871,10 +906,27 @@ this.onCreateConfirm() } addInputFieldGroup() { - this.inputFieldGroups.push({id:null, qty: '1', productSpec: '' }); // Add a new input field group to the array + if(this.fieldTitle != 'New Order'){ + console.log(this.product) + let activeProductList = this.product.filter(item => item.isActive == '1') + console.log(activeProductList) + this.product = activeProductList + } + // this.inputFieldGroups.push({id:null, qty: '1', productSpec: '' }); + // Add a new input field group to the array + const newGroup = { id: null, qty: 1, productSpec: '', isNew: true }; + this.inputFieldGroups.push(newGroup); //this.childButtonEvent.emit( this.inputFieldGroups); } +isReadOnly(param,index: number) { + console.log(this.inputFieldGroups) + console.log(param,index) + // You can add your condition here to determine if the option should be readonly. + // For example, if you want to make options at index 2 and 3 readonly: + // return index === 2 || index === 3; +} + removeInputFieldGroup(index: number) { console.log( this.inputFieldGroups[index].primaryId) this.delArr.push(this.inputFieldGroups[index].primaryId)