From 6c70d1ba4fd84d7145253f0a6830d23c45e8bf6a Mon Sep 17 00:00:00 2001 From: Juan Felipe Zapata Moreno Date: Sat, 7 Feb 2026 12:10:02 -0600 Subject: [PATCH] =?UTF-8?q?feat:=20agregar=20modal=20de=20edici=C3=B3n=20p?= =?UTF-8?q?ara=20movimientos=20y=20mejorar=20la=20gesti=C3=B3n=20de=20perm?= =?UTF-8?q?isos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/POS/Movements/DetailModal.vue | 105 ++++-- src/pages/POS/Movements/Edit.vue | 377 ++++++++++++++++++++++ src/pages/POS/Movements/ExitModal.vue | 53 --- src/pages/POS/Movements/Index.vue | 31 +- src/pages/POS/Movements/KardexModal.vue | 11 +- src/pages/POS/Movements/TransferModal.vue | 53 --- 6 files changed, 491 insertions(+), 139 deletions(-) create mode 100644 src/pages/POS/Movements/Edit.vue diff --git a/src/pages/POS/Movements/DetailModal.vue b/src/pages/POS/Movements/DetailModal.vue index f448614..c033ebf 100644 --- a/src/pages/POS/Movements/DetailModal.vue +++ b/src/pages/POS/Movements/DetailModal.vue @@ -2,6 +2,7 @@ import { ref, watch, computed } from 'vue'; import { useApi, apiURL } from '@Services/Api'; import { formatDate } from '@/utils/formatters'; +import { hasPermission } from '@Plugins/RolePermission'; import Modal from '@Holos/Modal.vue'; import GoogleIcon from '@Shared/GoogleIcon.vue'; @@ -15,7 +16,7 @@ const props = defineProps({ }); /** Eventos */ -const emit = defineEmits(['close']); +const emit = defineEmits(['close', 'edit']); /** Estado */ const movement = ref(null); @@ -38,6 +39,14 @@ const totalCost = computed(() => { return movement.value.products.reduce((sum, p) => sum + (Number(p.quantity) * Number(p.unit_cost || 0)), 0); }); +const canEdit = computed(() => { + return hasPermission('movements.edit'); +}); + +const canEditSingle = computed(() => { + return hasPermission('movements.edit') && !isMultiProduct.value; +}); + /** Métodos */ const fetchDetail = () => { if (!props.movementId) return; @@ -67,6 +76,29 @@ const handleClose = () => { emit('close'); }; +const handleEdit = () => { + emit('edit', movement.value); +}; + +const handleEditProduct = (product) => { + // Crear un objeto de movimiento individual a partir del producto + const individualMovement = { + id: product.movement_id, + movement_type: movement.value.movement_type, + quantity: product.quantity, + unit_cost: product.unit_cost, + warehouse_id: movement.value.warehouse_to?.id, + invoice_reference: movement.value.invoice_reference, + notes: movement.value.notes, + inventory: product.inventory, + warehouse_to: movement.value.warehouse_to, + warehouse_from: movement.value.warehouse_from, + user: movement.value.user, + created_at: movement.value.created_at + }; + emit('edit', individualMovement); +}; + const getTypeBadge = (type) => { const badges = { entry: { label: 'Entrada', class: 'bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300', icon: 'add_circle' }, @@ -136,31 +168,43 @@ watch(() => props.show, (isShown) => { :key="index" class="p-3 bg-white dark:bg-gray-800/50 rounded-lg border border-gray-200 dark:border-gray-700" > -
-
-

- {{ product.inventory?.name || 'N/A' }} -

-

- {{ product.inventory?.sku || 'N/A' }} -

-
-
- Cantidad: -

{{ product.quantity }}

-
-
- Costo unit.: -

- ${{ Number(product.unit_cost || 0).toFixed(2) }} -

-
-
- Subtotal: -

- ${{ (product.quantity * Number(product.unit_cost || 0)).toFixed(2) }} -

+
+
+
+

+ {{ product.inventory?.name || 'N/A' }} +

+

+ {{ product.inventory?.sku || 'N/A' }} +

+
+
+ Cantidad: +

{{ product.quantity }}

+
+
+ Costo unit.: +

+ ${{ Number(product.unit_cost || 0).toFixed(2) }} +

+
+
+ Subtotal: +

+ ${{ (product.quantity * Number(product.unit_cost || 0)).toFixed(2) }} +

+
+ +
@@ -252,7 +296,7 @@ watch(() => props.show, (isShown) => { -
+
+
diff --git a/src/pages/POS/Movements/Edit.vue b/src/pages/POS/Movements/Edit.vue new file mode 100644 index 0000000..aa7ae0c --- /dev/null +++ b/src/pages/POS/Movements/Edit.vue @@ -0,0 +1,377 @@ + + + diff --git a/src/pages/POS/Movements/ExitModal.vue b/src/pages/POS/Movements/ExitModal.vue index de7ab24..7557393 100644 --- a/src/pages/POS/Movements/ExitModal.vue +++ b/src/pages/POS/Movements/ExitModal.vue @@ -407,21 +407,6 @@ watch(() => form.warehouse_id, (newWarehouseId, oldWarehouseId) => { /> - -
- - -
-
@@ -436,50 +421,12 @@ watch(() => form.warehouse_id, (newWarehouseId, oldWarehouseId) => {
- - -
-

- Subtotal: - - {{ formatCurrency(item.quantity * item.unit_cost) }} - -

-
- - - - -
-
- - Total de productos: {{ selectedProducts.length }} - - - Cantidad total: {{ totalQuantity }} - - - Costo total: {{ formatCurrency(totalCost) }} -
- -
- - - -
-
- +
- +
props.show, (val) => {
- -
- - -
-
@@ -481,50 +466,12 @@ watch(() => form.warehouse_to_id, (newWarehouseId, oldWarehouseId) => {
- - -
-

- Subtotal: - - {{ formatCurrency(item.quantity * item.unit_cost) }} - -

-
-
- - - -
-
- - Total de productos: {{ selectedProducts.length }} - - - Cantidad total: {{ totalQuantity }} - - - Costo total: {{ formatCurrency(totalCost) }} -
- -
- - - -
-