feat: implement stock keeping unit management form and list components
- Added StockKeepingUnitFormComponent for creating and editing stock keeping units. - Introduced StockKeepingUnitsComponent for listing stock keeping units with pagination. - Integrated form fields for code, name, VAT, and SKU type in the stock keeping unit form. - Created API routes for stock keeping units with CRUD operations. - Updated input components to handle numeric and price types with Persian/Arabic digit normalization. - Enhanced key-value component to support tag display instead of badge. - Adjusted layout styles for sidebar menu. - Added AGENT.md for repository-specific coding guidelines and practices. - Implemented good management form with file upload and category selection.
This commit is contained in:
@@ -24,7 +24,7 @@ export class ConsumerAccountsComponent extends AbstractList<IAccountResponse> {
|
||||
|
||||
override setColumns(): void {
|
||||
this.columns = [
|
||||
{ field: 'id', header: 'شناسه', type: 'id' },
|
||||
// { field: 'id', header: 'شناسه', type: 'id' },
|
||||
{
|
||||
field: 'username',
|
||||
header: 'نام کاربری',
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ export class ConsumerComplexListComponent extends AbstractList<IComplexResponse>
|
||||
@Input({ required: true }) businessId!: string;
|
||||
@Input() fullHeight?: boolean;
|
||||
@Input() header: IColumn[] = [
|
||||
{ field: 'id', header: 'شناسه', type: 'id' },
|
||||
// { field: 'id', header: 'شناسه', type: 'id' },
|
||||
{ field: 'name', header: 'عنوان' },
|
||||
{ field: 'branch_code', header: 'کد شعبه' },
|
||||
{
|
||||
|
||||
+11
-17
@@ -1,17 +1,11 @@
|
||||
<shared-dialog [header]="preparedTitle" [(visible)]="visible" [modal]="true" [style]="{ width: '500px' }" [closable]="true">
|
||||
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
|
||||
<app-input label="عنوان" [control]="form.controls.name" name="name" />
|
||||
<app-input label="شناسه عمومی" [control]="form.controls.sku" name="sku" />
|
||||
<catalog-guild-goodCategories-select
|
||||
[guildId]="guildId"
|
||||
label="دستهبندی"
|
||||
[control]="form.controls.category_id"
|
||||
name="category_id"
|
||||
/>
|
||||
<app-enum-select type="unitType" [control]="form.controls.unit_type" />
|
||||
<app-enum-select type="goodPricingModel" [control]="form.controls.pricing_model" />
|
||||
<app-input label="توضیحات" [control]="form.controls.description" name="description" />
|
||||
|
||||
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||
</form>
|
||||
</shared-dialog>
|
||||
<shared-good-form
|
||||
[guildId]="guildId"
|
||||
[visible]="visible"
|
||||
(visibleChange)="visibleChange.emit($event)"
|
||||
[initialValues]="initialValues"
|
||||
[editMode]="editMode"
|
||||
[createFn]="create"
|
||||
[updateFn]="update"
|
||||
(onSubmit)="onSubmit.emit($event)"
|
||||
(onClose)="onClose.emit()"
|
||||
/>
|
||||
|
||||
+16
-42
@@ -1,57 +1,31 @@
|
||||
import { AbstractFormDialog } from '@/shared/abstractClasses';
|
||||
import { InputComponent } from '@/shared/components';
|
||||
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
|
||||
import { Component, inject, Input } from '@angular/core';
|
||||
import { ReactiveFormsModule, Validators } from '@angular/forms';
|
||||
import { Component, EventEmitter, Input, Output, inject } from '@angular/core';
|
||||
|
||||
import { EnumSelectComponent } from '@/shared/apiEnum/select.component';
|
||||
import { CatalogGuildGoodCategoriesSelectComponent } from '@/shared/catalog/guildGoodCategories';
|
||||
import { SharedDialogComponent } from '@/shared/components/dialog/dialog.component';
|
||||
import {
|
||||
IConsumerBusinessActivityGoodRequest,
|
||||
IConsumerBusinessActivityGoodResponse,
|
||||
} from '../../models/goods_io';
|
||||
import { AbstractDialog } from '@/shared/abstractClasses/abstract-dialog';
|
||||
import { IGoodResponse, SharedGoodFormComponent } from '@/shared/components/good';
|
||||
import { IConsumerBusinessActivityGoodResponse } from '../../models/goods_io';
|
||||
import { BusinessActivityGoodsService } from '../../services/goods.service';
|
||||
|
||||
@Component({
|
||||
selector: 'consumer-businessActivity-good-form',
|
||||
templateUrl: './form.component.html',
|
||||
imports: [
|
||||
ReactiveFormsModule,
|
||||
SharedDialogComponent,
|
||||
InputComponent,
|
||||
FormFooterActionsComponent,
|
||||
EnumSelectComponent,
|
||||
CatalogGuildGoodCategoriesSelectComponent,
|
||||
],
|
||||
imports: [SharedGoodFormComponent],
|
||||
})
|
||||
export class ConsumerBusinessActivityGoodFormComponent extends AbstractFormDialog<
|
||||
IConsumerBusinessActivityGoodRequest,
|
||||
IConsumerBusinessActivityGoodResponse
|
||||
> {
|
||||
export class ConsumerBusinessActivityGoodFormComponent extends AbstractDialog {
|
||||
@Input({ required: true }) businessId!: string;
|
||||
@Input({ required: true }) guildId!: string;
|
||||
@Input() categoryId?: string;
|
||||
@Input() initialValues?: IConsumerBusinessActivityGoodResponse;
|
||||
@Input() editMode?: boolean;
|
||||
|
||||
@Output() onSubmit = new EventEmitter<IGoodResponse>();
|
||||
|
||||
private service = inject(BusinessActivityGoodsService);
|
||||
|
||||
form = this.fb.group({
|
||||
name: [this.initialValues?.name || '', [Validators.required]],
|
||||
sku: [this.initialValues?.sku || '', [Validators.required]],
|
||||
unit_type: [this.initialValues?.unit_type || '', [Validators.required]],
|
||||
pricing_model: [this.initialValues?.pricing_model || '', [Validators.required]],
|
||||
category_id: [this.initialValues?.category.id || '', [Validators.required]],
|
||||
description: [this.initialValues?.description || ''],
|
||||
});
|
||||
|
||||
get preparedTitle() {
|
||||
return `${this.editMode ? 'ویرایش' : 'افزودن'} کالا`;
|
||||
}
|
||||
|
||||
override submitForm(payload: IConsumerBusinessActivityGoodRequest) {
|
||||
if (this.editMode) {
|
||||
return this.service.update(this.businessId, this.categoryId!, payload);
|
||||
}
|
||||
create = (payload: FormData) => {
|
||||
return this.service.create(this.businessId, payload);
|
||||
}
|
||||
};
|
||||
|
||||
update = (payload: FormData) => {
|
||||
return this.service.update(this.businessId, this.categoryId!, payload);
|
||||
};
|
||||
}
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ export class ConsumerBusinessActivityGoodsListComponent extends AbstractList<ICo
|
||||
@Input({ required: true }) guildId!: string;
|
||||
@Input() fullHeight?: boolean;
|
||||
@Input() header: IColumn[] = [
|
||||
{ field: 'id', header: 'شناسه', type: 'id' },
|
||||
// { field: 'id', header: 'شناسه', type: 'id' },
|
||||
{ field: 'name', header: 'عنوان' },
|
||||
{ field: 'sku', header: 'شناسه عمومی' },
|
||||
{
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ export class ConsumerSalesInvoicesComponent extends AbstractList<ISalesInvoicesR
|
||||
@Input({ required: true }) posId!: string;
|
||||
@Input() fullHeight?: boolean;
|
||||
@Input() header: IColumn[] = [
|
||||
{ field: 'id', header: 'شناسه', type: 'id' },
|
||||
// { field: 'id', header: 'شناسه', type: 'id' },
|
||||
{ field: 'code', header: 'کد رهگیری' },
|
||||
{ field: 'total_amount', header: 'مبلغ کل', type: 'price' },
|
||||
{
|
||||
|
||||
@@ -3,9 +3,10 @@ import ISummary from '@/core/models';
|
||||
export interface IConsumerBusinessActivityGoodRawResponse {
|
||||
id: string;
|
||||
name: string;
|
||||
sku: string;
|
||||
image_url: string;
|
||||
sku: ISummary;
|
||||
category: ISummary;
|
||||
unit_type: string;
|
||||
measure_unit: ISummary;
|
||||
pricing_model: string;
|
||||
description?: string;
|
||||
created_at: string;
|
||||
@@ -15,9 +16,9 @@ export interface IConsumerBusinessActivityGoodResponse extends IConsumerBusiness
|
||||
|
||||
export interface IConsumerBusinessActivityGoodRequest {
|
||||
name: string;
|
||||
sku: string;
|
||||
sku_id: string;
|
||||
category_id: string;
|
||||
unit_type: string;
|
||||
measure_unit_id: string;
|
||||
pricing_model: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import { Observable } from 'rxjs';
|
||||
import { CONSUMER_BUSINESS_ACTIVITY_GOODS_API_ROUTES } from '../constants/apiRoutes/businessActivityGoods';
|
||||
import {
|
||||
IConsumerBusinessActivityGoodRawResponse,
|
||||
IConsumerBusinessActivityGoodRequest,
|
||||
IConsumerBusinessActivityGoodResponse,
|
||||
} from '../models/goods_io';
|
||||
|
||||
@@ -28,10 +27,7 @@ export class BusinessActivityGoodsService {
|
||||
);
|
||||
}
|
||||
|
||||
create(
|
||||
businessId: string,
|
||||
data: IConsumerBusinessActivityGoodRequest,
|
||||
): Observable<IConsumerBusinessActivityGoodResponse> {
|
||||
create(businessId: string, data: FormData): Observable<IConsumerBusinessActivityGoodResponse> {
|
||||
return this.http.post<IConsumerBusinessActivityGoodResponse>(
|
||||
this.apiRoutes.list(businessId),
|
||||
data,
|
||||
@@ -41,7 +37,7 @@ export class BusinessActivityGoodsService {
|
||||
update(
|
||||
businessId: string,
|
||||
id: string,
|
||||
data: IConsumerBusinessActivityGoodRequest,
|
||||
data: FormData,
|
||||
): Observable<IConsumerBusinessActivityGoodResponse> {
|
||||
return this.http.patch<IConsumerBusinessActivityGoodResponse>(
|
||||
this.apiRoutes.single(businessId, id),
|
||||
|
||||
@@ -15,7 +15,7 @@ export class ConsumerBusinessActivitiesComponent extends AbstractList<IBusinessA
|
||||
|
||||
override setColumns(): void {
|
||||
this.columns = [
|
||||
{ field: 'id', header: 'شناسه', type: 'id' },
|
||||
// { field: 'id', header: 'شناسه', type: 'id' },
|
||||
{ field: 'name', header: 'عنوان' },
|
||||
{
|
||||
field: 'created_at',
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { AbstractDialog } from '@/shared/abstractClasses/abstract-dialog';
|
||||
import { SharedDialogComponent } from '@/shared/components/dialog/dialog.component';
|
||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { ICustomerResponse } from '../models';
|
||||
import { ConsumerCustomerIndividualFormComponent } from './form-individual.component';
|
||||
import { ConsumerCustomerLegalFormComponent } from './form-legal.component';
|
||||
import { SharedDialogComponent } from '@/shared/components/dialog/dialog.component';
|
||||
|
||||
@Component({
|
||||
selector: 'consumer-customer-form-dialog',
|
||||
|
||||
@@ -19,7 +19,7 @@ import { CustomersService } from '../services/main.service';
|
||||
export class ConsumerCustomerListComponent extends AbstractList<ICustomerResponse> {
|
||||
@Input() fullHeight?: boolean;
|
||||
@Input() header: IColumn[] = [
|
||||
{ field: 'id', header: 'شناسه', type: 'id' },
|
||||
// { field: 'id', header: 'شناسه', type: 'id' },
|
||||
{
|
||||
field: 'type',
|
||||
header: 'نوع مشتری',
|
||||
|
||||
@@ -2,7 +2,7 @@ import { EntityState, EntityStore } from '@/core/state';
|
||||
import { computed, inject, Injectable } from '@angular/core';
|
||||
import { MenuItem } from 'primeng/api';
|
||||
import { catchError, finalize } from 'rxjs';
|
||||
import { consumerPosesNamedRoutes } from '../../businessActivities/constants/routes/poses';
|
||||
import { ConsumerPosesNamedRoutes } from '../constants/routes/index';
|
||||
import { IPosResponse } from '../models';
|
||||
import { ConsumerPosesService } from '../services/main.service';
|
||||
|
||||
@@ -32,12 +32,12 @@ export class ConsumerPosStore extends EntityStore<IPosResponse, ConsumerPosState
|
||||
this.patchState({
|
||||
breadcrumbItems: [
|
||||
{
|
||||
...consumerPosesNamedRoutes.poses.meta,
|
||||
routerLink: consumerPosesNamedRoutes.poses.meta.pagePath!(),
|
||||
...ConsumerPosesNamedRoutes.poses.meta,
|
||||
routerLink: ConsumerPosesNamedRoutes.poses.meta.pagePath!(),
|
||||
},
|
||||
{
|
||||
title: this.entity()?.name,
|
||||
routerLink: consumerPosesNamedRoutes.pos.meta.pagePath!(posId),
|
||||
routerLink: ConsumerPosesNamedRoutes.pos.meta.pagePath!(posId),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user