diff --git a/frontend/src/lib/api/dashboard/a76/general_catalogs/units-of-measure.ts b/frontend/src/lib/api/dashboard/a76/general_catalogs/units-of-measure.ts index 2aa553ca..f680bae3 100644 --- a/frontend/src/lib/api/dashboard/a76/general_catalogs/units-of-measure.ts +++ b/frontend/src/lib/api/dashboard/a76/general_catalogs/units-of-measure.ts @@ -183,7 +183,7 @@ export interface UnitOfMeasureGeneralUpdate { } export interface UnitOfMeasureGeneralListResponse { - items: UnitOfMeasureGeneral[]; + items: UnitOfMeasureGeneral[]; total: number; page: number; page_size: number; @@ -273,3 +273,38 @@ export async function updateUnitOfMeasureCustoms(id: number, data: UnitOfMeasure export async function deleteUnitOfMeasureCustoms(id: number, companyId: number): Promise> { return await api.delete(`/v1/a76/units-of-measure/customs/${id}/?company_id=${companyId}`); } + +export interface UnitOfMeasure { + id: number; + code: string; // Ej: KG, PZ + description: string | null; + description_en: string | null; + customs_code: string | null; + american_code: string | null; + created_at: string | null; + updated_at: string | null; +} + +export interface UnitOfMeasureListResponse { + items: UnitOfMeasure[]; + total: number; + page: number; + page_size: number; + pages: number; +} + +export async function getUnitsOfMeasure( + page: number = 1, + pageSize: number = 50, + companyId: number, + filters: Record = {} +): Promise> { + const queryParams = new URLSearchParams({ + page: page.toString(), + page_size: pageSize.toString(), + company_id: companyId.toString(), + ...filters + }); + // Apunta a /v1/a76/units-of-measure/ (La ruta base del router) + return await api.get(`/v1/a76/units-of-measure/?${queryParams.toString()}`); +} \ No newline at end of file diff --git a/frontend/src/lib/components/dashboard/parts/unit-measure-dialog.svelte b/frontend/src/lib/components/dashboard/parts/unit-measure-dialog.svelte new file mode 100644 index 00000000..0deb485c --- /dev/null +++ b/frontend/src/lib/components/dashboard/parts/unit-measure-dialog.svelte @@ -0,0 +1,179 @@ + + + + + + Seleccionar Unidad de Medida + + Busca y selecciona una unidad del catálogo maestro. + + + +
+
+ + +
+ +
+ {#if loading} +
+ +
+ {/if} + + + + + Código + Descripción + + + + + {#if items.length === 0 && !loading} + + + No se encontraron resultados + + + {:else} + {#each items as item} + handleSelect(item)} + > + {item.code} + +
+ {item.description || '-'} + {#if item.description_en} + {item.description_en} + {/if} +
+
+ + + +
+ {/each} + {/if} +
+
+
+ +
+ Página {page} de {totalPages} +
+ + +
+
+
+
+
\ No newline at end of file diff --git a/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte b/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte index f78c1d18..dd3723c2 100644 --- a/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte +++ b/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte @@ -31,6 +31,7 @@ import ClientSelectorDialog from '$lib/components/dashboard/parts/client-selector-dialog.svelte'; import ClassSelectorDialog from '$lib/components/dashboard/parts/class-selector-dialog.svelte'; import MaterialTypeSelectorDialog from '$lib/components/dashboard/parts/material-type-selector-dialog.svelte'; + import UnitMeasureSelectorDialog from '$lib/components/dashboard/parts/unit-measure-dialog.svelte'; // --- 1. IDENTIFICACIÓN --- let id = $derived($page.params.id === 'new' ? null : Number($page.params.id)); @@ -45,6 +46,8 @@ let showClientModal = $state(false); let showClassModal = $state(false); let showMaterialModal = $state(false); + let showUOMModal = $state(false); + let showAltUOMModal = $state(false); // Descripciones Visuales let selectedClientName = $state(""); @@ -61,7 +64,7 @@ description_spanish: '', description_english: '', part_class: '', - material_type: '', // Corregido: coincide con backend + material_type: '', country_of_origin: 'MEX', unit_of_measure: 'PZ', // U.M. TIGIE @@ -215,6 +218,14 @@ selectedMaterialDesc = item.description; } + function handleUOMSelect(item: any) { + formData.unit_of_measure = item.code; +} + + function handleAltUOMSelect(item: any) { + formData.alternate_unit_measure = item.code; + } + // --- SUBMIT --- async function handleSubmit() { error = null; @@ -393,24 +404,25 @@ -->
- - - - {formData.unit_of_measure || 'Seleccione...'} - - - - Comunes - Pieza (PZ) - Kilogramo (KG) - Litro (L) - Metro Lineal (M) - Metro Cuadrado (M2) - Juego (JGO) - Par (PAR) - - - + +
+
+
+ +
+ showUOMModal = true} + /> +
+ +
@@ -563,27 +575,25 @@
- - - - {formData.alternate_unit_measure || 'Seleccione...'} - - - - Comunes - Pieza (PZ) - Kilogramo (KG) - Litro (L) - Metro Lineal (M) - Metro Cuadrado (M2) - Juego (JGO) - Par (PAR) - Set (SET) - Caja (CAJA) - Paquete (PK) - - - + +
+
+
+ +
+ showAltUOMModal = true} + /> +
+ +
@@ -658,6 +668,16 @@ onSelect={handleMaterialSelect} /> + + + +